com.icl.saxon
Class AttributeCollection

java.lang.Object
  |
  +--com.icl.saxon.AttributeCollection
All Implemented Interfaces:
org.xml.sax.AttributeList

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

AttributeCollection is an implementation of the SAX interface AttributeList 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()
          Create an empty attribute list.
AttributeCollection(int n)
          Create an empty attribute list with space for n attributes
 
Method Summary
 void addAttribute(Name name, 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
 AttributeCollection copy()
          Create a new attribute collection as a clone of this one
 Name getExpandedName(int i)
          Get the name of an attribute (by position).
 int getLength()
          Return the number of attributes in the list.
 java.lang.String getName(int i)
          Get the name of an attribute (by position).
 int getPosition(Name name)
          Find the position of an attribute with a given name
 java.lang.String getType(int i)
          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 getValue(int i)
          Get the value of an attribute (by position).
 java.lang.String getValue(Name name)
          Get the value of an attribute, given its full name.
 java.lang.String getValue(java.lang.String name)
          Get the value of an attribute (by name).
 void removeAttribute(Name name)
          Remove an attribute from the list.
 void setAttribute(Name name, java.lang.String value)
          Set an attribute value
 void setAttribute(Name name, 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()
Create an empty attribute list.

AttributeCollection

public AttributeCollection(int n)
Create an empty attribute list with space for n attributes
Method Detail

copy

public AttributeCollection copy()
Create a new attribute collection as a clone of this one

addAttribute

public void addAttribute(Name name,
                         java.lang.String type,
                         java.lang.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:
removeAttribute(com.icl.saxon.om.Name), 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.
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:
removeAttribute(com.icl.saxon.om.Name), DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)

removeAttribute

public void removeAttribute(Name name)
Remove an attribute from the list. The call has no effect if there is no attribute with the given name
Parameters:
name - The attribute name.

setAttribute

public void setAttribute(Name name,
                         java.lang.String value)
Set an attribute value
Parameters:
name - the name of the attribute
value - the value of the attribute

setAttribute

public void setAttribute(Name name,
                         java.lang.String type,
                         java.lang.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

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.AttributeList
Returns:
The number of attributes in the list.

getName

public java.lang.String getName(int i)
Get the name of an attribute (by position).
Specified by:
getName in interface org.xml.sax.AttributeList
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 java.lang.String getType(int i)
Get the type of an attribute (by position).
Specified by:
getType in interface org.xml.sax.AttributeList
Parameters:
i - 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.

getValue

public java.lang.String getValue(int i)
Get the value of an attribute (by position).
Specified by:
getValue in interface org.xml.sax.AttributeList
Parameters:
i - 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.

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.AttributeList
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.AttributeList
Parameters:
name - The attribute name.

getExpandedName

public Name getExpandedName(int i)
Get the 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.

getValue

public java.lang.String getValue(Name name)
Get the value of an attribute, given its full name.
Parameters:
name - The full name of the attribute in the list.
Returns:
The value of the attribute as a string, or null if there is no attribute with that name.

getPosition

public int getPosition(Name name)
Find the position of an attribute with a given name
Returns:
the position of the attribute in the list, or -1 if not present