Top Description Inners Fields Constructors Methods
org.jdom2.output.support

public abstract Class AbstractStAXStreamReader

extends AbstractOutputProcessor
implements XMLStreamReader
Class Inheritance
All Implemented Interfaces
javax.xml.stream.XMLStreamReader, javax.xml.stream.XMLStreamConstants
Known Direct Subclasses
org.jdom2.output.support.AbstractStAXStreamReaderProcessor.DefaultXMLStreamReader
Imports
java.util.Iterator, .NoSuchElementException, javax.xml.XMLConstants, javax.xml.namespace.NamespaceContext, .QName, javax.xml.stream.Location, .XMLInputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, org.jdom2.Attribute, .Content, .DocType, .Document, .Element, .EntityRef, .Namespace, .ProcessingInstruction, .Verifier, org.jdom2.internal.ArrayCopy, org.jdom2.output.Format, .StAXStreamOutputter, .StAXStreamReader, .XMLOutputter, .Format.TextMode, org.jdom2.util.JDOMNamespaceContext, .NamespaceStack

An XMLStreamReader implementation that reads the XML document out of a JDOM Document. This class is marked as abstract even though it is a full implementation of the XMLReader. This class can be overridden if needed. If you extend this class, you will need to also extend AbstractStAXStreamReaderProcessor and supply an instance of that customised class to the StAXStreamReader class.

The reader reads XML Events by walking the JDOM tree, reporting all XML stream events as it encounters them in the JDOM.

This class is the inverse of the class StAXStreamOutputter in the sense that this class is read from (it's an XMLStreamReader implementation) by interpreting a JDOM Document whereas the StAXStreamOutputter interprets a JDOM Document and writes to a user-supplied XMLStreamWriter. It is the difference between a 'pull' concept and a 'push' concept.

Authors
gordon burgett https://github.com/gburgett, Rolf Lear
Since
JDOM 2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private String
private String
private String
private String
private String
private String
private int
private int
private Document
private Element[]
private final FormatStack
private final NamespaceStack
private Walker[]

Constructor Summary

AccessConstructor and Description
public
AbstractStAXStreamReader(Document
the document to output.
document
,
Format
The output format to use.
format
)

Create a new AbstractStAXStreamReader that outputs a JDOM Document as an XMLStream.

public
AbstractStAXStreamReader(Document
the document to output.
document
)

Create a new AbstractStAXStreamReader that outputs a JDOM Document as an XMLStream using the Format.getRawFormat() format.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.xml.stream.XMLStreamReader.close.

Frees any resources associated with this Reader.
public int
getAttributeCount()

Implements javax.xml.stream.XMLStreamReader.getAttributeCount.

Returns the count of attributes on this START_ELEMENT, this method is only valid on a START_ELEMENT or ATTRIBUTE.
public String
getAttributeLocalName(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributeLocalName.

Returns the localName of the attribute at the provided index
public QName
getAttributeName(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributeName.

Returns the qname of the attribute at the provided index
public String
getAttributeNamespace(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributeNamespace.

Returns the namespace of the attribute at the provided index
public String
getAttributePrefix(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributePrefix.

Returns the prefix of this attribute at the provided index
public String
getAttributeType(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributeType.

Returns the XML type of the attribute at the provided index
public String
getAttributeValue(String
the namespace of the attribute
namespaceURI
,
String
the local name of the attribute, cannot be null
localName
)

Implements javax.xml.stream.XMLStreamReader.getAttributeValue.

Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality
public String
getAttributeValue(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.getAttributeValue.

Returns the value of the attribute at the index
public String
getCharacterEncodingScheme()

Implements javax.xml.stream.XMLStreamReader.getCharacterEncodingScheme.

Returns the character encoding declared on the xml declaration Returns null if none was declared
public String
getElementText()

Implements javax.xml.stream.XMLStreamReader.getElementText.

Reads the content of a text-only element, an exception is thrown if this is not a text-only element.
public String
getEncoding()

Implements javax.xml.stream.XMLStreamReader.getEncoding.

Return input encoding if known or null if unknown.
public int
getEventType()

Implements javax.xml.stream.XMLStreamReader.getEventType.

Returns an integer code that indicates the type of the event the cursor is pointing to.
public String
getLocalName()

Implements javax.xml.stream.XMLStreamReader.getLocalName.

Returns the (local) name of the current event.
public Location
getLocation()

Implements javax.xml.stream.XMLStreamReader.getLocation.

Return the current location of the processor.
public QName
getName()

Implements javax.xml.stream.XMLStreamReader.getName.

Returns a QName for the current START_ELEMENT or END_ELEMENT event
private final Namespace
public NamespaceContext
getNamespaceContext()

Implements javax.xml.stream.XMLStreamReader.getNamespaceContext.

Returns a read only namespace context for the current position.
public int
getNamespaceCount()

Implements javax.xml.stream.XMLStreamReader.getNamespaceCount.

Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT, this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE.
public String
getNamespacePrefix(int
the position of the namespace declaration
index
)

Implements javax.xml.stream.XMLStreamReader.getNamespacePrefix.

Returns the prefix for the namespace declared at the index.
public String
getNamespaceURI()

Implements javax.xml.stream.XMLStreamReader.getNamespaceURI.

If the current event is a START_ELEMENT or END_ELEMENT this method returns the URI of the prefix or the default namespace.
public String
getNamespaceURI(String
The prefix to lookup, may not be null
prefix
)

Implements javax.xml.stream.XMLStreamReader.getNamespaceURI.

Return the uri for the given prefix.
public String
getNamespaceURI(int
the position of the namespace declaration
index
)

Implements javax.xml.stream.XMLStreamReader.getNamespaceURI.

Returns the uri for the namespace declared at the index.
public String
getPIData()

Implements javax.xml.stream.XMLStreamReader.getPIData.

Get the data section of a processing instruction
public String
getPITarget()

Implements javax.xml.stream.XMLStreamReader.getPITarget.

Get the target of a processing instruction
public String
getPrefix()

Implements javax.xml.stream.XMLStreamReader.getPrefix.

Returns the prefix of the current event or null if the event does not have a prefix
public Object
getProperty(final String
The name of the property, may not be null
name
)

Implements javax.xml.stream.XMLStreamReader.getProperty.

Get the value of a feature/property from the underlying implementation
public String
getText()

Implements javax.xml.stream.XMLStreamReader.getText.

Returns the current value of the parse event as a string, this returns the string value of a CHARACTERS event, returns the value of a COMMENT, the replacement value for an ENTITY_REFERENCE, the string value of a CDATA section, the string value for a SPACE event, or the String value of the internal subset of the DTD.
public char[]
getTextCharacters()

Implements javax.xml.stream.XMLStreamReader.getTextCharacters.

Returns an array which contains the characters from this event.
public int
getTextCharacters(int
the index of the first character in the source array to copy
sourceStart
,
char[]
the destination array
target
,
int
the start offset in the target array
targetStart
,
int
the number of characters to copy
length
)

Implements javax.xml.stream.XMLStreamReader.getTextCharacters.

Gets the text associated with a CHARACTERS, SPACE or CDATA event.
public int
getTextLength()

Implements javax.xml.stream.XMLStreamReader.getTextLength.

Returns the length of the sequence of characters for this Text event within the text character array.
public int
getTextStart()

Implements javax.xml.stream.XMLStreamReader.getTextStart.

Returns the offset into the text character array where the first character (of this text event) is stored.
public String
getVersion()

Implements javax.xml.stream.XMLStreamReader.getVersion.

Get the xml version declared on the xml declaration Returns null if none was declared
public boolean
hasName()

Implements javax.xml.stream.XMLStreamReader.hasName.

returns a boolean indicating whether the current event has a name (is a START_ELEMENT or END_ELEMENT).
public boolean
hasNext()

Implements javax.xml.stream.XMLStreamReader.hasNext.

Returns true if there are more parsing events and false if there are no more events.
public boolean
hasText()

Implements javax.xml.stream.XMLStreamReader.hasText.

Return a boolean indicating whether the current event has text.
public boolean
isAttributeSpecified(int
the position of the attribute
index
)

Implements javax.xml.stream.XMLStreamReader.isAttributeSpecified.

Returns a boolean which indicates if this attribute was created by default
public boolean
isCharacters()

Implements javax.xml.stream.XMLStreamReader.isCharacters.

Returns true if the cursor points to a character data event
public boolean
isEndElement()

Implements javax.xml.stream.XMLStreamReader.isEndElement.

Returns true if the cursor points to an end tag (otherwise false)
public boolean
isStandalone()

Implements javax.xml.stream.XMLStreamReader.isStandalone.

Get the standalone declaration from the xml declaration
public boolean
isStartElement()

Implements javax.xml.stream.XMLStreamReader.isStartElement.

Returns true if the cursor points to a start tag (otherwise false)
public boolean
isWhiteSpace()

Implements javax.xml.stream.XMLStreamReader.isWhiteSpace.

Returns true if the cursor points to a character data event that consists of all whitespace
public int
next()

Implements javax.xml.stream.XMLStreamReader.next.

Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks.
public int
nextTag()

Implements javax.xml.stream.XMLStreamReader.nextTag.

Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached.
public void
require(int
the event type
type
,
String
the uri of the event, may be null
namespaceURI
,
String
the localName of the event, may be null
localName
)

Implements javax.xml.stream.XMLStreamReader.require.

Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event.
public boolean
standaloneSet()

Implements javax.xml.stream.XMLStreamReader.standaloneSet.

Checks if standalone was set in the document
Inherited from org.jdom2.output.support.AbstractOutputProcessor:
buildWalker