org.exist.stax
Class EmbeddedXMLStreamReader

java.lang.Object
  extended by org.exist.stax.EmbeddedXMLStreamReader
All Implemented Interfaces:
XMLStreamConstants, XMLStreamReader

public class EmbeddedXMLStreamReader
extends Object
implements XMLStreamReader

Lazy implementation of a StAX XMLStreamReader, which directly reads information from the persistent DOM. The class is optimized to support fast scanning of the DOM, where only a few selected node properties are requested. Node properties are extracted on demand. For example, the QName of an element will not be read unless getText() is called.


Field Summary
static String PROPERTY_NODE_ID
           
 
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
EmbeddedXMLStreamReader(DBBroker broker, DocumentImpl doc, RawNodeIterator iterator, boolean reportAttributes)
          Construct an EmbeddedXMLStreamReader.
 
Method Summary
 void close()
           
 int getAttributeCount()
           
 String getAttributeLocalName(int i)
           
 QName getAttributeName(int i)
           
 String getAttributeNamespace(int i)
           
 String getAttributePrefix(int i)
           
 String getAttributeType(int i)
           
 String getAttributeValue(int i)
           
 String getAttributeValue(String string, String string1)
           
 String getCharacterEncodingScheme()
           
 long getCurrentPosition()
          Returns the (internal) address of the node at the cursor's current position.
 String getElementText()
           
 String getEncoding()
           
 int getEventType()
           
 String getLocalName()
           
 Location getLocation()
           
 QName getName()
           
 NamespaceContext getNamespaceContext()
           
 int getNamespaceCount()
           
 String getNamespacePrefix(int i)
           
 String getNamespaceURI()
           
 String getNamespaceURI(int i)
           
 String getNamespaceURI(String string)
           
 StoredNode getNode()
          Deserialize the node at the current position of the cursor and return it as a StoredNode.
 short getNodeType()
           
 String getPIData()
           
 String getPITarget()
           
 String getPrefix()
           
 StoredNode getPreviousNode()
          Returns the last node in document sequence that occurs before the current node.
 Object getProperty(String string)
           
 QName getQName()
           
 String getText()
           
 char[] getTextCharacters()
           
 int getTextCharacters(int sourceStart, char[] chars, int targetStart, int length)
           
 int getTextLength()
           
 int getTextStart()
           
 String getVersion()
           
 boolean hasName()
           
 boolean hasNext()
           
 boolean hasText()
           
 boolean isAttributeSpecified(int i)
           
 boolean isCharacters()
           
 boolean isEndElement()
           
 boolean isStandalone()
           
 boolean isStartElement()
           
 boolean isWhiteSpace()
           
 int next()
           
 int nextTag()
           
 void reposition(DBBroker broker, NodeProxy proxy, boolean reportAttributes)
          Reposition the stream reader to another start node, maybe in a different document.
 void reposition(DBBroker broker, StoredNode node, boolean reportAttributes)
          Reposition the stream reader to another start node, maybe in a different document.
 void require(int i, String string, String string1)
           
 boolean standaloneSet()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NODE_ID

public static final String PROPERTY_NODE_ID
See Also:
Constant Field Values
Constructor Detail

EmbeddedXMLStreamReader

public EmbeddedXMLStreamReader(DBBroker broker,
                               DocumentImpl doc,
                               RawNodeIterator iterator,
                               boolean reportAttributes)
                        throws XMLStreamException
Construct an EmbeddedXMLStreamReader.

Parameters:
doc - the document to which the start node belongs.
iterator - a RawNodeIterator positioned on the start node.
reportAttributes - if set to true, attributes will be reported as top-level events.
Throws:
XMLStreamException
Method Detail

reposition

public void reposition(DBBroker broker,
                       StoredNode node,
                       boolean reportAttributes)
                throws IOException
Reposition the stream reader to another start node, maybe in a different document.

Parameters:
node - the new start node.
reportAttributes - if set to true, attributes will be reported as top-level events.
Throws:
IOException

reposition

public void reposition(DBBroker broker,
                       NodeProxy proxy,
                       boolean reportAttributes)
                throws IOException
Reposition the stream reader to another start node, maybe in a different document.

Parameters:
proxy - the new start node.
reportAttributes - if set to true, attributes will be reported as top-level events.
Throws:
IOException

getNodeType

public short getNodeType()

next

public int next()
         throws XMLStreamException
Specified by:
next in interface XMLStreamReader
Throws:
XMLStreamException

require

public void require(int i,
                    String string,
                    String string1)
             throws XMLStreamException
Specified by:
require in interface XMLStreamReader
Throws:
XMLStreamException

getElementText

public String getElementText()
                      throws XMLStreamException
Specified by:
getElementText in interface XMLStreamReader
Throws:
XMLStreamException

getProperty

public Object getProperty(String string)
                   throws IllegalArgumentException
Specified by:
getProperty in interface XMLStreamReader
Throws:
IllegalArgumentException

nextTag

public int nextTag()
            throws XMLStreamException
Specified by:
nextTag in interface XMLStreamReader
Throws:
XMLStreamException

hasNext

public boolean hasNext()
                throws XMLStreamException
Specified by:
hasNext in interface XMLStreamReader
Throws:
XMLStreamException

close

public void close()
           throws XMLStreamException
Specified by:
close in interface XMLStreamReader
Throws:
XMLStreamException

isStartElement

public boolean isStartElement()
Specified by:
isStartElement in interface XMLStreamReader

isEndElement

public boolean isEndElement()
Specified by:
isEndElement in interface XMLStreamReader

isCharacters

public boolean isCharacters()
Specified by:
isCharacters in interface XMLStreamReader

isWhiteSpace

public boolean isWhiteSpace()
Specified by:
isWhiteSpace in interface XMLStreamReader

getAttributeValue

public String getAttributeValue(String string,
                                String string1)
Specified by:
getAttributeValue in interface XMLStreamReader

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface XMLStreamReader

getAttributeName

public QName getAttributeName(int i)
Specified by:
getAttributeName in interface XMLStreamReader

getAttributeNamespace

public String getAttributeNamespace(int i)
Specified by:
getAttributeNamespace in interface XMLStreamReader

getAttributeLocalName

public String getAttributeLocalName(int i)
Specified by:
getAttributeLocalName in interface XMLStreamReader

getAttributePrefix

public String getAttributePrefix(int i)
Specified by:
getAttributePrefix in interface XMLStreamReader

getAttributeType

public String getAttributeType(int i)
Specified by:
getAttributeType in interface XMLStreamReader

getAttributeValue

public String getAttributeValue(int i)
Specified by:
getAttributeValue in interface XMLStreamReader

isAttributeSpecified

public boolean isAttributeSpecified(int i)
Specified by:
isAttributeSpecified in interface XMLStreamReader

getNamespaceCount

public int getNamespaceCount()
Specified by:
getNamespaceCount in interface XMLStreamReader

getNamespacePrefix

public String getNamespacePrefix(int i)
Specified by:
getNamespacePrefix in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI(int i)
Specified by:
getNamespaceURI in interface XMLStreamReader

getNamespaceContext

public NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface XMLStreamReader

getEventType

public int getEventType()
Specified by:
getEventType in interface XMLStreamReader

getText

public String getText()
Specified by:
getText in interface XMLStreamReader

getTextCharacters

public char[] getTextCharacters()
Specified by:
getTextCharacters in interface XMLStreamReader

getTextCharacters

public int getTextCharacters(int sourceStart,
                             char[] chars,
                             int targetStart,
                             int length)
                      throws XMLStreamException
Specified by:
getTextCharacters in interface XMLStreamReader
Throws:
XMLStreamException

getTextStart

public int getTextStart()
Specified by:
getTextStart in interface XMLStreamReader

getTextLength

public int getTextLength()
Specified by:
getTextLength in interface XMLStreamReader

getEncoding

public String getEncoding()
Specified by:
getEncoding in interface XMLStreamReader

hasText

public boolean hasText()
Specified by:
hasText in interface XMLStreamReader

getLocation

public Location getLocation()
Specified by:
getLocation in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI(String string)
Specified by:
getNamespaceURI in interface XMLStreamReader

getName

public QName getName()
Specified by:
getName in interface XMLStreamReader

getQName

public QName getQName()

getPrefix

public String getPrefix()
Specified by:
getPrefix in interface XMLStreamReader

getLocalName

public String getLocalName()
Specified by:
getLocalName in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI()
Specified by:
getNamespaceURI in interface XMLStreamReader

hasName

public boolean hasName()
Specified by:
hasName in interface XMLStreamReader

getNode

public StoredNode getNode()
Deserialize the node at the current position of the cursor and return it as a StoredNode.

Returns:
the node at the current position.

getPreviousNode

public StoredNode getPreviousNode()
Returns the last node in document sequence that occurs before the current node. Usually used to find the last child before an END_ELEMENT event.

Returns:
the last node in document sequence before the current node

getCurrentPosition

public long getCurrentPosition()
Returns the (internal) address of the node at the cursor's current position.

Returns:
internal address of node

getVersion

public String getVersion()
Specified by:
getVersion in interface XMLStreamReader

isStandalone

public boolean isStandalone()
Specified by:
isStandalone in interface XMLStreamReader

standaloneSet

public boolean standaloneSet()
Specified by:
standaloneSet in interface XMLStreamReader

getCharacterEncodingScheme

public String getCharacterEncodingScheme()
Specified by:
getCharacterEncodingScheme in interface XMLStreamReader

getPITarget

public String getPITarget()
Specified by:
getPITarget in interface XMLStreamReader

getPIData

public String getPIData()
Specified by:
getPIData in interface XMLStreamReader


Copyright (C) Wolfgang Meier. All rights reserved.