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(DocumentBuilder documentBuilder)DOMBuilder(Document document)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendNamespaceAttributes(Element element, Map<Object,Object> attributes)protected DocumentcreateDocument()protected ObjectcreateNode(Object name)protected ObjectcreateNode(Object name, Object value)protected ObjectcreateNode(Object name, Map attributes)protected ObjectcreateNode(Object name, Map attributes, Object value)static DOMBuildernewInstance()static DOMBuildernewInstance(boolean validating, boolean namespaceAware)static Documentparse(Reader reader)Creates a DocumentBuilder and uses it to parse the XML text read from the given reader.static Documentparse(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 Documentparse(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.DocumentparseText(String text)A helper method to parse the given text as XML.protected voidsetParent(Object parent, Object child)- 
Methods inherited from class groovy.util.BuilderSupportdoInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate, setCurrent
 - 
Methods inherited from class groovy.lang.GroovyObjectSupportgetMetaClass, setMetaClass
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface groovy.lang.GroovyObjectgetProperty, setProperty
 
- 
 
- 
- 
- 
Constructor Detail- 
DOMBuilderpublic DOMBuilder(Document document) 
 - 
DOMBuilderpublic DOMBuilder(DocumentBuilder documentBuilder) 
 
- 
 - 
Method Detail- 
newInstancepublic static DOMBuilder newInstance() throws ParserConfigurationException - Throws:
- ParserConfigurationException
 
 - 
newInstancepublic static DOMBuilder newInstance(boolean validating, boolean namespaceAware) throws ParserConfigurationException - Throws:
- ParserConfigurationException
 
 - 
parsepublic static Document parse(Reader reader) throws SAXException, IOException, ParserConfigurationException Creates 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:
- SAXException- Any SAX exception, possibly wrapping another exception.
- IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
- See Also:
- parse(Reader, boolean, boolean)
 
 - 
parsepublic static Document parse(Reader reader, boolean validating, boolean namespaceAware) throws SAXException, IOException, ParserConfigurationException 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. 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:
- SAXException- Any SAX exception, possibly wrapping another exception.
- IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
 
 - 
parsepublic static Document parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) throws SAXException, IOException, ParserConfigurationException 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.- 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:
- SAXException- Any SAX exception, possibly wrapping another exception.
- IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
 
 - 
parseTextpublic Document parseText(String text) throws SAXException, IOException, ParserConfigurationException A 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:
- SAXException- Any SAX exception, possibly wrapping another exception.
- IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
- ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
- See Also:
- parse(Reader)
 
 - 
setParentprotected void setParent(Object parent, Object child) - Specified by:
- setParentin class- BuilderSupport
 
 - 
createNodeprotected Object createNode(Object name) - Specified by:
- createNodein class- BuilderSupport
 
 - 
createDocumentprotected Document createDocument() 
 - 
createNodeprotected Object createNode(Object name, Object value) - Specified by:
- createNodein class- BuilderSupport
 
 - 
createNodeprotected Object createNode(Object name, Map attributes, Object value) - Specified by:
- createNodein class- BuilderSupport
 
 - 
createNodeprotected Object createNode(Object name, Map attributes) - Specified by:
- createNodein class- BuilderSupport
 
 
- 
 
-