public class

OffsetAttributeImpl

extends AttributeImpl
implements Serializable Cloneable OffsetAttribute
java.lang.Object
   ↳ org.apache.lucene.util.AttributeImpl
     ↳ org.apache.lucene.analysis.tokenattributes.OffsetAttributeImpl

Class Overview

The start and end character offset of a Token.

Summary

Public Constructors
OffsetAttributeImpl()
Public Methods
void clear()
Clears the values in this AttributeImpl and resets it to its default value.
void copyTo(AttributeImpl target)
Copies the values from this Attribute into the passed-in target attribute.
int endOffset()
Returns this Token's ending offset, one greater than the position of the last character corresponding to this token in the source text.
boolean equals(Object other)
All values used for computation of hashCode() should be checked here for equality.
int hashCode()
Subclasses must implement this method and should compute a hashCode similar to this:
   public int hashCode() {
     int code = startOffset;
     code = code * 31 + endOffset;
     return code;
   }
 
see also equals(Object)
void setOffset(int startOffset, int endOffset)
Set the starting and ending offset.
int startOffset()
Returns this Token's starting offset, the position of the first character corresponding to this token in the source text.
[Expand]
Inherited Methods
From class org.apache.lucene.util.AttributeImpl
From class java.lang.Object
From interface org.apache.lucene.analysis.tokenattributes.OffsetAttribute

Public Constructors

public OffsetAttributeImpl ()

Public Methods

public void clear ()

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.

public void copyTo (AttributeImpl target)

Copies the values from this Attribute into the passed-in target attribute. The target implementation must support all the Attributes this implementation supports.

public int endOffset ()

Returns this Token's ending offset, one greater than the position of the last character corresponding to this token in the source text. The length of the token in the source text is (endOffset - startOffset).

public boolean equals (Object other)

All values used for computation of hashCode() should be checked here for equality. see also equals(Object)

public int hashCode ()

Subclasses must implement this method and should compute a hashCode similar to this:

   public int hashCode() {
     int code = startOffset;
     code = code * 31 + endOffset;
     return code;
   }
 
see also equals(Object)

public void setOffset (int startOffset, int endOffset)

Set the starting and ending offset.

See Also

public int startOffset ()

Returns this Token's starting offset, the position of the first character corresponding to this token in the source text. Note that the difference between endOffset() and startOffset() may not be equal to termText.length(), as the term text may have been altered by a stemmer or some other filter.