Top Description Fields Constructors Methods
com.fasterxml.aalto.in

public final Class AttributeCollector

extends Object
Class Inheritance
Imports
java.text.MessageFormat, javax.xml.namespace.QName, javax.xml.stream.Location, .XMLStreamException, org.codehaus.stax2.typed.Base64Variant, .TypedArrayDecoder, .TypedValueDecoder, .TypedXMLStreamException, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder, .ValueDecoderFactory, com.fasterxml.aalto.impl.ErrorConsts, com.fasterxml.aalto.util.DataUtil

Object used by the tokenizer to collect and store information about attributes, specifically, names and values.

Field Summary

Modifier and TypeField and Description
private String
_allAttrValues

Concatenated String that contains all the attribute values for the element.

private int
_attrCount

Number of attributes currently held by this collector.

protected int[]
_attrMap

Int-based compact data structure that contains mapping from attribute names to attribute indexes in the main attribute name array.

pack-priv final ReaderConfig
private String
_errorMsg

For some errors, we'll have to temporarily store error message, to be thrown at a later point.

protected int
_hashAreaSize

Size of hash area in _attrMap; generally at least 20% more than number of attributes (_attrCount).

private PName[]
private boolean
_needToResetValues

Flag used to indicate that all attribute values for an element have been parsed, and that next call to startNewValue should reset the value structures

protected int
_spillAreaEnd

Pointer to int slot right after last spill entry, in _attrMap array.

private char[]
_valueBuffer

Consequtive character array, in which attribute values are concatenated in

private int[]
_valueOffsets

Array that contains ending offsets of the values in the shared buffer.

private static final int
DEFAULT_BUFFER_LENGTH

The default length of the value buffer is also chosen more to minimize overhead than to eliminate all need for resizing.

private static final int
DEFAULT_ENTRY_COUNT

Let's guess that most of the time there won't be more than 12 attributes.

private static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private final boolean
checkExpand(TypedArrayDecoder tad)

Internal method used to see if we can expand the buffer that the array decoder has.

public char[]
public byte[]
public final void
public final int
decodeValues(int index, TypedArrayDecoder dec, XmlScanner scanner)

private final int
decodeValues(TypedArrayDecoder dec, final char[] buf, int ptr, final int end, final XmlScanner scanner)

public int
findIndex(String nsUri, String localName)

public final int

Returns:

Number of attributes collected
finishLastValue
(int endingOffset)

Method called after all attribute entries have been parsed, and thus the end of the last value in the buffer is known.

public final int
public final int
public String
public final PName
getName(int index)

public final QName
getQName(int index)

public String
getValue(int index)

public String
getValue(String nsUri, String localName)

private static final boolean
isSpace(char c)

private void
noteDupAttr(int ix1, int ix2)

public char[]

Returns:

Underlying character buffer to use for storing attribute value characters
startNewValue
(PName attrName, int currOffset)

Method called by the parser right after attribute name has been parsed, but before value has been parsed.

public char[]
valueBufferFull()

Method called by the owner, when the

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_allAttrValuesback to summary
private String _allAttrValues

Concatenated String that contains all the attribute values for the element. Allows some buffer reuse, and should result in slight speed optimization, for elements with lots of attributes that are usually all (or none) accessed.

_attrCountback to summary
private int _attrCount

Number of attributes currently held by this collector.

_attrMapback to summary
protected int[] _attrMap

Int-based compact data structure that contains mapping from attribute names to attribute indexes in the main attribute name array.

Data structure contains two separate areas; main hash area (with size _hashAreaSize), and remaining spillover area that follows hash area up until (but not including) _spillAreaEnd 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.

_configback to summary
pack-priv final ReaderConfig _config
_errorMsgback to summary
private String _errorMsg

For some errors, we'll have to temporarily store error message, to be thrown at a later point.

_hashAreaSizeback to summary
protected int _hashAreaSize

Size of hash area in _attrMap; generally at least 20% more than number of attributes (_attrCount).

_namesback to summary
private PName[] _names
_needToResetValuesback to summary
private boolean _needToResetValues

Flag used to indicate that all attribute values for an element have been parsed, and that next call to startNewValue should reset the value structures

_spillAreaEndback to summary
protected int _spillAreaEnd

Pointer to int slot right after last spill entry, in _attrMap array.

_valueBufferback to summary
private char[] _valueBuffer

Consequtive character array, in which attribute values are concatenated in

_valueOffsetsback to summary
private int[] _valueOffsets

Array that contains ending offsets of the values in the shared buffer. Entries contain character offset after the end of the matching offset; so entry 0 for example contains starting offset of the entry 1.

DEFAULT_BUFFER_LENGTHback to summary
private static final int DEFAULT_BUFFER_LENGTH

The default length of the value buffer is also chosen more to minimize overhead than to eliminate all need for resizing.

DEFAULT_ENTRY_COUNTback to summary
private static final int DEFAULT_ENTRY_COUNT

Let's guess that most of the time there won't be more than 12 attributes. Since the underlying buffer will be expanded as necessary, exact value is chosen to minimize overhead rather than eliminate any resizing.

INT_SPACEback to summary
private static final int INT_SPACE

Constructor Detail

AttributeCollectorback to summary
protected AttributeCollector(ReaderConfig cfg)

Method Detail

checkExpandback to summary
private final boolean checkExpand(TypedArrayDecoder tad)

Internal method used to see if we can expand the buffer that the array decoder has. Bit messy, but simpler than having separately typed instances; and called rarely so that performance downside of instanceof is irrelevant.

continueValueback to summary
public char[] continueValue()
decodeBinaryValueback to summary
public byte[] decodeBinaryValue(int index, Base64Variant v, CharArrayBase64Decoder dec, XmlScanner scanner) throws XMLStreamException
decodeValueback to summary
public final void decodeValue(int index, TypedValueDecoder dec) throws IllegalArgumentException
decodeValuesback to summary
public final int decodeValues(int index, TypedArrayDecoder dec, XmlScanner scanner) throws XMLStreamException
decodeValuesback to summary
private final int decodeValues(TypedArrayDecoder dec, final char[] buf, int ptr, final int end, final XmlScanner scanner) throws XMLStreamException
findIndexback to summary
public int findIndex(String nsUri, String localName)
finishLastValueback to summary
public final int finishLastValue(int endingOffset)

Method called after all attribute entries have been parsed, and thus the end of the last value in the buffer is known.

Returns:int

Number of attributes collected

finishLastValue2back to summary
public final int finishLastValue2()
getCountback to summary
public final int getCount()
getErrorMsgback to summary
public String getErrorMsg()
getNameback to summary
public final PName getName(int index)
getQNameback to summary
public final QName getQName(int index)
getValueback to summary
public String getValue(int index)
getValueback to summary
public String getValue(String nsUri, String localName)
isSpaceback to summary
private static final boolean isSpace(char c)
noteDupAttrback to summary
private void noteDupAttr(int ix1, int ix2)
startNewValueback to summary
public char[] startNewValue(PName attrName, int currOffset)

Method called by the parser right after attribute name has been parsed, but before value has been parsed.

Returns:char[]

Underlying character buffer to use for storing attribute value characters

valueBufferFullback to summary
public char[] valueBufferFull()

Method called by the owner, when the