Class Stax2ReaderAdapter
- java.lang.Object
-
- javax.xml.stream.util.StreamReaderDelegate
-
- org.codehaus.stax2.ri.Stax2ReaderAdapter
-
- All Implemented Interfaces:
javax.xml.stream.XMLStreamConstants
,javax.xml.stream.XMLStreamReader
,AttributeInfo
,DTDInfo
,LocationInfo
,TypedXMLStreamReader
,Validatable
,XMLStreamReader2
public class Stax2ReaderAdapter extends javax.xml.stream.util.StreamReaderDelegate implements XMLStreamReader2, AttributeInfo, DTDInfo, LocationInfo
This adapter implements parts ofXMLStreamReader2
, the extended stream reader defined by Stax2 extension, by wrapping a vanilla Stax 1.0XMLStreamReader
implementation.Note: the implementation is incomplete as-is, since not all features needed are accessible via basic Stax 1.0 interface. As such, two main use cases for this wrapper are:
- Serve as convenient base class for a complete implementation, which can use native accessors provided by the wrapped Stax implementation
- To be used for tasks that make limited use of Stax2 API, such that missing parts are not needed
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBase64Decoder
_base64Decoder
Lazily-constructed decoder object for decoding base64 encoded binary content.protected ValueDecoderFactory
_decoderFactory
Factory used for constructing decoders we need for typed accessprotected int
_depth
Number of open (start) elements currently.protected java.lang.String
_typedContent
Content temporarily cached to be used for decoding typed content that is in chunked mode (int/long/float/double arrays, base64 encoded binary data)(package private) static int
INT_SPACE
private static int
MASK_GET_ELEMENT_TEXT
protected static int
MASK_TYPED_ACCESS_BINARY
-
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
-
Fields inherited from interface org.codehaus.stax2.XMLStreamReader2
FEATURE_DTD_OVERRIDE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Stax2ReaderAdapter(javax.xml.stream.XMLStreamReader sr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected StringBase64Decoder
_base64Decoder()
protected TypedXMLStreamException
_constructTypeException(java.lang.IllegalArgumentException iae, java.lang.String lexicalValue)
Method called to wrap or convert given conversion-fail exception into a fullTypedXMLStreamException
,protected TypedXMLStreamException
_constructTypeException(java.lang.String msg, java.lang.String lexicalValue)
protected ValueDecoderFactory
_decoderFactory()
protected int
_getAttributeAsArray(TypedArrayDecoder tad, java.lang.String attrValue)
private boolean
checkExpand(TypedArrayDecoder tad)
Internal method used to see if we can expand the buffer that the array decoder has.void
closeCompletely()
Method similar toXMLStreamReader.close()
, except that this method also does close the underlying input source if it has not yet been closed.int
findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
void
getAttributeAs(int index, TypedValueDecoder tvd)
Generic access method that can be used for efficient decoding of additional types not support natively by the typed stream reader.int
getAttributeAsArray(int index, TypedArrayDecoder tad)
Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.byte[]
getAttributeAsBinary(int index)
Read an attribute value as a byte array.byte[]
getAttributeAsBinary(int index, Base64Variant v)
boolean
getAttributeAsBoolean(int index)
Read an attribute value as a boolean.java.math.BigDecimal
getAttributeAsDecimal(int index)
double
getAttributeAsDouble(int index)
double[]
getAttributeAsDoubleArray(int index)
float
getAttributeAsFloat(int index)
float[]
getAttributeAsFloatArray(int index)
int
getAttributeAsInt(int index)
Read an attribute value as a boolean.int[]
getAttributeAsIntArray(int index)
Read an attribute content as an int array.java.math.BigInteger
getAttributeAsInteger(int index)
long
getAttributeAsLong(int index)
Read an attribute value as a boolean.long[]
getAttributeAsLongArray(int index)
javax.xml.namespace.QName
getAttributeAsQName(int index)
int
getAttributeIndex(java.lang.String namespaceURI, java.lang.String localName)
Returns the index of the attribute whose local name islocalName
and URI isnamespaceURI
or-1
if no such attribute exists.AttributeInfo
getAttributeInfo()
Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available.XMLStreamLocation2
getCurrentLocation()
A method that returns the current location of the stream reader at the input source.int
getDepth()
Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on.DTDInfo
getDTDInfo()
Method that can be called to get information about DOCTYPE declaration that the reader is currently pointing to, if the reader has parsed it.java.lang.String
getDTDInternalSubset()
java.lang.String
getDTDPublicId()
java.lang.String
getDTDRootName()
java.lang.String
getDTDSystemId()
void
getElementAs(TypedValueDecoder tvd)
Generic decoding method that can be used for efficient decoding of additional types not support natively by the typed stream reader.byte[]
getElementAsBinary()
Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
, in cases where neither performance nor memory usage is a big concern.byte[]
getElementAsBinary(Base64Variant v)
Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
, in cases where neither performance nor memory usage is a big concern.boolean
getElementAsBoolean()
Read an element content as a boolean.java.math.BigDecimal
getElementAsDecimal()
double
getElementAsDouble()
Read an element content as a 64-bit floating point value.float
getElementAsFloat()
Read an element content as a 32-bit floating point value.int
getElementAsInt()
Read an element content as a 32-bit integer.java.math.BigInteger
getElementAsInteger()
long
getElementAsLong()
Read an element content as a 64-bit integer.javax.xml.namespace.QName
getElementAsQName()
java.lang.String
getElementText()
long
getEndingByteOffset()
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.long
getEndingCharOffset()
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.XMLStreamLocation2
getEndLocation()
An optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).java.lang.Object
getFeature(java.lang.String name)
Deprecated.int
getIdAttributeIndex()
Returns the index of the id attribute (attribute with any name, type ID from DTD) of current (start) element, if any.LocationInfo
getLocationInfo()
Location information is always accessible, for this reader.javax.xml.namespace.NamespaceContext
getNonTransientNamespaceContext()
This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext()
, but one that is not transient.int
getNotationAttributeIndex()
Returns the index of the notation attribute (attribute with any name, type NOTATION from DTD) of current (start) element, if any.java.lang.String
getPrefixedName()
This method returns "prefix-qualified" name of the current element.java.lang.Object
getProcessedDTD()
DTDValidationSchema
getProcessedDTDSchema()
Method similar toDTDInfo.getProcessedDTD()
, but type-safe.long
getStartingByteOffset()
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.long
getStartingCharOffset()
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.XMLStreamLocation2
getStartLocation()
An optional method that either returns the location object that points the starting position of the current event, or null if implementation does not keep track of it (some may return only end location; and some no location at all).int
getText(java.io.Writer w, boolean preserveContents)
Method similar toXMLStreamReader.getText()
, except that it just uses provided Writer to write all textual content, and that it works for wider range of event types.boolean
isEmptyElement()
Alas, there is no way to find this out via Stax 1.0, so this implementation always returns false.boolean
isPropertySupported(java.lang.String name)
Method similar toXMLInputFactory.isPropertySupported(java.lang.String)
, used to determine whether a property is supported by the Reader instance.int
next()
int
readElementAsArray(TypedArrayDecoder tad)
Read an element content as an array of tokens.int
readElementAsBinary(byte[] resultBuffer, int offset, int maxLength)
int
readElementAsBinary(byte[] resultBuffer, int offset, int maxLength, Base64Variant v)
Read element content as decoded byte sequence; possibly only reading a fragment of all element content.int
readElementAsDoubleArray(double[] value, int from, int length)
int
readElementAsFloatArray(float[] value, int from, int length)
int
readElementAsIntArray(int[] value, int from, int length)
Read an element content as an int array.int
readElementAsLongArray(long[] value, int from, int length)
void
setFeature(java.lang.String name, java.lang.Object value)
Deprecated.boolean
setProperty(java.lang.String name, java.lang.Object value)
Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2
instance.ValidationProblemHandler
setValidationProblemHandler(ValidationProblemHandler h)
Method that application can call to define a custom handler for validation problems encountered during validation process.void
skipElement()
Method that will skip all the contents of the element that the stream currently points to.XMLValidator
stopValidatingAgainst(XMLValidationSchema schema)
Method that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier.XMLValidator
stopValidatingAgainst(XMLValidator validator)
Method that can be called by application to stop validating output using specified validator.protected void
throwNotStartElem(int type)
protected void
throwNotStartElemOrTextual(int type)
protected void
throwUnsupported()
XMLValidator
validateAgainst(XMLValidationSchema schema)
Method that will construct aXMLValidator
instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.static XMLStreamReader2
wrapIfNecessary(javax.xml.stream.XMLStreamReader sr)
Method that should be used to add dynamic support forXMLStreamReader2
.-
Methods inherited from class javax.xml.stream.util.StreamReaderDelegate
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getParent, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, require, setParent, standaloneSet
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.stax2.AttributeInfo
getAttributeCount
-
Methods inherited from interface org.codehaus.stax2.LocationInfo
getLocation
-
Methods inherited from interface javax.xml.stream.XMLStreamReader
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, require, standaloneSet
-
-
-
-
Field Detail
-
INT_SPACE
static final int INT_SPACE
- See Also:
- Constant Field Values
-
MASK_GET_ELEMENT_TEXT
private static final int MASK_GET_ELEMENT_TEXT
- See Also:
- Constant Field Values
-
MASK_TYPED_ACCESS_BINARY
protected static final int MASK_TYPED_ACCESS_BINARY
- See Also:
- Constant Field Values
-
_decoderFactory
protected ValueDecoderFactory _decoderFactory
Factory used for constructing decoders we need for typed access
-
_base64Decoder
protected StringBase64Decoder _base64Decoder
Lazily-constructed decoder object for decoding base64 encoded binary content.
-
_depth
protected int _depth
Number of open (start) elements currently.
-
_typedContent
protected java.lang.String _typedContent
Content temporarily cached to be used for decoding typed content that is in chunked mode (int/long/float/double arrays, base64 encoded binary data)
-
-
Method Detail
-
wrapIfNecessary
public static XMLStreamReader2 wrapIfNecessary(javax.xml.stream.XMLStreamReader sr)
Method that should be used to add dynamic support forXMLStreamReader2
. Method will check whether the stream reader passed happens to be aXMLStreamReader2
; and if it is, return it properly cast. If not, it will create necessary wrapper.
-
next
public int next() throws javax.xml.stream.XMLStreamException
- Specified by:
next
in interfacejavax.xml.stream.XMLStreamReader
- Overrides:
next
in classjavax.xml.stream.util.StreamReaderDelegate
- Throws:
javax.xml.stream.XMLStreamException
-
getElementText
public java.lang.String getElementText() throws javax.xml.stream.XMLStreamException
- Specified by:
getElementText
in interfacejavax.xml.stream.XMLStreamReader
- Overrides:
getElementText
in classjavax.xml.stream.util.StreamReaderDelegate
- Throws:
javax.xml.stream.XMLStreamException
-
getElementAsBoolean
public boolean getElementAsBoolean() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as a boolean. The lexical representation of a boolean is defined by the XML Schema boolean data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema boolean data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema boolean data type. (note: allowed lexical values are canonicals "true" and "false", as well as non-canonical "0" and "1")
These are the pre- and post-conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Specified by:
getElementAsBoolean
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getElementAsInt
public int getElementAsInt() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as a 32-bit integer. The lexical representation of a integer is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema integer data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Specified by:
getElementAsInt
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting character sequence into a Java (32-bit) integer.
-
getElementAsLong
public long getElementAsLong() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as a 64-bit integer. The lexical representation of a integer is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema integer data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Specified by:
getElementAsLong
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting character sequence into a Java (64-bit) integer.
-
getElementAsFloat
public float getElementAsFloat() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as a 32-bit floating point value. The lexical representation is defined by the XML Schema float data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema float data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
Note that valid representations include basic Java textual representations, as well as 3 special tokens: "INF", "-INF" and "NaN"These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Specified by:
getElementAsFloat
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting character sequence into a Java float
-
getElementAsDouble
public double getElementAsDouble() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as a 64-bit floating point value. The lexical representation is defined by the XML Schema double data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema double data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
Note that valid representations include basic Java textual representations, as well as 3 special tokens: "INF", "-INF" and "NaN"These are the pre and post conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
- Specified by:
getElementAsDouble
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting character sequence into a Java double
-
getElementAsInteger
public java.math.BigInteger getElementAsInteger() throws javax.xml.stream.XMLStreamException
- Specified by:
getElementAsInteger
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getElementAsDecimal
public java.math.BigDecimal getElementAsDecimal() throws javax.xml.stream.XMLStreamException
- Specified by:
getElementAsDecimal
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getElementAsQName
public javax.xml.namespace.QName getElementAsQName() throws javax.xml.stream.XMLStreamException
- Specified by:
getElementAsQName
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getElementAsBinary
public byte[] getElementAsBinary() throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
, in cases where neither performance nor memory usage is a big concern.Note: base64 variant defaults to
Base64Variants.MIME
.- Specified by:
getElementAsBinary
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
- See Also:
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
-
getElementAsBinary
public byte[] getElementAsBinary(Base64Variant v) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Convenience method that can be used similar to read binary content instead ofTypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
, in cases where neither performance nor memory usage is a big concern.- Specified by:
getElementAsBinary
in interfaceTypedXMLStreamReader
- Parameters:
v
- Base64 variant content is in; needed to decode alternative variants ("modified base64")- Throws:
javax.xml.stream.XMLStreamException
- See Also:
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
-
getElementAs
public void getElementAs(TypedValueDecoder tvd) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Generic decoding method that can be used for efficient decoding of additional types not support natively by the typed stream reader. When method is called, stream reader will collect all textual content of the current element (effectively doing something similar to a call toXMLStreamReader.getElementText()
, and then call one of decode methods defined inTypedValueDecoder
. The only difference is that passed value will be trimmed: that is, any leading or trailing white space will be removed prior to calling decode method. After the call, passed decoder object will have decoded and stored value (if succesful) or thrown an exception (if not).The main benefit of using this method (over just getting all content by calling
XMLStreamReader.getElementText()
is efficiency: the stream reader can efficiently gather all textual content necessary and pass it to the decoder, often avoiding construction of intemediate Strings.These are the pre- and post-conditions of calling this method:
- Precondition: the current event is START_ELEMENT.
- Postcondition: the current event is the corresponding END_ELEMENT.
Note that caller has to know more specific type of decoder, since the base interface does not specify methods for accessing actual decoded value.
- Specified by:
getElementAs
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsIntArray
public int readElementAsIntArray(int[] value, int from, int length) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as an int array. The lexical representation of a int array is defined by the following XML schema type:<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>
whose lexical space is a list of space-separated ints. Whitespace MUST be collapsed according to the whiteSpace facet for theintArray
type shown above. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by theintArray
data type.These are the pre and post conditions of calling this method:
- Precondition: the current event is either START_ELEMENT, or a textual event (CHARACTERS, CDATA), or END_ELEMENT (END_ELEMENT is allowed for convenience; if so, no read operation is tried, and -1 is returned immediately
- Postcondition: the current event is the corresponding END_ELEMENT or CHARACTERS if only a portion of the array has been copied thus far.
- Specified by:
readElementAsIntArray
in interfaceTypedXMLStreamReader
- Parameters:
value
- The array in which to copy the ints.from
- The index in the array from which copying starts.length
- The maximun number of ints to copy. Minimum value is 1; others anIllegalArgumentException
is thrown- Returns:
- The number of ints actually copied which must
be less or equal than
length
, but at least one if any ints found. If not, -1 is returned to signal end of ints to parse. - Throws:
javax.xml.stream.XMLStreamException
-
readElementAsLongArray
public int readElementAsLongArray(long[] value, int from, int length) throws javax.xml.stream.XMLStreamException
- Specified by:
readElementAsLongArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsFloatArray
public int readElementAsFloatArray(float[] value, int from, int length) throws javax.xml.stream.XMLStreamException
- Specified by:
readElementAsFloatArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsDoubleArray
public int readElementAsDoubleArray(double[] value, int from, int length) throws javax.xml.stream.XMLStreamException
- Specified by:
readElementAsDoubleArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsArray
public int readElementAsArray(TypedArrayDecoder tad) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an element content as an array of tokens. This is done by reader tokenizing textual content by white space, and sending each token to specified decoder for decoding. This is repeated as long as element content has more tokens and decoder can accept more values.These are the pre- and post-conditions of calling this method:
- Precondition: the current event is either START_ELEMENT, or a textual event (CHARACTERS, CDATA), or END_ELEMENT (END_ELEMENT is allowed for convenience; if so, no read operation is tried, and -1 is returned immediately
- Postcondition: the current event is the corresponding END_ELEMENT or CHARACTERS if only a portion of the array has been copied thus far.
Note: passed decoder must accept at least one value, reader will not verify capacity before calling it with the first token.
- Specified by:
readElementAsArray
in interfaceTypedXMLStreamReader
- Returns:
- Number of elements decoded, or -1 to indicate that there was no more element content tokens to decode.
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsBinary
public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength) throws javax.xml.stream.XMLStreamException
- Specified by:
readElementAsBinary
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
readElementAsBinary
public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength, Base64Variant v) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read element content as decoded byte sequence; possibly only reading a fragment of all element content. The lexical representation of a byte array is defined by the XML Schema base64Binary data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema base64Binary data type. An exception is thrown if content is not in the lexical space defined by the XML Schema base64Binary data type.Each call will read at least one decoded byte (and no more than the specified maximum length), if there is any content remaining. If none is available and END_ELEMENT is encountered, -1 is returned.
These are the pre and post conditions of calling this method:
- Precondition: the current event is either START_ELEMENT, or a textual event (CHARACTERS, CDATA), or END_ELEMENT (END_ELEMENT is allowed for convenience; if so, no read operation is tried, and -1 is returned immediately
- Postcondition: the current event is the corresponding END_ELEMENT, if all remaining binary content was read, or CHARACTERS if only a portion of the array was read
Additionally, caller MUST start decoding at START_ELEMENT; if the first decode calls is at CHARACTERS or CDATA event, results are not defined: result may be an exception, or invalid data being returned. Implementations are encouraged to throw an exception if possible, to make it easier to figure out the problem.
This method can be called multiple times until the cursor is positioned at the corresponding END_ELEMENT event. Stated differently, after the method is called for the first time, the cursor will move and remain in the CHARACTERS position while there are potentially more bytes available for reading.
- Specified by:
readElementAsBinary
in interfaceTypedXMLStreamReader
- Parameters:
resultBuffer
- Array in which to copy decoded bytes.offset
- Starting offset of the first decoded byte within result buffermaxLength
- Maximum number of bytes to decode with this call- Returns:
- The number of bytes actually decoded and returned,
if any were available; -1 if there is no more content.
If any content was copied, value must be less or equal than
maxLength
Note that this value is not guaranteed to equalmaxLength
even if enough content was available; that is, implementations can return shorter sections if they choose to, down to and including returning zero (0) if it was not possible to decode a full base64 triplet (3 output bytes from 4 input characters). - Throws:
javax.xml.stream.XMLStreamException
-
getAttributeIndex
public int getAttributeIndex(java.lang.String namespaceURI, java.lang.String localName)
Description copied from interface:TypedXMLStreamReader
Returns the index of the attribute whose local name islocalName
and URI isnamespaceURI
or-1
if no such attribute exists.- Specified by:
getAttributeIndex
in interfaceTypedXMLStreamReader
- Parameters:
namespaceURI
- The attribute's namespace URI. Values of null and "" are considered the same, i.e. "no namespace" (or "empty" namespace)localName
- The attribute's local name.- Returns:
- The attribute's index or
-1
if no such attribute exists.
-
getAttributeAsBoolean
public boolean getAttributeAsBoolean(int index) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema boolean data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema boolean data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema boolean data type.
- Specified by:
getAttributeAsBoolean
in interfaceTypedXMLStreamReader
- Parameters:
index
- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)
- Throws:
javax.xml.stream.XMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsInt
public int getAttributeAsInt(int index) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema integer data type. Whitespace MUST be collapsed according to the whiteSpace facet for the type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema integer data type.
- Specified by:
getAttributeAsInt
in interfaceTypedXMLStreamReader
- Parameters:
index
- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)
- Throws:
javax.xml.stream.XMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsLong
public long getAttributeAsLong(int index) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an attribute value as a boolean. The lexical representation of a boolean is defined by the XML Schema long data type. Whitespace MUST be collapsed according to the whiteSpace facet for the type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema long data type.
- Specified by:
getAttributeAsLong
in interfaceTypedXMLStreamReader
- Parameters:
index
- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)
- Throws:
javax.xml.stream.XMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsFloat
public float getAttributeAsFloat(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsFloat
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsDouble
public double getAttributeAsDouble(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsDouble
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsInteger
public java.math.BigInteger getAttributeAsInteger(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsInteger
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsDecimal
public java.math.BigDecimal getAttributeAsDecimal(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsDecimal
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsQName
public javax.xml.namespace.QName getAttributeAsQName(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsQName
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAs
public void getAttributeAs(int index, TypedValueDecoder tvd) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Generic access method that can be used for efficient decoding of additional types not support natively by the typed stream reader. The main benefit of using this method is that the stream reader can efficient gather all textual content necessary and pass it to the decoder, often avoiding construction of intemediate Strings.As with
TypedXMLStreamReader.getElementAs(org.codehaus.stax2.typed.TypedValueDecoder)
, value passed to a decode method will be trimmed of any leading or trailing white space.- Specified by:
getAttributeAs
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsIntArray
public int[] getAttributeAsIntArray(int index) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an attribute content as an int array. The lexical representation of a int array is defined by the following XML schema type:
<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>
whose lexical space is a list of space-separated ints. Whitespace MUST be collapsed according to the whiteSpace facet for theintArray
type shown above. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by theintArray
data type.- Specified by:
getAttributeAsIntArray
in interfaceTypedXMLStreamReader
- Parameters:
index
- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)
.- Returns:
- An array of ints with the content.
- Throws:
javax.xml.stream.XMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsLongArray
public long[] getAttributeAsLongArray(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsLongArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsFloatArray
public float[] getAttributeAsFloatArray(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsFloatArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsDoubleArray
public double[] getAttributeAsDoubleArray(int index) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsDoubleArray
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeAsArray
public int getAttributeAsArray(int index, TypedArrayDecoder tad) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Method that allows reading contents of an attribute as an array of whitespace-separate tokens, decoded using specified decoder.- Specified by:
getAttributeAsArray
in interfaceTypedXMLStreamReader
- Returns:
- Number of tokens decoded, 0 if none found
- Throws:
javax.xml.stream.XMLStreamException
-
_getAttributeAsArray
protected int _getAttributeAsArray(TypedArrayDecoder tad, java.lang.String attrValue) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
checkExpand
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.
-
getAttributeAsBinary
public byte[] getAttributeAsBinary(int index) throws javax.xml.stream.XMLStreamException
Description copied from interface:TypedXMLStreamReader
Read an attribute value as a byte array. The lexical representation of a byte array is defined by the XML Schema base64Binary data type. Whitespace MUST be collapsed according to the whiteSpace facet for the XML Schema base64Binary data type. An exception is thrown if, after whitespace is collapsed, the resulting sequence of characters is not in the lexical space defined by the XML Schema base64Binary data type.- Specified by:
getAttributeAsBinary
in interfaceTypedXMLStreamReader
- Parameters:
index
- The attribute's index as returned byTypedXMLStreamReader.getAttributeIndex(String, String)
.- Returns:
- An array of bytes with the content.
- Throws:
javax.xml.stream.XMLStreamException
- If unable to convert the resulting character sequence into an XML Schema boolean value.
-
getAttributeAsBinary
public byte[] getAttributeAsBinary(int index, Base64Variant v) throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeAsBinary
in interfaceTypedXMLStreamReader
- Throws:
javax.xml.stream.XMLStreamException
-
getFeature
@Deprecated public java.lang.Object getFeature(java.lang.String name)
Deprecated.Description copied from interface:XMLStreamReader2
Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.setFeature(java.lang.String, java.lang.Object)
, not all are: some features are read-only, some write-only- Specified by:
getFeature
in interfaceXMLStreamReader2
- Parameters:
name
- Name of the feature of which value to get- Returns:
- Value of the feature (possibly null), if supported; null otherwise
-
setFeature
@Deprecated public void setFeature(java.lang.String name, java.lang.Object value)
Deprecated.Description copied from interface:XMLStreamReader2
Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.getFeature(java.lang.String)
, not all are: some features are read-only, some write-only- Specified by:
setFeature
in interfaceXMLStreamReader2
- Parameters:
name
- Name of the feature to setvalue
- Value to set feature to.
-
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
Description copied from interface:XMLStreamReader2
Method similar toXMLInputFactory.isPropertySupported(java.lang.String)
, used to determine whether a property is supported by the Reader instance. This means that this method may return false for some properties that the input factory does support: specifically, it should only return true if the value is mutable on per-instance basis. False means that either the property is not recognized, or is not mutable via reader instance.- Specified by:
isPropertySupported
in interfaceXMLStreamReader2
-
setProperty
public boolean setProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:XMLStreamReader2
Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2
instance. Exactly which methods are mutable is implementation specific.- Specified by:
setProperty
in interfaceXMLStreamReader2
- Parameters:
name
- Name of the property to setvalue
- Value to set property to.- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
skipElement
public void skipElement() throws javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamReader2
Method that will skip all the contents of the element that the stream currently points to. Current event when calling the method has to be START_ELEMENT (or otherwiseIllegalStateException
is thrown); after the call the stream will point to the matching END_ELEMENT event, having skipped zero or more intervening events for the contents.- Specified by:
skipElement
in interfaceXMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
-
getAttributeInfo
public AttributeInfo getAttributeInfo() throws javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamReader2
Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available. Note that the reader has to currently point to START_ELEMENT; if not, aIllegalStateException
will be thrown.- Specified by:
getAttributeInfo
in interfaceXMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
-
getDTDInfo
public DTDInfo getDTDInfo() throws javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamReader2
Method that can be called to get information about DOCTYPE declaration that the reader is currently pointing to, if the reader has parsed it. Implementations can also choose to return null to indicate they do not provide extra information; but they should not throw any exceptions beyond normal parsing exceptions.- Specified by:
getDTDInfo
in interfaceXMLStreamReader2
- Returns:
- Information object for accessing further DOCTYPE information, iff the reader currently points to DTD event, AND is operating in mode that parses such information (DTD-aware at least, and usually also validating)
- Throws:
javax.xml.stream.XMLStreamException
-
getLocationInfo
public final LocationInfo getLocationInfo()
Location information is always accessible, for this reader.- Specified by:
getLocationInfo
in interfaceXMLStreamReader2
-
getText
public int getText(java.io.Writer w, boolean preserveContents) throws java.io.IOException, javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamReader2
Method similar toXMLStreamReader.getText()
, except that it just uses provided Writer to write all textual content, and that it works for wider range of event types. For further optimization, it may also be allowed to do true pass-through, thus possibly avoiding one temporary copy of the data. Finally, note that this method is also guaranteed NOT to return fragments, even when coalescing is not enabled and a parser is otherwised allowed to return partial segments: this requirement is due to there being little benefit in returning such short chunks when streaming. Coalescing property is still honored normally.Method can only be called on states CDATA, CHARACTERS, COMMENT, DTD, ENTITY_REFERENCE, SPACE and PROCESSING_INSTRUCTION; if called when reader is in another state,
IllegalStateException
will be thrown. Content written for elements is same as withXMLStreamReader.getText()
.- Specified by:
getText
in interfaceXMLStreamReader2
- Parameters:
w
- Writer to use for writing textual contentspreserveContents
- If true, reader has to preserve contents so that further calls togetText
will return proper conntets. If false, reader is allowed to skip creation of such copies: this can improve performance, but it also means that further calls togetText
is not guaranteed to return meaningful data.- Returns:
- Number of characters written to the reader
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
getDepth
public int getDepth()
Description copied from interface:XMLStreamReader2
Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on. Depth is same for matching start/end elements, as well as for the all children of an element.- Specified by:
getDepth
in interfaceXMLStreamReader2
- Returns:
- Number of open elements in the stack; 0 when parser is in prolog/epilog, 1 inside root element and so on.
-
isEmptyElement
public boolean isEmptyElement() throws javax.xml.stream.XMLStreamException
Alas, there is no way to find this out via Stax 1.0, so this implementation always returns false.- Specified by:
isEmptyElement
in interfaceXMLStreamReader2
- Returns:
- True, if current event is START_ELEMENT and is based on a parsed empty element; otherwise false
- Throws:
javax.xml.stream.XMLStreamException
-
getNonTransientNamespaceContext
public javax.xml.namespace.NamespaceContext getNonTransientNamespaceContext()
Description copied from interface:XMLStreamReader2
This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext()
, but one that is not transient. That is, one that will remain valid and unchanged after its creation. This allows the namespace context to be used independent of its source documents life cycle. One possible use case is to use this namespace context for 'initializing' writers (especially ones that use repairing mode) with optimal/preferred name space bindings.- Specified by:
getNonTransientNamespaceContext
in interfaceXMLStreamReader2
- Returns:
- Non-transient namespace context as explained above.
-
getPrefixedName
public java.lang.String getPrefixedName()
Description copied from interface:XMLStreamReader2
This method returns "prefix-qualified" name of the current element. In general, this means character-by-character exact name of the element in XML content, and may be useful in informational purposes, as well as when interacting with packages and APIs that use such names (such as what SAX may use as qnames).Note: implementations are encouraged to provide an implementation that would be more efficient than calling
getLocalName
andgetPrefix
separately, but are not required to do so. Nonetheless it is usually at least as efficient (if not more) to call this method as to do it fully in calling code.- Specified by:
getPrefixedName
in interfaceXMLStreamReader2
- Returns:
- Prefix-qualified name of the current element; essentially 'prefix:localName' if the element has a prefix, or 'localName' if it does not have one (belongs to the default namespace)
-
closeCompletely
public void closeCompletely() throws javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamReader2
Method similar toXMLStreamReader.close()
, except that this method also does close the underlying input source if it has not yet been closed. It is generally preferable to call this method if the parsing ends in an exception; and for some input sources (when passing aFile
orURL
for factory method) it has to be called as the application does not have access to the actually input source (InputStream
opened from aURL
and so on).- Specified by:
closeCompletely
in interfaceXMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
-
findAttributeIndex
public int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
- Specified by:
findAttributeIndex
in interfaceAttributeInfo
- Returns:
- Index of the specified attribute, if the current element has such an attribute (explicit, or one created via default value expansion); -1 if not.
-
getIdAttributeIndex
public int getIdAttributeIndex()
Description copied from interface:AttributeInfo
Returns the index of the id attribute (attribute with any name, type ID from DTD) of current (start) element, if any. Note that DTD only allows at most one such attribute per element.- Specified by:
getIdAttributeIndex
in interfaceAttributeInfo
- Returns:
- Index of the ID attribute of current element, if the current element has such an attribute defined; -1 if not.
-
getNotationAttributeIndex
public int getNotationAttributeIndex()
Description copied from interface:AttributeInfo
Returns the index of the notation attribute (attribute with any name, type NOTATION from DTD) of current (start) element, if any. Note that DTD only allows at most one such attribute per element.- Specified by:
getNotationAttributeIndex
in interfaceAttributeInfo
- Returns:
- Index of the NOTATION attribute of current element, if the current element has such an attribute defined; -1 if not.
-
getProcessedDTD
public java.lang.Object getProcessedDTD()
- Specified by:
getProcessedDTD
in interfaceDTDInfo
- Returns:
- If current event is DTD, DTD support is enabled, and reader supports DTD processing, returns an internal Object implementation uses for storing/processing DTD; otherwise returns null.
-
getDTDRootName
public java.lang.String getDTDRootName()
- Specified by:
getDTDRootName
in interfaceDTDInfo
- Returns:
- If current event is DTD, returns the full root name (including prefix, if any); otherwise returns null
-
getDTDPublicId
public java.lang.String getDTDPublicId()
- Specified by:
getDTDPublicId
in interfaceDTDInfo
- Returns:
- If current event is DTD, and has a public id, returns the public id; otherwise returns null.
-
getDTDSystemId
public java.lang.String getDTDSystemId()
- Specified by:
getDTDSystemId
in interfaceDTDInfo
- Returns:
- If current event is DTD, and has a system id, returns the system id; otherwise returns null.
-
getDTDInternalSubset
public java.lang.String getDTDInternalSubset()
- Specified by:
getDTDInternalSubset
in interfaceDTDInfo
- Returns:
- Internal subset portion of the DOCTYPE declaration, if any; empty String if none
-
getProcessedDTDSchema
public DTDValidationSchema getProcessedDTDSchema()
Description copied from interface:DTDInfo
Method similar toDTDInfo.getProcessedDTD()
, but type-safe. Will return the DTD schema instance that was read, if we are in mode where it does get read (at least dtd-aware).- Specified by:
getProcessedDTDSchema
in interfaceDTDInfo
-
getStartingByteOffset
public long getStartingByteOffset()
Description copied from interface:LocationInfo
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getStartingCharOffset()
, but usually only for single-byte character streams (Ascii, ISO-Latin).- Specified by:
getStartingByteOffset
in interfaceLocationInfo
- Returns:
- Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.
-
getStartingCharOffset
public long getStartingCharOffset()
Description copied from interface:LocationInfo
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getStartingByteOffset()
; this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).- Specified by:
getStartingCharOffset
in interfaceLocationInfo
- Returns:
- Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.
-
getEndingByteOffset
public long getEndingByteOffset() throws javax.xml.stream.XMLStreamException
Description copied from interface:LocationInfo
Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getEndingCharOffset()
, but usually only for single-byte character streams (Ascii, ISO-Latin).Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
- Specified by:
getEndingByteOffset
in interfaceLocationInfo
- Returns:
- Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.
- Throws:
javax.xml.stream.XMLStreamException
-
getEndingCharOffset
public long getEndingCharOffset() throws javax.xml.stream.XMLStreamException
Description copied from interface:LocationInfo
Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getEndingByteOffset()
; this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
- Specified by:
getEndingCharOffset
in interfaceLocationInfo
- Returns:
- Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.
- Throws:
javax.xml.stream.XMLStreamException
-
getStartLocation
public XMLStreamLocation2 getStartLocation()
Description copied from interface:LocationInfo
An optional method that either returns the location object that points the starting position of the current event, or null if implementation does not keep track of it (some may return only end location; and some no location at all).Note: since it is assumed that the start location must either have been collected by now, or is not accessible (i.e. implementation [always] returns null), no exception is allowed to be throws, as no parsing should ever need to be done (unlike with
LocationInfo.getEndLocation()
).- Specified by:
getStartLocation
in interfaceLocationInfo
- Returns:
- Location of the first character of the current event in the input source (which will also be the starting location of the following event, if any, or EOF if not), or null (if implementation does not track locations).
-
getCurrentLocation
public XMLStreamLocation2 getCurrentLocation()
Description copied from interface:LocationInfo
A method that returns the current location of the stream reader at the input source. This is somewhere between the start and end locations (inclusive), depending on how parser does it parsing (for non-lazy implementations it's always the end location; for others something else).Since this location information should always be accessible, no further parsing is to be done, and no exceptions can be thrown.
- Specified by:
getCurrentLocation
in interfaceLocationInfo
- Returns:
- Location of the next character reader will parse in the input source.
-
getEndLocation
public final XMLStreamLocation2 getEndLocation() throws javax.xml.stream.XMLStreamException
Description copied from interface:LocationInfo
An optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).Note: since some implementations may not yet know the end location (esp. ones that do lazy loading), this call may require further parsing. As a result, this method may throw a parsing or I/O errors.
- Specified by:
getEndLocation
in interfaceLocationInfo
- Returns:
- Location right after the end of the current event (which will also be the start location of the next event, if any, or of EOF otherwise).
- Throws:
javax.xml.stream.XMLStreamException
- If the stream reader had to advance to the end of the event (to find the location), it may encounter a parsing (or I/O) error; if so, that gets thrown
-
validateAgainst
public XMLValidator validateAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
Description copied from interface:Validatable
Method that will construct aXMLValidator
instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.
- Specified by:
validateAgainst
in interfaceValidatable
- Returns:
- Validator instance constructed, if validator was added, or null if a validator for the schema has already been constructed.
- Throws:
javax.xml.stream.XMLStreamException
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
Description copied from interface:Validatable
Method that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier.- Specified by:
stopValidatingAgainst
in interfaceValidatable
- Returns:
- Validator instance created from the schema that was removed, if one was in use; null if no such schema in use.
- Throws:
javax.xml.stream.XMLStreamException
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws javax.xml.stream.XMLStreamException
Description copied from interface:Validatable
Method that can be called by application to stop validating output using specified validator. The validator passed should be an earlier return value for a call toValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.Note: the specified validator is compared for identity with validators in use, not for equality.
- Specified by:
stopValidatingAgainst
in interfaceValidatable
- Returns:
- Validator instance found (ie. argument
validator
) if it was being used for validating current document; null if not. - Throws:
javax.xml.stream.XMLStreamException
-
setValidationProblemHandler
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Description copied from interface:Validatable
Method that application can call to define a custom handler for validation problems encountered during validation process.- Specified by:
setValidationProblemHandler
in interfaceValidatable
- Parameters:
h
- Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used- Returns:
- Previously set validation problem handler, if any; null if none was set
-
_decoderFactory
protected ValueDecoderFactory _decoderFactory()
-
_base64Decoder
protected StringBase64Decoder _base64Decoder()
-
throwUnsupported
protected void throwUnsupported() throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
throwNotStartElem
protected void throwNotStartElem(int type)
-
throwNotStartElemOrTextual
protected void throwNotStartElemOrTextual(int type)
-
_constructTypeException
protected TypedXMLStreamException _constructTypeException(java.lang.IllegalArgumentException iae, java.lang.String lexicalValue)
Method called to wrap or convert given conversion-fail exception into a fullTypedXMLStreamException
,- Parameters:
iae
- Problem as reported by converterlexicalValue
- Lexical value (element content, attribute value) that could not be converted succesfully.
-
_constructTypeException
protected TypedXMLStreamException _constructTypeException(java.lang.String msg, java.lang.String lexicalValue)
-
-