org.xml.sax
Interface Attributes

All Known Implementing Classes:
AttributesImpl

public interface Attributes

Interface for a list of XML attributes.

This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

This interface allows access to a list of attributes in three different ways:

  1. by attribute index;
  2. by Namespace-qualified name; or
  3. by raw XML 1.0 name.

The list will not contain attributes that were declared #IMPLIED but not specified in the start tag. It will also not contain attributes used as Namespace declarations (xmlns*) unless the http://xml.org/sax/features/raw-names feature is set to true (it is false by default).

If the raw-names feature is false, access by raw XML 1.0 may not be available; if the http://xml.org/sax/features/namespaces feature is false, access by Namespace-qualified names may not be available.

This interface replaces the now-deprecated SAX1 AttributeList interface, which does not contain Namespace support. In addition to Namespace support, it adds the getIndex methods.

The order of attributes in the list is random.

Since:
SAX 2.0
Version:
2.0beta
Author:
David Megginson, sax@megginson.com
See Also:
AttributeListImpl

Method Summary
 int getIndex(java.lang.String rawName)
          Look up the index of an attribute by raw XML 1.0 name.
 int getIndex(java.lang.String uri, java.lang.String localPart)
          Look up the index of an attribute by Namespace name.
 int getLength()
          Return the number of attributes in the list.
 java.lang.String getLocalName(int index)
          Look up an attribute's local name by index.
 java.lang.String getRawName(int index)
          Look up an attribute's raw XML 1.0 name by index.
 java.lang.String getType(int index)
          Look up an attribute's type by index.
 java.lang.String getType(java.lang.String rawName)
          Look up an attribute's type by raw XML 1.0 name.
 java.lang.String getType(java.lang.String uri, java.lang.String localName)
          Look up an attribute's type by Namespace name.
 java.lang.String getURI(int index)
          Look up an attribute's Namespace URI by index.
 java.lang.String getValue(int index)
          Look up an attribute's value by index.
 java.lang.String getValue(java.lang.String rawName)
          Look up an attribute's value by raw XML 1.0 name.
 java.lang.String getValue(java.lang.String uri, java.lang.String localName)
          Look up an attribute's value by Namespace name.
 

Method Detail

getLength

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

getURI

public java.lang.String getURI(int index)
Look up an attribute's Namespace URI by index.
Parameters:
index - The attribute index (zero-based).
Returns:
The Namespace URI, or the empty string if none is available, or null if the index is out of range.

getLocalName

public java.lang.String getLocalName(int index)
Look up an attribute's local name by index.
Parameters:
index - The attribute index (zero-based).
Returns:
The local name, or the empty string if Namespace processing is not being performed, or null if the index is out of range.

getRawName

public java.lang.String getRawName(int index)
Look up an attribute's raw XML 1.0 name by index.
Parameters:
index - The attribute index (zero-based).
Returns:
The raw XML 1.0 name, or the empty string if none is available, or null if the index is out of range.

getType

public java.lang.String getType(int index)
Look up an attribute's type by index.
Parameters:
index - The attribute index (zero-based).
Returns:
The attribute's type as a string, or null if the index is out of range.

getValue

public java.lang.String getValue(int index)
Look up an attribute's value by index.
Parameters:
index - The attribute index (zero-based).
Returns:
The attribute's value as a string, or null if the index is out of range.

getIndex

public int getIndex(java.lang.String uri,
                    java.lang.String localPart)
Look up the index of an attribute by Namespace name.
Parameters:
uri - The Namespace URI, or the empty string if the name has no Namespace URI.
localName - The attribute's local name.
Returns:
The index of the attribute, or -1 if it does not appear in the list.

getIndex

public int getIndex(java.lang.String rawName)
Look up the index of an attribute by raw XML 1.0 name.
Parameters:
rawName - The raw (prefixed) name.
Returns:
The index of the attribute, or -1 if it does not appear in the list.

getType

public java.lang.String getType(java.lang.String uri,
                                java.lang.String localName)
Look up an attribute's type by Namespace name.
Parameters:
uri - The Namespace URI, or the empty String if the name has no Namespace URI.
localName - The local name of the attribute.
Returns:
The attribute type as a string, or null if the attribute is not in the list or if Namespace processing is not being performed.

getType

public java.lang.String getType(java.lang.String rawName)
Look up an attribute's type by raw XML 1.0 name.
Parameters:
rawName - The raw XML 1.0 name.
Returns:
The attribute type as a string, or null if the attribute is not in the list or if raw names are not available.

getValue

public java.lang.String getValue(java.lang.String uri,
                                 java.lang.String localName)
Look up an attribute's value by Namespace name.
Parameters:
uri - The Namespace URI, or the empty String if the name has no Namespace URI.
localName - The local name of the attribute.
Returns:
The attribute value as a string, or null if the attribute is not in the list.

getValue

public java.lang.String getValue(java.lang.String rawName)
Look up an attribute's value by raw XML 1.0 name.
Parameters:
rawName - The raw XML 1.0 name.
Returns:
The attribute value as a string, or null if the attribute is not in the list or if raw names are not available.


Copyright © 1999 Apache XML Project. All Rights Reserved.