Class AttributeSource
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 IAttribute to
the AddAttribute<T>(), 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.
Inheritance
System.Object
AttributeSource
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Lucene.Net.dll
Syntax
public class AttributeSource
Constructors
|
Improve this Doc
View Source
AttributeSource()
Declaration
|
Improve this Doc
View Source
AttributeSource(AttributeSource)
Declaration
public AttributeSource(AttributeSource input)
Parameters
|
Improve this Doc
View Source
AttributeSource(AttributeSource.AttributeFactory)
Declaration
public AttributeSource(AttributeSource.AttributeFactory factory)
Parameters
Properties
|
Improve this Doc
View Source
HasAttributes
Declaration
public bool HasAttributes { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
AddAttribute<T>()
The caller must pass in an interface type that extends IAttribute.
This method first checks if an instance of the corresponding class is
already in this AttributeSource and returns it. Otherwise a
new instance is created, added to this AttributeSource and returned.
Declaration
public T AddAttribute<T>()
where T : IAttribute
Returns
Type Parameters
|
Improve this Doc
View Source
AddAttributeImpl(Attribute)
Expert: Adds a custom Attribute instance with one or more IAttribute interfaces.
Please note: It is not guaranteed, that att
is added to
the AttributeSource, because the provided attributes may already exist.
You should always retrieve the wanted attributes using GetAttribute<T>() after adding
with this method and cast to your System.Type.
The recommended way to use custom implementations is using an AttributeSource.AttributeFactory.
Declaration
public void AddAttributeImpl(Attribute att)
Parameters
|
Improve this Doc
View Source
CaptureState()
Declaration
public virtual AttributeSource.State CaptureState()
Returns
|
Improve this Doc
View Source
ClearAttributes()
Declaration
public void ClearAttributes()
|
Improve this Doc
View Source
CloneAttributes()
Declaration
public AttributeSource CloneAttributes()
Returns
|
Improve this Doc
View Source
CopyTo(AttributeSource)
Declaration
public void CopyTo(AttributeSource target)
Parameters
|
Improve this Doc
View Source
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.Object.Equals(System.Object)
|
Improve this Doc
View Source
GetAttribute<T>()
Declaration
public virtual T GetAttribute<T>()
where T : IAttribute
Returns
Type Parameters
Exceptions
|
Improve this Doc
View Source
GetAttributeClassesEnumerator()
Returns a new iterator that iterates the attribute classes
in the same order they were added in.
Declaration
public IEnumerator<Type> GetAttributeClassesEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<System.Type> |
|
|
Improve this Doc
View Source
GetAttributeFactory()
Declaration
public AttributeSource.AttributeFactory GetAttributeFactory()
Returns
|
Improve this Doc
View Source
GetAttributeImplsEnumerator()
Declaration
public IEnumerator<Attribute> GetAttributeImplsEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<Attribute> |
|
|
Improve this Doc
View Source
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.Object.GetHashCode()
|
Improve this Doc
View Source
HasAttribute<T>()
Declaration
public bool HasAttribute<T>()
where T : IAttribute
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
|
Improve this Doc
View Source
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 Source
ReflectWith(IAttributeReflector)
Declaration
public void ReflectWith(IAttributeReflector reflector)
Parameters
See Also
|
Improve this Doc
View Source
RestoreState(AttributeSource.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 (e.g. it is not possible to restore the state of
an AttributeSource containing a ICharTermAttribute 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 IOffsetAttribute, but this state doesn't, then
the value of the IOffsetAttribute remains unchanged. It might be desirable to
reset its value to the default, in which case the caller should first
call ClearAttributes() (TokenStream.ClearAttributes()
on the targetStream.
Declaration
public void RestoreState(AttributeSource.State state)
Parameters
|
Improve this Doc
View Source
ToString()
Returns a string consisting of the class's simple name, the hex representation of the identity hash code,
and the current reflection of all attributes.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
See Also