org.codehaus.stax2.ri.dom
Class DOMWrappingReader

java.lang.Object
  extended by org.codehaus.stax2.ri.dom.DOMWrappingReader
All Implemented Interfaces:
javax.xml.namespace.NamespaceContext, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader, AttributeInfo, DTDInfo, LocationInfo, TypedXMLStreamReader, Validatable, XMLStreamReader2
Direct Known Subclasses:
WstxDOMWrappingReader

public abstract class DOMWrappingReader
extends java.lang.Object
implements XMLStreamReader2, AttributeInfo, DTDInfo, LocationInfo, javax.xml.namespace.NamespaceContext, javax.xml.stream.XMLStreamConstants

This is an adapter class that presents a DOM document as if it was a regular XMLStreamReader.

Note that the implementation is only to be used for use with javax.xml.transform.dom.DOMSource. It can however be used for both full documents, and single element root fragments, depending on what node is passed as the argument.

Some notes regarding missing/incomplete functionality:


Field Summary
protected static int ERR_STATE_NO_LOCALNAME
           
protected static int ERR_STATE_NOT_ELEM
          Current state not START_ELEMENT or END_ELEMENT, should be
protected static int ERR_STATE_NOT_PI
          Current state not PROCESSING_INSTRUCTION
protected static int ERR_STATE_NOT_START_ELEM
          Current state not START_ELEMENT, should be
protected static int ERR_STATE_NOT_TEXTUAL
          Current state not one where getText() can be used
protected static int ERR_STATE_NOT_TEXTUAL_XXX
          Current state not one where getTextXxx() can be used
protected  java.util.List mAttrList
          Lazily instantiated List of all actual attributes for the current (start) element, NOT including namespace declarations.
protected  java.lang.String mCoalescedText
          In coalescing mode, we may need to combine textual content from multiple adjacent nodes.
protected  boolean mCoalescing
          Whether stream reader is to coalesce adjacent textual (CHARACTERS, SPACE, CDATA) events (as per property XMLInputFactory.IS_COALESCING) or not
protected  int mCurrEvent
           
protected  org.w3c.dom.Node mCurrNode
          Current node is the DOM node that contains information regarding the current event.
protected  int mDepth
           
protected  boolean mNsAware
          Whether stream reader is to be namespace aware (as per property XMLInputFactory.IS_NAMESPACE_AWARE) or not
protected  java.util.List mNsDeclList
          Lazily instantiated String pairs of all namespace declarations for the current (start/end) element.
protected  org.w3c.dom.Node mRootNode
           
protected  java.lang.String mSystemId
           
protected  Stax2Util.TextBuffer mTextBuffer
          Helper object used for combining segments of text as needed
protected  ValueDecoder mValueDecoder
          ValueDecoder to use for decoding typed content; lazily instantiated/accessed if and when needed
 
Fields inherited from interface org.codehaus.stax2.XMLStreamReader2
FEATURE_DTD_OVERRIDE
 
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
 
Constructor Summary
protected DOMWrappingReader(javax.xml.transform.dom.DOMSource src, boolean nsAware, boolean coalescing)
           
 
Method Summary
 void close()
           Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader.
 void closeCompletely()
          Method similar to XMLStreamReader.getNamespaceContext(), except that this method also does close the underlying input source if it has not yet been closed.
protected  void coalesceText(int initialType)
           
protected  TypedXMLStreamException constructTypeException(java.lang.IllegalArgumentException iae, java.lang.String lexicalValue)
          Method called to wrap or convert given conversion-fail exception into a full TypedXMLStreamException,
 int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
           
protected  java.lang.String findErrorDesc(int errorType, int currEvent)
          Method used to locate error message description to use.
 boolean getAttributeAsBoolean(int index)
          Read an attribute value as a boolean.
 int getAttributeAsInt(int index)
          Read an attribute value as a boolean.
 long getAttributeAsLong(int index)
          Read an attribute value as a boolean.
 int getAttributeCount()
           
 int getAttributeIndex(java.lang.String namespaceURI, java.lang.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.
 java.lang.String getAttributeLocalName(int index)
           
 javax.xml.namespace.QName getAttributeName(int index)
           
 java.lang.String getAttributeNamespace(int index)
           
 java.lang.String getAttributePrefix(int index)
           
 java.lang.String getAttributeType(int index)
           
 java.lang.String getAttributeValue(int index)
           
 java.lang.String getAttributeValue(java.lang.String nsURI, java.lang.String localName)
           
 java.lang.String getCharacterEncodingScheme()
          As per Stax (1.0) specs, needs to return whatever xml declaration claimed encoding is, if any; or null if no xml declaration found.
 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()
          Since this class implements DTDInfo, method can just return this.
 java.lang.String getDTDInternalSubset()
           
 java.lang.String getDTDPublicId()
           
 java.lang.String getDTDRootName()
           
 java.lang.String getDTDSystemId()
           
 boolean getElementAsBoolean()
          Read an element content as a boolean.
 int getElementAsInt()
          [TODO] Same as TypedXMLStreamReader.getElementAsBoolean() replacing boolean by int.
 long getElementAsLong()
          [TODO] Same as TypedXMLStreamReader.getElementAsBoolean() replacing boolean by long.
 java.lang.String getElementText()
          From StAX specs: Reads the content of a text-only element, an exception is thrown if this is not a text-only element.
 java.lang.String getEncoding()
          As per Stax (1.0) specs, needs to return whatever parser determined the encoding was, if it was able to figure it out.
 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).
protected  javax.xml.stream.Location getErrorLocation()
           
 int getEventType()
          Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.
 java.lang.Object getFeature(java.lang.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.
 java.lang.String getLocalName()
           
 javax.xml.stream.Location getLocation()
           
 LocationInfo getLocationInfo()
          Location information is always accessible, for this reader.
 javax.xml.namespace.QName getName()
           
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 int getNamespaceCount()
           
 java.lang.String getNamespacePrefix(int index)
          Alas, DOM does not expose any of information necessary for determining actual declarations.
 java.lang.String getNamespaceURI()
           
 java.lang.String getNamespaceURI(int index)
           
 java.lang.String getNamespaceURI(java.lang.String prefix)
           
 javax.xml.namespace.NamespaceContext getNonTransientNamespaceContext()
          This method returns a namespace contenxt 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.
 java.lang.String getPIData()
           
 java.lang.String getPITarget()
           
 java.lang.String getPrefix()
           
 java.lang.String getPrefix(java.lang.String namespaceURI)
           
 java.lang.String getPrefixedName()
          This method returns "prefix-qualified" name of the current element.
 java.util.Iterator getPrefixes(java.lang.String namespaceURI)
           
 java.lang.Object getProcessedDTD()
           
 DTDValidationSchema getProcessedDTDSchema()
          Method similar to DTDInfo.getProcessedDTD(), but type-safe.
abstract  java.lang.Object getProperty(java.lang.String name)
           
 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).
 java.lang.String getText()
           
 int getText(java.io.Writer w, boolean preserveContents)
          Method similar to getText(), except that it just uses provided Writer to write all textual content.
 char[] getTextCharacters()
           
 int getTextCharacters(int sourceStart, char[] target, int targetStart, int len)
           
 int getTextLength()
           
 int getTextStart()
           
 java.lang.String getVersion()
           
 boolean hasName()
           
 boolean hasNext()
           
 boolean hasText()
           
 boolean isAttributeSpecified(int index)
           
 boolean isCharacters()
           
 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 isEndElement()
           
abstract  boolean isPropertySupported(java.lang.String name)
          Method similar to XMLInputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Reader instance.
 boolean isStandalone()
           
 boolean isStartElement()
           
 boolean isWhiteSpace()
           
 int next()
           
 int nextTag()
           
protected  void reportParseProblem(int errorType)
           
protected  void reportWrongState(int errorType)
           
 void require(int type, java.lang.String nsUri, java.lang.String localName)
           
 void setFeature(java.lang.String name, java.lang.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.
abstract  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 matching XMLInputFactory2 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.
 boolean standaloneSet()
           
 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 throwStreamException(java.lang.String msg)
           
protected abstract  void throwStreamException(java.lang.String msg, javax.xml.stream.Location loc)
           
 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).
protected  ValueDecoder valueDecoder()
          This method can be overridden by sub-classes, if an alternate value decoder instance should be used for handling conversions needed to implement Typed Access API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_STATE_NOT_START_ELEM

protected static final int ERR_STATE_NOT_START_ELEM
Current state not START_ELEMENT, should be

See Also:
Constant Field Values

ERR_STATE_NOT_ELEM

protected static final int ERR_STATE_NOT_ELEM
Current state not START_ELEMENT or END_ELEMENT, should be

See Also:
Constant Field Values

ERR_STATE_NOT_PI

protected static final int ERR_STATE_NOT_PI
Current state not PROCESSING_INSTRUCTION

See Also:
Constant Field Values

ERR_STATE_NOT_TEXTUAL

protected static final int ERR_STATE_NOT_TEXTUAL
Current state not one where getText() can be used

See Also:
Constant Field Values

ERR_STATE_NOT_TEXTUAL_XXX

protected static final int ERR_STATE_NOT_TEXTUAL_XXX
Current state not one where getTextXxx() can be used

See Also:
Constant Field Values

ERR_STATE_NO_LOCALNAME

protected static final int ERR_STATE_NO_LOCALNAME
See Also:
Constant Field Values

mSystemId

protected final java.lang.String mSystemId

mRootNode

protected final org.w3c.dom.Node mRootNode

mNsAware

protected final boolean mNsAware
Whether stream reader is to be namespace aware (as per property XMLInputFactory.IS_NAMESPACE_AWARE) or not


mCoalescing

protected final boolean mCoalescing
Whether stream reader is to coalesce adjacent textual (CHARACTERS, SPACE, CDATA) events (as per property XMLInputFactory.IS_COALESCING) or not


mCurrEvent

protected int mCurrEvent

mCurrNode

protected org.w3c.dom.Node mCurrNode
Current node is the DOM node that contains information regarding the current event.


mDepth

protected int mDepth

mCoalescedText

protected java.lang.String mCoalescedText
In coalescing mode, we may need to combine textual content from multiple adjacent nodes. Since we shouldn't be modifying the underlying DOM tree, need to accumulate it into a temporary variable


mTextBuffer

protected Stax2Util.TextBuffer mTextBuffer
Helper object used for combining segments of text as needed


mAttrList

protected java.util.List mAttrList
Lazily instantiated List of all actual attributes for the current (start) element, NOT including namespace declarations. As such, elements are Attr instances.


mNsDeclList

protected java.util.List mNsDeclList
Lazily instantiated String pairs of all namespace declarations for the current (start/end) element. String pair means that for each declarations there are two Strings in the list: first one is prefix (empty String for the default namespace declaration), and second URI it is bound to.


mValueDecoder

protected ValueDecoder mValueDecoder
ValueDecoder to use for decoding typed content; lazily instantiated/accessed if and when needed

Constructor Detail

DOMWrappingReader

protected DOMWrappingReader(javax.xml.transform.dom.DOMSource src,
                            boolean nsAware,
                            boolean coalescing)
                     throws javax.xml.stream.XMLStreamException
Parameters:
src - Node that is the tree of the DOM document, or fragment.
nsAware - Whether resulting reader should operate in namespace aware mode or not. Note that this should be compatible with settings for the DOM builder that produced DOM tree or fragment being operated on, otherwise results are not defined.
coalescing - Whether resulting reader should coalesce adjacent text events or not
Throws:
javax.xml.stream.XMLStreamException
Method Detail

throwStreamException

protected abstract void throwStreamException(java.lang.String msg,
                                             javax.xml.stream.Location loc)
                                      throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

getCharacterEncodingScheme

public java.lang.String getCharacterEncodingScheme()
As per Stax (1.0) specs, needs to return whatever xml declaration claimed encoding is, if any; or null if no xml declaration found.

Specified by:
getCharacterEncodingScheme in interface javax.xml.stream.XMLStreamReader

getEncoding

public java.lang.String getEncoding()
As per Stax (1.0) specs, needs to return whatever parser determined the encoding was, if it was able to figure it out. If not (there are cases where this can not be found; specifically when being passed a Reader), it should return null.

Specified by:
getEncoding in interface javax.xml.stream.XMLStreamReader

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface javax.xml.stream.XMLStreamReader

isStandalone

public boolean isStandalone()
Specified by:
isStandalone in interface javax.xml.stream.XMLStreamReader

standaloneSet

public boolean standaloneSet()
Specified by:
standaloneSet in interface javax.xml.stream.XMLStreamReader

getProperty

public abstract java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface javax.xml.stream.XMLStreamReader

isPropertySupported

public abstract boolean isPropertySupported(java.lang.String name)
Description copied from interface: XMLStreamReader2
Method similar to 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.

Specified by:
isPropertySupported in interface XMLStreamReader2

setProperty

public abstract 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 matching XMLInputFactory2 instance. Exactly which methods are mutable is implementation specific.

Specified by:
setProperty in interface XMLStreamReader2
Parameters:
name - Name of the property to set
value - Value to set property to.
Returns:
True, if the specified property was succesfully set to specified value; false if its value was not changed

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface javax.xml.stream.XMLStreamReader
Specified by:
getAttributeCount in interface AttributeInfo
Returns:
Number of all attributes accessible (including ones created from the default values, if any) using this Object.

getAttributeLocalName

public java.lang.String getAttributeLocalName(int index)
Specified by:
getAttributeLocalName in interface javax.xml.stream.XMLStreamReader

getAttributeName

public javax.xml.namespace.QName getAttributeName(int index)
Specified by:
getAttributeName in interface javax.xml.stream.XMLStreamReader

getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)
Specified by:
getAttributeNamespace in interface javax.xml.stream.XMLStreamReader

getAttributePrefix

public java.lang.String getAttributePrefix(int index)
Specified by:
getAttributePrefix in interface javax.xml.stream.XMLStreamReader

getAttributeType

public java.lang.String getAttributeType(int index)
Specified by:
getAttributeType in interface javax.xml.stream.XMLStreamReader

getAttributeValue

public java.lang.String getAttributeValue(int index)
Specified by:
getAttributeValue in interface javax.xml.stream.XMLStreamReader

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String nsURI,
                                          java.lang.String localName)
Specified by:
getAttributeValue in interface javax.xml.stream.XMLStreamReader

getElementText

public java.lang.String getElementText()
                                throws javax.xml.stream.XMLStreamException
From StAX specs:
Reads the content of a text-only element, an exception is thrown if this is not a text-only element. Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content.
Precondition: the current event is START_ELEMENT.
Postcondition: the current event is the corresponding END_ELEMENT.

Specified by:
getElementText in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

getEventType

public int getEventType()
Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.

Specified by:
getEventType in interface javax.xml.stream.XMLStreamReader

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface javax.xml.stream.XMLStreamReader

getName

public javax.xml.namespace.QName getName()
Specified by:
getName in interface javax.xml.stream.XMLStreamReader

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface javax.xml.stream.XMLStreamReader

getNamespaceCount

public int getNamespaceCount()
Specified by:
getNamespaceCount in interface javax.xml.stream.XMLStreamReader

getNamespacePrefix

public java.lang.String getNamespacePrefix(int index)
Alas, DOM does not expose any of information necessary for determining actual declarations. Thus, have to indicate that there are no declarations.

Specified by:
getNamespacePrefix in interface javax.xml.stream.XMLStreamReader

getNamespaceURI

public java.lang.String getNamespaceURI()
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getNamespaceURI

public java.lang.String getNamespaceURI(int index)
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getPIData

public java.lang.String getPIData()
Specified by:
getPIData in interface javax.xml.stream.XMLStreamReader

getPITarget

public java.lang.String getPITarget()
Specified by:
getPITarget in interface javax.xml.stream.XMLStreamReader

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface javax.xml.stream.XMLStreamReader

getText

public java.lang.String getText()
Specified by:
getText in interface javax.xml.stream.XMLStreamReader

getTextCharacters

public char[] getTextCharacters()
Specified by:
getTextCharacters in interface javax.xml.stream.XMLStreamReader

getTextCharacters

public int getTextCharacters(int sourceStart,
                             char[] target,
                             int targetStart,
                             int len)
Specified by:
getTextCharacters in interface javax.xml.stream.XMLStreamReader

getTextLength

public int getTextLength()
Specified by:
getTextLength in interface javax.xml.stream.XMLStreamReader

getTextStart

public int getTextStart()
Specified by:
getTextStart in interface javax.xml.stream.XMLStreamReader

hasName

public boolean hasName()
Specified by:
hasName in interface javax.xml.stream.XMLStreamReader

hasNext

public boolean hasNext()
Specified by:
hasNext in interface javax.xml.stream.XMLStreamReader

hasText

public boolean hasText()
Specified by:
hasText in interface javax.xml.stream.XMLStreamReader

isAttributeSpecified

public boolean isAttributeSpecified(int index)
Specified by:
isAttributeSpecified in interface javax.xml.stream.XMLStreamReader

isCharacters

public boolean isCharacters()
Specified by:
isCharacters in interface javax.xml.stream.XMLStreamReader

isEndElement

public boolean isEndElement()
Specified by:
isEndElement in interface javax.xml.stream.XMLStreamReader

isStartElement

public boolean isStartElement()
Specified by:
isStartElement in interface javax.xml.stream.XMLStreamReader

isWhiteSpace

public boolean isWhiteSpace()
Specified by:
isWhiteSpace in interface javax.xml.stream.XMLStreamReader

require

public void require(int type,
                    java.lang.String nsUri,
                    java.lang.String localName)
             throws javax.xml.stream.XMLStreamException
Specified by:
require in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

next

public int next()
         throws javax.xml.stream.XMLStreamException
Specified by:
next in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

nextTag

public int nextTag()
            throws javax.xml.stream.XMLStreamException
Specified by:
nextTag in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

close

public void close()
           throws javax.xml.stream.XMLStreamException

Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader. That is, unless the new StAX2 property XMLInputFactory2.P_AUTO_CLOSE_INPUT is set to true.

Specified by:
close in interface javax.xml.stream.XMLStreamReader
Throws:
javax.xml.stream.XMLStreamException

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext
Specified by:
getNamespaceURI in interface javax.xml.stream.XMLStreamReader

getPrefix

public java.lang.String getPrefix(java.lang.String namespaceURI)
Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext

getPrefixes

public java.util.Iterator getPrefixes(java.lang.String namespaceURI)
Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext

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, regardless of whether an exception is thrown or not.

Specified by:
getElementAsBoolean in interface TypedXMLStreamReader
Throws:
javax.xml.stream.XMLStreamException - If unable to access content
TypedXMLStreamException - 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

[TODO] Same as TypedXMLStreamReader.getElementAsBoolean() replacing boolean by int.

Specified by:
getElementAsInt in interface TypedXMLStreamReader
Throws:
javax.xml.stream.XMLStreamException - If unable to access content
TypedXMLStreamException - If unable to convert the resulting character sequence into a 32-bit integer value

getElementAsLong

public long getElementAsLong()
                      throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamReader

[TODO] Same as TypedXMLStreamReader.getElementAsBoolean() replacing boolean by long.

Specified by:
getElementAsLong in interface TypedXMLStreamReader
Throws:
javax.xml.stream.XMLStreamException - If unable to access content
TypedXMLStreamException - If unable to convert the resulting character sequence into a 64-bit integer value

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 is localName and URI is namespaceURI or -1 if no such attribute exists.

Specified by:
getAttributeIndex in interface TypedXMLStreamReader
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 interface TypedXMLStreamReader
Parameters:
index - The attribute's index as returned by TypedXMLStreamReader.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 interface TypedXMLStreamReader
Parameters:
index - The attribute's index as returned by TypedXMLStreamReader.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 interface TypedXMLStreamReader
Parameters:
index - The attribute's index as returned by TypedXMLStreamReader.getAttributeIndex(String, String)
Throws:
javax.xml.stream.XMLStreamException - If unable to convert the resulting character sequence into an XML Schema boolean value.

getFeature

public java.lang.Object getFeature(java.lang.String name)
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 interface XMLStreamReader2
Parameters:
name - Name of the feature of which value to get
Returns:
Value of the feature (possibly null), if supported; null otherwise

setFeature

public void setFeature(java.lang.String name,
                       java.lang.Object value)
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 interface XMLStreamReader2
Parameters:
name - Name of the feature to set
value - Value to set feature to.

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 otherwise 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.

Specified by:
skipElement in interface XMLStreamReader2
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, a IllegalStateException will be thrown.

Specified by:
getAttributeInfo in interface XMLStreamReader2
Throws:
javax.xml.stream.XMLStreamException

findAttributeIndex

public int findAttributeIndex(java.lang.String nsURI,
                              java.lang.String localName)
Specified by:
findAttributeIndex in interface AttributeInfo
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 interface AttributeInfo
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 interface AttributeInfo
Returns:
Index of the NOTATION attribute of current element, if the current element has such an attribute defined; -1 if not.

getDTDInfo

public DTDInfo getDTDInfo()
                   throws javax.xml.stream.XMLStreamException
Since this class implements DTDInfo, method can just return this.

Specified by:
getDTDInfo in interface XMLStreamReader2
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 interface XMLStreamReader2

getText

public int getText(java.io.Writer w,
                   boolean preserveContents)
            throws java.io.IOException,
                   javax.xml.stream.XMLStreamException
Method similar to getText(), except that it just uses provided Writer to write all textual content. For further optimization, it may also be allowed to do true pass-through, thus possibly avoiding one temporary copy of the data.

TODO: try to optimize to allow completely streaming pass-through: currently will still read all data in memory buffers before outputting

Specified by:
getText in interface XMLStreamReader2
Parameters:
w - Writer to use for writing textual contents
preserveContents - 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.
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 interface XMLStreamReader2
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
Description copied from interface: XMLStreamReader2
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.

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.

Specified by:
isEmptyElement in interface XMLStreamReader2
Returns:
True, if cursor points to a start or end element that is constructed from 'empty' element (ends with '/>'); false otherwise.
Throws:
javax.xml.stream.XMLStreamException

getNonTransientNamespaceContext

public javax.xml.namespace.NamespaceContext getNonTransientNamespaceContext()
Description copied from interface: XMLStreamReader2
This method returns a namespace contenxt object that contains information identical to that returned by 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.

Specified by:
getNonTransientNamespaceContext in interface XMLStreamReader2
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 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.

Specified by:
getPrefixedName in interface XMLStreamReader2
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 to XMLStreamReader.getNamespaceContext(), 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).

Specified by:
closeCompletely in interface XMLStreamReader2
Throws:
javax.xml.stream.XMLStreamException

getProcessedDTD

public java.lang.Object getProcessedDTD()
Specified by:
getProcessedDTD in interface DTDInfo
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 interface DTDInfo
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 interface DTDInfo
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 interface DTDInfo
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 interface DTDInfo
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 to 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).

Specified by:
getProcessedDTDSchema in interface DTDInfo

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 interface LocationInfo
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 interface LocationInfo
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 interface LocationInfo
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 excep