Package org.apache.xml.serializer
Class AttributesImplSerializer
- java.lang.Object
-
- org.xml.sax.helpers.AttributesImpl
-
- org.apache.xml.serializer.AttributesImplSerializer
-
- All Implemented Interfaces:
org.xml.sax.Attributes
public final class AttributesImplSerializer extends org.xml.sax.helpers.AttributesImplThis 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
-
-
Constructor Summary
Constructors Constructor Description AttributesImplSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(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).voidclear()This method clears the accumulated attributes.intgetIndex(java.lang.String qname)This method gets the index of an attribute given its qName.intgetIndex(java.lang.String uri, java.lang.String localName)This method gets the index of an attribute given its uri and locanName.voidsetAttributes(org.xml.sax.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).
-
-
-
Method Detail
-
getIndex
public final int getIndex(java.lang.String qname)
This method gets the index of an attribute given its qName.- Specified by:
getIndexin interfaceorg.xml.sax.Attributes- Overrides:
getIndexin classorg.xml.sax.helpers.AttributesImpl- Parameters:
qname- the qualified name of the attribute, e.g. "prefix1:locName1"- Returns:
- the integer index of the attribute.
- 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).- Overrides:
addAttributein classorg.xml.sax.helpers.AttributesImpl- Parameters:
uri- the URI of the attributelocal- the local name of the attributeqname- the qualified name of the attributetype- the type of the attributeval- the value of the attribute- See Also:
AttributesImpl.addAttribute(String, String, String, String, String),getIndex(String)
-
clear
public final void clear()
This method clears the accumulated attributes.- Overrides:
clearin classorg.xml.sax.helpers.AttributesImpl- See Also:
AttributesImpl.clear()
-
setAttributes
public final void setAttributes(org.xml.sax.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).- Overrides:
setAttributesin classorg.xml.sax.helpers.AttributesImpl- Parameters:
atts- the attributes to copy into these attributes.- 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.- Specified by:
getIndexin interfaceorg.xml.sax.Attributes- Overrides:
getIndexin classorg.xml.sax.helpers.AttributesImpl- 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.
- See Also:
Attributes.getIndex(String)
-
-