java.lang.Object | +--org.xml.sax.helpers.AttributesImpl
Default implementation of the Attributes interface.
This module, both source code and documentation, is in the Public Domain, and comes withNO WARRANTY.
This class provides a default implementation of the SAX2Attributes
interface, with the addition of manipulators so that the list can be modified or reused.
There are two typical uses of this class:
startElement
event; orThis class replaces the now-deprecated SAX1AttributeListImpl
class; in addition to supporting the updated Attributes interface rather than the deprecatedAttributeList
interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.
AttributesImpl() Construct a new, empty AttributesImpl object. | |
AttributesImpl(Attributes atts) Copy an existing Attributes object. |
addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value) Add an attribute to the end of the list. | |
clear() Clear the attribute list for reuse. | |
getIndex(java.lang.String qName) Look up an attribute's index by qualified (prefixed) name. | |
getIndex(java.lang.String uri, java.lang.String localName) Look up an attribute's index by Namespace name. | |
getLength() Return the number of attributes in the list. | |
getLocalName(int index) Return an attribute's local name. | |
getQName(int index) Return an attribute's qualified (prefixed) name. | |
getType(int index) Return an attribute's type by index. | |
getType(java.lang.String qName) Look up an attribute's type by qualified (prefixed) name. | |
getType(java.lang.String uri, java.lang.String localName) Look up an attribute's type by Namespace-qualified name. | |
getURI(int index) Return an attribute's Namespace URI. | |
getValue(int index) Return an attribute's value by index. | |
getValue(java.lang.String qName) Look up an attribute's value by qualified (prefixed) name. | |
getValue(java.lang.String uri, java.lang.String localName) Look up an attribute's value by Namespace-qualified name. | |
removeAttribute(int index) Remove an attribute from the list. | |
setAttribute(int index, java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value) Set an attribute in the list. | |
setAttributes(Attributes atts) Copy an entire Attributes object. | |
setLocalName(int index, java.lang.String localName) Set the local name of a specific attribute. | |
setQName(int index, java.lang.String qName) Set the qualified name of a specific attribute. | |
setType(int index, java.lang.String type) Set the type of a specific attribute. | |
setURI(int index, java.lang.String uri) Set the Namespace URI of a specific attribute. | |
setValue(int index, java.lang.String value) Set the value of a specific attribute. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
publicAttributesImpl()
publicAttributesImpl(Attributes atts)
This constructor is especially useful inside astartElement
event.
atts
- The existing Attributes object.public intgetLength()
getLength
in interfaceAttributes
Attributes.getLength()
public java.lang.StringgetURI(int index)
getURI
in interfaceAttributes
index
- The attribute's index (zero-based).Attributes.getURI(int)
public java.lang.StringgetLocalName(int index)
getLocalName
in interfaceAttributes
index
- The attribute's index (zero-based).Attributes.getLocalName(int)
public java.lang.StringgetQName(int index)
getQName
in interfaceAttributes
index
- The attribute's index (zero-based).Attributes.getQName(int)
public java.lang.StringgetType(int index)
getType
in interfaceAttributes
index
- The attribute's index (zero-based).Attributes.getType(int)
public java.lang.StringgetValue(int index)
getValue
in interfaceAttributes
index
- The attribute's index (zero-based).Attributes.getValue(int)
public intgetIndex(java.lang.String uri, java.lang.String localName)
In many cases, it will be more efficient to look up the name once and use the index query methods rather than using the name query methods repeatedly.
getIndex
in interfaceAttributes
uri
- The attribute's Namespace URI, or the empty string if none is available.localName
- The attribute's local name.Attributes.getIndex(java.lang.String,java.lang.String)
public intgetIndex(java.lang.String qName)
getIndex
in interfaceAttributes
qName
- The qualified name.Attributes.getIndex(java.lang.String)
public java.lang.StringgetType(java.lang.String uri, java.lang.String localName)
getType
in interfaceAttributes
uri
- The Namespace URI, or the empty string for a name with no explicit Namespace URI.localName
- The local name.Attributes.getType(java.lang.String,java.lang.String)
public java.lang.StringgetType(java.lang.String qName)
getType
in interfaceAttributes
qName
- The qualified name.Attributes.getType(java.lang.String)
public java.lang.StringgetValue(java.lang.String uri, java.lang.String localName)
getValue
in interfaceAttributes
uri
- The Namespace URI, or the empty string for a name with no explicit Namespace URI.localName
- The local name.Attributes.getValue(java.lang.String,java.lang.String)
public java.lang.StringgetValue(java.lang.String qName)
getValue
in interfaceAttributes
qName
- The qualified name.Attributes.getValue(java.lang.String)
public voidclear()
Note that no memory is actually freed by this call: the current arrays are kept so that they can be reused.
public voidsetAttributes(Attributes atts)
It may be more efficient to reuse an existing object rather than constantly allocating new ones.
atts
- The attributes to copy.public voidaddAttribute(java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value)
For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
uri
- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName
- The local name, or the empty string if Namespace processing is not being performed.qName
- The qualified (prefixed) name, or the empty string if qualified names are not available.type
- The attribute type as a string.value
- The attribute value.public voidsetAttribute(int index, java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value)
For the sake of speed, this method does no checking for name conflicts or well-formedness: such checks are the responsibility of the application.
index
- The index of the attribute (zero-based).uri
- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName
- The local name, or the empty string if Namespace processing is not being performed.qName
- The qualified name, or the empty string if qualified names are not available.type
- The attribute type as a string.value
- The attribute value.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidremoveAttribute(int index)
index
- The index of the attribute (zero-based).java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidsetURI(int index, java.lang.String uri)
index
- The index of the attribute (zero-based).uri
- The attribute's Namespace URI, or the empty string for none.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidsetLocalName(int index, java.lang.String localName)
index
- The index of the attribute (zero-based).localName
- The attribute's local name, or the empty string for none.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidsetQName(int index, java.lang.String qName)
index
- The index of the attribute (zero-based).qName
- The attribute's qualified name, or the empty string for none.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidsetType(int index, java.lang.String type)
index
- The index of the attribute (zero-based).type
- The attribute's type.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.public voidsetValue(int index, java.lang.String value)
index
- The index of the attribute (zero-based).value
- The attribute's value.java.lang.ArrayIndexOutOfBoundsException
- When the supplied index does not point to an attribute in the list.