Package net.sf.saxon.tree.util

## Class AttributeCollectionImpl

- java.lang.Object
- - net.sf.saxon.tree.util.AttributeCollectionImpl

- All Implemented Interfaces:
    `org.xml.sax.Attributes`

      public class AttributeCollectionImpl
      extends java.lang.Object
      implements org.xml.sax.Attributes

  AttributeCollectionImpl is an implementation of the SAX2 interface Attributes.

  As well as providing the information required by the SAX2 interface, an AttributeCollection can hold type information (as needed to support the JAXP 1.3 `ValidatorHandler` interface), and location information for debugging. The location information is used in the case of attributes on a result tree to identify the location in the query or stylesheet from which they were generated.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AttributeCollectionImpl​(Configuration config, int initialSize)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAttribute​(NodeName nodeName, SimpleType type, java.lang.String value, Location locationId, int properties)` | Add an attribute to an attribute list.
    `int` | `getIndex​(java.lang.String qname)` | Get the index of an attribute, from its lexical QName
    `int` | `getIndex​(java.lang.String uri, java.lang.String localname)` | Get the index of an attribute (by name).
    `int` | `getLength()` | Return the number of attributes in the list.
    `java.lang.String` | `getLocalName​(int index)` | Get the local name of an attribute (by position).
    `Location` | `getLocation​(int index)` | Get the location of an attribute (by position)
    `int` | `getProperties​(int index)` | Get the properties of an attribute (by position)
    `java.lang.String` | `getQName​(int index)` | Get the lexical QName of an attribute (by position).
    `java.lang.String` | `getType​(int index)` | Get the type of an attribute (by position).
    `java.lang.String` | `getType​(java.lang.String name)` | Get the type of an attribute (by lexical QName).
    `java.lang.String` | `getType​(java.lang.String uri, java.lang.String localname)` | Get the type of an attribute (by name).
    `SimpleType` | `getTypeAnnotation​(int index)` | Get the type of an attribute (by position).
    `java.lang.String` | `getURI​(int index)` | Get the namespace URI of an attribute (by position).
    `java.lang.String` | `getValue​(int index)` | Get the value of an attribute (by position).
    `java.lang.String` | `getValue​(java.lang.String name)` | Get the value of an attribute (by lexnical QName).
    `java.lang.String` | `getValue​(java.lang.String uri, java.lang.String localname)` | Get the value of an attribute (by name).
    `void` | `setAttribute​(int index, NodeName nodeName, SimpleType type, java.lang.String value, Location locationId, int properties)` | Set (overwrite) an attribute in the attribute list.
    `void` | `setAttribute​(AttributeInfo attribute)` | Add an attribute to the collection, replacing any existing attribute with the same name
    `void` | `setTypeAnnotation​(int index, SimpleType type)` | Set the type annotation of an attribute

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AttributeCollectionImpl

          public AttributeCollectionImpl​(Configuration config,
                                         int initialSize)

  - ### Method Detail

    - #### addAttribute

          public void addAttribute​(NodeName nodeName,
                                   SimpleType type,
                                   java.lang.String value,
                                   Location locationId,
                                   int properties)

      Add an attribute to an attribute list. The parameters correspond to the parameters of the `Outputter.attribute(NodeName, SimpleType, CharSequence, Location, int)` method. There is no check that the name of the attribute is distinct from other attributes already in the collection: this check must be made by the caller.
      Parameters:
        `nodeName` - Object representing the attribute name.
        `type` - The attribute type
        `value` - The attribute value (must not be null)
        `locationId` - Identifies the attribute location.
        `properties` - Attribute properties

    - #### setAttribute

          public void setAttribute​(int index,
                                   NodeName nodeName,
                                   SimpleType type,
                                   java.lang.String value,
                                   Location locationId,
                                   int properties)

      Set (overwrite) an attribute in the attribute list. The parameters correspond to the parameters of the `Outputter.attribute(NodeName, SimpleType, CharSequence, Location, int)` method.
      Parameters:
        `index` - Identifies the entry to be replaced. Must be in range (nasty things happen if not)
        `nodeName` - representing the attribute name.
        `type` - The attribute type code
        `value` - The attribute value (must not be null)
        `locationId` - Identifies the attribtue location.
        `properties` - Attribute properties

    - #### getLength

          public int getLength()

      Return the number of attributes in the list.
      Specified by:
        `getLength` in interface `org.xml.sax.Attributes`
      Returns:
        The number of attributes that have been created in this attribute collection. This is the number of slots used in the list, including any slots allocated to attributes that have since been deleted. Such slots are not reused, to preserve attribute identity.

    - #### getTypeAnnotation

          public SimpleType getTypeAnnotation​(int index)

      Get the type of an attribute (by position).
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The type annotation

    - #### getLocation

          public Location getLocation​(int index)

      Get the location of an attribute (by position)
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The location of the attribute. This can be used to obtain the actual system identifier and line number of the relevant location

    - #### getProperties

          public int getProperties​(int index)

      Get the properties of an attribute (by position)
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The properties of the attribute. This is a set of bit-settings defined in class `ReceiverOption`. The most interesting of these is {`ReceiverOption.DEFAULTED_VALUE`, which indicates an attribute that was added to an element as a result of schema validation.

    - #### getQName

          public java.lang.String getQName​(int index)

      Get the lexical QName of an attribute (by position).
      Specified by:
        `getQName` in interface `org.xml.sax.Attributes`
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The lexical QName of the attribute as a string, or null if there is no attribute at that position.

    - #### getLocalName

          public java.lang.String getLocalName​(int index)

      Get the local name of an attribute (by position).
      Specified by:
        `getLocalName` in interface `org.xml.sax.Attributes`
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The local name of the attribute as a string, or null if there is no attribute at that position.

    - #### getURI

          public java.lang.String getURI​(int index)

      Get the namespace URI of an attribute (by position).
      Specified by:
        `getURI` in interface `org.xml.sax.Attributes`
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The local name of the attribute as a string, or null if there is no attribute at that position.

    - #### getType

          public java.lang.String getType​(int index)

      Get the type of an attribute (by position). This is a SAX2 method, so it gets the type name as a DTD attribute type, mapped from the schema type code.
      Specified by:
        `getType` in interface `org.xml.sax.Attributes`
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The attribute type as a string ("NMTOKEN" for an enumeration, and "CDATA" if no declaration was read), or null if there is no attribute at that position.

    - #### getType

          public java.lang.String getType​(java.lang.String uri,
                                          java.lang.String localname)

      Get the type of an attribute (by name).
      Specified by:
        `getType` in interface `org.xml.sax.Attributes`
      Parameters:
        `uri` - The namespace uri of the attribute.
        `localname` - The local name of the attribute.
      Returns:
        The index position of the attribute

    - #### getValue

          public java.lang.String getValue​(int index)

      Get the value of an attribute (by position).
      Specified by:
        `getValue` in interface `org.xml.sax.Attributes`
      Parameters:
        `index` - The position of the attribute in the list.
      Returns:
        The attribute value as a string, or null if there is no attribute at that position.

    - #### getValue

          public java.lang.String getValue​(java.lang.String uri,
                                           java.lang.String localname)

      Get the value of an attribute (by name).
      Specified by:
        `getValue` in interface `org.xml.sax.Attributes`
      Parameters:
        `uri` - The namespace uri of the attribute.
        `localname` - The local name of the attribute.
      Returns:
        The index position of the attribute

    - #### getIndex

          public int getIndex​(java.lang.String qname)

      Get the index of an attribute, from its lexical QName
      Specified by:
        `getIndex` in interface `org.xml.sax.Attributes`
      Parameters:
        `qname` - The lexical QName of the attribute. The prefix must match.
      Returns:
        The index position of the attribute

    - #### getIndex

          public int getIndex​(java.lang.String uri,
                              java.lang.String localname)

      Get the index of an attribute (by name).
      Specified by:
        `getIndex` in interface `org.xml.sax.Attributes`
      Parameters:
        `uri` - The namespace uri of the attribute.
        `localname` - The local name of the attribute.
      Returns:
        The index position of the attribute, or -1 if absent

    - #### getType

          public java.lang.String getType​(java.lang.String name)

      Get the type of an attribute (by lexical QName).
      Specified by:
        `getType` in interface `org.xml.sax.Attributes`
      Parameters:
        `name` - The lexical QName of the attribute.
      Returns:
        The attribute type as a string (e.g. "NMTOKEN", or "CDATA" if no declaration was read).

    - #### getValue

          public java.lang.String getValue​(java.lang.String name)

      Get the value of an attribute (by lexnical QName).
      Specified by:
        `getValue` in interface `org.xml.sax.Attributes`
      Parameters:
        `name` - The attribute name (a lexical QName). The prefix must match the prefix originally used. This method is defined in SAX, but is not recommended except where the prefix is null.

    - #### setTypeAnnotation

          public void setTypeAnnotation​(int index,
                                        SimpleType type)

      Set the type annotation of an attribute
      Parameters:
        `index` - the index position of the attribute node
        `type` - the new type for the attribute

    - #### setAttribute

          public void setAttribute​(AttributeInfo attribute)

      Add an attribute to the collection, replacing any existing attribute with the same name
      Parameters:
        `attribute` - the attribute to be added to the collection