Package org.apache.solr.spelling
Class Token
- java.lang.Object
-
- org.apache.lucene.util.AttributeImpl
-
- org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
-
- org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
- org.apache.solr.spelling.Token
-
- All Implemented Interfaces:
Appendable,CharSequence,Cloneable,org.apache.lucene.analysis.tokenattributes.CharTermAttribute,org.apache.lucene.analysis.tokenattributes.FlagsAttribute,org.apache.lucene.analysis.tokenattributes.OffsetAttribute,org.apache.lucene.analysis.tokenattributes.PayloadAttribute,org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute,org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute,org.apache.lucene.analysis.tokenattributes.TermFrequencyAttribute,org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute,org.apache.lucene.analysis.tokenattributes.TypeAttribute,org.apache.lucene.util.Attribute
@Deprecated public class Token extends org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl implements org.apache.lucene.analysis.tokenattributes.FlagsAttribute, org.apache.lucene.analysis.tokenattributes.PayloadAttribute
Deprecated.A Token is an occurrence of a term from the text of a field. It consists of a term's text, the start and end offset of the term in the text of the field, and a type string.The start and end offsets permit applications to re-associate a token with its source text, e.g., to display highlighted query terms in a document browser, or to show matching text fragments in a KWIC display, etc.
The type is a string, assigned by a lexical analyzer (a.k.a. tokenizer), naming the lexical or syntactic class that the token belongs to. For example an end of sentence marker token might be implemented with type "eos". The default token type is "word".
A Token can optionally have metadata (a.k.a. payload) in the form of a variable length byte array. Use
PostingsEnum.getPayload()to retrieve the payloads from the index. A few things to note:- clear() initializes all of the fields to default values. This was changed in contrast to Lucene 2.4, but should affect no one.
- Because
TokenStreamscan be chained, one cannot assume that theToken'scurrent type is correct. - The startOffset and endOffset represent the start and offset in the source text, so be careful in adjusting them.
- When caching a reusable token, clone it. When injecting a cached token into a stream that can be reset, clone it again.
-
-
Constructor Summary
Constructors Constructor Description Token()Deprecated.Constructs a Token will null text.Token(CharSequence text, int start, int end)Deprecated.Constructs a Token with the given term text, start and end offsets.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Deprecated.Resets the term text, payload, flags, positionIncrement, positionLength, startOffset, endOffset and token type to default.Tokenclone()Deprecated.voidcopyTo(org.apache.lucene.util.AttributeImpl target)Deprecated.booleanequals(Object obj)Deprecated.intgetFlags()Deprecated.org.apache.lucene.util.BytesRefgetPayload()Deprecated.inthashCode()Deprecated.voidreflectWith(org.apache.lucene.util.AttributeReflector reflector)Deprecated.voidsetFlags(int flags)Deprecated.voidsetPayload(org.apache.lucene.util.BytesRef payload)Deprecated.-
Methods inherited from class org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
end, endOffset, getPositionIncrement, getPositionLength, getTermFrequency, setOffset, setPositionIncrement, setPositionLength, setTermFrequency, setType, startOffset, type
-
Methods inherited from class org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
append, append, append, append, append, append, buffer, charAt, copyBuffer, getBytesRef, length, resizeBuffer, setEmpty, setLength, subSequence, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Constructor Detail
-
Token
public Token()
Deprecated.Constructs a Token will null text.
-
Token
public Token(CharSequence text, int start, int end)
Deprecated.Constructs a Token with the given term text, start and end offsets. The type defaults to "word." NOTE: for better indexing speed you should instead use the char[] termBuffer methods to set the term text.- Parameters:
text- term textstart- start offset in the source textend- end offset in the source text
-
-
Method Detail
-
getFlags
public int getFlags()
Deprecated.- Specified by:
getFlagsin interfaceorg.apache.lucene.analysis.tokenattributes.FlagsAttribute- See Also:
FlagsAttribute
-
setFlags
public void setFlags(int flags)
Deprecated.- Specified by:
setFlagsin interfaceorg.apache.lucene.analysis.tokenattributes.FlagsAttribute- See Also:
FlagsAttribute
-
getPayload
public org.apache.lucene.util.BytesRef getPayload()
Deprecated.- Specified by:
getPayloadin interfaceorg.apache.lucene.analysis.tokenattributes.PayloadAttribute- See Also:
PayloadAttribute
-
setPayload
public void setPayload(org.apache.lucene.util.BytesRef payload)
Deprecated.- Specified by:
setPayloadin interfaceorg.apache.lucene.analysis.tokenattributes.PayloadAttribute- See Also:
PayloadAttribute
-
clear
public void clear()
Deprecated.Resets the term text, payload, flags, positionIncrement, positionLength, startOffset, endOffset and token type to default.- Overrides:
clearin classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
equals
public boolean equals(Object obj)
Deprecated.- Overrides:
equalsin classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
hashCode
public int hashCode()
Deprecated.- Overrides:
hashCodein classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
clone
public Token clone()
Deprecated.- Overrides:
clonein classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
copyTo
public void copyTo(org.apache.lucene.util.AttributeImpl target)
Deprecated.- Overrides:
copyToin classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
reflectWith
public void reflectWith(org.apache.lucene.util.AttributeReflector reflector)
Deprecated.- Overrides:
reflectWithin classorg.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl
-
-