Package groovy.xml
Class DOMBuilder
- java.lang.Object
- 
- groovy.lang.GroovyObjectSupport
- 
- groovy.util.BuilderSupport
- 
- groovy.xml.DOMBuilder
 
 
 
- 
- All Implemented Interfaces:
- GroovyObject
 
 public class DOMBuilder extends BuilderSupport A helper class for creating a W3C DOM tree
- 
- 
Constructor SummaryConstructors Constructor Description DOMBuilder(javax.xml.parsers.DocumentBuilder documentBuilder)DOMBuilder(org.w3c.dom.Document document)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendNamespaceAttributes(org.w3c.dom.Element element, java.util.Map<java.lang.Object,java.lang.Object> attributes)protected org.w3c.dom.DocumentcreateDocument()protected java.lang.ObjectcreateNode(java.lang.Object name)protected java.lang.ObjectcreateNode(java.lang.Object name, java.lang.Object value)protected java.lang.ObjectcreateNode(java.lang.Object name, java.util.Map attributes)protected java.lang.ObjectcreateNode(java.lang.Object name, java.util.Map attributes, java.lang.Object value)static DOMBuildernewInstance()static DOMBuildernewInstance(boolean validating, boolean namespaceAware)static org.w3c.dom.Documentparse(java.io.Reader reader)Creates a DocumentBuilder and uses it to parse the XML text read from the given reader.static org.w3c.dom.Documentparse(java.io.Reader reader, boolean validating, boolean namespaceAware)Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled.static org.w3c.dom.Documentparse(java.io.Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration)Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.org.w3c.dom.DocumentparseText(java.lang.String text)A helper method to parse the given text as XML.protected voidsetParent(java.lang.Object parent, java.lang.Object child)- 
Methods inherited from class groovy.util.BuilderSupportdoInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate, setCurrent
 - 
Methods inherited from class groovy.lang.GroovyObjectSupportgetMetaClass, getProperty, setMetaClass, setProperty
 
- 
 
- 
- 
- 
Method Detail- 
newInstancepublic static DOMBuilder newInstance() throws javax.xml.parsers.ParserConfigurationException - Throws:
- javax.xml.parsers.ParserConfigurationException
 
 - 
newInstancepublic static DOMBuilder newInstance(boolean validating, boolean namespaceAware) throws javax.xml.parsers.ParserConfigurationException - Throws:
- javax.xml.parsers.ParserConfigurationException
 
 - 
parsepublic static org.w3c.dom.Document parse(java.io.Reader reader) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationExceptionCreates a DocumentBuilder and uses it to parse the XML text read from the given reader. A non-validating, namespace aware parser which does not allow DOCTYPE declarations is used.- Parameters:
- reader- the reader to read the XML text from
- Returns:
- the root node of the parsed tree of Nodes
- Throws:
- org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.
- java.io.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- javax.xml.parsers.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
- See Also:
- parse(Reader, boolean, boolean)
 
 - 
parsepublic static org.w3c.dom.Document parse(java.io.Reader reader, boolean validating, boolean namespaceAware) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationExceptionCreates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled. Documents are not allowed to contain DOCYTYPE declarations.- Parameters:
- reader- the reader to read the XML text from
- validating- whether to validate the XML
- namespaceAware- whether the parser should be namespace aware
- Returns:
- the root node of the parsed tree of Nodes
- Throws:
- org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.
- java.io.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- javax.xml.parsers.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
 
 - 
parsepublic static org.w3c.dom.Document parse(java.io.Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationExceptionCreates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.- Parameters:
- reader- the reader to read the XML text from
- validating- whether to validate the XML
- namespaceAware- whether the parser should be namespace aware
- allowDocTypeDeclaration- whether the parser should allow DOCTYPE declarations
- Returns:
- the root node of the parsed tree of Nodes
- Throws:
- org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.
- java.io.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- javax.xml.parsers.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
 
 - 
parseTextpublic org.w3c.dom.Document parseText(java.lang.String text) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationExceptionA helper method to parse the given text as XML.- Parameters:
- text- the XML text to parse
- Returns:
- the root node of the parsed tree of Nodes
- Throws:
- org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.
- java.io.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- javax.xml.parsers.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
- See Also:
- parse(Reader)
 
 - 
setParentprotected void setParent(java.lang.Object parent, java.lang.Object child)- Specified by:
- setParentin class- BuilderSupport
 
 - 
createNodeprotected java.lang.Object createNode(java.lang.Object name) - Specified by:
- createNodein class- BuilderSupport
 
 - 
createDocumentprotected org.w3c.dom.Document createDocument() 
 - 
createNodeprotected java.lang.Object createNode(java.lang.Object name, java.lang.Object value)- Specified by:
- createNodein class- BuilderSupport
 
 - 
createNodeprotected java.lang.Object createNode(java.lang.Object name, java.util.Map attributes, java.lang.Object value)- Specified by:
- createNodein class- BuilderSupport
 
 - 
createNodeprotected java.lang.Object createNode(java.lang.Object name, java.util.Map attributes)- Specified by:
- createNodein class- BuilderSupport
 
 - 
appendNamespaceAttributesprotected void appendNamespaceAttributes(org.w3c.dom.Element element, java.util.Map<java.lang.Object,java.lang.Object> attributes)
 
- 
 
-