javax.xml.stream

Interface XMLStreamReader

public interface XMLStreamReader extends XMLStreamConstants

Interface implemented by an XML parser.
Method Summary
voidclose()
Frees any resources used by this parser.
intgetAttributeCount()
Returns the number of attributes on this element.
StringgetAttributeLocalName(int index)
Returns the local-name of the attribute at the given index.
QNamegetAttributeName(int index)
Returns the QName of the attribute at the given index.
StringgetAttributeNamespace(int index)
Returns the namespace URI of the attribute at the given index.
StringgetAttributePrefix(int index)
Returns the namespace prefix of the attribute at the given index.
StringgetAttributeType(int index)
Returns the type of the attribute at the specified index.
StringgetAttributeValue(String namespaceURI, String localName)
Returns the normalized attribute value for the given attribute.
StringgetAttributeValue(int index)
Returns the normalized value of the attribute at the given index.
StringgetCharacterEncodingScheme()
Returns the encoding declared in the XML declaration.
StringgetElementText()
Returns the text content of a text-only element.
StringgetEncoding()
Returns the input encoding.
intgetEventType()
Returns the type of the current event.
StringgetLocalName()
Returns the local-name of the current element.
LocationgetLocation()
Returns the current location of the parser cursor in the underlying input source.
QNamegetName()
Returns the QName of the current element.
NamespaceContextgetNamespaceContext()
Returns the namespace context for the current position.
intgetNamespaceCount()
Returns the number of namespaces declared on this event.
StringgetNamespacePrefix(int index)
Returns the prefix of the namespace at the given index, or null if this is the default namespace declaration.
StringgetNamespaceURI(String prefix)
Returns the namespace URI for the given prefix.
StringgetNamespaceURI(int index)
Returns the URI of the namespace at the given index.
StringgetNamespaceURI()
Returns the namespace URI of the current element.
StringgetPIData()
Returns the data of the current processing instruction event.
StringgetPITarget()
Returns the target of the current processing instruction event.
StringgetPrefix()
Returns the namespace prefix of the current element.
ObjectgetProperty(String name)
Returns the implementation-specific feature or property of the given name.
StringgetText()
Returns the string value of the current event.
char[]getTextCharacters()
Returns the string value of the current event as a character array.
intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length)
Copies the string value of the current event into the specified character array.
intgetTextLength()
Returns the length of the characters in the text character array.
intgetTextStart()
Returns the offset of the first character in the text character array.
StringgetVersion()
Returns the XML version declared in the XML declaration.
booleanhasName()
Indicates whether the current event has a name.
booleanhasNext()
Indicates whether there are any remaining events to be read.
booleanhasText()
Indicates whether the current event has text.
booleanisAttributeSpecified(int index)
Indicates whether the attribute at the given index was specified in the underlying XML source or created by default.
booleanisCharacters()
Indicates whether the current event is character data.
booleanisEndElement()
Indicates whether the current event is END_ELEMENT.
booleanisStandalone()
Returns the standalone flag declared in the XML declaration.
booleanisStartElement()
Indicates whether the current event is START_ELEMENT.
booleanisWhiteSpace()
Indicates whether the current event is ignorable whitespace.
intnext()
Returns the next parsing event.
intnextTag()
Skips any ignorable whitespace, comments, and processing instructions until a START_ELEMENT or END_ELEMENT event is encountered.
voidrequire(int type, String namespaceURI, String localName)
Tests whether the current event is of the given type and namespace.
booleanstandaloneSet()
Indicates whether the standalone flag was set in the document.

Method Detail

close

public void close()
Frees any resources used by this parser. This method will not close the underlying input source.

getAttributeCount

public int getAttributeCount()
Returns the number of attributes on this element. This method can only be invoked on a START_ELEMENT event.

getAttributeLocalName

public String getAttributeLocalName(int index)
Returns the local-name of the attribute at the given index.

getAttributeName

public QName getAttributeName(int index)
Returns the QName of the attribute at the given index.

getAttributeNamespace

public String getAttributeNamespace(int index)
Returns the namespace URI of the attribute at the given index.

getAttributePrefix

public String getAttributePrefix(int index)
Returns the namespace prefix of the attribute at the given index.

getAttributeType

public String getAttributeType(int index)
Returns the type of the attribute at the specified index.

getAttributeValue

public String getAttributeValue(String namespaceURI, String localName)
Returns the normalized attribute value for the given attribute.

getAttributeValue

public String getAttributeValue(int index)
Returns the normalized value of the attribute at the given index.

getCharacterEncodingScheme

public String getCharacterEncodingScheme()
Returns the encoding declared in the XML declaration.

getElementText

public String getElementText()
Returns the text content of a text-only element. When invoked, the current event must be START_ELEMENT. On completion, the current event will be END_ELEMENT.

getEncoding

public String getEncoding()
Returns the input encoding.

getEventType

public int getEventType()
Returns the type of the current event.

getLocalName

public String getLocalName()
Returns the local-name of the current element.

getLocation

public Location getLocation()
Returns the current location of the parser cursor in the underlying input source.

getName

public QName getName()
Returns the QName of the current element. This method is only valid on a START_ELEMENT or END_ELEMENT event.

getNamespaceContext

public NamespaceContext getNamespaceContext()
Returns the namespace context for the current position.

getNamespaceCount

public int getNamespaceCount()
Returns the number of namespaces declared on this event. This method is only valid on a START_ELEMENT, END_ELEMENT, or NAMESPACE event.

getNamespacePrefix

public String getNamespacePrefix(int index)
Returns the prefix of the namespace at the given index, or null if this is the default namespace declaration.

getNamespaceURI

public String getNamespaceURI(String prefix)
Returns the namespace URI for the given prefix.

getNamespaceURI

public String getNamespaceURI(int index)
Returns the URI of the namespace at the given index.

getNamespaceURI

public String getNamespaceURI()
Returns the namespace URI of the current element.

getPIData

public String getPIData()
Returns the data of the current processing instruction event.

getPITarget

public String getPITarget()
Returns the target of the current processing instruction event.

getPrefix

public String getPrefix()
Returns the namespace prefix of the current element.

getProperty

public Object getProperty(String name)
Returns the implementation-specific feature or property of the given name.

getText

public String getText()
Returns the string value of the current event.

getTextCharacters

public char[] getTextCharacters()
Returns the string value of the current event as a character array.

getTextCharacters

public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
Copies the string value of the current event into the specified character array.

getTextLength

public int getTextLength()
Returns the length of the characters in the text character array.

getTextStart

public int getTextStart()
Returns the offset of the first character in the text character array.

getVersion

public String getVersion()
Returns the XML version declared in the XML declaration.

hasName

public boolean hasName()
Indicates whether the current event has a name.

hasNext

public boolean hasNext()
Indicates whether there are any remaining events to be read.

hasText

public boolean hasText()
Indicates whether the current event has text.

isAttributeSpecified

public boolean isAttributeSpecified(int index)
Indicates whether the attribute at the given index was specified in the underlying XML source or created by default.

isCharacters

public boolean isCharacters()
Indicates whether the current event is character data.

isEndElement

public boolean isEndElement()
Indicates whether the current event is END_ELEMENT.

isStandalone

public boolean isStandalone()
Returns the standalone flag declared in the XML declaration.

isStartElement

public boolean isStartElement()
Indicates whether the current event is START_ELEMENT.

isWhiteSpace

public boolean isWhiteSpace()
Indicates whether the current event is ignorable whitespace.

next

public int next()
Returns the next parsing event.

nextTag

public int nextTag()
Skips any ignorable whitespace, comments, and processing instructions until a START_ELEMENT or END_ELEMENT event is encountered.

Throws: XMLStreamException if an event of any other type is encountered

require

public void require(int type, String namespaceURI, String localName)
Tests whether the current event is of the given type and namespace.

Throws: XMLStreamException if the test fails

standaloneSet

public boolean standaloneSet()
Indicates whether the standalone flag was set in the document.