Groovy Documentation

org.jdesktop.dom
[Java] Class SimpleDocumentBuilder

java.lang.Object
  javax.xml.parsers.DocumentBuilder
      org.jdesktop.dom.SimpleDocumentBuilder

public class SimpleDocumentBuilder
extends DocumentBuilder

A DOM DocumentBuilder implementation that does not require the factory pattern for creation. Most of the time calling one of the static simpleParse methods is all that is required. Occasionally you may need to create an instance of SimpleDocumentBuilder to tweak some of the builder settings (such as setting an ErrorHandler or EntityResolver).

Authors:
rbair


Field Summary
private static ThreadLocal NS_PARSER

private static ThreadLocal PARSER

private DocumentBuilder builder

 
Constructor Summary
SimpleDocumentBuilder()

Create a new SimpleDocumentBuilder.

SimpleDocumentBuilder(boolean namespaceAware)

SimpleDocumentBuilder(DocumentBuilderFactory factory)

Create a SimpleDocumentBuilder that will wrap builders created from the given factory.

 
Method Summary
org.w3c.dom.DOMImplementation getDOMImplementation()

@inheritDoc

Schema getSchema()

@inheritDoc

boolean isNamespaceAware()

@inheritDoc

boolean isValidating()

@inheritDoc

boolean isXIncludeAware()

@inheritDoc

SimpleDocument newDocument()

@inheritDoc

org.w3c.dom.Document newPlainDocument()

Returns:
an unenclosed Document.

SimpleDocument parse(InputSource is)

@inheritDoc

SimpleDocument parse(InputStream is)

@inheritDoc

SimpleDocument parse(InputStream is, String systemId)

@inheritDoc

SimpleDocument parse(String uri)

@inheritDoc

SimpleDocument parse(File f)

@inheritDoc

SimpleDocument parseString(String xml)

Parse the content of the given String as an XML document and return a new DOM SimpleDocument object.

void reset()

@inheritDoc

void setEntityResolver(EntityResolver er)

@inheritDoc

void setErrorHandler(ErrorHandler eh)

@inheritDoc

static SimpleDocument simpleParse(InputSource is)

Parse the content of the given input source as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(InputStream in)

Parse the content of the given InputStream as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(URL url)

Parse the content of the given URL as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(String xml)

Parse the content of the given String as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(InputSource is, boolean namespaceAware)

Parse the content of the given input source as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(InputStream in, boolean namespaceAware)

Parse the content of the given InputStream as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(URL url, boolean namespaceAware)

Parse the content of the given URL as an XML document and return a new DOM SimpleDocument object.

static SimpleDocument simpleParse(String xml, boolean namespaceAware)

Parse the content of the given String as an XML document and return a new DOM SimpleDocument object.

 
Methods inherited from class DocumentBuilder
reset, parse, parse, parse, parse, parse, setErrorHandler, setEntityResolver, isNamespaceAware, isValidating, newDocument, getDOMImplementation, getSchema, isXIncludeAware, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

NS_PARSER

private static ThreadLocal NS_PARSER


PARSER

private static ThreadLocal PARSER


builder

private DocumentBuilder builder


 
Constructor Detail

SimpleDocumentBuilder

public SimpleDocumentBuilder()
Create a new SimpleDocumentBuilder. SimpleDocumentBuilder will delegate parsing to the default DocumentBuilder constructed via the default DocumentBuilderFactory. This builder factory will be constructed to be namespace aware by default, unlike the traditional Document builders.


SimpleDocumentBuilder

public SimpleDocumentBuilder(boolean namespaceAware)


SimpleDocumentBuilder

public SimpleDocumentBuilder(DocumentBuilderFactory factory)
Create a SimpleDocumentBuilder that will wrap builders created from the given factory. This can be used to construct non-namespace aware documents, for example.


 
Method Detail

getDOMImplementation

public org.w3c.dom.DOMImplementation getDOMImplementation()
inheritDoc:


getSchema

public Schema getSchema()
inheritDoc:


isNamespaceAware

public boolean isNamespaceAware()
inheritDoc:


isValidating

public boolean isValidating()
inheritDoc:


isXIncludeAware

public boolean isXIncludeAware()
inheritDoc:


newDocument

public SimpleDocument newDocument()
inheritDoc:


newPlainDocument

org.w3c.dom.Document newPlainDocument()
Returns:
an unenclosed Document. This is used only by the SimpleDocument no arg constructor


parse

public SimpleDocument parse(InputSource is)
inheritDoc:


parse

public SimpleDocument parse(InputStream is)
inheritDoc:


parse

public SimpleDocument parse(InputStream is, String systemId)
inheritDoc:


parse

public SimpleDocument parse(String uri)
inheritDoc:


parse

public SimpleDocument parse(File f)
inheritDoc:


parseString

public SimpleDocument parseString(String xml)
Parse the content of the given String as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the String is null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When xml is null
Parameters:
xml - String containing the content to be parsed.
Returns:
SimpleDocument result of parsing the String
See Also:
DocumentHandler


reset

public void reset()
inheritDoc:


setEntityResolver

public void setEntityResolver(EntityResolver er)
inheritDoc:


setErrorHandler

public void setErrorHandler(ErrorHandler eh)
inheritDoc:


simpleParse

public static SimpleDocument simpleParse(InputSource is)
Parse the content of the given input source as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the InputSource is null null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When is is null
Parameters:
is - InputSource containing the content to be parsed.
Returns:
A new DOM SimpleDocument object.
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(InputStream in)
Parse the content of the given InputStream as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the InputStream is null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When is is null
Parameters:
is - InputStream containing the content to be parsed.
Returns:
SimpleDocument result of parsing the InputStream
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(URL url)
Parse the content of the given URL as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the URI is null null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When url is null
Parameters:
uri - The location of the content to be parsed.
Returns:
A new DOM SimpleDocument object.
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(String xml)
Parse the content of the given String as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the String is null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When xml is null
Parameters:
xml - String containing the content to be parsed.
Returns:
SimpleDocument result of parsing the String
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(InputSource is, boolean namespaceAware)
Parse the content of the given input source as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the InputSource is null null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When is is null
Parameters:
is - InputSource containing the content to be parsed.
namespaceAware - whether the parser should be namespace aware
Returns:
A new DOM SimpleDocument object.
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(InputStream in, boolean namespaceAware)
Parse the content of the given InputStream as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the InputStream is null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When is is null
Parameters:
in - InputStream containing the content to be parsed.
namespaceAware - whether the parser should be namespace aware
Returns:
SimpleDocument result of parsing the InputStream
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(URL url, boolean namespaceAware)
Parse the content of the given URL as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the URI is null null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When url is null
Parameters:
url - The location of the content to be parsed.
namespaceAware - whether the parser should be namespace aware
Returns:
A new DOM SimpleDocument object.
See Also:
DocumentHandler


simpleParse

public static SimpleDocument simpleParse(String xml, boolean namespaceAware)
Parse the content of the given String as an XML document and return a new DOM SimpleDocument object. An IllegalArgumentException is thrown if the String is null.
throws:
IOException If any IO errors occur.
throws:
SAXException If any parse errors occur.
throws:
IllegalArgumentException When xml is null
Parameters:
xml - String containing the content to be parsed.
namespaceAware - whether the parser should be namespace aware
Returns:
SimpleDocument result of parsing the String
See Also:
DocumentHandler


 

Groovy Documentation