Show / Hide Table of Contents

    Class Attributes

    Default implementation of the Attributes interface.

    Inheritance
    System.Object
    Attributes
    Attributes2
    Implements
    IAttributes
    Namespace: Sax.Helpers
    Assembly: Lucene.Net.Benchmark.dll
    Syntax
    public class Attributes : object, 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 Source

    Attributes()

    Construct a new, empty Attributes object.

    Declaration
    public Attributes()
    | Improve this Doc View Source

    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 Source

    Length

    Return the number of attributes in the list.

    Declaration
    public virtual int Length { get; }
    Property Value
    Type Description
    System.Int32
    See Also
    Length

    Methods

    | Improve this Doc View Source

    AddAttribute(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.

    | Improve this Doc View Source

    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()
    | Improve this Doc View Source

    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
    GetIndex(String)
    | Improve this Doc View Source

    GetIndex(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
    GetIndex(String, String)
    | Improve this Doc View Source

    GetLocalName(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
    GetLocalName(Int32)
    | Improve this Doc View Source

    GetQName(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
    GetQName(Int32)
    | Improve this Doc View Source

    GetType(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
    GetType(Int32)
    | Improve this Doc View Source

    GetType(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
    GetType(String)
    | Improve this Doc View Source

    GetType(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
    GetType(String, String)
    | Improve this Doc View Source

    GetURI(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
    GetURI(Int32)
    | Improve this Doc View Source

    GetValue(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
    GetValue(Int32)
    | Improve this Doc View Source

    GetValue(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
    GetValue(String)
    | Improve this Doc View Source

    GetValue(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
    GetValue(String, String)
    | Improve this Doc View Source

    RemoveAttribute(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).

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    Implements

    IAttributes
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)