org.pf.six
Class XmlStreamReader

java.lang.Object
  extended by org.pf.six.XmlStreamReader
All Implemented Interfaces:
SAXConstants

public class XmlStreamReader
extends java.lang.Object
implements SAXConstants

This is the most simple service class to read a XML stream into a hierarchical String based structure or into a DOM tree. It is completely build on JAXP, so any compliant parser package can be used with it.

Version:
1.5
Author:
Manfred Duchrow

Field Summary
 
Fields inherited from interface org.pf.pax.SAXConstants
FEATURE_NAMESPACE_PREFIXES, FEATURE_NAMESPACES, FEATURE_VALIDATING
 
Method Summary
static org.w3c.dom.Document loadDOM(org.xml.sax.InputSource source, boolean validating)
          Read the given source with an XML parser and return the DOM tree structure.
static org.w3c.dom.Document loadDOM(java.io.InputStream xmlStream, java.lang.String uri, boolean validating)
          Read the given stream with an XML parser and return the DOM tree structure.
static Element loadFrom(org.xml.sax.InputSource source, boolean validating)
          Read the given input source with an XML parser and return the element structure.
static Element loadFrom(java.io.InputStream xmlStream)
          Read the given stream with an XML parser and return the element structure.
static Element loadFrom(java.io.InputStream xmlStream, boolean validating)
          Read the given stream with an XML parser and return the element structure.
static Element loadFrom(java.io.InputStream xmlStream, java.lang.String uri, boolean validating)
          Read the given stream with an XML parser and return the element structure.
static org.w3c.dom.Document readDOM(java.io.File file, boolean validating)
          Read the given file as XML stream and return the DOM tree structure.
static org.w3c.dom.Document readDOM(java.io.InputStream xmlStream, java.lang.String uri, boolean validating)
          Read the given stream with an XML parser and return the DOM tree structure.
static org.w3c.dom.Document readDOM(java.lang.String xmlFileName)
          Read the file with the given name as XML stream and return the DOM tree structure.
static org.w3c.dom.Document readDOM(java.lang.String xmlFileName, boolean validating)
          Read the file with the given name as XML stream and return the DOM tree structure.
static Element readFrom(java.io.File file, boolean validating)
          Read the given file as XML stream and return the element structure.
static Element readFrom(java.io.InputStream xmlStream)
          Read the given stream with an XML parser and return the element structure.
static Element readFrom(java.io.InputStream xmlStream, boolean validating)
          Read the given stream with an XML parser and return the element structure.
static Element readFrom(java.io.InputStream xmlStream, java.lang.String uri, boolean validating)
          Read the given stream with an XML parser and return the element structure.
static Element readFrom(java.lang.String xmlFileName)
          Read the file with the given name as XML stream and return the element structure.
static Element readFrom(java.lang.String xmlFileName, boolean validating)
          Read the file with the given name as XML stream and return the element structure.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFrom

public static Element readFrom(java.lang.String xmlFileName)
Read the file with the given name as XML stream and return the element structure.

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlFileName - The name of the file to read
Returns:
The element tree representing the XML file or null in case of exceptions

readFrom

public static Element readFrom(java.lang.String xmlFileName,
                               boolean validating)
Read the file with the given name as XML stream and return the element structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlFileName - The name of the file to read
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML file or null in case of exceptions

readFrom

public static Element readFrom(java.io.File file,
                               boolean validating)
Read the given file as XML stream and return the element structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
file - The file to read
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML file or null in case of exceptions

readFrom

public static Element readFrom(java.io.InputStream xmlStream,
                               java.lang.String uri,
                               boolean validating)
Read the given stream with an XML parser and return the element structure. The second argument is the URI of the stream to enable the lookup for the DTD. The third argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlStream - The XML stream to read
uri - The URI of the stream
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML file or null in case of exceptions

readDOM

public static org.w3c.dom.Document readDOM(java.lang.String xmlFileName)
Read the file with the given name as XML stream and return the DOM tree structure.

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlFileName - The name of the file to read
Returns:
The document tree representing the XML file or null in case of exceptions

readDOM

public static org.w3c.dom.Document readDOM(java.lang.String xmlFileName,
                                           boolean validating)
Read the file with the given name as XML stream and return the DOM tree structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlFileName - The name of the file to read
validating - if true the parser will validate against any defined DTD
Returns:
The document tree representing the XML file or null in case of exceptions

readDOM

public static org.w3c.dom.Document readDOM(java.io.File file,
                                           boolean validating)
Read the given file as XML stream and return the DOM tree structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
file - The file to read
validating - if true the parser will validate against any defined DTD
Returns:
The DOM tree representing the XML file or null in case of exceptions

readDOM

public static org.w3c.dom.Document readDOM(java.io.InputStream xmlStream,
                                           java.lang.String uri,
                                           boolean validating)
Read the given stream with an XML parser and return the DOM tree structure. The second argument is the URI of the stream to enable the lookup for the DTD. The third argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlStream - The XML stream to read
uri - The URI of the stream
validating - if true the parser will validate against any defined DTD
Returns:
The DOM tree representing the XML from the given stream or null in case of exceptions

readFrom

public static Element readFrom(java.io.InputStream xmlStream,
                               boolean validating)
Read the given stream with an XML parser and return the element structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlStream - The XML stream to read
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML from the given stream or null in case of exceptions

readFrom

public static Element readFrom(java.io.InputStream xmlStream)
Read the given stream with an XML parser and return the element structure. The parser will not validate the file against any DTD.

All exceptions will be caught and logged using the current component logger (see LoggerProvider).

Parameters:
xmlStream - The XML stream to read
Returns:
The element tree representing the XML from the given stream or null in case of exceptions

loadFrom

public static Element loadFrom(java.io.InputStream xmlStream)
                        throws java.io.IOException,
                               org.xml.sax.SAXException,
                               javax.xml.parsers.ParserConfigurationException
Read the given stream with an XML parser and return the element structure. The parser will not validate the file against any DTD.

Parameters:
xmlStream - The XML stream to read
Returns:
The element tree representing the XML from the given stream
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details

loadFrom

public static Element loadFrom(java.io.InputStream xmlStream,
                               boolean validating)
                        throws java.io.IOException,
                               org.xml.sax.SAXException,
                               javax.xml.parsers.ParserConfigurationException
Read the given stream with an XML parser and return the element structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

Parameters:
xmlStream - The XML stream to read
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML from the given stream
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details

loadFrom

public static Element loadFrom(java.io.InputStream xmlStream,
                               java.lang.String uri,
                               boolean validating)
                        throws java.io.IOException,
                               org.xml.sax.SAXException,
                               javax.xml.parsers.ParserConfigurationException
Read the given stream with an XML parser and return the element structure. The second argument is the URI of the stream to enable the lookup for the DTD. The third argument specifies whether or not the parser should validate the file against its DTD (if defined).

Parameters:
xmlStream - The XML stream to read
uri - The URI of the stream
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML from the given stream
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details

loadFrom

public static Element loadFrom(org.xml.sax.InputSource source,
                               boolean validating)
                        throws java.io.IOException,
                               org.xml.sax.SAXException,
                               javax.xml.parsers.ParserConfigurationException
Read the given input source with an XML parser and return the element structure. The second argument specifies whether or not the parser should validate the file against its DTD (if defined).

Parameters:
source - The input source that contains the XML stream to read
validating - if true the parser will validate against any defined DTD
Returns:
The element tree representing the XML from the given stream
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details

loadDOM

public static org.w3c.dom.Document loadDOM(java.io.InputStream xmlStream,
                                           java.lang.String uri,
                                           boolean validating)
                                    throws java.io.IOException,
                                           org.xml.sax.SAXException,
                                           javax.xml.parsers.ParserConfigurationException
Read the given stream with an XML parser and return the DOM tree structure. The second argument is the URI of the stream to enable the lookup for the DTD. The third argument specifies whether or not the parser should validate the file against its DTD (if defined).

Parameters:
xmlStream - The XML stream to read
uri - The URI of the stream
validating - if true the parser will validate against any defined DTD
Returns:
The DOM tree representing the XML file
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details

loadDOM

public static org.w3c.dom.Document loadDOM(org.xml.sax.InputSource source,
                                           boolean validating)
                                    throws java.io.IOException,
                                           org.xml.sax.SAXException,
                                           javax.xml.parsers.ParserConfigurationException
Read the given source with an XML parser and return the DOM tree structure. The second argument is the URI of the stream to enable the lookup for the DTD. The third argument specifies whether or not the parser should validate the file against its DTD (if defined).

Parameters:
source - The input source that contains the XML stream to read
validating - if true the parser will validate against any defined DTD
Returns:
The DOM tree representing the XML file
Throws:
java.io.IOException - If anything is wrong with reading the stream
javax.xml.parsers.ParserConfigurationException - See javax.xml.parsers for details
org.xml.sax.SAXException - See org.xml.sax for details