javax.xml.stream.util
Class StreamReaderDelegate

java.lang.Object
  extended by javax.xml.stream.util.StreamReaderDelegate
All Implemented Interfaces:
XMLStreamConstants, XMLStreamReader

public class StreamReaderDelegate
extends Object
implements XMLStreamReader, XMLStreamConstants

Base class for XML stream reader filters.


Field Summary
 
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
StreamReaderDelegate()
          Constructs an empty filter with no parent set.
StreamReaderDelegate(XMLStreamReader reader)
          Constructs an empty filter with the specfied parent.
 
Method Summary
 void close()
          Frees any resources used by this parser.
 int getAttributeCount()
          Returns the number of attributes on this element.
 String getAttributeLocalName(int index)
          Returns the local-name of the attribute at the given index.
 QName getAttributeName(int index)
          Returns the QName of the attribute at the given index.
 String getAttributeNamespace(int index)
          Returns the namespace URI of the attribute at the given index.
 String getAttributePrefix(int index)
          Returns the namespace prefix of the attribute at the given index.
 String getAttributeType(int index)
          Returns the type of the attribute at the specified index.
 String getAttributeValue(int index)
          Returns the normalized value of the attribute at the given index.
 String getAttributeValue(String namespaceUri, String localName)
          Returns the normalized attribute value for the given attribute.
 String getCharacterEncodingScheme()
          Returns the encoding declared in the XML declaration.
 String getElementText()
          Returns the text content of a text-only element.
 String getEncoding()
          Returns the input encoding.
 int getEventType()
          Returns the type of the current event.
 String getLocalName()
          Returns the local-name of the current element.
 Location getLocation()
          Returns the current location of the parser cursor in the underlying input source.
 QName getName()
          Returns the QName of the current element.
 NamespaceContext getNamespaceContext()
          Returns the namespace context for the current position.
 int getNamespaceCount()
          Returns the number of namespaces declared on this event.
 String getNamespacePrefix(int index)
          Returns the prefix of the namespace at the given index, or null if this is the default namespace declaration.
 String getNamespaceURI()
          Returns the namespace URI of the current element.
 String getNamespaceURI(int index)
          Returns the URI of the namespace at the given index.
 String getNamespaceURI(String prefix)
          Returns the namespace URI for the given prefix.
 XMLStreamReader getParent()
          Returns the parent.
 String getPIData()
          Returns the data of the current processing instruction event.
 String getPITarget()
          Returns the target of the current processing instruction event.
 String getPrefix()
          Returns the namespace prefix of the current element.
 Object getProperty(String name)
          Returns the implementation-specific feature or property of the given name.
 String getText()
          Returns the string value of the current event.
 char[] getTextCharacters()
          Returns the string value of the current event as a character array.
 int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
          Copies the string value of the current event into the specified character array.
 int getTextLength()
          Returns the length of the characters in the text character array.
 int getTextStart()
          Returns the offset of the first character in the text character array.
 String getVersion()
          Returns the XML version declared in the XML declaration.
 boolean hasName()
          Indicates whether the current event has a name.
 boolean hasNext()
          Indicates whether there are any remaining events to be read.
 boolean hasText()
          Indicates whether the current event has text.
 boolean isAttributeSpecified(int index)
          Indicates whether the attribute at the given index was specified in the underlying XML source or created by default.
 boolean isCharacters()
          Indicates whether the current event is character data.
 boolean isEndElement()
          Indicates whether the current event is END_ELEMENT.
 boolean isStandalone()
          Returns the standalone flag declared in the XML declaration.
 boolean isStartElement()
          Indicates whether the current event is START_ELEMENT.
 boolean isWhiteSpace()
          Indicates whether the current event is ignorable whitespace.
 int next()
          Returns the next parsing event.
 int nextTag()
          Skips any ignorable whitespace, comments, and processing instructions until a START_ELEMENT or END_ELEMENT event is encountered.
 void require(int type, String namespaceURI, String localName)
          Tests whether the current event is of the given type and namespace.
 void setParent(XMLStreamReader reader)
          Sets the parent.
 boolean standaloneSet()
          Indicates whether the standalone flag was set in the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamReaderDelegate

public StreamReaderDelegate()
Constructs an empty filter with no parent set.


StreamReaderDelegate

public StreamReaderDelegate(XMLStreamReader reader)
Constructs an empty filter with the specfied parent.

Method Detail

setParent

public void setParent(XMLStreamReader reader)
Sets the parent.


getParent

public XMLStreamReader getParent()
Returns the parent.


next

public int next()
         throws XMLStreamException
Description copied from interface: XMLStreamReader
Returns the next parsing event.

Specified by:
next in interface XMLStreamReader
Throws:
XMLStreamException

nextTag

public int nextTag()
            throws XMLStreamException
Description copied from interface: XMLStreamReader
Skips any ignorable whitespace, comments, and processing instructions until a START_ELEMENT or END_ELEMENT event is encountered.

Specified by:
nextTag in interface XMLStreamReader
Throws:
XMLStreamException - if an event of any other type is encountered

getElementText

public String getElementText()
                      throws XMLStreamException
Description copied from interface: XMLStreamReader
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.

Specified by:
getElementText in interface XMLStreamReader
Throws:
XMLStreamException

require

public void require(int type,
                    String namespaceURI,
                    String localName)
             throws XMLStreamException
Description copied from interface: XMLStreamReader
Tests whether the current event is of the given type and namespace.

Specified by:
require in interface XMLStreamReader
Throws:
XMLStreamException - if the test fails

hasNext

public boolean hasNext()
                throws XMLStreamException
Description copied from interface: XMLStreamReader
Indicates whether there are any remaining events to be read.

Specified by:
hasNext in interface XMLStreamReader
Throws:
XMLStreamException

close

public void close()
           throws XMLStreamException
Description copied from interface: XMLStreamReader
Frees any resources used by this parser. This method will not close the underlying input source.

Specified by:
close in interface XMLStreamReader
Throws:
XMLStreamException

getNamespaceURI

public String getNamespaceURI(String prefix)
Description copied from interface: XMLStreamReader
Returns the namespace URI for the given prefix.

Specified by:
getNamespaceURI in interface XMLStreamReader

getNamespaceContext

public NamespaceContext getNamespaceContext()
Description copied from interface: XMLStreamReader
Returns the namespace context for the current position.

Specified by:
getNamespaceContext in interface XMLStreamReader

isStartElement

public boolean isStartElement()
Description copied from interface: XMLStreamReader
Indicates whether the current event is START_ELEMENT.

Specified by:
isStartElement in interface XMLStreamReader

isEndElement

public boolean isEndElement()
Description copied from interface: XMLStreamReader
Indicates whether the current event is END_ELEMENT.

Specified by:
isEndElement in interface XMLStreamReader

isCharacters

public boolean isCharacters()
Description copied from interface: XMLStreamReader
Indicates whether the current event is character data.

Specified by:
isCharacters in interface XMLStreamReader

isWhiteSpace

public boolean isWhiteSpace()
Description copied from interface: XMLStreamReader
Indicates whether the current event is ignorable whitespace.

Specified by:
isWhiteSpace in interface XMLStreamReader

getAttributeValue

public String getAttributeValue(String namespaceUri,
                                String localName)
Description copied from interface: XMLStreamReader
Returns the normalized attribute value for the given attribute.

Specified by:
getAttributeValue in interface XMLStreamReader

getAttributeCount

public int getAttributeCount()
Description copied from interface: XMLStreamReader
Returns the number of attributes on this element. This method can only be invoked on a START_ELEMENT event.

Specified by:
getAttributeCount in interface XMLStreamReader

getAttributeName

public QName getAttributeName(int index)
Description copied from interface: XMLStreamReader
Returns the QName of the attribute at the given index.

Specified by:
getAttributeName in interface XMLStreamReader

getAttributePrefix

public String getAttributePrefix(int index)
Description copied from interface: XMLStreamReader
Returns the namespace prefix of the attribute at the given index.

Specified by:
getAttributePrefix in interface XMLStreamReader

getAttributeNamespace

public String getAttributeNamespace(int index)
Description copied from interface: XMLStreamReader
Returns the namespace URI of the attribute at the given index.

Specified by:
getAttributeNamespace in interface XMLStreamReader

getAttributeLocalName

public String getAttributeLocalName(int index)
Description copied from interface: XMLStreamReader
Returns the local-name of the attribute at the given index.

Specified by:
getAttributeLocalName in interface XMLStreamReader

getAttributeType

public String getAttributeType(int index)
Description copied from interface: XMLStreamReader
Returns the type of the attribute at the specified index.

Specified by:
getAttributeType in interface XMLStreamReader

getAttributeValue

public String getAttributeValue(int index)
Description copied from interface: XMLStreamReader
Returns the normalized value of the attribute at the given index.

Specified by:
getAttributeValue in interface XMLStreamReader

isAttributeSpecified

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

Specified by:
isAttributeSpecified in interface XMLStreamReader

getNamespaceCount

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

Specified by:
getNamespaceCount in interface XMLStreamReader

getNamespacePrefix

public String getNamespacePrefix(int index)
Description copied from interface: XMLStreamReader
Returns the prefix of the namespace at the given index, or null if this is the default namespace declaration.

Specified by:
getNamespacePrefix in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI(int index)
Description copied from interface: XMLStreamReader
Returns the URI of the namespace at the given index.

Specified by:
getNamespaceURI in interface XMLStreamReader

getEventType

public int getEventType()
Description copied from interface: XMLStreamReader
Returns the type of the current event.

Specified by:
getEventType in interface XMLStreamReader

getText

public String getText()
Description copied from interface: XMLStreamReader
Returns the string value of the current event.

Specified by:
getText in interface XMLStreamReader

getTextCharacters

public int getTextCharacters(int sourceStart,
                             char[] target,
                             int targetStart,
                             int length)
                      throws XMLStreamException
Description copied from interface: XMLStreamReader
Copies the string value of the current event into the specified character array.

Specified by:
getTextCharacters in interface XMLStreamReader
Throws:
XMLStreamException

getTextCharacters

public char[] getTextCharacters()
Description copied from interface: XMLStreamReader
Returns the string value of the current event as a character array.

Specified by:
getTextCharacters in interface XMLStreamReader

getTextStart

public int getTextStart()
Description copied from interface: XMLStreamReader
Returns the offset of the first character in the text character array.

Specified by:
getTextStart in interface XMLStreamReader

getTextLength

public int getTextLength()
Description copied from interface: XMLStreamReader
Returns the length of the characters in the text character array.

Specified by:
getTextLength in interface XMLStreamReader

getEncoding

public String getEncoding()
Description copied from interface: XMLStreamReader
Returns the input encoding.

Specified by:
getEncoding in interface XMLStreamReader

hasText

public boolean hasText()
Description copied from interface: XMLStreamReader
Indicates whether the current event has text.

Specified by:
hasText in interface XMLStreamReader

getLocation

public Location getLocation()
Description copied from interface: XMLStreamReader
Returns the current location of the parser cursor in the underlying input source.

Specified by:
getLocation in interface XMLStreamReader

getName

public QName getName()
Description copied from interface: XMLStreamReader
Returns the QName of the current element. This method is only valid on a START_ELEMENT or END_ELEMENT event.

Specified by:
getName in interface XMLStreamReader

getLocalName

public String getLocalName()
Description copied from interface: XMLStreamReader
Returns the local-name of the current element.

Specified by:
getLocalName in interface XMLStreamReader

hasName

public boolean hasName()
Description copied from interface: XMLStreamReader
Indicates whether the current event has a name.

Specified by:
hasName in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI()
Description copied from interface: XMLStreamReader
Returns the namespace URI of the current element.

Specified by:
getNamespaceURI in interface XMLStreamReader

getPrefix

public String getPrefix()
Description copied from interface: XMLStreamReader
Returns the namespace prefix of the current element.

Specified by:
getPrefix in interface XMLStreamReader

getVersion

public String getVersion()
Description copied from interface: XMLStreamReader
Returns the XML version declared in the XML declaration.

Specified by:
getVersion in interface XMLStreamReader

isStandalone

public boolean isStandalone()
Description copied from interface: XMLStreamReader
Returns the standalone flag declared in the XML declaration.

Specified by:
isStandalone in interface XMLStreamReader

standaloneSet

public boolean standaloneSet()
Description copied from interface: XMLStreamReader
Indicates whether the standalone flag was set in the document.

Specified by:
standaloneSet in interface XMLStreamReader

getCharacterEncodingScheme

public String getCharacterEncodingScheme()
Description copied from interface: XMLStreamReader
Returns the encoding declared in the XML declaration.

Specified by:
getCharacterEncodingScheme in interface XMLStreamReader

getPITarget

public String getPITarget()
Description copied from interface: XMLStreamReader
Returns the target of the current processing instruction event.

Specified by:
getPITarget in interface XMLStreamReader

getPIData

public String getPIData()
Description copied from interface: XMLStreamReader
Returns the data of the current processing instruction event.

Specified by:
getPIData in interface XMLStreamReader

getProperty

public Object getProperty(String name)
Description copied from interface: XMLStreamReader
Returns the implementation-specific feature or property of the given name.

Specified by:
getProperty in interface XMLStreamReader