org.compass.core.xml.javax.converter.support
Class Stax2DomBuilder

java.lang.Object
  extended by org.compass.core.xml.javax.converter.support.Stax2DomBuilder

public class Stax2DomBuilder
extends Object

Builds a DOM Document using a XMLStreamReader.


Field Summary
protected  boolean mCfgIgnoreWs
          Whether ignorable white space should be ignored, ie not added in the resulting JDOM tree.
protected  String mLastLocalName
           
protected  String mLastPrefix
           
protected  String mLastQName
           
protected  boolean mNsAware
           
 
Constructor Summary
Stax2DomBuilder()
          Default constructor.
 
Method Summary
 Document build(javax.xml.stream.XMLStreamReader r)
          This method will create a Document instance using the default JAXP mechanism and populate using the given StAX stream reader.
 void build(javax.xml.stream.XMLStreamReader r, Document doc)
          This method will populate given Document using the given StAX stream reader instance.
 Document build(javax.xml.stream.XMLStreamReader r, DocumentBuilder docbuilder)
           
protected  void buildTree(javax.xml.stream.XMLStreamReader r, Document doc)
          This method takes a XMLStreamReader and builds up a JDOM tree.
protected  void checkReaderSettings(javax.xml.stream.XMLStreamReader r)
           
protected  String getQualified(String prefix, String localName)
           
static void main(String[] args)
          Trivial test driver for testing functionality.
 void setIgnoreWhitespace(boolean state)
          Method used to change whether the build methods will add ignorable (element) white space in the DOM tree or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCfgIgnoreWs

protected boolean mCfgIgnoreWs
Whether ignorable white space should be ignored, ie not added in the resulting JDOM tree. If true, it will be ignored; if false, it will be added in the tree. Default value if false.


mNsAware

protected boolean mNsAware

mLastPrefix

protected String mLastPrefix

mLastLocalName

protected String mLastLocalName

mLastQName

protected String mLastQName
Constructor Detail

Stax2DomBuilder

public Stax2DomBuilder()
Default constructor.

Method Detail

setIgnoreWhitespace

public void setIgnoreWhitespace(boolean state)
Method used to change whether the build methods will add ignorable (element) white space in the DOM tree or not.

Whether all-whitespace text segment is ignorable white space or not is based on DTD read in, as per XML specifications (white space is only significant in mixed content or pure text elements).


build

public Document build(javax.xml.stream.XMLStreamReader r)
               throws ParserConfigurationException,
                      javax.xml.stream.XMLStreamException
This method will create a Document instance using the default JAXP mechanism and populate using the given StAX stream reader.

Parameters:
r - Stream reader from which input is read.
Returns:
Document - DOM document object.
Throws:
javax.xml.stream.XMLStreamException - If the reader threw such exception (to indicate a parsing or I/O problem)
ParserConfigurationException

build

public Document build(javax.xml.stream.XMLStreamReader r,
                      DocumentBuilder docbuilder)
               throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

build

public void build(javax.xml.stream.XMLStreamReader r,
                  Document doc)
           throws javax.xml.stream.XMLStreamException
This method will populate given Document using the given StAX stream reader instance.

Parameters:
r - Stream reader from which input is read.
Throws:
javax.xml.stream.XMLStreamException - If the reader threw such exception (to indicate a parsing or I/O problem)

buildTree

protected void buildTree(javax.xml.stream.XMLStreamReader r,
                         Document doc)
                  throws javax.xml.stream.XMLStreamException
This method takes a XMLStreamReader and builds up a JDOM tree. Recursion has been eliminated by using nodes' parent/child relationship; this improves performance somewhat (classic recursion-by-iteration-and-explicit stack transformation)

Throws:
javax.xml.stream.XMLStreamException

getQualified

protected String getQualified(String prefix,
                              String localName)

checkReaderSettings

protected void checkReaderSettings(javax.xml.stream.XMLStreamReader r)
                            throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

main

public static void main(String[] args)
                 throws Exception
Trivial test driver for testing functionality.

Throws:
Exception


Copyright (c) 2004-2008 The Compass Project.