org.n52.security.common.xml
Class DOMParser

java.lang.Object
  extended by org.n52.security.common.xml.DOMParser

public abstract class DOMParser
extends java.lang.Object

Class DOMParser encapsulates the common usage of the DocumentBuilder class within a this helpfull DOMParser class.

At first it is designed for performance, such as you can discover a pooling DomParser, what is recommended. Only in very few situations you need a non pooling DOMParser.

To simple use simple use the DOMParser.createNew() method, than you use the best performance.

At next the DOMParser class uses a ClasspathEntityResolver, which ensures that the wrapped DocumentBuilder can always parse an XMLFile, and entities are only discovered within the classpath.

The DOMParser class uses the factory method pattern, there with you can create DOMParsers by using the static methodds createPoolingParser() and createNonPoolingParser().

For fast creation of empty xml documents, or for in memory creation of DOM documents use the createEmptyDocument() method.

Version:
$Revision: $
Author:
Marko Reiprecht Created on 24.03.2008

Constructor Summary
DOMParser()
           
 
Method Summary
protected static javax.xml.parsers.DocumentBuilder createDocumentBuilder(DOMParserOptions parseroptions)
          Method creates a new DocumentBuilder with the given attributes.
static org.w3c.dom.Document createEmptyDocument()
          Method creates an empty Document.
static org.w3c.dom.Document createEmptyDocument(DOMParserOptions options)
          Method creates an empty Document for the given options.
static DOMParser createNew()
          Method creates a new DOMParser.
static DOMParser createNew(DOMParserOptions options)
          Method creates a new DOMParser.
static DOMParser createNonPoolingParser()
          Method creates a non pooling Parser, with default options.
static DOMParser createNonPoolingParser(DOMParserOptions options)
          Method creates a non pooling Parser, with the given options.
static DOMParser createPoolingParser()
          Method creates a pooling Parser with default options and using the global DocumentBuilder pool.
static DOMParser createPoolingParser(DOMParserOptions options)
          Method creates a pooling Parser with the given options, using the global DocumentBuilder pool.
static DOMParser createPoolingParser(DOMParserOptions options, DocumentBuilderPool pool)
          Method creates a pooling Parser with the given options, which uses the given document builder pool.
static org.xml.sax.EntityResolver getDefaultEntityResolver()
          Method gets the defaultEntityResolver.
 org.w3c.dom.Document parse(org.xml.sax.InputSource inputSource)
          Method parses the inputsource.
 org.w3c.dom.Document parse(org.xml.sax.InputSource inputSource, org.xml.sax.ErrorHandler errorhandler)
          Method parses the inputsource and informs the error handler about errors.
abstract  org.w3c.dom.Document parse(org.xml.sax.InputSource source, org.xml.sax.ErrorHandler errorhandler, org.xml.sax.EntityResolver entityResolver)
          Method parses the inputsource using the errorhandler and entityresolver.
static void setDefaultEntityResolver(org.xml.sax.EntityResolver defaultresolver)
          Method sets the defaultEntityResolver.
static void setDocumentBuilderPool(DocumentBuilderPool builderPool)
          Method sets the documentBuilderPool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMParser

public DOMParser()
Method Detail

getDefaultEntityResolver

public static org.xml.sax.EntityResolver getDefaultEntityResolver()
Method gets the defaultEntityResolver.

By default this method creates a ClasspathEntityResolver in quite mode, which means the parsing will never fail because of non existing entities (e.g. dtd's).

Returns:
EntityResolver.

setDefaultEntityResolver

public static void setDefaultEntityResolver(org.xml.sax.EntityResolver defaultresolver)
Method sets the defaultEntityResolver.

the default entity resolver is set on each new created DocumentBuilder.

Parameters:
defaultresolver - the defaultEntityResolver.

setDocumentBuilderPool

public static void setDocumentBuilderPool(DocumentBuilderPool builderPool)
Method sets the documentBuilderPool.

Parameters:
builderPool - the documentBuilderPool.

createDocumentBuilder

protected static javax.xml.parsers.DocumentBuilder createDocumentBuilder(DOMParserOptions parseroptions)
Method creates a new DocumentBuilder with the given attributes.

Parameters:
parseroptions - options for the new parser.
Returns:
DocumentBuilder.

createEmptyDocument

public static org.w3c.dom.Document createEmptyDocument()
Method creates an empty Document.

Returns:
Document.

createEmptyDocument

public static org.w3c.dom.Document createEmptyDocument(DOMParserOptions options)
Method creates an empty Document for the given options.

Parameters:
options - the options.
Returns:
Document.

createNew

public static DOMParser createNew()
Method creates a new DOMParser. This method shall be used by dependend classes, it will delegate to createPoolingParser() methods, so it uses the fastest approach.

Returns:
DOMParser.

createNew

public static DOMParser createNew(DOMParserOptions options)
Method creates a new DOMParser. This method shall be used by dependend classes, it will delegate to createPoolingParser() methods, so it uses the fastest aproach.

Parameters:
options - the options.
Returns:
DOMParser.

createNonPoolingParser

public static DOMParser createNonPoolingParser()
Method creates a non pooling Parser, with default options.

Returns:
DOMParser.

createNonPoolingParser

public static DOMParser createNonPoolingParser(DOMParserOptions options)
Method creates a non pooling Parser, with the given options.

Parameters:
options - the options.
Returns:
DOMParser.

createPoolingParser

public static DOMParser createPoolingParser()
Method creates a pooling Parser with default options and using the global DocumentBuilder pool.

Returns:
DOMParser.

createPoolingParser

public static DOMParser createPoolingParser(DOMParserOptions options)
Method creates a pooling Parser with the given options, using the global DocumentBuilder pool.

Parameters:
options - the options.
Returns:
DOMParser.

createPoolingParser

public static DOMParser createPoolingParser(DOMParserOptions options,
                                            DocumentBuilderPool pool)
Method creates a pooling Parser with the given options, which uses the given document builder pool.

Parameters:
options - the options.
pool - the document builder pool.
Returns:
DOMParser.

parse

public org.w3c.dom.Document parse(org.xml.sax.InputSource inputSource,
                                  org.xml.sax.ErrorHandler errorhandler)
                           throws DOMParserException
Method parses the inputsource and informs the error handler about errors.

Parameters:
inputSource - the inputSource.
errorhandler - the errorhandler.
Returns:
Document.
Throws:
DOMParserException - if an SAXException or IOException occurs.

parse

public abstract org.w3c.dom.Document parse(org.xml.sax.InputSource source,
                                           org.xml.sax.ErrorHandler errorhandler,
                                           org.xml.sax.EntityResolver entityResolver)
                                    throws DOMParserException
Method parses the inputsource using the errorhandler and entityresolver.

Parameters:
source - the source.
errorhandler - the errorhandler.
entityResolver - the entityResolver.
Returns:
Document.
Throws:
DOMParserException - if an SAXException or IOException occurs.

parse

public org.w3c.dom.Document parse(org.xml.sax.InputSource inputSource)
                           throws DOMParserException
Method parses the inputsource.

Parameters:
inputSource - the inputSource.
Returns:
Document.
Throws:
DOMParserException - if an SAXException or IOException occurs.


Copyright © 2004-2009 52north.org. All Rights Reserved.