Package org.jdesktop.dom
Class SimpleDocumentBuilder
java.lang.Object
javax.xml.parsers.DocumentBuilder
org.jdesktop.dom.SimpleDocumentBuilder
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).
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new SimpleDocumentBuilder.SimpleDocumentBuilder(boolean namespaceAware)SimpleDocumentBuilder(DocumentBuilderFactory factory)Create a SimpleDocumentBuilder that will wrap builders created from the given factory. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanparse(InputStream is)parse(InputStream is, String systemId)parse(InputSource is)parseString(String xml)Parse the content of the given String as an XML document and return a new DOMSimpleDocumentobject.voidreset()voidvoidstatic SimpleDocumentsimpleParse(InputStream in)Parse the content of the givenInputStreamas an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(InputStream in, boolean namespaceAware)Parse the content of the givenInputStreamas an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(String xml)Parse the content of the given String as an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(String xml, boolean namespaceAware)Parse the content of the given String as an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(URL url)Parse the content of the given URL as an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(URL url, boolean namespaceAware)Parse the content of the given URL as an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(InputSource is)Parse the content of the given input source as an XML document and return a new DOMSimpleDocumentobject.static SimpleDocumentsimpleParse(InputSource is, boolean namespaceAware)Parse the content of the given input source as an XML document and return a new DOMSimpleDocumentobject.
-
Constructor Details
-
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
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 Details
-
parseString
Parse the content of the given String as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if the String is null.- Parameters:
xml- String containing the content to be parsed.- Returns:
SimpleDocumentresult of parsing the String- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenxmlisnull- See Also:
DocumentHandler
-
parse
- Specified by:
parsein classDocumentBuilder- Throws:
SAXExceptionIOException
-
parse
- Overrides:
parsein classDocumentBuilder- Throws:
SAXExceptionIOException
-
parse
- Overrides:
parsein classDocumentBuilder- Throws:
SAXExceptionIOException
-
parse
- Overrides:
parsein classDocumentBuilder- Throws:
SAXExceptionIOException
-
parse
- Overrides:
parsein classDocumentBuilder- Throws:
SAXExceptionIOException
-
isNamespaceAware
public boolean isNamespaceAware()- Specified by:
isNamespaceAwarein classDocumentBuilder
-
isValidating
public boolean isValidating()- Specified by:
isValidatingin classDocumentBuilder
-
setEntityResolver
- Specified by:
setEntityResolverin classDocumentBuilder
-
setErrorHandler
- Specified by:
setErrorHandlerin classDocumentBuilder
-
newDocument
- Specified by:
newDocumentin classDocumentBuilder
-
getDOMImplementation
- Specified by:
getDOMImplementationin classDocumentBuilder
-
reset
public void reset()- Overrides:
resetin classDocumentBuilder
-
getSchema
- Overrides:
getSchemain classDocumentBuilder
-
isXIncludeAware
public boolean isXIncludeAware()- Overrides:
isXIncludeAwarein classDocumentBuilder
-
simpleParse
Parse the content of the given input source as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if theInputSourceisnullnull.- Parameters:
is- InputSource containing the content to be parsed.- Returns:
- A new DOM SimpleDocument object.
- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenisisnull- See Also:
DocumentHandler
-
simpleParse
Parse the content of the givenInputStreamas an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if theInputStreamis null.- Parameters:
is- InputStream containing the content to be parsed.- Returns:
SimpleDocumentresult of parsing theInputStream- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenisisnull- See Also:
DocumentHandler
-
simpleParse
Parse the content of the given URL as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if the URI isnullnull.- Parameters:
uri- The location of the content to be parsed.- Returns:
- A new DOM SimpleDocument object.
- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenurlisnull- See Also:
DocumentHandler
-
simpleParse
Parse the content of the given String as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if the String is null.- Parameters:
xml- String containing the content to be parsed.- Returns:
SimpleDocumentresult of parsing the String- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenxmlisnull- See Also:
DocumentHandler
-
simpleParse
public static SimpleDocument simpleParse(InputSource is, boolean namespaceAware) throws SAXException, IOExceptionParse the content of the given input source as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if theInputSourceisnullnull.- Parameters:
is- InputSource containing the content to be parsed.namespaceAware- whether the parser should be namespace aware- Returns:
- A new DOM SimpleDocument object.
- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenisisnull- See Also:
DocumentHandler
-
simpleParse
public static SimpleDocument simpleParse(InputStream in, boolean namespaceAware) throws SAXException, IOExceptionParse the content of the givenInputStreamas an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if theInputStreamis null.- Parameters:
in- InputStream containing the content to be parsed.namespaceAware- whether the parser should be namespace aware- Returns:
SimpleDocumentresult of parsing theInputStream- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenisisnull- See Also:
DocumentHandler
-
simpleParse
public static SimpleDocument simpleParse(URL url, boolean namespaceAware) throws SAXException, IOExceptionParse the content of the given URL as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if the URI isnullnull.- Parameters:
url- The location of the content to be parsed.namespaceAware- whether the parser should be namespace aware- Returns:
- A new DOM SimpleDocument object.
- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenurlisnull- See Also:
DocumentHandler
-
simpleParse
public static SimpleDocument simpleParse(String xml, boolean namespaceAware) throws SAXException, IOExceptionParse the content of the given String as an XML document and return a new DOMSimpleDocumentobject. AnIllegalArgumentExceptionis thrown if the String is null.- Parameters:
xml- String containing the content to be parsed.namespaceAware- whether the parser should be namespace aware- Returns:
SimpleDocumentresult of parsing the String- Throws:
IOException- If any IO errors occur.SAXException- If any parse errors occur.IllegalArgumentException- Whenxmlisnull- See Also:
DocumentHandler
-