Class AttributeCollection
java.lang.Object
com.icl.saxon.tree.AttributeCollection
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionAttributeCollection(NamePool pool) Create an empty attribute list.AttributeCollection(NamePool pool, int n) Create an empty attribute list with space for n attributesAttributeCollection(NamePool pool, Attributes atts) Create a new attribute collection as a cloneCreate a new attribute collection as a clone -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(int nameCode, String type, String value) Add an attribute to an attribute list.voidAdd an attribute to an attribute list.voidclear()Clear the attribute list.voidcompact()Compact the attribute list to avoid wasting memoryintGet the index of an attribute (by name).intGet the index of an attribute (by name).intgetIndexByFingerprint(int fingerprint) Get the index, given the fingerprintintReturn the number of attributes in the list.getLocalName(int index) Get the local name of an attribute (by position).intgetNameCode(int index) Get the namecode of an attribute (by position).getQName(int index) Get the display name of an attribute (by position).getType(int index) Get the type of an attribute (by position).Get the type of an attribute (by name).Get the type of an attribute (by name).getURI(int index) Get the namespace URI of an attribute (by position).getValue(int index) Get the value of an attribute (by position).Get the value of an attribute (by name).Get the value of an attribute (by name).getValueByFingerprint(int fingerprint) Get the attribute value using its fingerprintvoidsetAttribute(int nameCode, String type, String value) Set an attribute valuevoidSet an attribute value
-
Constructor Details
-
AttributeCollection
Create an empty attribute list. -
AttributeCollection
Create an empty attribute list with space for n attributes -
AttributeCollection
Create a new attribute collection as a clone -
AttributeCollection
Create a new attribute collection as a clone
-
-
Method Details
-
addAttribute
-
addAttribute
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).localname- The local part of the attribute name.- See Also:
-
setAttribute
-
setAttribute
-
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:
getLengthin interfaceAttributes- Returns:
- The number of attributes in the list.
-
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
Get the display name of an attribute (by position).- Specified by:
getQNamein interfaceAttributes- 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.
-
getLocalName
Get the local name of an attribute (by position).- Specified by:
getLocalNamein interfaceAttributes- 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.
-
getURI
Get the namespace URI of an attribute (by position).- Specified by:
getURIin interfaceAttributes- 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
Get the type of an attribute (by position).- Specified by:
getTypein interfaceAttributes- 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
Get the type of an attribute (by name).- Specified by:
getTypein interfaceAttributes- Parameters:
uri- The namespace uri of the attribute.localname- The local name of the attribute.- Returns:
- The index position of the attribute
-
getValue
Get the value of an attribute (by position).- Specified by:
getValuein interfaceAttributes- 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
Get the value of an attribute (by name).- Specified by:
getValuein interfaceAttributes- Parameters:
uri- The namespace uri of the attribute.localname- The local name of the attribute.- Returns:
- The index position of the attribute
-
getValueByFingerprint
Get the attribute value using its fingerprint -
getIndex
Get the index of an attribute (by name).- Specified by:
getIndexin interfaceAttributes- Parameters:
name- The display name of the attribute.- Returns:
- The index position of the attribute
-
getIndex
Get the index of an attribute (by name).- Specified by:
getIndexin interfaceAttributes- 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
Get the type of an attribute (by name).- Specified by:
getTypein interfaceAttributes- 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
Get the value of an attribute (by name).- Specified by:
getValuein interfaceAttributes- Parameters:
name- The attribute name.
-