Package: groovy.xml

## [Java] Class NamespaceBuilderSupport

- groovy.xml.NamespaceBuilderSupport

-     public class NamespaceBuilderSupport
      extends BuilderSupport

  A helper class for creating namespaced GroovyMarkup

- - ### Constructor Summary

    Constructors
    Constructor and 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.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and 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.
    `` | `public 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.
    `` | `public Object` | `invokeMethod(String methodName, Object args)` Allow automatic detection of namespace declared in the attributes
    `` | `public NamespaceBuilderSupport` | `namespace(String namespaceURI)` Associates the default prefix with the supplied namespace URI.
    `` | `public 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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BuilderSupport` | `createNode, createNode, createNode, createNode, doInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate, setCurrent, setParent`
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Constructor Detail

    - #### public NamespaceBuilderSupport(BuilderSupport builder)

      Creates a namespace-aware wrapper around the supplied builder.

      Parameters:
        `builder` - the builder to wrap

    - #### 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

    - #### 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`

    - #### 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

    - #### 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 Detail

    - #### protected Object createNode(Object name)

      Builder lifecycle callback that keeps the resolved node name for the wrapped builder.

      Parameters:
        `name` - the resolved node name
      Returns:
        the same node name

    - #### protected Object createNode(Object name, Object value)

      Builder lifecycle callback that keeps the resolved node name for the wrapped builder.

      Parameters:
        `name` - the resolved node name
        `value` - the node value supplied by the builder call
      Returns:
        the same node name

    - #### protected Object createNode(Object name, Map attributes)

      Builder lifecycle callback that keeps the resolved node name for the wrapped builder.

      Parameters:
        `name` - the resolved node name
        `attributes` - the attributes supplied by the builder call
      Returns:
        the same node name

    - #### protected Object createNode(Object name, Map attributes, Object value)

      Builder lifecycle callback that keeps the resolved node name for the wrapped builder.

      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

    - #### 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

    - #### protected Object getCurrent()

      Builder lifecycle callback that exposes the wrapped builder's current node. Subclasses may override to customize how builder state is shared.

      Returns:
        the wrapped builder's current node marker

    - #### 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.

      Parameters:
        `methodName` - the method name invoked on the wrapper
      Returns:
        a QName when a namespace mapping is available, otherwise the original method name

    - #### public Object invokeMethod(String methodName, Object args)

      Allow automatic detection of namespace declared in the attributes

      Parameters:
        `methodName` - the builder method being invoked
        `args` - the builder arguments, including any attribute map
      Returns:
        the result from the wrapped builder invocation

    - #### public NamespaceBuilderSupport namespace(String namespaceURI)

      Associates the default prefix with the supplied namespace URI.

      Parameters:
        `namespaceURI` - the namespace URI to bind
      Returns:
        this wrapper

    - #### 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

    - #### 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.

      Parameters:
        `current` - the new current node marker

    - #### 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.

      Parameters:
        `parent` - the parent node marker
        `child` - the child node marker