ca.infoway.messagebuilder.util.xml
Class DocumentFactory

Package class diagram package DocumentFactory
java.lang.Object
  extended by ca.infoway.messagebuilder.util.xml.DocumentFactory

public class DocumentFactory
extends Object

A class that simplifies the process of parsing XML documents.

Author:
Intelliware Development

Constructor Summary
DocumentFactory()
          Standard constructor.
DocumentFactory(EntityResolver entityResolver)
          Standard constructor.
 
Method Summary
protected  DocumentBuilder createDocumentBuilder()
           
 Document createFromByteArray(byte[] xml)
          Parse the byte array as XML.
 Document createFromFile(File xmlFile)
          Read in a file and parse it as XML.
 Document createFromResource(InputStreamResource resource)
          Read in a resource and parse it as XML.
 Document createFromStream(InputStream stream)
          Read in a stream and parse it as XML.
 Document createFromString(String xml)
          Parse the string as XML.
 Document newDocument()
          Create a new (blank) document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentFactory

public DocumentFactory()

Standard constructor.


DocumentFactory

public DocumentFactory(EntityResolver entityResolver)

Standard constructor.

Parameters:
entityResolver - - a class that can help resolve entity references.
Method Detail

createFromFile

public Document createFromFile(File xmlFile)
                        throws SAXException,
                               IOException

Read in a file and parse it as XML.

Parameters:
xmlFile - - the file that contains the XML
Returns:
- the DOM document.
Throws:
SAXException - - if the XML file cannot be parsed.
IOException - - if the file cannot be read.

createFromStream

public Document createFromStream(InputStream stream)
                          throws SAXException,
                                 IOException

Read in a stream and parse it as XML.

Parameters:
stream - - the stream that contains the XML
Returns:
- the DOM document.
Throws:
SAXException - - if the stream cannot be parsed as XML.
IOException - - if the stream cannot be read.

createFromString

public Document createFromString(String xml)
                          throws SAXException

Parse the string as XML.

Parameters:
xml - - the string that contains the XML
Returns:
- the DOM document.
Throws:
SAXException - - if the stream cannot be parsed as XML.

createFromResource

public Document createFromResource(InputStreamResource resource)
                            throws IOException,
                                   SAXException

Read in a resource and parse it as XML.

Parameters:
resource - - the resource that contains the XML
Returns:
- the DOM document.
Throws:
SAXException - - if the resource cannot be parsed as XML.
IOException - - if the resource cannot be read.

createFromByteArray

public Document createFromByteArray(byte[] xml)
                             throws SAXException

Parse the byte array as XML.

Parameters:
xml - - the byte array that contains the XML
Returns:
- the DOM document.
Throws:
SAXException - - if the byte array cannot be parsed as XML.

createDocumentBuilder

protected DocumentBuilder createDocumentBuilder()

newDocument

public Document newDocument()

Create a new (blank) document.

Returns:
- a new document


Copyright © 2013. All Rights Reserved.