public abstract class Stax2ReaderImpl extends Object implements XMLStreamReader2, AttributeInfo, DTDInfo, LocationInfo
XMLStreamReader2
,
the extended stream reader that is part of Stax2.Modifier and Type | Field and Description |
---|---|
protected ValueDecoderFactory |
_decoderFactory
Factory used for constructing decoders we need for typed access
|
FEATURE_DTD_OVERRIDE
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Modifier | Constructor and Description |
---|---|
protected |
Stax2ReaderImpl() |
Modifier and Type | Method and Description |
---|---|
protected TypedXMLStreamException |
_constructTypeException(IllegalArgumentException iae,
String lexicalValue) |
protected ValueDecoderFactory |
_decoderFactory() |
void |
closeCompletely()
Method similar to
XMLStreamReader.close() ,
except that this method also does close the underlying input
source if it has not yet been closed. |
int |
findAttributeIndex(String nsURI,
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.
|
abstract int |
getAttributeAsArray(int index,
TypedArrayDecoder tad)
Actual implementation needs to implement tokenization.
|
abstract byte[] |
getAttributeAsBinary(Base64Variant v,
int index) |
byte[] |
getAttributeAsBinary(int index)
Read an attribute value as a byte array.
|
boolean |
getAttributeAsBoolean(int index)
Read an attribute value as a boolean.
|
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.
|
BigInteger |
getAttributeAsInteger(int index) |
long |
getAttributeAsLong(int index)
Read an attribute value as a boolean.
|
long[] |
getAttributeAsLongArray(int index) |
QName |
getAttributeAsQName(int index) |
abstract int |
getAttributeIndex(String namespaceURI,
String localName)
Returns the index of the attribute whose local name is
localName and URI is namespaceURI
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.
|
abstract XMLStreamLocation2 |
getCurrentLocation()
A method that returns the current location of the stream reader
at the input source.
|
abstract 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.
|
String |
getDTDInternalSubset() |
String |
getDTDPublicId() |
String |
getDTDRootName() |
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 of
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant) , in cases where neither performance nor
memory usage is a big concern. |
abstract byte[] |
getElementAsBinary(Base64Variant v)
Convenience method that can be used similar to read binary content
instead of
TypedXMLStreamReader.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.
|
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.
|
BigInteger |
getElementAsInteger() |
long |
getElementAsLong()
Read an element content as a 64-bit integer.
|
QName |
getElementAsQName() |
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.
|
abstract 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).
|
Object |
getFeature(String name)
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.
|
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.
|
abstract NamespaceContext |
getNonTransientNamespaceContext()
This method returns a namespace context object that contains
information identical to that returned by
XMLStreamReader.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.
|
String |
getPrefixedName()
This method returns "prefix-qualified" name of the current
element.
|
Object |
getProcessedDTD() |
DTDValidationSchema |
getProcessedDTDSchema()
Method similar to
DTDInfo.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.
|
abstract 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(Writer w,
boolean preserveContents)
Method similar to
XMLStreamReader.getText() , except
that it just uses provided Writer to write all textual content,
and that it works for wider range of event types. |
abstract boolean |
isEmptyElement()
Method that can be used to check whether current START_ELEMENT
event was created for an empty element (xml short-hand notation
where one tag implies start and end, ending with "/>"), or not.
|
boolean |
isPropertySupported(String name)
Method similar to
XMLInputFactory.isPropertySupported(java.lang.String) , used
to determine whether a property is supported by the Reader
instance. |
abstract int |
readElementAsArray(TypedArrayDecoder dec)
Actual implementation needs to implement tokenization and state
keeping.
|
abstract int |
readElementAsBinary(Base64Variant b64variant,
byte[] resultBuffer,
int offset,
int maxLength) |
int |
readElementAsBinary(byte[] resultBuffer,
int offset,
int maxLength) |
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(String name,
Object value)
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.
|
boolean |
setProperty(String name,
Object value)
Method that can be used to set per-reader properties; a subset of
properties one can set via matching
XMLInputFactory2
instance. |
abstract 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 which
Validatable.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() |
protected void |
throwUnsupported() |
XMLValidator |
validateAgainst(XMLValidationSchema schema)
Method that will construct a
XMLValidator 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 to
Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttributeAsBinary, readElementAsBinary
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, 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, next, nextTag, require, standaloneSet
getAttributeCount
getLocation
protected ValueDecoderFactory _decoderFactory
public Object getFeature(String name)
XMLStreamReader2
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
getFeature
in interface XMLStreamReader2
name
- Name of the feature of which value to getpublic void setFeature(String name, Object value)
XMLStreamReader2
Note: although some feature names are shared with
XMLStreamReader2.getFeature(java.lang.String)
, not all are: some features are read-only,
some write-only
setFeature
in interface XMLStreamReader2
name
- Name of the feature to setvalue
- Value to set feature to.public boolean isPropertySupported(String name)
XMLStreamReader2
XMLInputFactory.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.isPropertySupported
in interface XMLStreamReader2
public boolean setProperty(String name, Object value)
XMLStreamReader2
XMLInputFactory2
instance. Exactly which methods are mutable is implementation
specific.setProperty
in interface XMLStreamReader2
name
- Name of the property to setvalue
- Value to set property to.public void skipElement() throws XMLStreamException
XMLStreamReader2
IllegalStateException
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.skipElement
in interface XMLStreamReader2
XMLStreamException
public AttributeInfo getAttributeInfo() throws XMLStreamException
XMLStreamReader2
IllegalStateException
will be thrown.getAttributeInfo
in interface XMLStreamReader2
XMLStreamException
public DTDInfo getDTDInfo() throws XMLStreamException
XMLStreamReader2
getDTDInfo
in interface XMLStreamReader2
XMLStreamException
public final LocationInfo getLocationInfo()
getLocationInfo
in interface XMLStreamReader2
public int getText(Writer w, boolean preserveContents) throws IOException, XMLStreamException
XMLStreamReader2
XMLStreamReader.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 with XMLStreamReader.getText()
.
getText
in interface XMLStreamReader2
w
- Writer to use for writing textual contentspreserveContents
- If true, reader has to preserve contents
so that further calls to getText
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 to getText
is not guaranteed to
return meaningful data.IOException
XMLStreamException
public abstract int getDepth()
XMLStreamReader2
getDepth
in interface XMLStreamReader2
public abstract boolean isEmptyElement() throws XMLStreamException
XMLStreamReader2
Note: method may need to read more data to know if the element
is an empty one, and as such may throw an i/o or parsing exception
(as XMLStreamException
); however, it won't throw exceptions
for non-START_ELEMENT event types.
isEmptyElement
in interface XMLStreamReader2
XMLStreamException
public abstract NamespaceContext getNonTransientNamespaceContext()
XMLStreamReader2
XMLStreamReader.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.getNonTransientNamespaceContext
in interface XMLStreamReader2
public String getPrefixedName()
XMLStreamReader2
Note: implementations are encouraged to provide an implementation
that would be more efficient than calling getLocalName
and getPrefix
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.
getPrefixedName
in interface XMLStreamReader2
public void closeCompletely() throws XMLStreamException
XMLStreamReader2
XMLStreamReader.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
a File
or URL
for factory
method) it has to be called as the application does not have
access to the actually input source (InputStream
opened from a URL
and so on).closeCompletely
in interface XMLStreamReader2
XMLStreamException
public int findAttributeIndex(String nsURI, String localName)
findAttributeIndex
in interface AttributeInfo
public int getIdAttributeIndex()
AttributeInfo
getIdAttributeIndex
in interface AttributeInfo
public int getNotationAttributeIndex()
AttributeInfo
getNotationAttributeIndex
in interface AttributeInfo
public Object getProcessedDTD()
getProcessedDTD
in interface DTDInfo
public String getDTDRootName()
getDTDRootName
in interface DTDInfo
public String getDTDPublicId()
getDTDPublicId
in interface DTDInfo
public String getDTDSystemId()
getDTDSystemId
in interface DTDInfo
public String getDTDInternalSubset()
getDTDInternalSubset
in interface DTDInfo
public DTDValidationSchema getProcessedDTDSchema()
DTDInfo
DTDInfo.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).getProcessedDTDSchema
in interface DTDInfo
public long getStartingByteOffset()
LocationInfo
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).
getStartingByteOffset
in interface LocationInfo
public long getStartingCharOffset()
LocationInfo
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).
getStartingCharOffset
in interface LocationInfo
public long getEndingByteOffset() throws XMLStreamException
LocationInfo
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.
getEndingByteOffset
in interface LocationInfo
XMLStreamException
public long getEndingCharOffset() throws XMLStreamException
LocationInfo
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.
getEndingCharOffset
in interface LocationInfo
XMLStreamException
public abstract XMLStreamLocation2 getStartLocation()
LocationInfo
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()
).
getStartLocation
in interface LocationInfo
public abstract XMLStreamLocation2 getCurrentLocation()
LocationInfo
Since this location information should always be accessible, no further parsing is to be done, and no exceptions can be thrown.
getCurrentLocation
in interface LocationInfo
public abstract XMLStreamLocation2 getEndLocation() throws XMLStreamException
LocationInfo
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.
getEndLocation
in interface LocationInfo
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 thrownpublic XMLValidator validateAgainst(XMLValidationSchema schema) throws XMLStreamException
Validatable
XMLValidator
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 to
Validatable.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.
validateAgainst
in interface Validatable
XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier.stopValidatingAgainst
in interface Validatable
XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.
Note: the specified validator is compared for identity with validators in use, not for equality.
stopValidatingAgainst
in interface Validatable
validator
)
if it was being used for validating current document; null if not.XMLStreamException
public abstract ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Validatable
setValidationProblemHandler
in interface Validatable
h
- Handler to install, if non null; if null, indicates that
the default (implementation-specific) handling should be usedpublic boolean getElementAsBoolean() throws XMLStreamException
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:
getElementAsBoolean
in interface TypedXMLStreamReader
XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public int getElementAsInt() throws XMLStreamException
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:
getElementAsInt
in interface TypedXMLStreamReader
XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting
character sequence into a Java (32-bit) integer.public long getElementAsLong() throws XMLStreamException
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:
getElementAsLong
in interface TypedXMLStreamReader
XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting
character sequence into a Java (64-bit) integer.public float getElementAsFloat() throws XMLStreamException
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:
getElementAsFloat
in interface TypedXMLStreamReader
XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting
character sequence into a Java floatpublic double getElementAsDouble() throws XMLStreamException
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:
getElementAsDouble
in interface TypedXMLStreamReader
XMLStreamException
- If unable to access contentTypedXMLStreamException
- If unable to convert the resulting
character sequence into a Java doublepublic BigInteger getElementAsInteger() throws XMLStreamException
getElementAsInteger
in interface TypedXMLStreamReader
XMLStreamException
public BigDecimal getElementAsDecimal() throws XMLStreamException
getElementAsDecimal
in interface TypedXMLStreamReader
XMLStreamException
public QName getElementAsQName() throws XMLStreamException
getElementAsQName
in interface TypedXMLStreamReader
XMLStreamException
public byte[] getElementAsBinary() throws XMLStreamException
TypedXMLStreamReader
TypedXMLStreamReader.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
.
getElementAsBinary
in interface TypedXMLStreamReader
XMLStreamException
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
public abstract byte[] getElementAsBinary(Base64Variant v) throws XMLStreamException
TypedXMLStreamReader
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
, in cases where neither performance nor
memory usage is a big concern.getElementAsBinary
in interface TypedXMLStreamReader
v
- Base64 variant content is in; needed to decode
alternative variants ("modified base64")XMLStreamException
TypedXMLStreamReader.readElementAsBinary(byte[], int, int, org.codehaus.stax2.typed.Base64Variant)
public void getElementAs(TypedValueDecoder tvd) throws XMLStreamException
TypedXMLStreamReader
XMLStreamReader.getElementText()
,
and then call one of decode methods defined in
TypedValueDecoder
. 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:
Note that caller has to know more specific type of decoder, since the base interface does not specify methods for accessing actual decoded value.
getElementAs
in interface TypedXMLStreamReader
XMLStreamException
public int readElementAsIntArray(int[] value, int from, int length) throws XMLStreamException
TypedXMLStreamReader
<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 the
intArray
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 the intArray
data
type.
These are the pre and post conditions of calling this method:
readElementAsIntArray
in interface TypedXMLStreamReader
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 an IllegalArgumentException
is thrownlength
, but
at least one if any ints found. If not, -1 is returned
to signal end of ints to parse.XMLStreamException
public int readElementAsLongArray(long[] value, int from, int length) throws XMLStreamException
readElementAsLongArray
in interface TypedXMLStreamReader
XMLStreamException
public int readElementAsFloatArray(float[] value, int from, int length) throws XMLStreamException
readElementAsFloatArray
in interface TypedXMLStreamReader
XMLStreamException
public int readElementAsDoubleArray(double[] value, int from, int length) throws XMLStreamException
readElementAsDoubleArray
in interface TypedXMLStreamReader
XMLStreamException
public abstract int readElementAsArray(TypedArrayDecoder dec) throws XMLStreamException
!!! TODO: should be possible to implement completely
readElementAsArray
in interface TypedXMLStreamReader
XMLStreamException
public int readElementAsBinary(byte[] resultBuffer, int offset, int maxLength) throws XMLStreamException
readElementAsBinary
in interface TypedXMLStreamReader
XMLStreamException
public abstract int readElementAsBinary(Base64Variant b64variant, byte[] resultBuffer, int offset, int maxLength) throws XMLStreamException
XMLStreamException
public abstract int getAttributeIndex(String namespaceURI, String localName)
TypedXMLStreamReader
localName
and URI is namespaceURI
or -1
if no such attribute exists.getAttributeIndex
in interface TypedXMLStreamReader
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.-1
if no
such attribute exists.public boolean getAttributeAsBoolean(int index) throws XMLStreamException
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.
getAttributeAsBoolean
in interface TypedXMLStreamReader
index
- The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
XMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public int getAttributeAsInt(int index) throws XMLStreamException
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.
getAttributeAsInt
in interface TypedXMLStreamReader
index
- The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
XMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public long getAttributeAsLong(int index) throws XMLStreamException
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.
getAttributeAsLong
in interface TypedXMLStreamReader
index
- The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
XMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public float getAttributeAsFloat(int index) throws XMLStreamException
getAttributeAsFloat
in interface TypedXMLStreamReader
XMLStreamException
public double getAttributeAsDouble(int index) throws XMLStreamException
getAttributeAsDouble
in interface TypedXMLStreamReader
XMLStreamException
public BigInteger getAttributeAsInteger(int index) throws XMLStreamException
getAttributeAsInteger
in interface TypedXMLStreamReader
XMLStreamException
public BigDecimal getAttributeAsDecimal(int index) throws XMLStreamException
getAttributeAsDecimal
in interface TypedXMLStreamReader
XMLStreamException
public QName getAttributeAsQName(int index) throws XMLStreamException
getAttributeAsQName
in interface TypedXMLStreamReader
XMLStreamException
public void getAttributeAs(int index, TypedValueDecoder tvd) throws XMLStreamException
TypedXMLStreamReader
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.
getAttributeAs
in interface TypedXMLStreamReader
XMLStreamException
public int[] getAttributeAsIntArray(int index) throws XMLStreamException
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 the
intArray
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 the intArray
data
type.getAttributeAsIntArray
in interface TypedXMLStreamReader
index
- The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
.XMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public long[] getAttributeAsLongArray(int index) throws XMLStreamException
getAttributeAsLongArray
in interface TypedXMLStreamReader
XMLStreamException
public float[] getAttributeAsFloatArray(int index) throws XMLStreamException
getAttributeAsFloatArray
in interface TypedXMLStreamReader
XMLStreamException
public double[] getAttributeAsDoubleArray(int index) throws XMLStreamException
getAttributeAsDoubleArray
in interface TypedXMLStreamReader
XMLStreamException
public abstract int getAttributeAsArray(int index, TypedArrayDecoder tad) throws XMLStreamException
!!! TODO: should be possible to implement completely
getAttributeAsArray
in interface TypedXMLStreamReader
XMLStreamException
public byte[] getAttributeAsBinary(int index) throws XMLStreamException
TypedXMLStreamReader
getAttributeAsBinary
in interface TypedXMLStreamReader
index
- The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
.XMLStreamException
- If unable to convert the resulting
character sequence into an XML Schema boolean value.public abstract byte[] getAttributeAsBinary(Base64Variant v, int index) throws XMLStreamException
XMLStreamException
protected ValueDecoderFactory _decoderFactory()
protected TypedXMLStreamException _constructTypeException(IllegalArgumentException iae, String lexicalValue)
protected void throwUnsupported() throws XMLStreamException
XMLStreamException
protected void throwNotStartElem()
Copyright © 2015 fasterxml.com. All Rights Reserved.