Package com.bea.xml.stream
Class SubReader
- java.lang.Object
-
- com.bea.xml.stream.ReaderDelegate
-
- com.bea.xml.stream.SubReader
-
- All Implemented Interfaces:
javax.xml.stream.XMLStreamConstants,javax.xml.stream.XMLStreamReader
public class SubReader extends ReaderDelegate
Creates a SubReader over a node of a document
-
-
Constructor Summary
Constructors Constructor Description SubReader(javax.xml.stream.XMLStreamReader reader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Returns true if there are more parsing events and false if there are no more events.static voidmain(java.lang.String[] args)booleanmoveToEndElement()booleanmoveToEndElement(java.lang.String localName)booleanmoveToEndElement(java.lang.String localName, java.lang.String namespaceUri)booleanmoveToStartElement()booleanmoveToStartElement(java.lang.String localName)booleanmoveToStartElement(java.lang.String localName, java.lang.String namespaceUri)intnext()Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks.intnextElement()static voidprint(javax.xml.stream.XMLStreamReader r, int depth)static voidsub(javax.xml.stream.XMLStreamReader r, int depth)-
Methods inherited from class com.bea.xml.stream.ReaderDelegate
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getDelegate, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, require, setDelegate, standaloneSet
-
-
-
-
Method Detail
-
next
public int next() throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamReaderGet next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks. If the property javax.xml.stream.isCoalescing is set to true element content must be coalesced and only one CHARACTERS event must be returned for contiguous element content or CDATA Sections. By default entity references must be expanded and reported transparently to the application. An exception will be thrown if an entity reference cannot be expanded. If element content is empty (i.e. content is "") then no CHARACTERS event will be reported.Given the following XML:
<foo><!--description-->content text<![CDATA[<greeting>Hello</greeting>]]>other content</foo>
The behavior of calling next() when being on foo will be:
1- the comment (COMMENT)
2- then the characters section (CHARACTERS)
3- then the CDATA section (another CHARACTERS)
4- then the next characters section (another CHARACTERS)
5- then the END_ELEMENT
NOTE: empty element (such as <tag/>) will be reported with two separate events: START_ELEMENT, END_ELEMENT - This preserves parsing equivalency of empty element to <tag></tag>. This method will throw an IllegalStateException if it is called after hasNext() returns false.
- Specified by:
nextin interfacejavax.xml.stream.XMLStreamReader- Overrides:
nextin classReaderDelegate- Returns:
- the integer code corresponding to the current parse event
- Throws:
javax.xml.stream.XMLStreamException- if there is an error processing the underlying XML source- See Also:
XMLEvent
-
nextElement
public int nextElement() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
hasNext
public boolean hasNext() throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamReaderReturns true if there are more parsing events and false if there are no more events. This method will return false if the current state of the XMLStreamReader is END_DOCUMENT- Specified by:
hasNextin interfacejavax.xml.stream.XMLStreamReader- Overrides:
hasNextin classReaderDelegate- Returns:
- true if there are more events, false otherwise
- Throws:
javax.xml.stream.XMLStreamException- if there is a fatal error detecting the next state
-
moveToStartElement
public boolean moveToStartElement() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
moveToStartElement
public boolean moveToStartElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
moveToStartElement
public boolean moveToStartElement(java.lang.String localName, java.lang.String namespaceUri) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
moveToEndElement
public boolean moveToEndElement() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
moveToEndElement
public boolean moveToEndElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
moveToEndElement
public boolean moveToEndElement(java.lang.String localName, java.lang.String namespaceUri) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
print
public static void print(javax.xml.stream.XMLStreamReader r, int depth) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
sub
public static void sub(javax.xml.stream.XMLStreamReader r, int depth) throws java.lang.Exception- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-