Class TypedStreamReader

  • All Implemented Interfaces:
    InputConfigFlags, ParsingErrorMsgs, InputProblemReporter, StreamReaderImpl, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader, org.codehaus.stax2.DTDInfo, org.codehaus.stax2.LocationInfo, org.codehaus.stax2.typed.TypedXMLStreamReader, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.XMLStreamReader2
    Direct Known Subclasses:
    ValidatingStreamReader

    public class TypedStreamReader
    extends BasicStreamReader
    Complete implementation of XMLStreamReader2, including Typed Access API (Stax2 v3.0) implementation. Only functionality missing is DTD validation, which is provided by a specialized sub-class.
    • Field Detail

      • MASK_TYPED_ACCESS_ARRAY

        protected static final int MASK_TYPED_ACCESS_ARRAY
        Mask of event types that are legal (starting) states to call Typed Access API from.
        See Also:
        Constant Field Values
      • MASK_TYPED_ACCESS_BINARY

        protected static final int MASK_TYPED_ACCESS_BINARY
        See Also:
        Constant Field Values
      • MIN_BINARY_CHUNK

        static final int MIN_BINARY_CHUNK
        Minimum length of text chunks to parse before base64 decoding. Will try to limit it to fit within regular result buffers.
        See Also:
        Constant Field Values
      • _decoderFactory

        protected org.codehaus.stax2.ri.typed.ValueDecoderFactory _decoderFactory
        Factory used for constructing decoders we need for typed access
      • _base64Decoder

        protected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder _base64Decoder
        Lazily-constructed decoder object for decoding base64 encoded element binary content.
    • Method Detail

      • createStreamReader

        public static TypedStreamReader createStreamReader​(BranchingReaderSource input,
                                                           ReaderCreator owner,
                                                           ReaderConfig cfg,
                                                           InputBootstrapper bs,
                                                           boolean forER)
                                                    throws javax.xml.stream.XMLStreamException
        Factory method for constructing readers.
        Parameters:
        owner - "Owner" of this reader, factory that created the reader; needed for returning updated symbol table information after parsing.
        input - Input source used to read the XML document.
        cfg - Object that contains reader configuration info.
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsBoolean

        public boolean getElementAsBoolean()
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsInt

        public int getElementAsInt()
                            throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsLong

        public long getElementAsLong()
                              throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsFloat

        public float getElementAsFloat()
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsDouble

        public double getElementAsDouble()
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsInteger

        public java.math.BigInteger getElementAsInteger()
                                                 throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsDecimal

        public java.math.BigDecimal getElementAsDecimal()
                                                 throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsQName

        public javax.xml.namespace.QName getElementAsQName()
                                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsBinary

        public final byte[] getElementAsBinary()
                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAsBinary

        public byte[] getElementAsBinary​(org.codehaus.stax2.typed.Base64Variant v)
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getElementAs

        public void getElementAs​(org.codehaus.stax2.typed.TypedValueDecoder tvd)
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsIntArray

        public int readElementAsIntArray​(int[] value,
                                         int from,
                                         int length)
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsLongArray

        public int readElementAsLongArray​(long[] value,
                                          int from,
                                          int length)
                                   throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsFloatArray

        public int readElementAsFloatArray​(float[] value,
                                           int from,
                                           int length)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsDoubleArray

        public int readElementAsDoubleArray​(double[] value,
                                            int from,
                                            int length)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsArray

        public final int readElementAsArray​(org.codehaus.stax2.typed.TypedArrayDecoder dec)
                                     throws javax.xml.stream.XMLStreamException
        Method called to parse array of primitives.

        !!! 05-Sep-2008, tatu: Current implementation is not optimal either performance-wise, or from getting accurate Location for decoding problems. But it works otherwise, and we need to get Woodstox 4.0 out by the end of the year... so it'll do, for now.

        Returns:
        Number of elements decoded (if any were decoded), or -1 to indicate that no more values can be decoded.
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsBinary

        public final int readElementAsBinary​(byte[] resultBuffer,
                                             int offset,
                                             int maxLength)
                                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readElementAsBinary

        public int readElementAsBinary​(byte[] resultBuffer,
                                       int offset,
                                       int maxLength,
                                       org.codehaus.stax2.typed.Base64Variant v)
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • _initBinaryChunks

        private final void _initBinaryChunks​(org.codehaus.stax2.typed.Base64Variant v,
                                             org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec,
                                             int type,
                                             boolean isFirst)
                                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeIndex

        public int getAttributeIndex​(java.lang.String namespaceURI,
                                     java.lang.String localName)
      • getAttributeAsBoolean

        public boolean getAttributeAsBoolean​(int index)
                                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsInt

        public int getAttributeAsInt​(int index)
                              throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsLong

        public long getAttributeAsLong​(int index)
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsFloat

        public float getAttributeAsFloat​(int index)
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsDouble

        public double getAttributeAsDouble​(int index)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsInteger

        public java.math.BigInteger getAttributeAsInteger​(int index)
                                                   throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsDecimal

        public java.math.BigDecimal getAttributeAsDecimal​(int index)
                                                   throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsQName

        public javax.xml.namespace.QName getAttributeAsQName​(int index)
                                                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAs

        public void getAttributeAs​(int index,
                                   org.codehaus.stax2.typed.TypedValueDecoder tvd)
                            throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsIntArray

        public int[] getAttributeAsIntArray​(int index)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsLongArray

        public long[] getAttributeAsLongArray​(int index)
                                       throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsFloatArray

        public float[] getAttributeAsFloatArray​(int index)
                                         throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsDoubleArray

        public double[] getAttributeAsDoubleArray​(int index)
                                           throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsArray

        public int getAttributeAsArray​(int index,
                                       org.codehaus.stax2.typed.TypedArrayDecoder tad)
                                throws javax.xml.stream.XMLStreamException
        Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.
        Returns:
        Number of tokens decoded, 0 if none found
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsBinary

        public byte[] getAttributeAsBinary​(int index)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getAttributeAsBinary

        public byte[] getAttributeAsBinary​(int index,
                                           org.codehaus.stax2.typed.Base64Variant v)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • _verifyQName

        protected javax.xml.namespace.QName _verifyQName​(javax.xml.namespace.QName n)
                                                  throws org.codehaus.stax2.typed.TypedXMLStreamException
        Method called to verify validity of the parsed QName element or attribute value. At this point binding of a prefixed name (if qname has a prefix) has been verified, and thereby prefix also must be valid (since there must have been a preceding declaration). But local name might still not be a legal well-formed xml name, so let's verify that.
        Throws:
        org.codehaus.stax2.typed.TypedXMLStreamException
      • _decoderFactory

        protected org.codehaus.stax2.ri.typed.ValueDecoderFactory _decoderFactory()
      • _base64Decoder

        protected org.codehaus.stax2.ri.typed.CharArrayBase64Decoder _base64Decoder()
      • _handleEmptyValue

        private void _handleEmptyValue​(org.codehaus.stax2.typed.TypedValueDecoder dec)
                                throws javax.xml.stream.XMLStreamException
        Method called to handle value that has empty String as representation. This will usually either lead to an exception, or parsing to the default value for the type in question (null for nullable types and so on).
        Throws:
        javax.xml.stream.XMLStreamException
      • _constructTypeException

        protected org.codehaus.stax2.typed.TypedXMLStreamException _constructTypeException​(java.lang.IllegalArgumentException iae,
                                                                                           java.lang.String lexicalValue)
        Method called to wrap or convert given conversion-fail exception into a full TypedXMLStreamException,
        Parameters:
        iae - Problem as reported by converter
        lexicalValue - Lexical value (element content, attribute value) that could not be converted succesfully.