com.icl.saxon.tree

Class AttributeCollection

public final class AttributeCollection extends Object implements 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(NamePool pool)
Create an empty attribute list.
AttributeCollection(NamePool pool, int n)
Create an empty attribute list with space for n attributes
AttributeCollection(AttributeCollection atts)
Create a new attribute collection as a clone
AttributeCollection(NamePool pool, Attributes atts)
Create a new attribute collection as a clone
Method Summary
voidaddAttribute(int nameCode, String type, String value)
Add an attribute to an attribute list.
voidaddAttribute(String prefix, String uri, String localName, String type, String value)
Add an attribute to an attribute list.
voidclear()
Clear the attribute list.
voidcompact()
Compact the attribute list to avoid wasting memory
intgetIndex(String name)
Get the index of an attribute (by name).
intgetIndex(String uri, String localname)
Get the index of an attribute (by name).
intgetIndexByFingerprint(int fingerprint)
Get the index, given the fingerprint
intgetLength()
Return the number of attributes in the list.
StringgetLocalName(int index)
Get the local name of an attribute (by position).
intgetNameCode(int index)
Get the namecode of an attribute (by position).
StringgetQName(int index)
Get the display name of an attribute (by position).
StringgetType(int index)
Get the type of an attribute (by position).
StringgetType(String uri, String localname)
Get the type of an attribute (by name).
StringgetType(String name)
Get the type of an attribute (by name).
StringgetURI(int index)
Get the namespace URI of an attribute (by position).
StringgetValue(int index)
Get the value of an attribute (by position).
StringgetValue(String uri, String localname)
Get the value of an attribute (by name).
StringgetValue(String name)
Get the value of an attribute (by name).
StringgetValueByFingerprint(int fingerprint)
Get the attribute value using its fingerprint
voidsetAttribute(String prefix, String uri, String localName, String type, String value)
Set an attribute value
voidsetAttribute(int nameCode, String type, String value)
Set an attribute value

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, Attributes atts)
Create a new attribute collection as a clone

Method Detail

addAttribute

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

Parameters: name The attribute name. type The attribute type ("NMTOKEN" for an enumeration). value The attribute value (must not be null).

See Also: org.xml.sax.DocumentHandler#startElement

addAttribute

public void addAttribute(String prefix, String uri, String localName, String type, 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. localname The local part of the attribute name. type The attribute type (e.g. "NMTOKEN"). value The attribute value (must not be null).

See Also: org.xml.sax.DocumentHandler#startElement

clear

public void clear()
Clear the attribute list.

compact

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

getIndex

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

Parameters: name The display name of the attribute.

Returns: The index position of the attribute

getIndex

public int getIndex(String uri, String localname)
Get the index of an attribute (by name).

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

getLength

public int getLength()
Return the number of attributes in the list.

Returns: The number of attributes in the list.

getLocalName

public String getLocalName(int index)
Get the local name of an attribute (by position).

Parameters: i 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.

getNameCode

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

Parameters: i The position of the attribute in the list.

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

getQName

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

Parameters: i The position of the attribute in the list.

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

getType

public String getType(int index)
Get the type of an attribute (by position).

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 String getType(String uri, String localname)
Get the type of an attribute (by name).

Parameters: uri The namespace uri of the attribute. localname The local name of the attribute.

Returns: The index position of the attribute

getType

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

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

getURI

public String getURI(int index)
Get the namespace URI of an attribute (by position).

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.

getValue

public String getValue(int index)
Get the value of an attribute (by position).

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 String getValue(String uri, String localname)
Get the value of an attribute (by name).

Parameters: uri The namespace uri of the attribute. localname The local name of the attribute.

Returns: The index position of the attribute

getValue

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

Parameters: name The attribute name.

getValueByFingerprint

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

setAttribute

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

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

setAttribute

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

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