Class Attribute
Base class for Attributes that can be added to a AttributeSource.
Attributes are used to add data in a dynamic, yet type-safe way to a source of usually streamed objects, e. g. a TokenStream.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public abstract class Attribute : IAttribute
Methods
| Improve this Doc View SourceClear()
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.
Declaration
public abstract void Clear()
Clone()
Shallow clone. Subclasses must override this if they need to clone any members deeply,
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
System.Object |
CopyTo(IAttribute)
Copies the values from this Attribute into the passed-in
target
attribute. The target
implementation must support all the
IAttributes this implementation supports.
Declaration
public abstract void CopyTo(IAttribute target)
Parameters
Type | Name | Description |
---|---|---|
IAttribute | target |
ReflectAsString(Boolean)
This method returns the current attribute values as a string in the following format by calling the ReflectWith(IAttributeReflector) method:
- if
prependAttClass
=true:"AttributeClass.Key=value,AttributeClass.Key=value"
- if
prependAttClass
=false:"key=value,key=value"
Declaration
public string ReflectAsString(bool prependAttClass)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | prependAttClass |
Returns
Type | Description |
---|---|
System.String |
See Also
| Improve this Doc View SourceReflectWith(IAttributeReflector)
This method is for introspection of attributes, it should simply add the key/values this attribute holds to the given IAttributeReflector.
The default implementation calls Reflect(Type, String, Object) for all non-static fields from the implementing class, using the field name as key and the field value as value. The IAttribute class is also determined by Reflection. Please note that the default implementation can only handle single-Attribute implementations.
Custom implementations look like this (e.g. for a combined attribute implementation):
public void ReflectWith(IAttributeReflector reflector)
{
reflector.Reflect(typeof(ICharTermAttribute), "term", GetTerm());
reflector.Reflect(typeof(IPositionIncrementAttribute), "positionIncrement", GetPositionIncrement());
}
If you implement this method, make sure that for each invocation, the same set of IAttribute
interfaces and keys are passed to Reflect(Type, String, Object) in the same order, but possibly
different values. So don't automatically exclude e.g. null
properties!
Declaration
public virtual void ReflectWith(IAttributeReflector reflector)
Parameters
Type | Name | Description |
---|---|---|
IAttributeReflector | reflector |
See Also
| Improve this Doc View SourceToString()
The default implementation of this method accesses all declared fields of this object and prints the values in the following syntax:
public String ToString()
{
return "start=" + startOffset + ",end=" + endOffset;
}
This method may be overridden by subclasses.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |