APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer

public final Class AttributesImplSerializer

extends AttributesImpl
Class Inheritance
Imports
java.util.HashMap, .Map, org.xml.sax.Attributes, org.xml.sax.helpers.AttributesImpl

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

Field Summary

Modifier and TypeField and Description
private final StringBuffer
private final Map<String, Integer>
m_indexFromQName

Hash table of qName/index values to quickly lookup the index of an attributes qName.

private static final int
MAX

This is the number of attributes before switching to the hash table, and can be tuned, but 12 seems good for now - Brian M.

private static final int
MAXMinus1

One less than the number of attributes before switching to the Map.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
addAttribute(String
the URI of the attribute
uri
,
String
the local name of the attribute
local
,
String
the qualified name of the attribute
qname
,
String
the type of the attribute
type
,
String
the value of the attribute
val
)

Overrides org.xml.sax.helpers.AttributesImpl.addAttribute.

This method adds the attribute, but also records its qName/index pair in the hashtable for fast lookup by getIndex(qName).

public final void
clear()

Overrides org.xml.sax.helpers.AttributesImpl.clear.

This method clears the accumulated attributes.

public final int

Returns:

the integer index of the attribute.
getIndex
(String
the qualified name of the attribute, e.g. "prefix1:locName1"
qname
)

Overrides org.xml.sax.helpers.AttributesImpl.getIndex.

Implements org.xml.sax.Attributes.getIndex.

This method gets the index of an attribute given its qName.

public final int

Returns:

the integer index of the attribute.
getIndex
(String
the URI of the attribute name.
uri
,
String
the local namer (after the ':' ) of the attribute name.
localName
)

Overrides org.xml.sax.helpers.AttributesImpl.getIndex.

Implements org.xml.sax.Attributes.getIndex.

This method gets the index of an attribute given its uri and locanName.

public final void
setAttributes(Attributes
the attributes to copy into these attributes.
atts
)

Overrides org.xml.sax.helpers.AttributesImpl.setAttributes.

This method sets the attributes, previous attributes are cleared, it also keeps the hashtable up to date for quick lookup via getIndex(qName).

private void
switchOverToHash(int numAtts)

We are switching over to having a hash table for quick look up of attributes, but up until now we haven't kept any information in the Map, so we now update the Map.

Inherited from org.xml.sax.helpers.AttributesImpl:
getLengthgetLocalNamegetQNamegetTypegetTypegetTypegetURIgetValuegetValuegetValueremoveAttributesetAttributesetLocalNamesetQNamesetTypesetURIsetValue

Field Detail

m_buffback to summary
private final StringBuffer m_buff
m_indexFromQNameback to summary
private final Map<String, Integer> m_indexFromQName

Hash table of qName/index values to quickly lookup the index of an attributes qName. qNames are in uppercase in the hash table to make the search case insensitive. The keys to the hashtable to find the index are either "prefix:localName" or "{uri}localName".

MAXback to summary
private static final int MAX

This is the number of attributes before switching to the hash table, and can be tuned, but 12 seems good for now - Brian M.

MAXMinus1back to summary
private static final int MAXMinus1

One less than the number of attributes before switching to the Map.

Constructor Detail

AttributesImplSerializerback to summary
public AttributesImplSerializer()

Method Detail

addAttributeback to summary
public final void addAttribute(String uri, String local, String qname, String type, String val)

Overrides org.xml.sax.helpers.AttributesImpl.addAttribute.

This method adds the attribute, but also records its qName/index pair in the hashtable for fast lookup by getIndex(qName).

Parameters
uri:String

the URI of the attribute

local:String

the local name of the attribute

qname:String

the qualified name of the attribute

type:String

the type of the attribute

val:String

the value of the attribute

See Also
org.xml.sax.helpers.AttributesImpl#addAttribute(String, String, String, String, String), getIndex(String)
clearback to summary
public final void clear()

Overrides org.xml.sax.helpers.AttributesImpl.clear.

This method clears the accumulated attributes.

See Also
org.xml.sax.helpers.AttributesImpl#clear()
getIndexback to summary
public final int getIndex(String qname)

Overrides org.xml.sax.helpers.AttributesImpl.getIndex.

Implements org.xml.sax.Attributes.getIndex.

This method gets the index of an attribute given its qName.

Parameters
qname:String

the qualified name of the attribute, e.g. "prefix1:locName1"

Returns:int

the integer index of the attribute.

See Also
org.xml.sax.Attributes#getIndex(String)
getIndexback to summary
public final int getIndex(String uri, String localName)

Overrides org.xml.sax.helpers.AttributesImpl.getIndex.

Implements org.xml.sax.Attributes.getIndex.

This method gets the index of an attribute given its uri and locanName.

Parameters
uri:String

the URI of the attribute name.

localName:String

the local namer (after the ':' ) of the attribute name.

Returns:int

the integer index of the attribute.

See Also
org.xml.sax.Attributes#getIndex(String)
setAttributesback to summary
public final void setAttributes(Attributes atts)

Overrides org.xml.sax.helpers.AttributesImpl.setAttributes.

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:Attributes

the attributes to copy into these attributes.

See Also
org.xml.sax.helpers.AttributesImpl#setAttributes(Attributes), getIndex(String)
switchOverToHashback to summary
private void switchOverToHash(int numAtts)

We are switching over to having a hash table for quick look up of attributes, but up until now we haven't kept any information in the Map, so we now update the Map. Future additional attributes will update the Map as they are added.