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::TermAttribute Class Reference

The term text of a Token. More...

#include <TermAttribute.h>

+ Inheritance diagram for Lucene::TermAttribute:

Public Member Functions

 TermAttribute ()
 
virtual ~TermAttribute ()
 
virtual String getClassName ()
 
boost::shared_ptr< TermAttributeshared_from_this ()
 
virtual String toString ()
 Returns a string representation of the object.
 
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 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 hashCode ()
 Subclasses must implement this method and should compute a hashCode similar to this:
 
virtual void clear ()
 Clears the values in this Attribute and resets it to its default value. If this implementation implements more than one Attribute interface it clears all.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Shallow clone. Subclasses must override this if they need to clone any members deeply.
 
virtual bool equals (const LuceneObjectPtr &other)
 All values used for computation of hashCode() should be checked here for equality.
 
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 Public Member Functions inherited from Lucene::Attribute
static String _getClassName ()
 

Protected Member Functions

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 ()
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Protected Attributes

CharArray _termBuffer
 
int32_t _termLength
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Static Protected Attributes

static const int32_t MIN_BUFFER_SIZE
 

Detailed Description

The term text of a Token.

Constructor & Destructor Documentation

◆ TermAttribute()

Lucene::TermAttribute::TermAttribute ( )

◆ ~TermAttribute()

virtual Lucene::TermAttribute::~TermAttribute ( )
virtual

Member Function Documentation

◆ _getClassName()

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

◆ clear()

virtual void Lucene::TermAttribute::clear ( )
virtual

Clears the values in this Attribute and resets it to its default value. If this implementation implements more than one Attribute interface it clears all.

Implements Lucene::Attribute.

◆ clone()

virtual LuceneObjectPtr Lucene::TermAttribute::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.

◆ copyTo()

virtual void Lucene::TermAttribute::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.

◆ equals()

virtual bool Lucene::TermAttribute::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::TermAttribute::getClassName ( )
inlinevirtual

Reimplemented from Lucene::Attribute.

◆ growTermBuffer()

void Lucene::TermAttribute::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::TermAttribute::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::TermAttribute::initTermBuffer ( )
protected

◆ resizeTermBuffer()

virtual CharArray Lucene::TermAttribute::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

◆ setTermBuffer() [1/2]

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

Copies the contents of buffer into the termBuffer array.

Parameters
bufferthe buffer to copy

◆ setTermBuffer() [2/2]

virtual void Lucene::TermAttribute::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::TermAttribute::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

◆ shared_from_this()

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

◆ term()

virtual String Lucene::TermAttribute::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 new String(token.termBuffer(), 0, token.termLength())

◆ termBuffer()

virtual CharArray Lucene::TermAttribute::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::TermAttribute::termBufferArray ( )
virtual

Optimized implementation of termBuffer.

◆ termLength()

virtual int32_t Lucene::TermAttribute::termLength ( )
virtual

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

◆ toString()

virtual String Lucene::TermAttribute::toString ( )
virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

Field Documentation

◆ _termBuffer

CharArray Lucene::TermAttribute::_termBuffer
protected

◆ _termLength

int32_t Lucene::TermAttribute::_termLength
protected

◆ MIN_BUFFER_SIZE

const int32_t Lucene::TermAttribute::MIN_BUFFER_SIZE
staticprotected

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

clucene.sourceforge.net