com.icl.saxon.tree
Class AttributeCollection

java.lang.Object
  extended bycom.icl.saxon.tree.AttributeCollection
All Implemented Interfaces:
org.xml.sax.Attributes

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

AttributeCollection is an implementation of the SAX2 interface Attributes that also provides the ability to manipulate namespaces and to convert attributes into Nodes. It is extremely similar (both in interface and in implementation) to the SAX2 Attributes class, but was defined before SAX2 was available.


Constructor Summary
AttributeCollection(AttributeCollection atts)
          Create a new attribute collection as a clone
AttributeCollection(NamePool pool)
          Create an empty attribute list.
AttributeCollection(NamePool pool, org.xml.sax.Attributes atts)
          Create a new attribute collection as a clone
AttributeCollection(NamePool pool, int n)
          Create an empty attribute list with space for n attributes
 
Method Summary
 void addAttribute(int nameCode, java.lang.String type, java.lang.String value)
          Add an attribute to an attribute list.
 void addAttribute(java.lang.String prefix, java.lang.String uri, java.lang.String localName, java.lang.String type, java.lang.String value)
          Add an attribute to an attribute list.
 void clear()
          Clear the attribute list.
 void compact()
          Compact the attribute list to avoid wasting memory
 int getIndex(java.lang.String name)
          Get the index of an attribute (by name).
 int getIndex(java.lang.String uri, java.lang.String localname)
          Get the index of an attribute (by name).
 int getIndexByFingerprint(int fingerprint)
          Get the index, given the fingerprint
 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).
 int getNameCode(int index)
          Get the namecode of an attribute (by position).
 java.lang.String getQName(int index)
          Get the display name 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 name).
 java.lang.String getType(java.lang.String uri, java.lang.String localname)
          Get the type of an attribute (by name).
 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 name).
 java.lang.String getValue(java.lang.String uri, java.lang.String localname)
          Get the value of an attribute (by name).
 java.lang.String getValueByFingerprint(int fingerprint)
          Get the attribute value using its fingerprint
 void setAttribute(int nameCode, java.lang.String type, java.lang.String value)
          Set an attribute value
 void setAttribute(java.lang.String prefix, java.lang.String uri, java.lang.String localName, java.lang.String type, java.lang.String value)
          Set an attribute value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeCollection

public AttributeCollection(NamePool pool)
Create an empty attribute list.


AttributeCollection

public AttributeCollection(NamePool pool,
                           int n)
Create an empty attribute list with space for n attributes


AttributeCollection

public AttributeCollection(AttributeCollection atts)
Create a new attribute collection as a clone


AttributeCollection

public AttributeCollection(NamePool pool,
                           org.xml.sax.Attributes atts)
Create a new attribute collection as a clone

Method Detail

addAttribute

public void addAttribute(int nameCode,
                         java.lang.String type,
                         java.lang.String value)
Add an attribute to an attribute list.

Parameters:
type - The attribute type ("NMTOKEN" for an enumeration).
value - The attribute value (must not be null).
See Also:
DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)

addAttribute

public void addAttribute(java.lang.String prefix,
                         java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String type,
                         java.lang.String value)
Add an attribute to an attribute list.

Parameters:
prefix - The namespace prefix of the attribute name.
uri - The namespace uri of the attribute name.
type - The attribute type (e.g. "NMTOKEN").
value - The attribute value (must not be null).
See Also:
DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)

setAttribute

public void setAttribute(java.lang.String prefix,
                         java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String type,
                         java.lang.String value)
Set an attribute value

Parameters:
type - the type of the attribute (e.g. CDATA)
value - the value of the attribute

setAttribute

public void setAttribute(int nameCode,
                         java.lang.String type,
                         java.lang.String value)
Set an attribute value

Parameters:
type - the type of the attribute (e.g. CDATA)
value - the value of the attribute

clear

public void clear()
Clear the attribute list.


compact

public void compact()
Compact the attribute list to avoid wasting memory


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 in the list.

getNameCode

public int getNameCode(int index)
Get the namecode of an attribute (by position).

Returns:
The display name of the attribute as a string, or null if there is no attribute at that position.

getQName

public java.lang.String getQName(int index)
Get the display name of an attribute (by position).

Specified by:
getQName in interface org.xml.sax.Attributes
Returns:
The display name 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
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).

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

getValueByFingerprint

public java.lang.String getValueByFingerprint(int fingerprint)
Get the attribute value using its fingerprint


getIndex

public int getIndex(java.lang.String name)
Get the index of an attribute (by name).

Specified by:
getIndex in interface org.xml.sax.Attributes
Parameters:
name - The display name of the attribute.
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

getIndexByFingerprint

public int getIndexByFingerprint(int fingerprint)
Get the index, given the fingerprint


getType

public java.lang.String getType(java.lang.String name)
Get the type of an attribute (by name).

Specified by:
getType in interface org.xml.sax.Attributes
Parameters:
name - The display name of the attribute.
Returns:
The attribute type as a string ("NMTOKEN" for an enumeration, and "CDATA" if no declaration was read).

getValue

public java.lang.String getValue(java.lang.String name)
Get the value of an attribute (by name).

Specified by:
getValue in interface org.xml.sax.Attributes
Parameters:
name - The attribute name.