Class AttributeCollector

java.lang.Object
com.fasterxml.aalto.in.AttributeCollector

public final class AttributeCollector extends Object
Object used by the tokenizer to collect and store information about attributes, specifically, names and values.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Concatenated String that contains all the attribute values for the element.
    private int
    Number of attributes currently held by this collector.
    protected int[]
    Int-based compact data structure that contains mapping from attribute names to attribute indexes in the main attribute name array.
    (package private) final ReaderConfig
     
    private String
    For some errors, we'll have to temporarily store error message, to be thrown at a later point.
    protected int
    Size of hash area in _attrMap; generally at least 20% more than number of attributes (_attrCount).
    private PName[]
     
    private boolean
    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
    Pointer to int slot right after last spill entry, in _attrMap array.
    private char[]
    Consequtive character array, in which attribute values are concatenated in
    private int[]
    Array that contains ending offsets of the values in the shared buffer.
    private static final int
    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
    Let's guess that most of the time there won't be more than 12 attributes.
    private static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private final boolean
    checkExpand(org.codehaus.stax2.typed.TypedArrayDecoder tad)
    Internal method used to see if we can expand the buffer that the array decoder has.
    char[]
     
    byte[]
    decodeBinaryValue(int index, org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, XmlScanner scanner)
     
    final void
    decodeValue(int index, org.codehaus.stax2.typed.TypedValueDecoder dec)
     
    final int
    decodeValues(int index, org.codehaus.stax2.typed.TypedArrayDecoder dec, XmlScanner scanner)
     
    private final int
    decodeValues(org.codehaus.stax2.typed.TypedArrayDecoder dec, char[] buf, int ptr, int end, XmlScanner scanner)
     
    int
    findIndex(String nsUri, String localName)
     
    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.
    final int
     
    final int
     
     
    final PName
    getName(int index)
     
    final QName
    getQName(int index)
     
    getValue(int index)
     
    getValue(String nsUri, String localName)
     
    private static final boolean
    isSpace(char c)
     
    private void
    noteDupAttr(int ix1, int ix2)
     
    char[]
    startNewValue(PName attrName, int currOffset)
    Method called by the parser right after attribute name has been parsed, but before value has been parsed.
    char[]
    Method called by the owner, when the

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INT_SPACE

      private static final int INT_SPACE
      See Also:
    • DEFAULT_ENTRY_COUNT

      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.
      See Also:
    • DEFAULT_BUFFER_LENGTH

      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.
      See Also:
    • _config

      final ReaderConfig _config
    • _attrCount

      private int _attrCount
      Number of attributes currently held by this collector.
    • _names

      private PName[] _names
    • _valueBuffer

      private char[] _valueBuffer
      Consequtive character array, in which attribute values are concatenated in
    • _attrMap

      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.

    • _hashAreaSize

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

      protected int _spillAreaEnd
      Pointer to int slot right after last spill entry, in _attrMap array.
    • _valueOffsets

      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.
    • _needToResetValues

      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
    • _errorMsg

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

      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.
  • Constructor Details

    • AttributeCollector

      protected AttributeCollector(ReaderConfig cfg)
  • Method Details

    • startNewValue

      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:
      Underlying character buffer to use for storing attribute value characters
    • continueValue

      public char[] continueValue()
    • finishLastValue

      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:
      Number of attributes collected
    • finishLastValue2

      public final int finishLastValue2()
    • valueBufferFull

      public char[] valueBufferFull()
      Method called by the owner, when the
    • getCount

      public final int getCount()
    • getName

      public final PName getName(int index)
    • getQName

      public final QName getQName(int index)
    • getValue

      public String getValue(int index)
    • getValue

      public String getValue(String nsUri, String localName)
    • findIndex

      public int findIndex(String nsUri, String localName)
    • getErrorMsg

      public String getErrorMsg()
    • decodeValue

      public final void decodeValue(int index, org.codehaus.stax2.typed.TypedValueDecoder dec) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • decodeValues

      public final int decodeValues(int index, org.codehaus.stax2.typed.TypedArrayDecoder dec, XmlScanner scanner) throws XMLStreamException
      Throws:
      XMLStreamException
    • decodeValues

      private final int decodeValues(org.codehaus.stax2.typed.TypedArrayDecoder dec, char[] buf, int ptr, int end, XmlScanner scanner) throws XMLStreamException
      Throws:
      XMLStreamException
    • decodeBinaryValue

      public byte[] decodeBinaryValue(int index, org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, XmlScanner scanner) throws XMLStreamException
      Throws:
      XMLStreamException
    • isSpace

      private static final boolean isSpace(char c)
    • checkExpand

      private final boolean checkExpand(org.codehaus.stax2.typed.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.
    • noteDupAttr

      private void noteDupAttr(int ix1, int ix2)