Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
Lucene::Token Class Reference

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. More...

#include <Token.h>

+ Inheritance diagram for Lucene::Token:

Public Member Functions

 Token ()
 Constructs a Token will null text.
 
 Token (int32_t start, int32_t end)
 Constructs a Token with null text and start and end offsets.
 
 Token (int32_t start, int32_t end, const String &type)
 Constructs a Token with null text and start and end offsets plus the Token type.
 
 Token (int32_t start, int32_t end, int32_t flags)
 Constructs a Token with null text and start and end offsets plus flags.
 
 Token (const String &text, int32_t start, int32_t end)
 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.
 
 Token (const String &text, int32_t start, int32_t end, const String &type)
 Constructs a Token with the given term text, start and end offsets and type. NOTE: for better indexing speed you should instead use the char[] termBuffer methods to set the term text.
 
 Token (const String &text, int32_t start, int32_t end, int32_t flags)
 Constructs a Token with the given term text, start and end offsets and flags. NOTE: for better indexing speed you should instead use the char[] termBuffer methods to set the term text.
 
 Token (CharArray startTermBuffer, int32_t termBufferOffset, int32_t termBufferLength, int32_t start, int32_t end)
 Constructs a Token with the given term buffer (offset and length), start and end offsets.
 
virtual ~Token ()
 
virtual String getClassName ()
 
boost::shared_ptr< Tokenshared_from_this ()
 
virtual void setPositionIncrement (int32_t positionIncrement)
 Set the position increment. This determines the position of this token relative to the previous Token in a TokenStream, used in phrase searching.
 
virtual int32_t getPositionIncrement ()
 Returns the position increment of this Token.
 
virtual String term ()
 Returns the Token's term text.
 
virtual void setTermBuffer (const wchar_t *buffer, int32_t offset, int32_t length)
 Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.
 
virtual void setTermBuffer (const String &buffer)
 Copies the contents of buffer into the termBuffer array.
 
virtual void setTermBuffer (const String &buffer, int32_t offset, int32_t length)
 Copies the contents of buffer, starting at offset and continuing for length characters, into the termBuffer array.
 
virtual CharArray termBuffer ()
 Returns the internal termBuffer character array which you can then directly alter. If the array is too small for your token, use resizeTermBuffer(int) to increase it. After altering the buffer be sure to call setTermLength to record the number of valid characters that were placed into the termBuffer.
 
virtual wchar_t * termBufferArray ()
 Optimized implementation of termBuffer.
 
virtual CharArray resizeTermBuffer (int32_t newSize)
 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 setTermBuffer(char[], int, int), setTermBuffer(String), or setTermBuffer(String, int, int) to optimally combine the resize with the setting of the termBuffer.
 
virtual int32_t termLength ()
 Return number of valid characters (length of the term) in the termBuffer array.
 
virtual void setTermLength (int32_t length)
 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 resizeTermBuffer(int) first.
 
virtual int32_t startOffset ()
 Returns this Token's starting offset, the position of the first character corresponding to this token in the source text.
 
virtual void setStartOffset (int32_t offset)
 Set the starting offset.
 
virtual int32_t 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).
 
virtual void setEndOffset (int32_t offset)
 Set the ending offset.
 
virtual void setOffset (int32_t startOffset, int32_t endOffset)
 Set the starting and ending offset.
 
virtual String type ()
 Returns this Token's lexical type. Defaults to "word".
 
virtual void setType (const String &type)
 Set the lexical type.
 
virtual int32_t getFlags ()
 Get the bitset for any bits that have been set. This is completely distinct from type(), although they do share similar purposes. The flags can be used to encode information about the token for use by other TokenFilters.
 
virtual void setFlags (int32_t flags)
 
virtual PayloadPtr getPayload ()
 Returns this Token's payload.
 
virtual void setPayload (const PayloadPtr &payload)
 Sets this Token's payload.
 
virtual String toString ()
 Returns a string representation of the object.
 
virtual void clear ()
 Resets the term text, payload, flags, and positionIncrement, startOffset, endOffset and token type to default.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Shallow clone. Subclasses must override this if they need to clone any members deeply.
 
TokenPtr clone (CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset)
 Makes a clone, but replaces the term buffer and start/end offset in the process. This is more efficient than doing a full clone (and then calling setTermBuffer) because it saves a wasted copy of the old termBuffer.
 
virtual bool equals (const LuceneObjectPtr &other)
 All values used for computation of hashCode() should be checked here for equality.
 
virtual int32_t hashCode ()
 Subclasses must implement this method and should compute a hashCode similar to this:
 
TokenPtr reinit (CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset, const String &newType)
 Shorthand for calling clear, setTermBuffer(char[], int, int), setStartOffset, setEndOffset, setType.
 
TokenPtr reinit (CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset)
 Shorthand for calling clear, setTermBuffer(char[], int, int), setStartOffset, setEndOffset, setType on Token::DEFAULT_TYPE.
 
TokenPtr reinit (const String &newTerm, int32_t newStartOffset, int32_t newEndOffset, const String &newType)
 Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType.
 
TokenPtr reinit (const String &newTerm, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset, const String &newType)
 Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType.
 
TokenPtr reinit (const String &newTerm, int32_t newStartOffset, int32_t newEndOffset)
 Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType on Token::DEFAULT_TYPE.
 
TokenPtr reinit (const String &newTerm, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset)
 Shorthand for calling clear, setTermBuffer(String, int, int), setStartOffset, setEndOffset, setType on Token::DEFAULT_TYPE.
 
void reinit (const TokenPtr &prototype)
 Copy the prototype token's fields into this one. Note: Payloads are shared.
 
void reinit (const TokenPtr &prototype, const String &newTerm)
 Copy the prototype token's fields into this one, with a different term. Note: Payloads are shared.
 
void reinit (const TokenPtr &prototype, CharArray newTermBuffer, int32_t offset, int32_t length)
 Copy the prototype token's fields into this one, with a different term. Note: Payloads are shared.
 
virtual void copyTo (const AttributePtr &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 Member Functions inherited from Lucene::Attribute
virtual ~Attribute ()
 
boost::shared_ptr< Attributeshared_from_this ()
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
 
virtual void unlock ()
 Unlock this object.
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
 
virtual void notifyAll ()
 Notify all threads waiting for signal.
 

Static Public Member Functions

static String _getClassName ()
 
static const String & DEFAULT_TYPE ()
 
static AttributeFactoryPtr TOKEN_ATTRIBUTE_FACTORY ()
 Convenience factory that returns Token as implementation for the basic attributes.
 
- Static Public Member Functions inherited from Lucene::Attribute
static String _getClassName ()
 

Protected Member Functions

void ConstructToken (int32_t start, int32_t end, const String &type, int32_t flags)
 Construct Token and initialize values.
 
void growTermBuffer (int32_t newSize)
 Allocates a buffer char[] of at least newSize, without preserving the existing content. Its always used in places that set the content.
 
void initTermBuffer ()
 
void clearNoTermBuffer ()
 Like clear() but doesn't clear termBuffer/text.
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Protected Attributes

CharArray _termBuffer
 
int32_t _termLength
 
int32_t _startOffset
 
int32_t _endOffset
 
String _type
 
int32_t flags
 
PayloadPtr payload
 
int32_t positionIncrement
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Static Protected Attributes

static const int32_t MIN_BUFFER_SIZE
 

Detailed Description

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, eg., to display highlighted query terms in a document browser, or to show matching text fragments in a <abbr title="KeyWord In Context">KWIC</abbr> 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 TermPositions#getPayloadLength() and TermPositions#getPayload(byte[], int) to retrieve the payloads from the index.

Tokenizers and TokenFilters should try to re-use a Token instance when possible for best performance, by implementing the TokenStream#incrementToken() API. Failing that, to create a new Token you should first use one of the constructors that starts with null text. To load the token from a char[] use setTermBuffer(char[], int, int). To load from a String use setTermBuffer(String) or setTermBuffer(String, int, int). Alternatively you can get the Token's termBuffer by calling either termBuffer(), if you know that your text is shorter than the capacity of the termBuffer or resizeTermBuffer(int), if there is any possibility that you may need to grow the buffer. Fill in the characters of your term into this buffer, with String#getChars(int, int, char[], int) if loading from a string, or with System#arraycopy(Object, int, Object, int, int), and finally call setTermLength(int) to set the length of the term text.

Typical Token reuse patterns:

Copying text from a string (type is reset to DEFAULT_TYPE if not specified):

return reusableToken->reinit(string, startOffset, endOffset[, type]);

Copying some text from a string (type is reset to DEFAULT_TYPE if not specified):

return reusableToken->reinit(string, 0, string.length(), startOffset, endOffset[, type]);

Copying text from char[] buffer (type is reset to DEFAULT_TYPE if not specified):

return reusableToken->reinit(buffer, 0, buffer.length, startOffset, endOffset[, type]);

Copying some text from a char[] buffer (type is reset to DEFAULT_TYPE if not specified):

return reusableToken->reinit(buffer, start, end - start, startOffset, endOffset[, type]);

Copying from one one Token to another (type is reset to DEFAULT_TYPE if not specified):

return reusableToken.reinit(source.termBuffer(), 0, source.termLength(), source.startOffset(), source.endOffset()[, source.type()]);

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 TokenStreams can be chained, one cannot assume that the Token's current 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.

See also
Payload

Constructor & Destructor Documentation

◆ Token() [1/8]

Lucene::Token::Token ( )

Constructs a Token will null text.

◆ Token() [2/8]

Lucene::Token::Token ( int32_t  start,
int32_t  end 
)

Constructs a Token with null text and start and end offsets.

Parameters
startstart offset in the source text
endend offset in the source text

◆ Token() [3/8]

Lucene::Token::Token ( int32_t  start,
int32_t  end,
const String &  type 
)

Constructs a Token with null text and start and end offsets plus the Token type.

Parameters
startstart offset in the source text
endend offset in the source text
typethe lexical type of this Token

◆ Token() [4/8]

Lucene::Token::Token ( int32_t  start,
int32_t  end,
int32_t  flags 
)

Constructs a Token with null text and start and end offsets plus flags.

Parameters
startstart offset in the source text
endend offset in the source text
flagsThe bits to set for this token

◆ Token() [5/8]

Lucene::Token::Token ( const String &  text,
int32_t  start,
int32_t  end 
)

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
textterm text
startstart offset in the source text
endend offset in the source text

◆ Token() [6/8]

Lucene::Token::Token ( const String &  text,
int32_t  start,
int32_t  end,
const String &  type 
)

Constructs a Token with the given term text, start and end offsets and type. NOTE: for better indexing speed you should instead use the char[] termBuffer methods to set the term text.

Parameters
textterm text
startstart offset in the source text
endend offset in the source text
typethe lexical type of this Token

◆ Token() [7/8]

Lucene::Token::Token ( const String &  text,
int32_t  start,
int32_t  end,
int32_t  flags 
)

Constructs a Token with the given term text, start and end offsets and flags. NOTE: for better indexing speed you should instead use the char[] termBuffer methods to set the term text.

Parameters
textterm text
startstart offset in the source text
endend offset in the source text
flagsThe bits to set for this token

◆ Token() [8/8]

Lucene::Token::Token ( CharArray  startTermBuffer,
int32_t  termBufferOffset,
int32_t  termBufferLength,
int32_t  start,
int32_t  end 
)

Constructs a Token with the given term buffer (offset and length), start and end offsets.

◆ ~Token()

virtual Lucene::Token::~Token ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::Token::_getClassName ( )
inlinestatic

◆ clear()

virtual void Lucene::Token::clear ( )
virtual

Resets the term text, payload, flags, and positionIncrement, startOffset, endOffset and token type to default.

Implements Lucene::Attribute.

◆ clearNoTermBuffer()

void Lucene::Token::clearNoTermBuffer ( )
protected

Like clear() but doesn't clear termBuffer/text.

◆ clone() [1/2]

TokenPtr Lucene::Token::clone ( CharArray  newTermBuffer,
int32_t  newTermOffset,
int32_t  newTermLength,
int32_t  newStartOffset,
int32_t  newEndOffset 
)

Makes a clone, but replaces the term buffer and start/end offset in the process. This is more efficient than doing a full clone (and then calling setTermBuffer) because it saves a wasted copy of the old termBuffer.

◆ clone() [2/2]

virtual LuceneObjectPtr Lucene::Token::clone ( const LuceneObjectPtr other = LuceneObjectPtr())
virtual

Shallow clone. Subclasses must override this if they need to clone any members deeply.

Parameters
baseclone reference - null when called initially, then set in top virtual override.

Implements Lucene::Attribute.

◆ ConstructToken()

void Lucene::Token::ConstructToken ( int32_t  start,
int32_t  end,
const String &  type,
int32_t  flags 
)
protected

Construct Token and initialize values.

◆ copyTo()

virtual void Lucene::Token::copyTo ( const AttributePtr target)
virtual

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

Implements Lucene::Attribute.

◆ DEFAULT_TYPE()

static const String & Lucene::Token::DEFAULT_TYPE ( )
static

◆ endOffset()

virtual int32_t Lucene::Token::endOffset ( )
virtual

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).

◆ equals()

virtual bool Lucene::Token::equals ( const LuceneObjectPtr other)
virtual

All values used for computation of hashCode() should be checked here for equality.

see also LuceneObject#equals(Object)

Implements Lucene::Attribute.

◆ getClassName()

virtual String Lucene::Token::getClassName ( )
inlinevirtual

Reimplemented from Lucene::Attribute.

◆ getFlags()

virtual int32_t Lucene::Token::getFlags ( )
virtual

Get the bitset for any bits that have been set. This is completely distinct from type(), although they do share similar purposes. The flags can be used to encode information about the token for use by other TokenFilters.

Returns
The bits

◆ getPayload()

virtual PayloadPtr Lucene::Token::getPayload ( )
virtual

Returns this Token's payload.

◆ getPositionIncrement()

virtual int32_t Lucene::Token::getPositionIncrement ( )
virtual

Returns the position increment of this Token.

See also
setPositionIncrement

◆ growTermBuffer()

void Lucene::Token::growTermBuffer ( int32_t  newSize)
protected

Allocates a buffer char[] of at least newSize, without preserving the existing content. Its always used in places that set the content.

Parameters
newSizeminimum size of the buffer

◆ hashCode()

virtual int32_t Lucene::Token::hashCode ( )
virtual

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

int32_t hashCode() { int32_t code = startOffset; code = code * 31 + endOffset; return code; }

see also equals(Object)

Implements Lucene::Attribute.

◆ initTermBuffer()

void Lucene::Token::initTermBuffer ( )
protected

◆ reinit() [1/9]

TokenPtr Lucene::Token::reinit ( CharArray  newTermBuffer,
int32_t  newTermOffset,
int32_t  newTermLength,
int32_t  newStartOffset,
int32_t  newEndOffset 
)

◆ reinit() [2/9]

TokenPtr Lucene::Token::reinit ( CharArray  newTermBuffer,
int32_t  newTermOffset,
int32_t  newTermLength,
int32_t  newStartOffset,
int32_t  newEndOffset,
const String &  newType 
)

Shorthand for calling clear, setTermBuffer(char[], int, int), setStartOffset, setEndOffset, setType.

Returns
this Token instance

◆ reinit() [3/9]

TokenPtr Lucene::Token::reinit ( const String &  newTerm,
int32_t  newStartOffset,
int32_t  newEndOffset 
)

Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType on Token::DEFAULT_TYPE.

Returns
this Token instance

◆ reinit() [4/9]

TokenPtr Lucene::Token::reinit ( const String &  newTerm,
int32_t  newStartOffset,
int32_t  newEndOffset,
const String &  newType 
)

Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType.

Returns
this Token instance

◆ reinit() [5/9]

TokenPtr Lucene::Token::reinit ( const String &  newTerm,
int32_t  newTermOffset,
int32_t  newTermLength,
int32_t  newStartOffset,
int32_t  newEndOffset 
)

◆ reinit() [6/9]

TokenPtr Lucene::Token::reinit ( const String &  newTerm,
int32_t  newTermOffset,
int32_t  newTermLength,
int32_t  newStartOffset,
int32_t  newEndOffset,
const String &  newType 
)

Shorthand for calling clear, setTermBuffer(String), setStartOffset, setEndOffset, setType.

Returns
this Token instance

◆ reinit() [7/9]

void Lucene::Token::reinit ( const TokenPtr prototype)

Copy the prototype token's fields into this one. Note: Payloads are shared.

◆ reinit() [8/9]

void Lucene::Token::reinit ( const TokenPtr prototype,
CharArray  newTermBuffer,
int32_t  offset,
int32_t  length 
)

Copy the prototype token's fields into this one, with a different term. Note: Payloads are shared.

◆ reinit() [9/9]

void Lucene::Token::reinit ( const TokenPtr prototype,
const String &  newTerm 
)

Copy the prototype token's fields into this one, with a different term. Note: Payloads are shared.

◆ resizeTermBuffer()

virtual CharArray Lucene::Token::resizeTermBuffer ( int32_t  newSize)
virtual

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 setTermBuffer(char[], int, int), setTermBuffer(String), or setTermBuffer(String, int, int) to optimally combine the resize with the setting of the termBuffer.

Parameters
newSizeminimum size of the new termBuffer
Returns
newly created termBuffer with length >= newSize

◆ setEndOffset()

virtual void Lucene::Token::setEndOffset ( int32_t  offset)
virtual

Set the ending offset.

See also
endOffset()

◆ setFlags()

virtual void Lucene::Token::setFlags ( int32_t  flags)
virtual
See also
getFlags()

◆ setOffset()

virtual void Lucene::Token::setOffset ( int32_t  startOffset,
int32_t  endOffset 
)
virtual

Set the starting and ending offset.

See also
startOffset() and endOffset()

◆ setPayload()

virtual void Lucene::Token::setPayload ( const PayloadPtr payload)
virtual

Sets this Token's payload.

◆ setPositionIncrement()

virtual void Lucene::Token::setPositionIncrement ( int32_t  positionIncrement)
virtual

Set the position increment. This determines the position of this token relative to the previous Token in a TokenStream, used in phrase searching.

The default value is one.

Some common uses for this are:

Set it to zero to put multiple terms in the same position. This is useful if, eg., a word has multiple stems. Searches for phrases including either stem will match. In this case, all but the first stem's increment should be set to zero: the increment of the first instance should be one. Repeating a token with an increment of zero can also be used to boost the scores of matches on that token.

Set it to values greater than one to inhibit exact phrase matches. If, for example, one does not want phrases to match across removed stop words, then one could build a stop word filter that removes stop words and also sets the increment to the number of stop words removed before each non-stop word. Then exact phrase queries will only match when the terms occur with no intervening stop words.

Parameters
positionIncrementthe distance from the prior term
See also
TermPositions

◆ setStartOffset()

virtual void Lucene::Token::setStartOffset ( int32_t  offset)
virtual

Set the starting offset.

See also
startOffset()

◆ setTermBuffer() [1/3]

virtual void Lucene::Token::setTermBuffer ( const String &  buffer)
virtual

Copies the contents of buffer into the termBuffer array.

Parameters
bufferthe buffer to copy

◆ setTermBuffer() [2/3]

virtual void Lucene::Token::setTermBuffer ( const String &  buffer,
int32_t  offset,
int32_t  length 
)
virtual

Copies the contents of buffer, starting at offset and continuing for length characters, into the termBuffer array.

Parameters
bufferthe buffer to copy
offsetthe index in the buffer of the first character to copy
lengththe number of characters to copy

◆ setTermBuffer() [3/3]

virtual void Lucene::Token::setTermBuffer ( const wchar_t *  buffer,
int32_t  offset,
int32_t  length 
)
virtual

Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.

Parameters
bufferthe buffer to copy
offsetthe index in the buffer of the first character to copy
lengththe number of characters to copy

◆ setTermLength()

virtual void Lucene::Token::setTermLength ( int32_t  length)
virtual

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 resizeTermBuffer(int) first.

Parameters
lengththe truncated length

◆ setType()

virtual void Lucene::Token::setType ( const String &  type)
virtual

Set the lexical type.

See also
type()

◆ shared_from_this()

boost::shared_ptr< Token > Lucene::Token::shared_from_this ( )
inline

◆ startOffset()

virtual int32_t Lucene::Token::startOffset ( )
virtual

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 termLength, as the term text may have been altered by a stemmer or some other filter.

◆ term()

virtual String Lucene::Token::term ( )
virtual

Returns the Token's term text.

This method has a performance penalty because the text is stored internally in a char[]. If possible, use termBuffer() and termLength() directly instead. If you really need a String, use this method, which is nothing more than a convenience call to String(token->termBuffer(), token->termLength())

◆ termBuffer()

virtual CharArray Lucene::Token::termBuffer ( )
virtual

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

◆ termBufferArray()

virtual wchar_t * Lucene::Token::termBufferArray ( )
virtual

Optimized implementation of termBuffer.

◆ termLength()

virtual int32_t Lucene::Token::termLength ( )
virtual

Return number of valid characters (length of the term) in the termBuffer array.

◆ TOKEN_ATTRIBUTE_FACTORY()

static AttributeFactoryPtr Lucene::Token::TOKEN_ATTRIBUTE_FACTORY ( )
static

Convenience factory that returns Token as implementation for the basic attributes.

◆ toString()

virtual String Lucene::Token::toString ( )
virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

◆ type()

virtual String Lucene::Token::type ( )
virtual

Returns this Token's lexical type. Defaults to "word".

Field Documentation

◆ _endOffset

int32_t Lucene::Token::_endOffset
protected

◆ _startOffset

int32_t Lucene::Token::_startOffset
protected

◆ _termBuffer

CharArray Lucene::Token::_termBuffer
protected

◆ _termLength

int32_t Lucene::Token::_termLength
protected

◆ _type

String Lucene::Token::_type
protected

◆ flags

int32_t Lucene::Token::flags
protected

◆ MIN_BUFFER_SIZE

const int32_t Lucene::Token::MIN_BUFFER_SIZE
staticprotected

◆ payload

PayloadPtr Lucene::Token::payload
protected

◆ positionIncrement

int32_t Lucene::Token::positionIncrement
protected

The documentation for this class was generated from the following file:

clucene.sourceforge.net