Class Attributes
Default implementation of the Attributes interface.
Implements
Inherited Members
Namespace: Sax.Helpers
Assembly: Lucene.Net.Benchmark.dll
Syntax
public class Attributes : IAttributes
Remarks
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
This class provides a default implementation of the SAX2 Attributes interface, with the addition of manipulators so that the list can be modified or reused.
There are two typical uses of this class:
- to take a persistent snapshot of an Attributes object in a StartElement(String, String, String, IAttributes) event; or
- to construct or modify an Attributes object in a SAX2 driver or filter.
This class replaces the now-deprecated SAX1 AttributeListImpl class; in addition to supporting the updated Attributes interface rather than the deprecated IAttributeList interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.
Constructors
| Improve this Doc View SourceAttributes()
Construct a new, empty Attributes object.
Declaration
public Attributes()
Attributes(IAttributes)
Copy an existing Attributes object.
This constructor is especially useful inside a StartElement(String, String, String, IAttributes).
Declaration
public Attributes(IAttributes atts)
Parameters
| Type | Name | Description |
|---|---|---|
| IAttributes | atts | The existing Attributes object. |
Properties
| Improve this Doc View SourceLength
Return the number of attributes in the list.
Declaration
public virtual int Length { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
See Also
Methods
| Improve this Doc View SourceAddAttribute(String, String, String, String, String)
Add an attribute to the end of the list.
For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
Declaration
public virtual void AddAttribute(string uri, string localName, string qName, string type, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The Namespace URI, or the empty string if none is available or Namespace processing is not being performed. |
| System.String | localName | The local name, or the empty string if Namespace processing is not being performed. |
| System.String | qName | The qualified (prefixed) name, or the empty string if qualified names are not available. |
| System.String | type | The attribute type as a string. |
| System.String | value | The attribute value. |
Clear()
Clear the attribute list for reuse.
Note that little memory is freed by this call: the current array is kept so it can be reused.
Declaration
public virtual void Clear()
GetIndex(String)
Look up an attribute's index by qualified (prefixed) name.
Declaration
public virtual int GetIndex(string qName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | qName | The qualified name. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The attribute's index, or -1 if none matches. |
See Also
| Improve this Doc View SourceGetIndex(String, String)
Look up an attribute's index by Namespace name.
Declaration
public virtual int GetIndex(string uri, string localName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The attribute's Namespace URI, or the empty string if none is available. |
| System.String | localName | The attribute's local name. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The attribute's index, or -1 if none matches. |
Remarks
In many cases, it will be more efficient to look up the name once and use the index query methods rather than using the name query methods repeatedly.
See Also
| Improve this Doc View SourceGetLocalName(Int32)
Return an attribute's local name.
Declaration
public virtual string GetLocalName(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The attribute's index (zero-based). |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's local name, the empty string if none is available, or null if the index if out of range. |
See Also
| Improve this Doc View SourceGetQName(Int32)
Return an attribute's qualified (prefixed) name.
Declaration
public virtual string GetQName(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The attribute's index (zero-based). |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's qualified name, the empty string if none is available, or null if the index is out of bounds. |
See Also
| Improve this Doc View SourceGetType(Int32)
Return an attribute's type by index.
Declaration
public virtual string GetType(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The attribute's index (zero-based). |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's type, "CDATA" if the type is unknown, or null if the index is out of bounds. |
See Also
| Improve this Doc View SourceGetType(String)
Look up an attribute's type by qualified (prefixed) name.
Declaration
public virtual string GetType(string qName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | qName | The qualified name. |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's type, or null if there is no matching attribute. |
See Also
| Improve this Doc View SourceGetType(String, String)
Look up an attribute's type by Namespace-qualified name.
Declaration
public virtual string GetType(string uri, string localName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The Namespace URI, or the empty string for a name with no explicit Namespace URI. |
| System.String | localName | The local name. |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's type, or null if there is no matching attribute. |
See Also
| Improve this Doc View SourceGetURI(Int32)
Return an attribute's Namespace URI.
Declaration
public virtual string GetURI(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The attribute's index (zero-based). |
Returns
| Type | Description |
|---|---|
| System.String | The Namespace URI, the empty string if none is available, or null if the index is out of range. |
See Also
| Improve this Doc View SourceGetValue(Int32)
Return an attribute's value by index.
Declaration
public virtual string GetValue(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The attribute's index (zero-based). |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's value or null if the index is out of bounds. |
See Also
| Improve this Doc View SourceGetValue(String)
Look up an attribute's value by qualified (prefixed) name.
Declaration
public virtual string GetValue(string qName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | qName | The qualified name. |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's value, or null if there is no matching attribute. |
See Also
| Improve this Doc View SourceGetValue(String, String)
Look up an attribute's value by Namespace-qualified name.
Declaration
public virtual string GetValue(string uri, string localName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The Namespace URI, or the empty string for a name with no explicit Namespace URI. |
| System.String | localName | The local name. |
Returns
| Type | Description |
|---|---|
| System.String | The attribute's value, or null if there is no matching attribute. |
See Also
| Improve this Doc View SourceRemoveAttribute(Int32)
Remove an attribute from the list.
Declaration
public virtual void RemoveAttribute(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetAttribute(Int32, String, String, String, String, String)
Set an attribute in the list.
For the sake of speed, this method does no checking for name conflicts or well-formedness: such checks are the responsibility of the application.
Declaration
public virtual void SetAttribute(int index, string uri, string localName, string qName, string type, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | uri | The Namespace URI, or the empty string if none is available or Namespace processing is not being performed. |
| System.String | localName | The local name, or the empty string if Namespace processing is not being performed. |
| System.String | qName | The qualified name, or the empty string if qualified names are not available. |
| System.String | type | The attribute type as a string. |
| System.String | value | The attribute value. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetAttributes(IAttributes)
Copy an entire Attributes object.
It may be more efficient to reuse an existing object rather than constantly allocating new ones.
Declaration
public virtual void SetAttributes(IAttributes atts)
Parameters
| Type | Name | Description |
|---|---|---|
| IAttributes | atts | The attributes to copy. |
SetLocalName(Int32, String)
Set the local name of a specific attribute.
Declaration
public virtual void SetLocalName(int index, string localName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | localName | The attribute's local name, or the empty string for none. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetQName(Int32, String)
Set the qualified name of a specific attribute.
Declaration
public virtual void SetQName(int index, string qName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | qName | The attribute's qualified name, or the empty string for none. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetType(Int32, String)
Set the type of a specific attribute.
Declaration
public virtual void SetType(int index, string type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | type | The attribute's type. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetURI(Int32, String)
Set the Namespace URI of a specific attribute.
Declaration
public virtual void SetURI(int index, string uri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | uri | The attribute's Namespace URI, or the empty string for none. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |
SetValue(Int32, String)
Set the value of a specific attribute.
Declaration
public virtual void SetValue(int index, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the attribute (zero-based). |
| System.String | value | The attribute's value. |
Exceptions
| Type | Condition |
|---|---|
| System.IndexOutOfRangeException | When the supplied index does not point to an attribute in the list. |