Package groovy.xml

# Class NamespaceBuilderSupport

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.util.BuilderSupport
groovy.xml.NamespaceBuilderSupport

All Implemented Interfaces:
  `GroovyObject`

public class NamespaceBuilderSupport extends BuilderSupport
A helper class for creating namespaced GroovyMarkup

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NamespaceBuilderSupport(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 Type
  Method
  Description
  `protected Object`
  `createNode(Object name)`
  Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
  `protected Object`
  `createNode(Object name, Object value)`
  Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
  `protected Object`
  `createNode(Object name, Map attributes)`
  Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
  `protected Object`
  `createNode(Object name, Map attributes, Object value)`
  Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
  `NamespaceBuilderSupport`
  `declareNamespace(Map nsMap)`
  Replaces the current namespace mappings used to resolve subsequent builder calls.
  `protected Object`
  `getCurrent()`
  Builder lifecycle callback that exposes the wrapped builder's current node.
  `protected Object`
  `getName(String methodName)`
  Resolves a builder method name into a namespace-aware node name.
  `Object`
  `invokeMethod(String methodName, Object args)`
  Allow automatic detection of namespace declared in the attributes
  `NamespaceBuilderSupport`
  `namespace(String namespaceURI)`
  Associates the default prefix with the supplied namespace URI.
  `NamespaceBuilderSupport`
  `namespace(String namespaceURI, String prefix)`
  Associates the supplied prefix with the supplied namespace URI.
  `protected void`
  `setCurrent(Object current)`
  Builder lifecycle callback that updates the wrapped builder's current node marker.
  `protected void`
  `setParent(Object parent, Object child)`
  Builder lifecycle callback invoked after a child node has been created.

  ### Methods inherited from class groovy.util.BuilderSupport

  `doInvokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate`

  ### Methods inherited from class groovy.lang.GroovyObjectSupport

  `getMetaClass, setMetaClass`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface groovy.lang.GroovyObject

  `getProperty, setProperty`

- ## Constructor Details

  - ### NamespaceBuilderSupport

    public NamespaceBuilderSupport(BuilderSupport builder)
    Creates a namespace-aware wrapper around the supplied builder.
    Parameters:
      `builder` - the builder to wrap

  - ### NamespaceBuilderSupport

    public NamespaceBuilderSupport(BuilderSupport builder, String uri)
    Creates a namespace-aware wrapper and binds the default prefix to the supplied namespace URI.
    Parameters:
      `builder` - the builder to wrap
      `uri` - the namespace URI to bind to the default prefix

  - ### NamespaceBuilderSupport

    public NamespaceBuilderSupport(BuilderSupport builder, String uri, String prefix)
    Creates a namespace-aware wrapper and binds the supplied prefix to the supplied namespace URI.
    Parameters:
      `builder` - the builder to wrap
      `uri` - the namespace URI to bind
      `prefix` - the prefix to associate with `uri`

  - ### 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 wrap
      `uri` - the namespace URI to bind
      `prefix` - the prefix to associate with `uri`
      `autoPrefix` - whether the configured prefix should be applied automatically

  - ### NamespaceBuilderSupport

    public NamespaceBuilderSupport(BuilderSupport builder, Map nsMap)
    Creates a namespace-aware wrapper using the supplied prefix-to-URI mappings.
    Parameters:
      `builder` - the builder to wrap
      `nsMap` - the namespace mappings to use

- ## Method Details

  - ### namespace

    public NamespaceBuilderSupport namespace(String namespaceURI)
    Associates the default prefix with the supplied namespace URI.
    Parameters:
      `namespaceURI` - the namespace URI to bind
    Returns:
      this wrapper

  - ### namespace

    public NamespaceBuilderSupport namespace(String namespaceURI, String prefix)
    Associates the supplied prefix with the supplied namespace URI.
    Parameters:
      `namespaceURI` - the namespace URI to bind
      `prefix` - the prefix to associate with `namespaceURI`
    Returns:
      this wrapper

  - ### declareNamespace

    public NamespaceBuilderSupport declareNamespace(Map nsMap)
    Replaces the current namespace mappings used to resolve subsequent builder calls.
    Parameters:
      `nsMap` - the prefix-to-URI mappings to use
    Returns:
      this wrapper

  - ### getCurrent

    protected Object getCurrent()
    Builder lifecycle callback that exposes the wrapped builder's current node. Subclasses may override to customize how builder state is shared.
    Overrides:
      `getCurrent` in class `BuilderSupport`
    Returns:
      the wrapped builder's current node marker

  - ### setCurrent

    protected void setCurrent(Object current)
    Builder lifecycle callback that updates the wrapped builder's current node marker. Subclasses may override to customize how builder state is shared.
    Overrides:
      `setCurrent` in class `BuilderSupport`
    Parameters:
      `current` - the new current node marker

  - ### setParent

    protected void setParent(Object parent, Object child)
    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:
      `setParent` in class `BuilderSupport`
    Parameters:
      `parent` - the parent node marker
      `child` - the child node marker

  - ### getName

    protected Object getName(String methodName)
    Resolves a builder method name into a namespace-aware node name. Subclasses may override to customize method-to-`QName` resolution.
    Overrides:
      `getName` in class `BuilderSupport`
    Parameters:
      `methodName` - the method name invoked on the wrapper
    Returns:
      a `QName` when a namespace mapping is available, otherwise the original method name

  - ### invokeMethod

    public Object invokeMethod(String methodName, Object args)
    Allow automatic detection of namespace declared in the attributes
    Specified by:
      `invokeMethod` in interface `GroovyObject`
    Overrides:
      `invokeMethod` in class `BuilderSupport`
    Parameters:
      `methodName` - the builder method being invoked
      `args` - the builder arguments, including any attribute map
    Returns:
      the result from the wrapped builder invocation

  - ### createNode

    protected Object createNode(Object name)
    Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
    Specified by:
      `createNode` in class `BuilderSupport`
    Parameters:
      `name` - the resolved node name
    Returns:
      the same node name

  - ### createNode

    protected Object createNode(Object name, Object value)
    Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
    Specified by:
      `createNode` in class `BuilderSupport`
    Parameters:
      `name` - the resolved node name
      `value` - the node value supplied by the builder call
    Returns:
      the same node name

  - ### createNode

    protected Object createNode(Object name, Map attributes)
    Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
    Specified by:
      `createNode` in class `BuilderSupport`
    Parameters:
      `name` - the resolved node name
      `attributes` - the attributes supplied by the builder call
    Returns:
      the same node name

  - ### createNode

    protected Object createNode(Object name, Map attributes, Object value)
    Builder lifecycle callback that keeps the resolved node name for the wrapped builder.
    Specified by:
      `createNode` in class `BuilderSupport`
    Parameters:
      `name` - the resolved node name
      `attributes` - the attributes supplied by the builder call
      `value` - the node value supplied by the builder call
    Returns:
      the same node name