|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ctc.wstx.sr.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 TextBuilders that
are used to create efficient semi-shared value Strings.
In addition
| 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 boolean |
mNormAttrs
|
protected TextBuilder |
mValueBuffer
TextBuilder into which values of all attributes are appended to, including default valued ones (defaults are added after explicit ones) |
| Constructor Summary | |
protected |
AttributeCollector(boolean normAttrs)
|
| Method Summary | |
abstract void |
addDefaultAttr(InputProblemReporter rep,
StringVector ns,
java.lang.String prefix,
java.lang.String localName,
java.lang.String value)
Method called by validator to insert an attribute that has a default value and wasn't yet included in collector's attribute set. |
abstract ElemAttrs |
buildAttrOb()
Method needed by event builder code; called to build a non-transient attribute container to use by a start element event. |
java.lang.String |
checkEnumValue(int index,
WordResolver res)
Method called by validation/normalization code for enumeration-valued attributes, to trim specified attribute value (full normalization not needed -- called for values that CAN NOT have spaces inside; such values can not be legal), and then check whether it is included in set of words (tokens) passed in. |
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)
|
boolean |
isSpecified(int index)
|
void |
normalizeValue(int index)
Method called by validation/normalization code, to normalize specified attribute value and return it as (non-interned) String, if normalization was done. |
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)
|
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,
char quoteChar,
java.io.Writer mainWriter,
java.io.Writer attrValueWriter)
Method that basically serializes the specified (read-in) attribute using Writers provided. |
void |
writeValue(int index,
java.io.Writer w)
Method that can be used to get the specified attribute value, by getting it written using Writer passed in. |
| 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 final boolean mNormAttrs
protected int mAttrCount
protected int mNonDefCount
mAttrCount.
protected final TextBuilder mValueBuffer
protected final StringVector mAttrNames
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(boolean normAttrs)
| 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 boolean isSpecified(int index)
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 void normalizeValue(int index)
public java.lang.String checkEnumValue(int index,
WordResolver res)
public abstract void addDefaultAttr(InputProblemReporter rep,
StringVector ns,
java.lang.String prefix,
java.lang.String localName,
java.lang.String value)
throws WstxException
WstxExceptionpublic final TextBuilder getAttrBuilder()
public final void setNormalizedValue(int index,
java.lang.String value)
protected void throwIndex(int index)
public StringVector getNameList()
InputElementStack instance that "owns" this
attribute collector;
public final void writeValue(int index,
java.io.Writer w)
throws java.io.IOException
java.io.IOException
public abstract void writeAttribute(int index,
char quoteChar,
java.io.Writer mainWriter,
java.io.Writer attrValueWriter)
throws java.io.IOException
java.io.IOExceptionprotected 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 | |||||||||