Package groovy.xml
Class NamespaceBuilderSupport
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.util.BuilderSupport
groovy.xml.NamespaceBuilderSupport
- All Implemented Interfaces:
GroovyObject
A helper class for creating namespaced GroovyMarkup
-
Constructor Summary
ConstructorsConstructorDescriptionNamespaceBuilderSupport(BuilderSupport builder) Creates a namespace-aware wrapper around the supplied builder.NamespaceBuilderSupport(BuilderSupport builder, String uri) Creates a namespace-aware wrapper and binds the default prefix to the supplied namespace URI.NamespaceBuilderSupport(BuilderSupport builder, String uri, String prefix) Creates a namespace-aware wrapper and binds the supplied prefix to the supplied namespace URI.NamespaceBuilderSupport(BuilderSupport builder, String uri, String prefix, boolean autoPrefix) Creates a namespace-aware wrapper with optional automatic prefixing for unqualified method names.NamespaceBuilderSupport(BuilderSupport builder, Map nsMap) Creates a namespace-aware wrapper using the supplied prefix-to-URI mappings. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectcreateNode(Object name) Builder lifecycle callback that keeps the resolved node name for the wrapped builder.protected ObjectcreateNode(Object name, Object value) Builder lifecycle callback that keeps the resolved node name for the wrapped builder.protected ObjectcreateNode(Object name, Map attributes) Builder lifecycle callback that keeps the resolved node name for the wrapped builder.protected ObjectcreateNode(Object name, Map attributes, Object value) Builder lifecycle callback that keeps the resolved node name for the wrapped builder.declareNamespace(Map nsMap) Replaces the current namespace mappings used to resolve subsequent builder calls.protected ObjectBuilder lifecycle callback that exposes the wrapped builder's current node.protected ObjectResolves a builder method name into a namespace-aware node name.invokeMethod(String methodName, Object args) Allow automatic detection of namespace declared in the attributesAssociates the default prefix with the supplied namespace URI.Associates the supplied prefix with the supplied namespace URI.protected voidsetCurrent(Object current) Builder lifecycle callback that updates the wrapped builder's current node marker.protected voidBuilder lifecycle callback invoked after a child node has been created.Methods inherited from class groovy.util.BuilderSupport
doInvokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegateMethods 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
-
NamespaceBuilderSupport
Creates a namespace-aware wrapper around the supplied builder.- Parameters:
builder- the builder to wrap
-
NamespaceBuilderSupport
Creates a namespace-aware wrapper and binds the default prefix to the supplied namespace URI.- Parameters:
builder- the builder to wrapuri- the namespace URI to bind to the default prefix
-
NamespaceBuilderSupport
Creates a namespace-aware wrapper and binds the supplied prefix to the supplied namespace URI.- Parameters:
builder- the builder to wrapuri- the namespace URI to bindprefix- the prefix to associate withuri
-
NamespaceBuilderSupport
public NamespaceBuilderSupport(BuilderSupport builder, String uri, String prefix, boolean autoPrefix) Creates a namespace-aware wrapper with optional automatic prefixing for unqualified method names.- Parameters:
builder- the builder to wrapuri- the namespace URI to bindprefix- the prefix to associate withuriautoPrefix- whether the configured prefix should be applied automatically
-
NamespaceBuilderSupport
Creates a namespace-aware wrapper using the supplied prefix-to-URI mappings.- Parameters:
builder- the builder to wrapnsMap- the namespace mappings to use
-
-
Method Details
-
namespace
Associates the default prefix with the supplied namespace URI.- Parameters:
namespaceURI- the namespace URI to bind- Returns:
- this wrapper
-
namespace
Associates the supplied prefix with the supplied namespace URI.- Parameters:
namespaceURI- the namespace URI to bindprefix- the prefix to associate withnamespaceURI- Returns:
- this wrapper
-
declareNamespace
Replaces the current namespace mappings used to resolve subsequent builder calls.- Parameters:
nsMap- the prefix-to-URI mappings to use- Returns:
- this wrapper
-
getCurrent
Builder lifecycle callback that exposes the wrapped builder's current node. Subclasses may override to customize how builder state is shared.- Overrides:
getCurrentin classBuilderSupport- Returns:
- the wrapped builder's current node marker
-
setCurrent
Builder lifecycle callback that updates the wrapped builder's current node marker. Subclasses may override to customize how builder state is shared.- Overrides:
setCurrentin classBuilderSupport- Parameters:
current- the new current node marker
-
setParent
Builder lifecycle callback invoked after a child node has been created. This implementation is a no-op because parent handling is delegated to the wrapped builder.- Specified by:
setParentin classBuilderSupport- Parameters:
parent- the parent node markerchild- the child node marker
-
getName
Resolves a builder method name into a namespace-aware node name. Subclasses may override to customize method-to-QNameresolution.- Overrides:
getNamein classBuilderSupport- Parameters:
methodName- the method name invoked on the wrapper- Returns:
- a
QNamewhen a namespace mapping is available, otherwise the original method name
-
invokeMethod
Allow automatic detection of namespace declared in the attributes- Specified by:
invokeMethodin interfaceGroovyObject- Overrides:
invokeMethodin classBuilderSupport- Parameters:
methodName- the builder method being invokedargs- the builder arguments, including any attribute map- Returns:
- the result from the wrapped builder invocation
-
createNode
Builder lifecycle callback that keeps the resolved node name for the wrapped builder.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the resolved node name- Returns:
- the same node name
-
createNode
Builder lifecycle callback that keeps the resolved node name for the wrapped builder.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the resolved node namevalue- the node value supplied by the builder call- Returns:
- the same node name
-
createNode
Builder lifecycle callback that keeps the resolved node name for the wrapped builder.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the resolved node nameattributes- the attributes supplied by the builder call- Returns:
- the same node name
-
createNode
Builder lifecycle callback that keeps the resolved node name for the wrapped builder.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the resolved node nameattributes- the attributes supplied by the builder callvalue- the node value supplied by the builder call- Returns:
- the same node name
-