public interface XMLStreamReader2 extends TypedXMLStreamReader, Validatable
XMLStreamReader
.
It also adds limited number of methods that are important for
efficient pass-through processing (such as one needed when routing
SOAP-messages).
The features supported via setFeature(java.lang.String, java.lang.Object)
are:
Since version 3.0, stream writer will also implement "Typed Access API" on output side.
Modifier and Type | Field and Description |
---|---|
static String |
FEATURE_DTD_OVERRIDE
Deprecated.
Use
XMLInputFactory2.P_DTD_OVERRIDE instead. |
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Modifier and Type | Method and Description |
---|---|
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. |
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.
|
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.
|
Object |
getFeature(String name)
Deprecated.
Should use
XMLStreamReader.getProperty(java.lang.String) instead |
LocationInfo |
getLocationInfo() |
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. |
String |
getPrefixedName()
This method returns "prefix-qualified" name of the current
element.
|
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. |
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. |
void |
setFeature(String name,
Object value)
Deprecated.
Should use
setProperty(java.lang.String, java.lang.Object) instead |
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. |
void |
skipElement()
Method that will skip all the contents of the element that the
stream currently points to.
|
getAttributeAs, getAttributeAsArray, getAttributeAsBinary, getAttributeAsBinary, getAttributeAsBoolean, getAttributeAsDecimal, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsFloatArray, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLongArray, getAttributeAsQName, getAttributeIndex, getElementAs, getElementAsBinary, getElementAsBinary, getElementAsBoolean, getElementAsDecimal, getElementAsDouble, getElementAsFloat, getElementAsInt, getElementAsInteger, getElementAsLong, getElementAsQName, readElementAsArray, readElementAsBinary, readElementAsBinary, readElementAsDoubleArray, readElementAsFloatArray, readElementAsIntArray, readElementAsLongArray
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
setValidationProblemHandler, stopValidatingAgainst, stopValidatingAgainst, validateAgainst
static final String FEATURE_DTD_OVERRIDE
XMLInputFactory2.P_DTD_OVERRIDE
instead.boolean isPropertySupported(String name)
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.boolean setProperty(String name, Object value)
XMLInputFactory2
instance. Exactly which methods are mutable is implementation
specific.name
- Name of the property to setvalue
- Value to set property to.InvalidArgumentException
- if the property is not supported
(or recognized) by the stream reader implementationObject getFeature(String name)
XMLStreamReader.getProperty(java.lang.String)
instead
Note: although some feature names are shared with
setFeature(java.lang.String, java.lang.Object)
, not all are: some features are read-only,
some write-only
name
- Name of the feature of which value to getvoid setFeature(String name, Object value)
setProperty(java.lang.String, java.lang.Object)
instead
Note: although some feature names are shared with
getFeature(java.lang.String)
, not all are: some features are read-only,
some write-only
name
- Name of the feature to setvalue
- Value to set feature to.void skipElement() throws XMLStreamException
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.XMLStreamException
DTDInfo getDTDInfo() throws XMLStreamException
XMLStreamException
AttributeInfo getAttributeInfo() throws XMLStreamException
IllegalStateException
will be thrown.XMLStreamException
LocationInfo getLocationInfo()
int getText(Writer w, boolean preserveContents) throws IOException, XMLStreamException
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()
.
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
boolean isEmptyElement() throws XMLStreamException
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.
XMLStreamException
int getDepth()
NamespaceContext getNonTransientNamespaceContext()
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.String getPrefixedName()
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.
void closeCompletely() throws XMLStreamException
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).XMLStreamException
Copyright © 2015 fasterxml.com. All Rights Reserved.