Package groovy.xml
Class SAXBuilder
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.util.BuilderSupport
groovy.xml.SAXBuilder
- All Implemented Interfaces:
GroovyObject
A builder for generating W3C SAX events. Use similar to MarkupBuilder.
-
Constructor Summary
ConstructorsConstructorDescriptionSAXBuilder(ContentHandler handler) Creates a builder that forwards markup events to the supplied SAX content handler. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectcreateNode(Object name) Builder lifecycle callback that starts an element with no attributes or body text.protected ObjectcreateNode(Object name, Object value) Builder lifecycle callback that starts an element and immediately emits text content.protected ObjectcreateNode(Object name, Map attributes) Builder lifecycle callback that starts an element and emits attributes without body text.protected ObjectcreateNode(Object name, Map attributeMap, Object text) Builder lifecycle callback that starts an element, emits attributes and optionally emits text content.protected voiddoStartElement(Object name, Attributes attributes) Emits a SAXstartElementevent for the supplied node name.protected voidHandles checkedSAXExceptions raised while emitting SAX events.protected voidnodeCompleted(Object parent, Object name) Builder lifecycle callback invoked when the current node is complete.protected voidBuilder lifecycle callback invoked after a child node has been created.Methods inherited from class groovy.util.BuilderSupport
doInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, postNodeCompletion, setClosureDelegate, setCurrentMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface groovy.lang.GroovyObject
getProperty, setProperty
-
Constructor Details
-
SAXBuilder
Creates a builder that forwards markup events to the supplied SAX content handler.- Parameters:
handler- the content handler receiving generated SAX events
-
-
Method Details
-
setParent
Builder lifecycle callback invoked after a child node has been created. This implementation is a no-op because parent relationships are expressed through SAX events.- Specified by:
setParentin classBuilderSupport- Parameters:
parent- the parent node markerchild- the child node marker
-
createNode
Builder lifecycle callback that starts an element with no attributes or body text.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the node name- Returns:
- the node marker used for subsequent callbacks
-
createNode
Builder lifecycle callback that starts an element and immediately emits text content.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the node namevalue- the text content to emit- Returns:
- the node marker used for subsequent callbacks
-
createNode
Builder lifecycle callback that starts an element, emits attributes and optionally emits text content.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the node nameattributeMap- the attributes to expose through the SAX eventtext- the optional text content to emit after the start element- Returns:
- the node marker used for subsequent callbacks
-
doStartElement
Emits a SAXstartElementevent for the supplied node name. Subclasses may override to customize how start-element events are generated.- Parameters:
name- the node nameattributes- the attributes to include with the start-element event
-
nodeCompleted
Builder lifecycle callback invoked when the current node is complete.- Overrides:
nodeCompletedin classBuilderSupport- Parameters:
parent- the parent node markername- the completed node name
-
handleException
Handles checkedSAXExceptions raised while emitting SAX events. Subclasses may override to translate them differently.- Parameters:
e- the SAX exception to handle- Throws:
RuntimeException- by default, wrappinge
-
createNode
Builder lifecycle callback that starts an element and emits attributes without body text.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the node nameattributes- the attributes to expose through the SAX event- Returns:
- the node marker used for subsequent callbacks
-