APIdia Launch Partner
Top Description Methods
javax.xml.stream

public Interface XMLEventReader

extends Iterator<Object>
Known Direct Implementers
javax.xml.stream.util.EventReaderDelegate, com.sun.xml.internal.stream.XMLEventReaderImpl
Imports
javax.xml.stream.events.XMLEvent, java.util.Iterator

This is the top level interface for parsing XML Events. It provides the ability to peek at the next event and returns configuration information through the property interface.
Author
Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
Since
1.6
Version
1.0
See Also
XMLInputFactory, XMLEventWriter

Method Summary

Modifier and TypeMethod and Description
public void
close()

Frees any resources associated with this Reader.

public String

Returns:

the text of the element
getElementText
()

Reads the content of a text-only element.

public Object

Returns:

The value of the property
getProperty
(String
The name of the property
name
)

Get the value of a feature/property from the underlying implementation

public boolean

Returns:

true if the event reader has more events, false otherwise
hasNext
()

Redeclares java.util.Iterator.hasNext.

Check if there are more events.

public XMLEvent

Returns:

the next XMLEvent
nextEvent
()

Gets the next XMLEvent.

public XMLEvent

Returns:

a START_ELEMENT or END_ELEMENT
nextTag
()

Skips any insignificant space events until a START_ELEMENT or END_ELEMENT is reached.

public XMLEvent

Returns:

the next XMLEvent
peek
()

Check the next XMLEvent without reading it from the stream.

Inherited from java.util.Iterator:
forEachRemainingnextremove

Method Detail

closeback to summary
public void close() throws XMLStreamException

Frees any resources associated with this Reader. This method does not close the underlying input source.

Exceptions
XMLStreamException:
if there are errors freeing associated resources
getElementTextback to summary
public String getElementText() throws XMLStreamException

Reads the content of a text-only element.

Precondition

the current event is START_ELEMENT. Postcondition: The current event is the corresponding END_ELEMENT.

Returns:String

the text of the element

Exceptions
XMLStreamException:
if the current event is not a START_ELEMENT or if a non text element is encountered
getPropertyback to summary
public Object getProperty(String name) throws IllegalArgumentException

Get the value of a feature/property from the underlying implementation

Parameters
name:String

The name of the property

Returns:Object

The value of the property

Exceptions
IllegalArgumentException:
if the property is not supported
hasNextback to summary
public boolean hasNext()

Redeclares java.util.Iterator.hasNext.

Check if there are more events. Returns true if there are more events and false otherwise.

Returns:boolean

true if the event reader has more events, false otherwise

Annotations
@Override
nextEventback to summary
public XMLEvent nextEvent() throws XMLStreamException

Gets the next XMLEvent. The initial event is StartDocument.

Returns:XMLEvent

the next XMLEvent

Exceptions
XMLStreamException:
if there is an error with the underlying XML.
NoSuchElementException:
iteration has no more elements.
See Also
XMLEvent
nextTagback to summary
public XMLEvent nextTag() throws XMLStreamException

Skips any insignificant space events until a START_ELEMENT or END_ELEMENT is reached. If anything other than space characters are encountered, an exception is thrown. This method should be used when processing element-only content because the parser is not able to recognize ignorable whitespace if the DTD is missing or not interpreted.

Returns:XMLEvent

a START_ELEMENT or END_ELEMENT

Exceptions
XMLStreamException:
if anything other than space characters are encountered
peekback to summary
public XMLEvent peek() throws XMLStreamException

Check the next XMLEvent without reading it from the stream. Returns null if the stream is at EOF or has no more XMLEvents. A call to peek() will be equal to the next return of next().

Returns:XMLEvent

the next XMLEvent

Exceptions
XMLStreamException:
if an error occurs
See Also
XMLEvent