CharTermAttributeImpl (Lucene 3.6.2 API)
Keywords: org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.analysis.tokenattributes
Class CharTermAttributeImpl

    java.lang.Object
      org.apache.lucene.util.AttributeImpl
          org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl

All Implemented Interfaces:
  Serializable, Appendable, CharSequence, Cloneable, CharTermAttribute, TermAttribute, Attribute

Direct Known Subclasses:
  TermAttributeImpl

    public class CharTermAttributeImpl

extends AttributeImpl
implements CharTermAttribute, TermAttribute, Cloneable, Serializable

The term text of a Token.

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.apache.lucene.util.AttributeImpl
`enableBackwards`

Constructor Summary
`CharTermAttributeImpl()`

Method Summary
`CharTermAttribute` | `append(char c)`
`CharTermAttribute` | `append(CharSequence csq)`
`CharTermAttribute` | `append(CharSequence csq, int start, int end)`
`CharTermAttribute` | `append(CharTermAttribute ta)` Appends the contents of the other `CharTermAttribute` to this character sequence.
`CharTermAttribute` | `append(String s)` Appends the specified `String` to this character sequence.
`CharTermAttribute` | `append(StringBuilder s)` Appends the specified `StringBuilder` to this character sequence.
`char[]` | `buffer()` Returns the internal termBuffer character array which you can then directly alter.
`char` | `charAt(int index)`
`void` | `clear()` Clears the values in this AttributeImpl and resets it to its default value.
`Object` | `clone()` Shallow clone.
`void` | `copyBuffer(char[] buffer, int offset, int length)` Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.
`void` | `copyTo(AttributeImpl target)` Copies the values from this Attribute into the passed-in target attribute.
`boolean` | `equals(Object other)`
`int` | `hashCode()`
`int` | `length()`
`void` | `reflectWith(AttributeReflector reflector)` This method is for introspection of attributes, it should simply add the key/values this attribute holds to the given `AttributeReflector`.
`char[]` | `resizeBuffer(int newSize)` Grows the termBuffer to at least size newSize, preserving the existing content.
`char[]` | `resizeTermBuffer(int newSize)` Deprecated.
`CharTermAttribute` | `setEmpty()` Sets the length of the termBuffer to zero.
`CharTermAttribute` | `setLength(int length)` Set number of valid characters (length of the term) in the termBuffer array.
`void` | `setTermBuffer(char[] buffer, int offset, int length)` Deprecated.
`void` | `setTermBuffer(String buffer)` Deprecated.
`void` | `setTermBuffer(String buffer, int offset, int length)` Deprecated.
`void` | `setTermLength(int length)` Deprecated.
`CharSequence` | `subSequence(int start, int end)`
`String` | `term()` Deprecated.
`char[]` | `termBuffer()` Deprecated.
`int` | `termLength()` Deprecated.
`String` | `toString()` Returns solely the term text as specified by the `CharSequence` interface.

Methods inherited from class org.apache.lucene.util.AttributeImpl
`reflectAsString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CharTermAttributeImpl

    public CharTermAttributeImpl()

Method Detail

### term

    @Deprecated
    public String term()

  Deprecated.

  Description copied from interface: `TermAttribute`
  Returns the Token's term text. This method has a performance penalty because the text is stored internally in a char[]. If possible, use `TermAttribute.termBuffer()` and `TermAttribute.termLength()` directly instead. If you really need a String, use this method, which is nothing more than a convenience call to new String(token.termBuffer(), 0, token.termLength())

  Specified by:
    `term` in interface `TermAttribute`

### copyBuffer

    public final void copyBuffer(char[] buffer,
                                 int offset,
                                 int length)

  Description copied from interface: `CharTermAttribute`
  Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.

  Specified by:
    `copyBuffer` in interface `CharTermAttribute`
  Parameters:
    `buffer` - the buffer to copy
    `offset` - the index in the buffer of the first character to copy
    `length` - the number of characters to copy

### setTermBuffer

    @Deprecated
    public void setTermBuffer(char[] buffer,
                                         int offset,
                                         int length)

  Deprecated.

  Description copied from interface: `TermAttribute`
  Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.

  Specified by:
    `setTermBuffer` in interface `TermAttribute`
  Parameters:
    `buffer` - the buffer to copy
    `offset` - the index in the buffer of the first character to copy
    `length` - the number of characters to copy

### setTermBuffer

    @Deprecated
    public void setTermBuffer(String buffer)

  Deprecated.

  Description copied from interface: `TermAttribute`
  Copies the contents of buffer into the termBuffer array.

  Specified by:
    `setTermBuffer` in interface `TermAttribute`
  Parameters:
    `buffer` - the buffer to copy

### setTermBuffer

    @Deprecated
    public void setTermBuffer(String buffer,
                                         int offset,
                                         int length)

  Deprecated.

  Description copied from interface: `TermAttribute`
  Copies the contents of buffer, starting at offset and continuing for length characters, into the termBuffer array.

  Specified by:
    `setTermBuffer` in interface `TermAttribute`
  Parameters:
    `buffer` - the buffer to copy
    `offset` - the index in the buffer of the first character to copy
    `length` - the number of characters to copy

### buffer

    public final char[] buffer()

  Description copied from interface: `CharTermAttribute`
  Returns the internal termBuffer character array which you can then directly alter. If the array is too small for your token, use `CharTermAttribute.resizeBuffer(int)` to increase it. After altering the buffer be sure to call `CharTermAttribute.setLength(int)` to record the number of valid characters that were placed into the termBuffer.

  Specified by:
    `buffer` in interface `CharTermAttribute`

### termBuffer

    @Deprecated
    public char[] termBuffer()

  Deprecated.

  Description copied from interface: `TermAttribute`
  Returns the internal termBuffer character array which you can then directly alter. If the array is too small for your token, use `TermAttribute.resizeTermBuffer(int)` to increase it. After altering the buffer be sure to call `TermAttribute.setTermLength(int)` to record the number of valid characters that were placed into the termBuffer.

  Specified by:
    `termBuffer` in interface `TermAttribute`

### resizeBuffer

    public final char[] resizeBuffer(int newSize)

  Description copied from interface: `CharTermAttribute`
  Grows the termBuffer to at least size newSize, preserving the existing content.

  Specified by:
    `resizeBuffer` in interface `CharTermAttribute`
  Parameters:
    `newSize` - minimum size of the new termBuffer
  Returns:
    newly created termBuffer with length >= newSize

### resizeTermBuffer

    @Deprecated
    public char[] resizeTermBuffer(int newSize)

  Deprecated.

  Description copied from interface: `TermAttribute`
  Grows the termBuffer to at least size newSize, preserving the existing content. Note: If the next operation is to change the contents of the term buffer use `TermAttribute.setTermBuffer(char[], int, int)`, `TermAttribute.setTermBuffer(String)`, or `TermAttribute.setTermBuffer(String, int, int)` to optimally combine the resize with the setting of the termBuffer.

  Specified by:
    `resizeTermBuffer` in interface `TermAttribute`
  Parameters:
    `newSize` - minimum size of the new termBuffer
  Returns:
    newly created termBuffer with length >= newSize

### termLength

    @Deprecated
    public int termLength()

  Deprecated.

  Description copied from interface: `TermAttribute`
  Return number of valid characters (length of the term) in the termBuffer array.

  Specified by:
    `termLength` in interface `TermAttribute`

### setLength

    public final CharTermAttribute setLength(int length)

  Description copied from interface: `CharTermAttribute`
  Set number of valid characters (length of the term) in the termBuffer array. Use this to truncate the termBuffer or to synchronize with external manipulation of the termBuffer. Note: to grow the size of the array, use `CharTermAttribute.resizeBuffer(int)` first.

  Specified by:
    `setLength` in interface `CharTermAttribute`
  Parameters:
    `length` - the truncated length

### setEmpty

    public final CharTermAttribute setEmpty()

  Description copied from interface: `CharTermAttribute`
  Sets the length of the termBuffer to zero. Use this method before appending contents using the `Appendable` interface.

  Specified by:
    `setEmpty` in interface `CharTermAttribute`

### setTermLength

    @Deprecated
    public void setTermLength(int length)

  Deprecated.

  Description copied from interface: `TermAttribute`
  Set number of valid characters (length of the term) in the termBuffer array. Use this to truncate the termBuffer or to synchronize with external manipulation of the termBuffer. Note: to grow the size of the array, use `TermAttribute.resizeTermBuffer(int)` first.

  Specified by:
    `setTermLength` in interface `TermAttribute`
  Parameters:
    `length` - the truncated length

### length

    public final int length()

  Specified by:
    `length` in interface `CharSequence`

### charAt

    public final char charAt(int index)

  Specified by:
    `charAt` in interface `CharSequence`

### subSequence

    public final CharSequence subSequence(int start,
                                          int end)

  Specified by:
    `subSequence` in interface `CharSequence`

### append

    public final CharTermAttribute append(CharSequence csq)

  Specified by:
    `append` in interface `Appendable`
  Specified by:
    `append` in interface `CharTermAttribute`

### append

    public final CharTermAttribute append(CharSequence csq,
                                          int start,
                                          int end)

  Specified by:
    `append` in interface `Appendable`
  Specified by:
    `append` in interface `CharTermAttribute`

### append

    public final CharTermAttribute append(char c)

  Specified by:
    `append` in interface `Appendable`
  Specified by:
    `append` in interface `CharTermAttribute`

### append

    public final CharTermAttribute append(String s)

  Description copied from interface: `CharTermAttribute`
  Appends the specified `String` to this character sequence.

  The characters of the `String` argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is `null`, then the four characters `"null"` are appended.

  Specified by:
    `append` in interface `CharTermAttribute`

### append

    public final CharTermAttribute append(StringBuilder s)

  Description copied from interface: `CharTermAttribute`
  Appends the specified `StringBuilder` to this character sequence.

  The characters of the `StringBuilder` argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is `null`, then the four characters `"null"` are appended.

  Specified by:
    `append` in interface `CharTermAttribute`

### append

    public final CharTermAttribute append(CharTermAttribute ta)

  Description copied from interface: `CharTermAttribute`
  Appends the contents of the other `CharTermAttribute` to this character sequence.

  The characters of the `CharTermAttribute` argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument is `null`, then the four characters `"null"` are appended.

  Specified by:
    `append` in interface `CharTermAttribute`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### clear

    public void clear()

  Description copied from class: `AttributeImpl`
  Clears the values in this AttributeImpl and resets it to its default value. If this implementation implements more than one Attribute interface it clears all.

  Specified by:
    `clear` in class `AttributeImpl`

### clone

    public Object clone()

  Description copied from class: `AttributeImpl`
  Shallow clone. Subclasses must override this if they need to clone any members deeply,

  Overrides:
    `clone` in class `AttributeImpl`

### equals

    public boolean equals(Object other)

  Overrides:
    `equals` in class `Object`

### toString

    public String toString()

  Returns solely the term text as specified by the `CharSequence` interface.

  This method changed the behavior with Lucene 3.1, before it returned a String representation of the whole term with all attributes. This affects especially the `Token` subclass.

  Specified by:
    `toString` in interface `CharSequence`
  Overrides:
    `toString` in class `AttributeImpl`

### reflectWith

    public void reflectWith(AttributeReflector reflector)

  Description copied from class: `AttributeImpl`
  This method is for introspection of attributes, it should simply add the key/values this attribute holds to the given `AttributeReflector`.

  The default implementation calls `AttributeReflector.reflect(java.lang.Class, java.lang.String, java.lang.Object)` for all non-static fields from the implementing class, using the field name as key and the field value as value. The Attribute class is also determined by reflection. Please note that the default implementation can only handle single-Attribute implementations.

  Custom implementations look like this (e.g. for a combined attribute implementation):

         public void reflectWith(AttributeReflector reflector) {
           reflector.reflect(CharTermAttribute.class, "term", term());
           reflector.reflect(PositionIncrementAttribute.class, "positionIncrement", getPositionIncrement());
         }

  If you implement this method, make sure that for each invocation, the same set of `Attribute` interfaces and keys are passed to `AttributeReflector.reflect(java.lang.Class, java.lang.String, java.lang.Object)` in the same order, but possibly different values. So don't automatically exclude e.g. `null` properties!

  Overrides:
    `reflectWith` in class `AttributeImpl`
  See Also:
    `AttributeImpl.reflectAsString(boolean)`

### copyTo

    public void copyTo(AttributeImpl target)

  Description copied from class: `AttributeImpl`
  Copies the values from this Attribute into the passed-in target attribute. The target implementation must support all the Attributes this implementation supports.

  Specified by:
    `copyTo` in class `AttributeImpl`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD