com.legstar.dom
Class DocumentFactory

java.lang.Object
  extended by com.legstar.dom.DocumentFactory

public final class DocumentFactory
extends Object

Builds a DOM document from an input stream.

Uses a new document builder with any useful attributes.

This is not thread safe.


Method Summary
static Document create()
          Creates a new, empty, DOM document.
protected static com.legstar.dom.DocumentFactory.ParsingErrorHandler initBuilder()
          Creates a builder if it is not there and associate an error handler.
static Document parse(File file)
          Parse an input file and return a new DOM document.
static Document parse(InputStream in)
          Parse an input stream and return a new DOM document.
static Document parse(String xml)
          Parse an input string and return a new DOM document.
static Document parse(URI uri)
          Parse an input URI and return a new DOM document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Document create()
                       throws Exception
Creates a new, empty, DOM document.

Returns:
a DOM document
Throws:
Exception - if creation fails

parse

public static Document parse(InputStream in)
                      throws InvalidDocumentException
Parse an input stream and return a new DOM document.

Parameters:
in - the input stream
Returns:
the DOM document
Throws:
InvalidDocumentException - if parsing failed

parse

public static Document parse(URI uri)
                      throws InvalidDocumentException
Parse an input URI and return a new DOM document.

Parameters:
uri - the input URI (relative or absolute)
Returns:
the DOM document
Throws:
InvalidDocumentException - if parsing failed

initBuilder

protected static com.legstar.dom.DocumentFactory.ParsingErrorHandler initBuilder()
                                                                          throws InvalidDocumentException
Creates a builder if it is not there and associate an error handler.

This is not thread safe.

Returns:
and error handler associated with the builder
Throws:
InvalidDocumentException - if initialization fails

parse

public static Document parse(File file)
                      throws InvalidDocumentException
Parse an input file and return a new DOM document.

Parameters:
file - the input file
Returns:
the DOM document
Throws:
InvalidDocumentException - if parsing failed

parse

public static Document parse(String xml)
                      throws InvalidDocumentException
Parse an input string and return a new DOM document.

Parameters:
file - the input file
Returns:
the DOM document
Throws:
InvalidDocumentException - if parsing failed


Copyright © 2012 LegSem. All Rights Reserved.