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

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Lucene::AttributeSource Class Reference

An AttributeSource contains a list of different Attributes, and methods to add and get them. There can only be a single instance of an attribute in the same AttributeSource instance. This is ensured by passing in the actual type of the Attribute (Class<Attribute>) to the addAttribute(Class), which then checks if an instance of that type is already present. If yes, it returns the instance, otherwise it creates a new instance and returns it. More...

`#include <AttributeSource.h>`

Inheritance diagram for Lucene::AttributeSource:

## Public Member Functions

| AttributeSource ()
| An AttributeSource using the default attribute factory DefaultAttributeFactory. More...
| AttributeSource (const AttributeSourcePtr &input)
| An AttributeSource that uses the same attributes as the supplied one. More...
| AttributeSource (const AttributeFactoryPtr &factory)
| An AttributeSource using the supplied AttributeFactory for creating new Attribute instances. More...
virtual | ~AttributeSource ()
virtual String | getClassName ()
boost::shared_ptr< AttributeSource > | shared_from_this ()
AttributeFactoryPtr | getAttributeFactory ()
| returns the used AttributeFactory. More...
template<class ATTR >
boost::shared_ptr< ATTR > | addAttribute ()
| This method first checks if an instance of that class is already in this AttributeSource and returns it. Otherwise a new instance is created, added to this AttributeSource and returned. More...
void | addAttribute (const String &className, const AttributePtr &attrImpl)
| Adds a custom Attribute instance. More...
bool | hasAttributes ()
| Returns true if this AttributeSource has any attributes. More...
template<class ATTR >
bool | hasAttribute ()
| Returns true, if this AttributeSource contains the passed-in Attribute. More...
template<class ATTR >
boost::shared_ptr< ATTR > | getAttribute ()
| Returns the instance of the passed in Attribute contained in this AttributeSource. More...
void | clearAttributes ()
| Resets all Attributes in this AttributeSource by calling AttributeImpl#clear() on each Attribute implementation. More...
AttributeSourceStatePtr | captureState ()
| Captures the state of all Attributes. The return value can be passed to restoreState to restore the state of this or another AttributeSource. More...
void | restoreState (const AttributeSourceStatePtr &state)

Restores this state by copying the values of all attribute implementations that this state contains into the attributes implementations of the targetStream. The targetStream must contain a corresponding instance for each argument contained in this state (eg. it is not possible to restore the state of an AttributeSource containing a TermAttribute into a AttributeSource using a Token instance as implementation). More...

virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual String | toString ()
| Returns a string representation of the object. More...
AttributeSourcePtr | cloneAttributes ()
| Performs a clone of all AttributeImpl instances returned in a new AttributeSource instance. This method can be used to eg. create another TokenStream with exactly the same attributes (using {}) More...
Collection< AttributePtr > | getAttributes ()
| Return a vector of attributes based on currentState. More...
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. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()

## Protected Member Functions

AttributePtr | getAttribute (const String &className)
| The caller must pass in a className value. This method checks if an instance of that class is already in this AttributeSource and returns it. More...
bool | hasAttribute (const String &className)
| Returns true, if this AttributeSource contains the passed-in Attribute. More...
void | computeCurrentState ()
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Protected Attributes

AttributeFactoryPtr | factory
MapStringAttribute | attributes
AttributeSourceStatePtr | currentState
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Detailed Description

An AttributeSource contains a list of different Attributes, and methods to add and get them. There can only be a single instance of an attribute in the same AttributeSource instance. This is ensured by passing in the actual type of the Attribute (Class<Attribute>) to the addAttribute(Class), which then checks if an instance of that type is already present. If yes, it returns the instance, otherwise it creates a new instance and returns it.

## Constructor & Destructor Documentation

## ◆ AttributeSource() [1/3]

Lucene::AttributeSource::AttributeSource | ( |  | ) |

An AttributeSource using the default attribute factory DefaultAttributeFactory.

## ◆ AttributeSource() [2/3]

Lucene::AttributeSource::AttributeSource | ( | const AttributeSourcePtr & | input | ) |

An AttributeSource that uses the same attributes as the supplied one.

## ◆ AttributeSource() [3/3]

Lucene::AttributeSource::AttributeSource | ( | const AttributeFactoryPtr & | factory | ) |

An AttributeSource using the supplied AttributeFactory for creating new Attribute instances.

## ◆ ~AttributeSource()

virtual Lucene::AttributeSource::~AttributeSource | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::AttributeSource::_getClassName | ( |  | ) |

inline static

## ◆ addAttribute() [1/2]

template<class ATTR >

boost::shared_ptr<ATTR> Lucene::AttributeSource::addAttribute | ( |  | ) |

inline

This method first checks if an instance of that class is already in this AttributeSource and returns it. Otherwise a new instance is created, added to this AttributeSource and returned.

## ◆ addAttribute() [2/2]

void Lucene::AttributeSource::addAttribute | ( | const String & | className,
|  | const AttributePtr & | attrImpl
| ) |  |

Adds a custom Attribute instance.

## ◆ captureState()

AttributeSourceStatePtr Lucene::AttributeSource::captureState | ( |  | ) |

Captures the state of all Attributes. The return value can be passed to restoreState to restore the state of this or another AttributeSource.

## ◆ clearAttributes()

void Lucene::AttributeSource::clearAttributes | ( |  | ) |

Resets all Attributes in this AttributeSource by calling AttributeImpl#clear() on each Attribute implementation.

## ◆ cloneAttributes()

AttributeSourcePtr Lucene::AttributeSource::cloneAttributes | ( |  | ) |

Performs a clone of all AttributeImpl instances returned in a new AttributeSource instance. This method can be used to eg. create another TokenStream with exactly the same attributes (using {})

## ◆ computeCurrentState()

void Lucene::AttributeSource::computeCurrentState | ( |  | ) |

protected

## ◆ equals()

virtual bool Lucene::AttributeSource::equals | ( | const LuceneObjectPtr & | other | ) |

virtual

Return whether two objects are equal.

Reimplemented from Lucene::LuceneObject.

## ◆ getAttribute() [1/2]

template<class ATTR >

boost::shared_ptr<ATTR> Lucene::AttributeSource::getAttribute | ( |  | ) |

inline

Returns the instance of the passed in Attribute contained in this AttributeSource.

## ◆ getAttribute() [2/2]

AttributePtr Lucene::AttributeSource::getAttribute | ( | const String & | className | ) |

protected

The caller must pass in a className value. This method checks if an instance of that class is already in this AttributeSource and returns it.

## ◆ getAttributeFactory()

AttributeFactoryPtr Lucene::AttributeSource::getAttributeFactory | ( |  | ) |

returns the used AttributeFactory.

## ◆ getAttributes()

Collection<AttributePtr> Lucene::AttributeSource::getAttributes | ( |  | ) |

Return a vector of attributes based on currentState.

## ◆ getClassName()

virtual String Lucene::AttributeSource::getClassName | ( |  | ) |

inline virtual

Reimplemented in Lucene::SinkTokenStream, Lucene::NumericTokenStream, Lucene::TeeSinkTokenFilter, Lucene::TokenStream, Lucene::SingleTokenAttributeSource, Lucene::StandardTokenizer, Lucene::ASCIIFoldingFilter, Lucene::Tokenizer, Lucene::PorterStemFilter, Lucene::LowerCaseTokenizer, Lucene::StopFilter, Lucene::LetterTokenizer, Lucene::WhitespaceTokenizer, Lucene::ISOLatin1AccentFilter, Lucene::TokenFilter, Lucene::CachingTokenFilter, Lucene::KeywordTokenizer, Lucene::CharTokenizer, Lucene::LengthFilter, Lucene::StandardFilter, and Lucene::LowerCaseFilter.

## ◆ hasAttribute() [1/2]

template<class ATTR >

bool Lucene::AttributeSource::hasAttribute | ( |  | ) |

inline

Returns true, if this AttributeSource contains the passed-in Attribute.

## ◆ hasAttribute() [2/2]

bool Lucene::AttributeSource::hasAttribute | ( | const String & | className | ) |

protected

Returns true, if this AttributeSource contains the passed-in Attribute.

## ◆ hasAttributes()

bool Lucene::AttributeSource::hasAttributes | ( |  | ) |

Returns true if this AttributeSource has any attributes.

## ◆ hashCode()

virtual int32_t Lucene::AttributeSource::hashCode | ( |  | ) |

virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

## ◆ restoreState()

void Lucene::AttributeSource::restoreState | ( | const AttributeSourceStatePtr & | state | ) |

Restores this state by copying the values of all attribute implementations that this state contains into the attributes implementations of the targetStream. The targetStream must contain a corresponding instance for each argument contained in this state (eg. it is not possible to restore the state of an AttributeSource containing a TermAttribute into a AttributeSource using a Token instance as implementation).

Note that this method does not affect attributes of the targetStream that are not contained in this state. In other words, if for example the targetStream contains an OffsetAttribute, but this state doesn't, then the value of the OffsetAttribute remains unchanged. It might be desirable to reset its value to the default, in which case the caller should first call TokenStream#clearAttributes() on the targetStream.

## ◆ shared_from_this()

boost::shared_ptr< AttributeSource > Lucene::AttributeSource::shared_from_this | ( |  | ) |

inline

## ◆ toString()

virtual String Lucene::AttributeSource::toString | ( |  | ) |

virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

Reimplemented in Lucene::NumericTokenStream.

## Field Documentation

## ◆ attributes

MapStringAttribute Lucene::AttributeSource::attributes

protected

## ◆ currentState

AttributeSourceStatePtr Lucene::AttributeSource::currentState

protected

## ◆ factory

AttributeFactoryPtr Lucene::AttributeSource::factory

protected

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

- AttributeSource.h

clucene.sourceforge.net