Package org.red5.io.utils
Class Stax2DomBuilder
- java.lang.Object
-
- org.red5.io.utils.Stax2DomBuilder
-
public class Stax2DomBuilder extends Object
Builds a DOMDocumentusing aXMLStreamReader.- Version:
- $Revision: 1.00 $, $Date: 2004/12/11 00:00:00 $
- Author:
- Tatu Saloranta
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanmCfgIgnoreWsWhether ignorable white space should be ignored, ie not added in the resulting JDOM tree.protected StringmLastLocalNameprotected StringmLastPrefixprotected StringmLastQNameprotected booleanmNsAware
-
Constructor Summary
Constructors Constructor Description Stax2DomBuilder()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Documentbuild(XMLStreamReader r)This method will create aDocumentinstance using the default JAXP mechanism and populate using the given StAX stream reader.Documentbuild(XMLStreamReader r, DocumentBuilder docbuilder)voidbuild(XMLStreamReader r, Document doc)This method will populate givenDocumentusing the given StAX stream reader instance.protected voidbuildTree(XMLStreamReader r, Document doc)This method takes aXMLStreamReaderand builds up a JDOM tree.protected voidcheckReaderSettings(XMLStreamReader r)protected StringgetQualified(String prefix, String localName)voidsetIgnoreWhitespace(boolean ignoreWS)Method used to change whether the build methods will add ignorable (element) white space in the DOM tree or not.
-
-
-
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
-
-
Method Detail
-
setIgnoreWhitespace
public void setIgnoreWhitespace(boolean ignoreWS)
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).
- Parameters:
ignoreWS- true to ignore whitespace; false otherwise.
-
build
public Document build(XMLStreamReader r) throws ParserConfigurationException, XMLStreamException
This method will create aDocumentinstance 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:
ParserConfigurationException- if parse is not configuredXMLStreamException- If the reader threw such exception (to indicate a parsing or I/O problem)
-
build
public Document build(XMLStreamReader r, DocumentBuilder docbuilder) throws XMLStreamException
- Throws:
XMLStreamException
-
build
public void build(XMLStreamReader r, Document doc) throws XMLStreamException
This method will populate givenDocumentusing the given StAX stream reader instance.- Parameters:
r- Stream reader from which input is read.doc-Document- DOM document object.- Throws:
XMLStreamException- If the reader threw such exception (to indicate a parsing or I/O problem)
-
buildTree
protected void buildTree(XMLStreamReader r, Document doc) throws XMLStreamException
This method takes aXMLStreamReaderand 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)- Parameters:
r- Stream reader to use for reading the document from which to build the treedoc- JDOMDocumentbeing built.- Throws:
XMLStreamException- for fun
-
checkReaderSettings
protected void checkReaderSettings(XMLStreamReader r) throws XMLStreamException
- Throws:
XMLStreamException
-
-