FileDocCategorySizeDatePackage
AttList.javaAPI DocJava SE 5 API6161Fri Aug 26 14:56:04 BST 2005com.sun.org.apache.xml.internal.utils

AttList

public class AttList extends Object implements Attributes
Wraps a DOM attribute list in a SAX Attributes.
xsl.usage
internal

Fields Summary
NamedNodeMap
m_attrs
List of attribute nodes
int
m_lastIndex
Index of last attribute node
DOMHelper
m_dh
Local reference to DOMHelper
Constructors Summary
public AttList(NamedNodeMap attrs, DOMHelper dh)
Constructor AttList

param
attrs List of attributes this will contain
param
dh DOMHelper


    m_attrs = attrs;
    m_lastIndex = m_attrs.getLength() - 1;
    m_dh = dh;
  
Methods Summary
public intgetIndex(java.lang.String uri, java.lang.String localPart)
Look up the index of an attribute by Namespace name.

param
uri The Namespace URI, or the empty string if the name has no Namespace URI.
param
localPart The attribute's local name.
return
The index of the attribute, or -1 if it does not appear in the list.

    for(int i=m_attrs.getLength()-1;i>=0;--i)
    {
      Node a=m_attrs.item(i);
      String u=a.getNamespaceURI();
      if( (u==null ? uri==null : u.equals(uri))
	  &&
	  a.getLocalName().equals(localPart) )
	return i;
    }
    return -1;
  
public intgetIndex(java.lang.String qName)
Look up the index of an attribute by raw XML 1.0 name.

param
qName The qualified (prefixed) name.
return
The index of the attribute, or -1 if it does not appear in the list.

    for(int i=m_attrs.getLength()-1;i>=0;--i)
    {
      Node a=m_attrs.item(i);
      if(a.getNodeName().equals(qName) )
	return i;
    }
    return -1;
  
public intgetLength()
Get the number of attribute nodes in the list

return
number of attribute nodes

    return m_attrs.getLength();
  
public java.lang.StringgetLocalName(int index)
Look up an attribute's local name by index.

param
index The attribute index (zero-based).
return
The local name, or the empty string if Namespace processing is not being performed, or null if the index is out of range.

    return m_dh.getLocalNameOfNode(((Attr) m_attrs.item(index)));
  
public java.lang.StringgetQName(int i)
Look up an attribute's qualified name by index.

param
index The attribute index (zero-based).
return
The attribute's qualified name

    return ((Attr) m_attrs.item(i)).getName();
  
public java.lang.StringgetType(int i)
Get the attribute's node type by index

param
index The attribute index (zero-based)
return
the attribute's node type

    return "CDATA";  // for the moment
  
public java.lang.StringgetType(java.lang.String name)
Get the attribute's node type by name

param
name Attribute name
return
the attribute's node type

    return "CDATA";  // for the moment
  
public java.lang.StringgetType(java.lang.String uri, java.lang.String localName)
Look up an attribute's type by Namespace name.

param
uri The Namespace URI, or the empty String if the name has no Namespace URI.
param
localName The local name of the attribute.
return
The attribute type as a string, or null if the attribute is not in the list or if Namespace processing is not being performed.

    return "CDATA";  // for the moment
  
public java.lang.StringgetURI(int index)
Look up an attribute's Namespace URI by index.

param
index The attribute index (zero-based).
return
The Namespace URI, or the empty string if none is available, or null if the index is out of range.

    String ns = m_dh.getNamespaceOfNode(((Attr) m_attrs.item(index)));
    if(null == ns)
      ns = "";
    return ns;
  
public java.lang.StringgetValue(java.lang.String name)
Look up an attribute's value by name.

param
name The attribute node's name
return
The attribute node's value

    Attr attr = ((Attr) m_attrs.getNamedItem(name));
    return (null != attr) 
          ? attr.getValue() : null;
  
public java.lang.StringgetValue(java.lang.String uri, java.lang.String localName)
Look up an attribute's value by Namespace name.

param
uri The Namespace URI, or the empty String if the name has no Namespace URI.
param
localName The local name of the attribute.
return
The attribute value as a string, or null if the attribute is not in the list.

		Node a=m_attrs.getNamedItemNS(uri,localName);
		return (a==null) ? null : a.getNodeValue();
  
public java.lang.StringgetValue(int i)
Get the attribute's node value by index

param
index The attribute index (zero-based)
return
the attribute's node value

    return ((Attr) m_attrs.item(i)).getValue();