Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
org.xml.sax.helpers

Class AttributesImpl

java.lang.Object
|
+--org.xml.sax.helpers.AttributesImpl

All Implemented Interfaces:

Attributes


public class AttributesImpl

extends Object

implements Attributes

Default implementation of the Attributes interface.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.

This class provides a default implementation of the SAX2 org.xml.sax.Attributes Attributes interface, with the addition of manipulators so that the list can be modified or reused.

There are two typical uses of this class:

  1. to take a persistent snapshot of an Attributes object in a org.xml.sax.ContentHandler#startElement startElement event; or
  2. to construct or modify an Attributes object in a SAX2 driver or filter.

This class replaces the now-deprecated SAX1 org.xml.sax.helpers.AttributeListImpl AttributeListImpl class; in addition to supporting the updated Attributes interface rather than the deprecated org.xml.sax.AttributeList AttributeList interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.

Since:Author:

Constructor Summary

AttributesImpl()

Construct a new, empty AttributesImpl object.
AttributesImpl(org.xml.sax.Attributes atts)

Copy an existing Attributes object.

Method Summary

voidaddAttribute(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.
voidclear()

Clear the attribute list for reuse.
intgetIndex(java.lang.String uri, java.lang.String localName)

Look up an attribute's index by Namespace name.
intgetIndex(java.lang.String qName)

Look up an attribute's index by qualified (prefixed) name.
intgetLength()

Return the number of attributes in the list.
java.lang.StringgetLocalName(int index)

Return an attribute's local name.
java.lang.StringgetQName(int index)

Return an attribute's qualified (prefixed) name.
java.lang.StringgetType(int index)

Return an attribute's type by index.
java.lang.StringgetType(java.lang.String uri, java.lang.String localName)

Look up an attribute's type by Namespace-qualified name.
java.lang.StringgetType(java.lang.String qName)

Look up an attribute's type by qualified (prefixed) name.
java.lang.StringgetURI(int index)

Return an attribute's Namespace URI.
java.lang.StringgetValue(int index)

Return an attribute's value by index.
java.lang.StringgetValue(java.lang.String uri, java.lang.String localName)

Look up an attribute's value by Namespace-qualified name.
java.lang.StringgetValue(java.lang.String qName)

Look up an attribute's value by qualified (prefixed) name.
voidremoveAttribute(int index)

Remove an attribute from the list.
voidsetAttribute(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.
voidsetAttributes(org.xml.sax.Attributes atts)

Copy an entire Attributes object.
voidsetLocalName(int index, java.lang.String localName)

Set the local name of a specific attribute.
voidsetQName(int index, java.lang.String qName)

Set the qualified name of a specific attribute.
voidsetType(int index, java.lang.String type)

Set the type of a specific attribute.
voidsetURI(int index, java.lang.String uri)

Set the Namespace URI of a specific attribute.
voidsetValue(int index, java.lang.String value)

Set the value of a specific attribute.

Constructor Details

AttributesImpl

public AttributesImpl()

Construct a new, empty AttributesImpl object.


AttributesImpl

public AttributesImpl(org.xml.sax.Attributes atts)

Copy an existing Attributes object.

This constructor is especially useful inside a org.xml.sax.ContentHandler#startElement startElement event.

Parameters:


Method Details

addAttribute

public void 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.

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.

Parameters:


clear

public void clear()

Clear the attribute list for reuse.

Note that little memory is freed by this call: the current array is kept so it can be reused.


getIndex

public int getIndex(java.lang.String qName)

Look up an attribute's index by qualified (prefixed) name.

Parameters:

Returns:

See Also:


getIndex

public int getIndex(java.lang.String uri, java.lang.String localName)

Look up an attribute's index by Namespace name.

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.

Parameters:

Returns:

See Also:


getLength

public int getLength()

Return the number of attributes in the list.

Returns:

See Also:


getLocalName

public String getLocalName(int index)

Return an attribute's local name.

Parameters:

Returns:

See Also:


getQName

public String getQName(int index)

Return an attribute's qualified (prefixed) name.

Parameters:

Returns:

See Also:


getType

public String getType(int index)

Return an attribute's type by index.

Parameters:

Returns:

See Also:


getType

public String getType(java.lang.String qName)

Look up an attribute's type by qualified (prefixed) name.

Parameters:

Returns:

See Also:


getType

public String getType(java.lang.String uri, java.lang.String localName)

Look up an attribute's type by Namespace-qualified name.

Parameters:

Returns:

See Also:


getURI

public String getURI(int index)

Return an attribute's Namespace URI.

Parameters:

Returns:

See Also:


getValue

public String getValue(int index)

Return an attribute's value by index.

Parameters:

Returns:

See Also:


getValue

public String getValue(java.lang.String qName)

Look up an attribute's value by qualified (prefixed) name.

Parameters:

Returns:

See Also:


getValue

public String getValue(java.lang.String uri, java.lang.String localName)

Look up an attribute's value by Namespace-qualified name.

Parameters:

Returns:

See Also:


removeAttribute

public void removeAttribute(int index)

Remove an attribute from the list.

Parameters:

Throws:


setAttribute

public void 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.

For the sake of speed, this method does no checking for name conflicts or well-formedness: such checks are the responsibility of the application.

Parameters:

Throws:


setAttributes

public void setAttributes(org.xml.sax.Attributes atts)

Copy an entire Attributes object.

It may be more efficient to reuse an existing object rather than constantly allocating new ones.

Parameters:


setLocalName

public void setLocalName(int index, java.lang.String localName)

Set the local name of a specific attribute.

Parameters:

Throws:


setQName

public void setQName(int index, java.lang.String qName)

Set the qualified name of a specific attribute.

Parameters:

Throws:


setType

public void setType(int index, java.lang.String type)

Set the type of a specific attribute.

Parameters:

Throws:


setURI

public void setURI(int index, java.lang.String uri)

Set the Namespace URI of a specific attribute.

Parameters:

Throws:


setValue

public void setValue(int index, java.lang.String value)

Set the value of a specific attribute.

Parameters:

Throws: