public final class ElemAttrs
extends java.lang.Object
Implementation note: code for using Map-like structure is unfortunately
cut'n pasted from AttributeCollector
. Problem
with refactoring is that it's 90% the same code, but not 100%.
Although instances of this class are constructed by stream readers, it is actually used by element event objects.
Modifier and Type | Field and Description |
---|---|
private int |
mAttrHashSize |
private int[] |
mAttrMap |
private int |
mAttrSpillEnd |
private int |
mDefaultOffset
Raw offset (in
mRawAttrs ) of the first attribute
instance that was created through default value expansion. |
private java.lang.String[] |
mRawAttrs
Array that contains 4 Strings for each attribute;
localName, URI, prefix, value.
|
private static int |
OFFSET_NS_URI |
Constructor and Description |
---|
ElemAttrs(java.lang.String[] rawAttrs,
int defOffset)
Method called to create "short" attribute list; list that has
only few entries, and can thus be searched for attributes using
linear search, without using any kind of Map structure.
|
ElemAttrs(java.lang.String[] rawAttrs,
int defOffset,
int[] attrMap,
int hashSize,
int spillEnd)
Method called to create "long" attribute list; list that has
a few entries, and efficient access by fully-qualified name should
not be done by linear search.
|
Modifier and Type | Method and Description |
---|---|
int |
findIndex(javax.xml.namespace.QName name) |
private int |
findMapIndex(java.lang.String nsURI,
java.lang.String localName)
Note: this method is very similar to
com.ctc.wstx.sr.AttributeCollector#getAttrValue ; basically
most of it was cut'n pasted. |
int |
getFirstDefaultOffset() |
java.lang.String[] |
getRawAttrs() |
boolean |
isDefault(int ix) |
private static final int OFFSET_NS_URI
private final java.lang.String[] mRawAttrs
private final int mDefaultOffset
mRawAttrs
) of the first attribute
instance that was created through default value expansion.private final int[] mAttrMap
private final int mAttrHashSize
private final int mAttrSpillEnd
public ElemAttrs(java.lang.String[] rawAttrs, int defOffset)
Currently the limit is 4 attributes; 1, 2 or 3 attribute lists are considered short, 4 or more 'long'.
rawAttrs
- Array that contains 4 Strings for each attribute;
localName, URI, prefix, value. Can be used to lazily construct
structure(s) needed to return Iterator for accessing all
attributes.defOffset
- Index of the first default attribute, if any;
number of all attributes if nonepublic ElemAttrs(java.lang.String[] rawAttrs, int defOffset, int[] attrMap, int hashSize, int spillEnd)
rawAttrs
- Array that contains 4 Strings for each attribute;
localName, URI, prefix, value. Can be used to lazily construct
structure(s) needed to return Iterator for accessing all
attributes.public java.lang.String[] getRawAttrs()
public int findIndex(javax.xml.namespace.QName name)
public int getFirstDefaultOffset()
public boolean isDefault(int ix)
private final int findMapIndex(java.lang.String nsURI, java.lang.String localName)
Note: this method is very similar to
com.ctc.wstx.sr.AttributeCollector#getAttrValue
; basically
most of it was cut'n pasted. Would be nice to refactor, but it's
bit hard to do that since data structures are not 100% identical
(mostly attribute storage, not Map structure itself).