|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ctc.wstx.sr.AttributeCollector
public abstract class AttributeCollector
Shared base class that defines API stream reader uses to communicate
with the attribute collector implementation, independent of whether it's
operating in namespace-aware or non-namespace modes.
Collector class is used to build up attribute lists; for the most part
will just hold references to few specialized TextBuilder
s that
are used to create efficient semi-shared value Strings.
Field Summary | |
---|---|
protected static int |
EXP_ATTR_COUNT
Expected typical maximum number of attributes for any element; chosen to minimize need to resize, while trying not to waste space. |
protected static int |
LONG_ATTR_LIST_LEN
Threshold value that indicates minimum length for lists instances that need a Map structure, for fast attribute access by fully-qualified name. |
protected int |
mAttrCount
Actual number of attributes collected, including attributes added via default values. |
protected int |
mAttrHashSize
Size of hash area in mAttrMap ; generally at least 20%
more than number of attributes (mAttrCount ). |
protected int[] |
mAttrMap
Encoding of a data structure that contains mapping from attribute names to attribute index in main attribute name arrays. |
protected StringVector |
mAttrNames
Vector in which attribute names are added; exact number of elements per attribute depends on whether namespace support is enabled or not (non-namespace mode only needs one entry; namespace mode two, one for prefix, one for local name). |
protected int |
mAttrSpillEnd
Pointer to int slot right after last spill entr, in mAttrMap array. |
protected java.lang.String[] |
mAttrValues
Array in which attribute value Strings are added, first time they are requested. |
protected int |
mNonDefCount
Number of attribute values actually parsed, not including ones created via default value expansion. |
protected TextBuilder |
mValueBuffer
TextBuilder into which values of all attributes are appended to, including default valued ones (defaults are added after explicit ones). |
protected int |
mXmlIdAttrIndex
Index of "xml:id" attribute, if one exists for the current element; XMLID_IX_NONE if none. |
protected static int |
XMLID_IX_DISABLED
This value is used to indicate that we shouldn't keep track of index of xml:id attribute -- generally done when Xml:id support is disabled |
protected static int |
XMLID_IX_NONE
|
Constructor Summary | |
---|---|
protected |
AttributeCollector(ReaderConfig cfg)
|
Method Summary | |
---|---|
protected void |
allocBuffers()
Method called to initialize buffers that need not be immediately initialized |
abstract ElemAttrs |
buildAttrOb()
Method needed by event builder code; called to build a non-transient attribute container to use by a start element event. |
TextBuilder |
getAttrBuilder()
Low-level accessor method that attribute validation code may call for certain types of attributes; generally only for id and idref/idrefs attributes. |
abstract TextBuilder |
getAttrBuilder(java.lang.String attrPrefix,
java.lang.String attrLocalName)
|
int |
getCount()
|
abstract TextBuilder |
getDefaultNsBuilder()
|
abstract java.lang.String |
getLocalName(int index)
|
StringVector |
getNameList()
Method called by InputElementStack instance that "owns" this
attribute collector; |
abstract TextBuilder |
getNsBuilder(java.lang.String localName)
|
abstract int |
getNsCount()
|
abstract java.lang.String |
getNsPrefix(int index)
|
abstract java.lang.String |
getNsURI(int index)
|
abstract java.lang.String |
getPrefix(int index)
|
abstract javax.xml.namespace.QName |
getQName(int index)
|
int |
getSpecifiedCount()
|
abstract java.lang.String |
getURI(int index)
|
java.lang.String |
getValue(int index)
Note: the main reason this method is defined at this level, and made final, is performance. |
abstract java.lang.String |
getValue(java.lang.String nsURI,
java.lang.String localName)
|
int |
getXmlIdAttrIndex()
|
boolean |
isSpecified(int index)
|
protected abstract void |
reset()
Method called to allow reusing of collector, usually right before starting collecting attributes for a new start tag. |
protected static java.lang.String[] |
resize(java.lang.String[] old)
Method that can be used to get the specified attribute value, by getting it written using Writer passed in. |
void |
setNormalizedValue(int index,
java.lang.String value)
Low-level mutator method that attribute validation code may call for certain types of attributes, when it wants to handle the whole validation and normalization process by itself. |
protected void |
throwDupAttr(InputProblemReporter rep,
int index)
|
protected void |
throwIndex(int index)
|
abstract void |
writeAttribute(int index,
XmlWriter xw)
Method that basically serializes the specified (read-in) attribute using Writers provided. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int LONG_ATTR_LIST_LEN
protected static final int EXP_ATTR_COUNT
protected static final int XMLID_IX_DISABLED
protected static final int XMLID_IX_NONE
protected int mAttrCount
protected int mNonDefCount
mAttrCount
.
protected TextBuilder mValueBuffer
protected StringVector mAttrNames
protected int mXmlIdAttrIndex
XMLID_IX_NONE
if none.
protected java.lang.String[] mAttrValues
mValueBuffer
,
from which a String is created, and finally substring created as
needed and added to this array.
protected int[] mAttrMap
Data structure contains two separate areas; main hash area (with
size mAttrHashSize
), and remaining spillover area
that follows hash area up until (but not including)
mAttrSpillEnd
index.
Main hash area only contains indexes (index+1; 0 signifying empty slot)
to actual attributes; spillover area has both hash and index for
any spilled entry. Spilled entries are simply stored in order
added, and need to be searched using linear search. In case of both
primary hash hits and spills, eventual comparison with the local
name needs to be done with actual name array.
protected int mAttrHashSize
mAttrMap
; generally at least 20%
more than number of attributes (mAttrCount
).
protected int mAttrSpillEnd
mAttrMap
array.
Constructor Detail |
---|
protected AttributeCollector(ReaderConfig cfg)
Method Detail |
---|
protected abstract void reset()
public abstract int getNsCount()
public abstract java.lang.String getNsPrefix(int index)
public abstract java.lang.String getNsURI(int index)
public final int getCount()
public int getSpecifiedCount()
public abstract java.lang.String getPrefix(int index)
public abstract java.lang.String getLocalName(int index)
public abstract java.lang.String getURI(int index)
public abstract javax.xml.namespace.QName getQName(int index)
public final java.lang.String getValue(int index)
Note: the main reason this method is defined at this level, and made final, is performance. JIT may be able to fully inline this method, even when reference is via this base class. This is important since this is likely to be the most often called method of the collector instances.
public abstract java.lang.String getValue(java.lang.String nsURI, java.lang.String localName)
public final boolean isSpecified(int index)
public final int getXmlIdAttrIndex()
public abstract TextBuilder getDefaultNsBuilder()
public abstract TextBuilder getNsBuilder(java.lang.String localName)
public abstract TextBuilder getAttrBuilder(java.lang.String attrPrefix, java.lang.String attrLocalName)
public abstract ElemAttrs buildAttrOb()
public final TextBuilder getAttrBuilder()
public final void setNormalizedValue(int index, java.lang.String value)
protected void throwIndex(int index)
public final StringVector getNameList()
InputElementStack
instance that "owns" this
attribute collector;
public abstract void writeAttribute(int index, XmlWriter xw) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected final void allocBuffers()
protected static java.lang.String[] resize(java.lang.String[] old)
protected void throwDupAttr(InputProblemReporter rep, int index) throws WstxException
WstxException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |