org.apache.xml.serializer
Class AttributesImplSerializer

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

public final class AttributesImplSerializer
extends AttributesImpl

This class extends org.xml.sax.helpers.AttributesImpl which implements org. xml.sax.Attributes. But for optimization this class adds a Hashtable for faster lookup of an index by qName, which is commonly done in the stream serializer.

See Also:
Attributes
Usage:
**For internal use only**

Constructor Summary
AttributesImplSerializer()
           
 
Method Summary
 void addAttribute(java.lang.String uri, java.lang.String local, java.lang.String qname, java.lang.String type, java.lang.String val)
          This method adds the attribute, but also records its qName/index pair in the hashtable for fast lookup by getIndex(qName).
 void clear()
          This method clears the accumulated attributes.
 int getIndex(java.lang.String qname)
          This method gets the index of an attribute given its qName.
 int getIndex(java.lang.String uri, java.lang.String localName)
          This method gets the index of an attribute given its uri and locanName.
 void setAttributes(Attributes atts)
          This method sets the attributes, previous attributes are cleared, it also keeps the hashtable up to date for quick lookup via getIndex(qName).
 
Methods inherited from class org.xml.sax.helpers.AttributesImpl
getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue, removeAttribute, setAttribute, setLocalName, setQName, setType, setURI, setValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributesImplSerializer

public AttributesImplSerializer()
Method Detail

getIndex

public final int getIndex(java.lang.String qname)
This method gets the index of an attribute given its qName.
Parameters:
qname - the qualified name of the attribute, e.g. "prefix1:locName1"
Returns:
the integer index of the attribute.
Overrides:
getIndex in class AttributesImpl
See Also:
Attributes.getIndex(String)

addAttribute

public final void addAttribute(java.lang.String uri,
                               java.lang.String local,
                               java.lang.String qname,
                               java.lang.String type,
                               java.lang.String val)
This method adds the attribute, but also records its qName/index pair in the hashtable for fast lookup by getIndex(qName).
Parameters:
uri - the URI of the attribute
local - the local name of the attribute
qname - the qualified name of the attribute
type - the type of the attribute
val - the value of the attribute
Overrides:
addAttribute in class AttributesImpl
See Also:
AttributesImpl.addAttribute(String, String, String, String, String), getIndex(String)

clear

public final void clear()
This method clears the accumulated attributes.
Overrides:
clear in class AttributesImpl
See Also:
AttributesImpl.clear()

setAttributes

public final void setAttributes(Attributes atts)
This method sets the attributes, previous attributes are cleared, it also keeps the hashtable up to date for quick lookup via getIndex(qName).
Parameters:
atts - the attributes to copy into these attributes.
Overrides:
setAttributes in class AttributesImpl
See Also:
AttributesImpl.setAttributes(Attributes), getIndex(String)

getIndex

public final int getIndex(java.lang.String uri,
                          java.lang.String localName)
This method gets the index of an attribute given its uri and locanName.
Parameters:
uri - the URI of the attribute name.
localName - the local namer (after the ':' ) of the attribute name.
Returns:
the integer index of the attribute.
Overrides:
getIndex in class AttributesImpl
See Also:
Attributes.getIndex(String)


Copyright © 2006 Apache XML Project. All Rights Reserved.