Package: groovy.util

## [Java] Class FactoryBuilderSupport

- groovy.util.FactoryBuilderSupport

-     public abstract class FactoryBuilderSupport
      extends Binding

  Mix of BuilderSupport and SwingBuilder's factory support. Warning: this implementation is not thread safe and should not be used across threads in a multithreaded environment. A locking mechanism should be implemented by the subclass if use is expected across multiple threads.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `CHILD_BUILDER` | Context key for the builder used to create child nodes.
    `static String` | `CURRENT_BUILDER` | Context key for the builder of the current node.
    `static String` | `CURRENT_FACTORY` | Context key for the factory creating the current node.
    `static String` | `CURRENT_NAME` | Context key for the current node name.
    `static String` | `CURRENT_NODE` | Context key for the current node.
    `static String` | `OWNER` | Context key for a nested closure owner.
    `static String` | `PARENT_BUILDER` | Context key for the builder of the parent node.
    `static String` | `PARENT_CONTEXT` | Context key for the parent node context.
    `static String` | `PARENT_FACTORY` | Context key for the factory that created the parent node.
    `static String` | `PARENT_NAME` | Context key for the parent node name.
    `static String` | `PARENT_NODE` | Context key for the parent node.
    `static String` | `SCRIPT_CLASS_NAME` | Binding key for the currently executing script class name.
    `protected LinkedList<Closure>` | `attributeDelegates` |
    `protected boolean` | `autoRegistrationComplete` | Tracks whether auto-registration has completed.
    `protected boolean` | `autoRegistrationRunning` | Tracks whether auto-registration is currently in progress.
    `protected Map<String, Closure>` | `explicitMethods` | Explicit methods exposed by the builder.
    `protected Map<String, Closure>` | `explicitProperties` | Explicit property accessors exposed by the builder.
    `protected Closure` | `methodMissingDelegate` | Fallback invoked when a builder method cannot be resolved.
    `protected LinkedList<Closure>` | `postInstantiateDelegates` | Delegates invoked after a factory creates a node.
    `protected LinkedList<Closure>` | `postNodeCompletionDelegates` | Delegates invoked after a node and its children are complete.
    `protected LinkedList<Closure>` | `preInstantiateDelegates` | Delegates invoked before a factory creates a node.
    `protected Closure` | `propertyMissingDelegate` | Fallback invoked when a builder property cannot be resolved.
    `protected Map<String, Set<String>>` | `registrationGroup` | Registered names grouped by registration phase.
    `protected String` | `registrationGroupName` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `FactoryBuilderSupport()` Creates a builder without performing automatic node registration.
    `FactoryBuilderSupport(boolean init)` Creates a builder and optionally performs automatic node registration.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Closure` | `addAttributeDelegate(Closure attrDelegate)` Add an attribute delegate so it can intercept attributes being set.
    `` | `public void` | `addDisposalClosure(Closure closure)` Registers a closure to run when the builder is disposed.
    `` | `public Closure` | `addPostInstantiateDelegate(Closure delegate)` Add a postInstantiate delegate so it can intercept nodes after they are created.
    `` | `public Closure` | `addPostNodeCompletionDelegate(Closure delegate)` Add a nodeCompletion delegate so it can intercept nodes after they done with building.
    `` | `public Closure` | `addPreInstantiateDelegate(Closure delegate)` Add a preInstantiate delegate so it can intercept nodes before they are created.
    `` | `public void` | `autoRegisterNodes()` Ask the nodes to be registered
    `` | `public Object` | `build(Class viewClass)` Runs a script class using this builder as its binding.
    `` | `public Object` | `build(Script script)` Runs a script instance using this builder as its binding.
    `` | `public Object` | `build(String script, GroovyClassLoader loader)` Parses and runs an inline script using the supplied class loader.
    `` | `protected boolean` | `checkExplicitMethod(String methodName, Object args, Reference result)` Resolves and invokes an explicit builder method if one is registered.
    `` | `public static void` | `checkValueIsNull(Object value, Object name)` Throws an exception if value is null.
    `` | `public static boolean` | `checkValueIsType(Object value, Object name, Class type)` Checks type of value against builder type
    `` | `public static boolean` | `checkValueIsTypeNotString(Object value, Object name, Class type)` Checks values against factory's type
    `` | `protected Object` | `createNode(Object name, Map attributes, Object value)` This method is responsible for instantiating a node and configure its properties.
    `` | `protected Object` | `dispatchNodeCall(Object name, Object args)` Dispatches a builder method call to node creation and nested closure handling.
    `` | `protected Object` | `dispathNodeCall(Object name, Object args)` Use FactoryBuilderSupport.dispatchNodeCall instead.
    `` | `public void` | `dispose()` Invokes registered disposal closures in reverse registration order.
    `` | `public List<Closure>` | `getAttributeDelegates()` Returns the active attribute delegates.
    `` | `public FactoryBuilderSupport` | `getChildBuilder()` Returns the builder currently used for child node creation.
    `` | `public Map<String, Object>` | `getContext()` Returns: the context of the current node.
    `` | `public Object` | `getContextAttribute(String key)` Looks up a value from the current builder context.
    `` | `protected LinkedList<Map<String, Object>>` | `getContexts()` Returns: the stack of available contexts.
    `` | `protected Map<String, Object>` | `getContinuationData()` Stores the thread local states in a Map that can be passed across threads
    `` | `public Object` | `getCurrent()` Returns: the current node being built.
    `` | `public FactoryBuilderSupport` | `getCurrentBuilder()` Returns: the builder that built the current node.
    `` | `public Factory` | `getCurrentFactory()` Returns: the factory that built the current node.
    `` | `public String` | `getCurrentName()` Returns: the factory of the parent of the current node.
    `` | `public List<Closure>` | `getDisposalClosures()` Returns the registered disposal closures.
    `` | `public Map<String, Closure>` | `getExplicitMethods()` Returns: the explicit methods map (Unmodifiable Map).
    `` | `public Map<String, Closure>` | `getExplicitProperties()` Returns: the explicit properties map (Unmodifiable Map).
    `` | `public Map<String, Factory>` | `getFactories()` Returns: the factory map (Unmodifiable Map).
    `` | `public Map<String, Closure>` | `getLocalExplicitMethods()` Returns: the explicit methods map (Unmodifiable Map).
    `` | `public Map<String, Closure>` | `getLocalExplicitProperties()` Returns: the explicit properties map (Unmodifiable Map).
    `` | `public Map<String, Factory>` | `getLocalFactories()` Returns: the factory map (Unmodifiable Map).
    `` | `public Closure` | `getMethodMissingDelegate()` Returns the method-missing fallback closure.
    `` | `public Object` | `getName(String methodName)` A hook to allow names to be converted into some other object such as a QName in XML or ObjectName in JMX.
    `` | `public Closure` | `getNameMappingClosure()` Returns the closure that maps method names to builder names.
    `` | `public Map` | `getParentContext()` Returns: the context of the parent of the current node.
    `` | `public Factory` | `getParentFactory()` Returns: the factory of the parent of the current node.
    `` | `public String` | `getParentName()` Returns: the name of the parent of the current node.
    `` | `public Object` | `getParentNode()` Returns: the node of the parent of the current node.
    `` | `public List<Closure>` | `getPostInstantiateDelegates()` Returns the active post-instantiation delegates.
    `` | `public List<Closure>` | `getPostNodeCompletionDelegates()` Returns the active post-node-completion delegates.
    `` | `public List<Closure>` | `getPreInstantiateDelegates()` Returns the active pre-instantiation delegates.
    `` | `public Object` | `getProperty(String property)` Overloaded to make variables appear as bean properties or via the subscript operator
    `` | `public Closure` | `getPropertyMissingDelegate()` Returns the property-missing fallback closure.
    `` | `protected FactoryBuilderSupport` | `getProxyBuilder()` Proxy builders are useful for changing the building context, thus enabling mix & match builders.
    `` | `public Set<String>` | `getRegistrationGroupItems(String group)` Returns the names registered in the supplied group.
    `` | `public Set<String>` | `getRegistrationGroups()` Returns the available registration group names.
    `` | `public Object` | `getVariable(String name)` Parameters: `name` - the name of the variable to lookup
    `` | `public Map` | `getVariables()` * Returns the variables map, creating it on first access. * * Returns: the backing variables map
    `` | `protected void` | `handleNodeAttributes(Object node, Map attributes)` Assigns any existing properties to the node.
    `` | `public Object` | `invokeMethod(String methodName)` Convenience method when no arguments are required
    `` | `public Object` | `invokeMethod(String methodName, Object args)` * Invokes the given method. * * Parameters: `name` - the name of the method to call * `args` - the arguments to use for the method call * Returns: the result of invoking the method
    `` | `protected void` | `newContext()` Pushes a new context on the stack.
    `` | `protected void` | `nodeCompleted(Object parent, Object node)` A hook to allow nodes to be processed once they have had all of their children applied.
    `` | `protected Map<String, Object>` | `popContext()` Removes the last context from the stack.
    `` | `protected void` | `postInstantiate(Object name, Map attributes, Object node)` A hook after the factory creates the node and before attributes are set.
    `` | `protected Object` | `postNodeCompletion(Object parent, Object node)` A hook to allow nodes to be processed once they have had all of their children applied and allows the actual node object that represents the Markup element to be changed.
    `` | `protected void` | `preInstantiate(Object name, Map attributes, Object value)` A hook before the factory creates the node.
    `` | `public void` | `registerBeanFactory(String theName, Class beanClass)` Registers a factory for a JavaBean.
    `` | `public void` | `registerBeanFactory(String theName, String groupName, Class beanClass)` Registers a factory for a JavaBean.
    `` | `public void` | `registerExplicitMethod(String name, Closure closure)` Registers an explicit method in the current registration group.
    `` | `public void` | `registerExplicitMethod(String name, String groupName, Closure closure)` Registers an explicit method and tracks it in the supplied group.
    `` | `public void` | `registerExplicitProperty(String name, Closure getter, Closure setter)` Registers an explicit property in the current registration group.
    `` | `public void` | `registerExplicitProperty(String name, String groupName, Closure getter, Closure setter)` Registers an explicit property and tracks any generated accessor names.
    `` | `public void` | `registerFactory(String name, Factory factory)` Registers a factory for a node name.
    `` | `public void` | `registerFactory(String name, String groupName, Factory factory)` Registers a factory for a node name.
    `` | `public void` | `removeAttributeDelegate(Closure attrDelegate)` Remove the most recently added instance of the attribute delegate.
    `` | `public void` | `removePostInstantiateDelegate(Closure delegate)` Remove the most recently added instance of the postInstantiate delegate.
    `` | `public void` | `removePostNodeCompletionDelegate(Closure delegate)` Remove the most recently added instance of the nodeCompletion delegate.
    `` | `public void` | `removePreInstantiateDelegate(Closure delegate)` Remove the most recently added instance of the preInstantiate delegate.
    `` | `protected void` | `reset()` Clears the context stack.
    `` | `protected Closure` | `resolveExplicitMethod(String methodName, Object args)` This is a hook for subclasses to plug in a custom strategy for mapping names to explicit methods.
    `` | `protected Closure[]` | `resolveExplicitProperty(String propertyName)` This is a hook for subclasses to plug in a custom strategy for mapping names to property methods.
    `` | `protected Factory` | `resolveFactory(Object name, Map attributes, Object value)` This is a hook for subclasses to plug in a custom strategy for mapping names to factories.
    `` | `protected void` | `restoreFromContinuationData(Map<String, Object> data)` Restores the state of the current builder to the same state as an older build.
    `` | `protected void` | `setClosureDelegate(Closure closure, Object node)` A strategy method to allow derived builders to use builder-trees and switch in different kinds of builders.
    `` | `public void` | `setMethodMissingDelegate(Closure delegate)` Sets the method-missing fallback closure.
    `` | `public void` | `setNameMappingClosure(Closure nameMappingClosure)` Sets the closure used to map method names to builder names.
    `` | `protected void` | `setNodeAttributes(Object node, Map attributes)` Maps attributes key/values to properties on node.
    `` | `protected void` | `setParent(Object parent, Object child)` Strategy method to establish parent/child relationships.
    `` | `public void` | `setProperty(String property, Object newValue)` Overloaded to make variables appear as bean properties or via the subscript operator
    `` | `public void` | `setPropertyMissingDelegate(Closure delegate)` Sets the property-missing fallback closure.
    `` | `protected void` | `setProxyBuilder(FactoryBuilderSupport proxyBuilder)` Sets the builder to be used as a proxy.
    `` | `public void` | `setVariable(String name, Object value)` Sets the value of the given variable
    `` | `public Object` | `withBuilder(FactoryBuilderSupport builder, Closure closure)` Switches the builder's proxyBuilder during the execution of a closure.
    `` | `public Object` | `withBuilder(FactoryBuilderSupport builder, String name, Closure closure)` Switches the builder's proxyBuilder during the execution of a closure.
    `` | `public Object` | `withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure)` Switches the builder's proxyBuilder during the execution of a closure.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Binding` | `getProperty, getVariable, getVariables, hasVariable, removeVariable, setProperty, setVariable`
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Field Detail

    - #### public static final String CHILD_BUILDER

      Context key for the builder used to create child nodes.

    - #### public static final String CURRENT_BUILDER

      Context key for the builder of the current node.

    - #### public static final String CURRENT_FACTORY

      Context key for the factory creating the current node.

    - #### public static final String CURRENT_NAME

      Context key for the current node name.

    - #### public static final String CURRENT_NODE

      Context key for the current node.

    - #### public static final String OWNER

      Context key for a nested closure owner.

    - #### public static final String PARENT_BUILDER

      Context key for the builder of the parent node.

    - #### public static final String PARENT_CONTEXT

      Context key for the parent node context.

    - #### public static final String PARENT_FACTORY

      Context key for the factory that created the parent node.

    - #### public static final String PARENT_NAME

      Context key for the parent node name.

    - #### public static final String PARENT_NODE

      Context key for the parent node.

    - #### public static final String SCRIPT_CLASS_NAME

      Binding key for the currently executing script class name.

    - #### protected LinkedList<Closure> attributeDelegates

    - #### protected boolean autoRegistrationComplete

      Tracks whether auto-registration has completed.

    - #### protected boolean autoRegistrationRunning

      Tracks whether auto-registration is currently in progress.

    - #### protected Map<String, Closure> explicitMethods

      Explicit methods exposed by the builder.

    - #### protected Map<String, Closure> explicitProperties

      Explicit property accessors exposed by the builder.

    - #### protected Closure methodMissingDelegate

      Fallback invoked when a builder method cannot be resolved.

    - #### protected LinkedList<Closure> postInstantiateDelegates

      Delegates invoked after a factory creates a node.

    - #### protected LinkedList<Closure> postNodeCompletionDelegates

      Delegates invoked after a node and its children are complete.

    - #### protected LinkedList<Closure> preInstantiateDelegates

      Delegates invoked before a factory creates a node.

    - #### protected Closure propertyMissingDelegate

      Fallback invoked when a builder property cannot be resolved.

    - #### protected Map<String, Set<String>> registrationGroup

      Registered names grouped by registration phase.

    - #### protected String registrationGroupName

  - ### Constructor Detail

    - #### public FactoryBuilderSupport()

      Creates a builder without performing automatic node registration.

    - #### public FactoryBuilderSupport(boolean init)

      Creates a builder and optionally performs automatic node registration.

      Parameters:
        `init` - `true` to invoke autoRegisterNodes()

  - ### Method Detail

    - #### public Closure addAttributeDelegate(Closure attrDelegate)

      Add an attribute delegate so it can intercept attributes being set. Attribute delegates are fired in a FILO pattern, so that nested delegates get first crack.

      Parameters:
        `attrDelegate` - the closure to be called
      Returns:
        attrDelegate

    - #### public void addDisposalClosure(Closure closure)

      Registers a closure to run when the builder is disposed.

      Parameters:
        `closure` - the disposal action

    - #### public Closure addPostInstantiateDelegate(Closure delegate)

      Add a postInstantiate delegate so it can intercept nodes after they are created. PostInstantiate delegates are fired in a FILO pattern, so that nested delegates get first crack.

      Parameters:
        `delegate` - the closure to invoke
      Returns:
        delegate

    - #### public Closure addPostNodeCompletionDelegate(Closure delegate)

      Add a nodeCompletion delegate so it can intercept nodes after they done with building. NodeCompletion delegates are fired in a FILO pattern, so that nested delegates get first crack.

      Parameters:
        `delegate` - the closure to invoke
      Returns:
        delegate

    - #### public Closure addPreInstantiateDelegate(Closure delegate)

      Add a preInstantiate delegate so it can intercept nodes before they are created. PreInstantiate delegates are fired in a FILO pattern, so that nested delegates get first crack.

      Parameters:
        `delegate` - the closure to invoke
      Returns:
        delegate

    - #### public void autoRegisterNodes()

      Ask the nodes to be registered

    - #### public Object build(Class viewClass)

      Runs a script class using this builder as its binding.

      Parameters:
        `viewClass` - the script class to execute
      Returns:
        the script result

    - #### public Object build(Script script)

      Runs a script instance using this builder as its binding.

      Parameters:
        `script` - the script to execute
      Returns:
        the script result

    - #### public Object build(String script, GroovyClassLoader loader)

      Parses and runs an inline script using the supplied class loader.

      Parameters:
        `script` - the script source
        `loader` - the class loader used to parse the script
      Returns:
        the script result

    - #### protected boolean checkExplicitMethod(String methodName, Object args, Reference result)

      Resolves and invokes an explicit builder method if one is registered.

      Parameters:
        `methodName` - the method name to resolve
        `args` - the original method arguments
        `result` - receives the explicit method result when one is invoked
      Returns:
        `true` if an explicit method handled the call

    - #### public static void checkValueIsNull(Object value, Object name)

      Throws an exception if value is null.

      Parameters:
        `value` - the node's value
        `name` - the node's name

    - #### public static boolean checkValueIsType(Object value, Object name, Class type)

      Checks type of value against builder type

      Parameters:
        `value` - the node's value
        `name` - the node's name
        `type` - a Class that may be assignable to the value's class
      Returns:
        true if type is assignable to the value's class, false if value is null.

    - #### public static boolean checkValueIsTypeNotString(Object value, Object name, Class type)

      Checks values against factory's type

      Parameters:
        `value` - the node's value
        `name` - the node's name
        `type` - a Class that may be assignable to the value's class
      Returns:
        Returns true if type is assignable to the value's class, false if value is null or a String.

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

      This method is responsible for instantiating a node and configure its properties.

      Parameters:
        `name` - the name of the node
        `attributes` - the attributes for the node
        `value` - the value arguments for the node
      Returns:
        the object return from the factory

    - #### protected Object dispatchNodeCall(Object name, Object args)

      Dispatches a builder method call to node creation and nested closure handling.

      Parameters:
        `name` - the resolved node name
        `args` - the original method arguments
      Returns:
        the created node

    - #### @Deprecated
      protected Object dispathNodeCall(Object name, Object args)

      Use FactoryBuilderSupport.dispatchNodeCall instead.

    - #### public void dispose()

      Invokes registered disposal closures in reverse registration order.

    - #### public List<Closure> getAttributeDelegates()

      Returns the active attribute delegates.

      Returns:
        the attribute delegates in invocation order

    - #### public FactoryBuilderSupport getChildBuilder()

      Returns the builder currently used for child node creation.

      Returns:
        the child builder from the current context

    - #### public Map<String, Object> getContext()

      Returns:
        the context of the current node.

    - #### public Object getContextAttribute(String key)

      Looks up a value from the current builder context.

      Parameters:
        `key` - the context key
      Returns:
        the associated value, or `null`

    - #### protected LinkedList<Map<String, Object>> getContexts()

      Returns:
        the stack of available contexts.

    - #### protected Map<String, Object> getContinuationData()

      Stores the thread local states in a Map that can be passed across threads

      Returns:
        the map

    - #### public Object getCurrent()

      Returns:
        the current node being built.

    - #### public FactoryBuilderSupport getCurrentBuilder()

      Returns:
        the builder that built the current node.

    - #### public Factory getCurrentFactory()

      Returns:
        the factory that built the current node.

    - #### public String getCurrentName()

      Returns:
        the factory of the parent of the current node.

    - #### public List<Closure> getDisposalClosures()

      Returns the registered disposal closures.

      Returns:
        the disposal closures in execution order

    - #### public Map<String, Closure> getExplicitMethods()

      Returns:
        the explicit methods map (Unmodifiable Map).

    - #### public Map<String, Closure> getExplicitProperties()

      Returns:
        the explicit properties map (Unmodifiable Map).

    - #### public Map<String, Factory> getFactories()

      Returns:
        the factory map (Unmodifiable Map).

    - #### public Map<String, Closure> getLocalExplicitMethods()

      Returns:
        the explicit methods map (Unmodifiable Map).

    - #### public Map<String, Closure> getLocalExplicitProperties()

      Returns:
        the explicit properties map (Unmodifiable Map).

    - #### public Map<String, Factory> getLocalFactories()

      Returns:
        the factory map (Unmodifiable Map).

    - #### public Closure getMethodMissingDelegate()

      Returns the method-missing fallback closure.

      Returns:
        the method-missing delegate, or `null`

    - #### public Object getName(String methodName)

      A hook to allow names to be converted into some other object such as a QName in XML or ObjectName in JMX.

      Parameters:
        `methodName` - the name of the desired method
      Returns:
        the object representing the name

    - #### public Closure getNameMappingClosure()

      Returns the closure that maps method names to builder names.

      Returns:
        the name mapping closure, or `null`

    - #### public Map getParentContext()

      Returns:
        the context of the parent of the current node.

    - #### public Factory getParentFactory()

      Returns:
        the factory of the parent of the current node.

    - #### public String getParentName()

      Returns:
        the name of the parent of the current node.

    - #### public Object getParentNode()

      Returns:
        the node of the parent of the current node.

    - #### public List<Closure> getPostInstantiateDelegates()

      Returns the active post-instantiation delegates.

      Returns:
        the post-instantiation delegates in invocation order

    - #### public List<Closure> getPostNodeCompletionDelegates()

      Returns the active post-node-completion delegates.

      Returns:
        the node completion delegates in invocation order

    - #### public List<Closure> getPreInstantiateDelegates()

      Returns the active pre-instantiation delegates.

      Returns:
        the pre-instantiation delegates in invocation order

    - #### public Object getProperty(String property)

      Overloaded to make variables appear as bean properties or via the subscript operator

    - #### public Closure getPropertyMissingDelegate()

      Returns the property-missing fallback closure.

      Returns:
        the property-missing delegate, or `null`

    - #### protected FactoryBuilderSupport getProxyBuilder()

      Proxy builders are useful for changing the building context, thus enabling mix & match builders.

      Returns:
        the current builder that serves as a proxy.

    - #### public Set<String> getRegistrationGroupItems(String group)

      Returns the names registered in the supplied group.

      Parameters:
        `group` - the registration group name
      Returns:
        an unmodifiable view of the registered names

    - #### public Set<String> getRegistrationGroups()

      Returns the available registration group names.

      Returns:
        an unmodifiable view of the registration groups

    - #### public Object getVariable(String name)

      Parameters:
        `name` - the name of the variable to lookup
      Returns:
        the variable value

    - #### public Map getVariables()

      * Returns the variables map, creating it on first access. * *

      Returns:
        the backing variables map

    - #### protected void handleNodeAttributes(Object node, Map attributes)

      Assigns any existing properties to the node.
      It will call attributeDelegates before passing control to the factory that built the node.

      Parameters:
        `node` - the object returned by tne node factory
        `attributes` - the attributes for the node

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

      Convenience method when no arguments are required

      Parameters:
        `methodName` - the name of the method to invoke
      Returns:
        the result of the call

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

      * Invokes the given method. * *

      Parameters:
        `name` - the name of the method to call *
        `args` - the arguments to use for the method call *
      Returns:
        the result of invoking the method

    - #### protected void newContext()

      Pushes a new context on the stack.

    - #### protected void nodeCompleted(Object parent, Object node)

      A hook to allow nodes to be processed once they have had all of their children applied.

      Parameters:
        `node` - the current node being processed
        `parent` - the parent of the node being processed

    - #### protected Map<String, Object> popContext()

      Removes the last context from the stack.

      Returns:
        the content just removed

    - #### protected void postInstantiate(Object name, Map attributes, Object node)

      A hook after the factory creates the node and before attributes are set.
      It will call any registered postInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.

      Parameters:
        `name` - the name of the node
        `attributes` - the attributes for the node
        `node` - the object created by the node factory

    - #### protected Object postNodeCompletion(Object parent, Object node)

      A hook to allow nodes to be processed once they have had all of their children applied and allows the actual node object that represents the Markup element to be changed.
      It will call any registered postNodeCompletionDelegates, if you override this method be sure to call this impl at the end of your code.

      Parameters:
        `node` - the current node being processed
        `parent` - the parent of the node being processed
      Returns:
        the node, possibly new, that represents the markup element

    - #### protected void preInstantiate(Object name, Map attributes, Object value)

      A hook before the factory creates the node.
      It will call any registered preInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.

      Parameters:
        `name` - the name of the node
        `attributes` - the attributes of the node
        `value` - the value argument(s) of the node

    - #### public void registerBeanFactory(String theName, Class beanClass)

      Registers a factory for a JavaBean.
      The JavaBean class should have a no-arg constructor.

      Parameters:
        `theName` - name of the node
        `beanClass` - the factory to handle the name

    - #### public void registerBeanFactory(String theName, String groupName, Class beanClass)

      Registers a factory for a JavaBean.
      The JavaBean class should have a no-arg constructor.

      Parameters:
        `theName` - name of the node
        `groupName` - thr group to register this node in
        `beanClass` - the factory to handle the name

    - #### public void registerExplicitMethod(String name, Closure closure)

      Registers an explicit method in the current registration group.

      Parameters:
        `name` - the method name
        `closure` - the implementation closure

    - #### public void registerExplicitMethod(String name, String groupName, Closure closure)

      Registers an explicit method and tracks it in the supplied group.

      Parameters:
        `name` - the method name
        `groupName` - the registration group name
        `closure` - the implementation closure

    - #### public void registerExplicitProperty(String name, Closure getter, Closure setter)

      Registers an explicit property in the current registration group.

      Parameters:
        `name` - the property name
        `getter` - the optional getter closure
        `setter` - the optional setter closure

    - #### public void registerExplicitProperty(String name, String groupName, Closure getter, Closure setter)

      Registers an explicit property and tracks any generated accessor names.

      Parameters:
        `name` - the property name
        `groupName` - the registration group name
        `getter` - the optional getter closure
        `setter` - the optional setter closure

    - #### public void registerFactory(String name, Factory factory)

      Registers a factory for a node name.

      Parameters:
        `name` - the name of the node
        `factory` - the factory to return the values

    - #### public void registerFactory(String name, String groupName, Factory factory)

      Registers a factory for a node name.

      Parameters:
        `name` - the name of the node
        `groupName` - thr group to register this node in
        `factory` - the factory to return the values

    - #### public void removeAttributeDelegate(Closure attrDelegate)

      Remove the most recently added instance of the attribute delegate.

      Parameters:
        `attrDelegate` - the instance of the closure to be removed

    - #### public void removePostInstantiateDelegate(Closure delegate)

      Remove the most recently added instance of the postInstantiate delegate.

      Parameters:
        `delegate` - the closure to invoke

    - #### public void removePostNodeCompletionDelegate(Closure delegate)

      Remove the most recently added instance of the nodeCompletion delegate.

      Parameters:
        `delegate` - the closure to be removed

    - #### public void removePreInstantiateDelegate(Closure delegate)

      Remove the most recently added instance of the preInstantiate delegate.

      Parameters:
        `delegate` - the closure to invoke

    - #### protected void reset()

      Clears the context stack.

    - #### protected Closure resolveExplicitMethod(String methodName, Object args)

      This is a hook for subclasses to plug in a custom strategy for mapping names to explicit methods.

      Parameters:
        `methodName` - the name of the explicit method
        `args` - the arguments for the method
      Returns:
        the closure for the matched explicit method.

    - #### protected Closure[] resolveExplicitProperty(String propertyName)

      This is a hook for subclasses to plug in a custom strategy for mapping names to property methods.

      Parameters:
        `propertyName` - the name of the explicit method
      Returns:
        the get and set closures (in that order) for the matched explicit property.

    - #### protected Factory resolveFactory(Object name, Map attributes, Object value)

      This is a hook for subclasses to plug in a custom strategy for mapping names to factories.

      Parameters:
        `name` - the name of the factory
        `attributes` - the attributes from the node
        `value` - value arguments from te node
      Returns:
        the Factory associated with name.

    - #### protected void restoreFromContinuationData(Map<String, Object> data)

      Restores the state of the current builder to the same state as an older build. Caution, this will destroy rather than merge the current build context if there is any,

      Parameters:
        `data` - the data retrieved from a compatible getContinuationData call

    - #### protected void setClosureDelegate(Closure closure, Object node)

      A strategy method to allow derived builders to use builder-trees and switch in different kinds of builders. This method should call the setDelegate() method on the closure which by default passes in this but if node is-a builder we could pass that in instead (or do something wacky too)

      Parameters:
        `closure` - the closure on which to call setDelegate()
        `node` - the node value that we've just created, which could be a builder

    - #### public void setMethodMissingDelegate(Closure delegate)

      Sets the method-missing fallback closure.

      Parameters:
        `delegate` - the delegate to invoke for unresolved methods

    - #### public void setNameMappingClosure(Closure nameMappingClosure)

      Sets the closure used to map method names to builder names.

      Parameters:
        `nameMappingClosure` - the mapping closure to use

    - #### protected void setNodeAttributes(Object node, Map attributes)

      Maps attributes key/values to properties on node.

      Parameters:
        `node` - the object from the node
        `attributes` - the attributes to be set

    - #### protected void setParent(Object parent, Object child)

      Strategy method to establish parent/child relationships.

      Parameters:
        `parent` - the object from the parent node
        `child` - the object from the child node

    - #### public void setProperty(String property, Object newValue)

      Overloaded to make variables appear as bean properties or via the subscript operator

    - #### public void setPropertyMissingDelegate(Closure delegate)

      Sets the property-missing fallback closure.

      Parameters:
        `delegate` - the delegate to invoke for unresolved properties

    - #### protected void setProxyBuilder(FactoryBuilderSupport proxyBuilder)

      Sets the builder to be used as a proxy.

      Parameters:
        `proxyBuilder` - the new proxy

    - #### public void setVariable(String name, Object value)

      Sets the value of the given variable

      Parameters:
        `name` - the name of the variable to set
        `value` - the new value for the given variable

    - #### public Object withBuilder(FactoryBuilderSupport builder, Closure closure)

      Switches the builder's proxyBuilder during the execution of a closure.
      This is useful to temporary change the building context to another builder without the need for a contrived setup. It will also take care of restoring the previous proxyBuilder when the execution finishes, even if an exception was thrown from inside the closure.

      throws:
        RuntimeException - any exception the closure might have thrown during execution.
      Parameters:
        `builder` - the temporary builder to switch to as proxyBuilder.
        `closure` - the closure to be executed under the temporary builder.
      Returns:
        the execution result of the closure.

    - #### public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure)

      Switches the builder's proxyBuilder during the execution of a closure.
      This is useful to temporary change the building context to another builder without the need for a contrived setup. It will also take care of restoring the previous proxyBuilder when the execution finishes, even if an exception was thrown from inside the closure. Additionally it will use the closure's result as the value for the node identified by 'name'.

      throws:
        RuntimeException - any exception the closure might have thrown during execution.
      Parameters:
        `builder` - the temporary builder to switch to as proxyBuilder.
        `name` - the node to build on the 'parent' builder.
        `closure` - the closure to be executed under the temporary builder.
      Returns:
        a node that responds to value of name with the closure's result as its value.

    - #### public Object withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure)

      Switches the builder's proxyBuilder during the execution of a closure.
      This is useful to temporary change the building context to another builder without the need for a contrived setup. It will also take care of restoring the previous proxyBuilder when the execution finishes, even if an exception was thrown from inside the closure. Additionally it will use the closure's result as the value for the node identified by 'name' and assign any attributes that might have been set.

      throws:
        RuntimeException - any exception the closure might have thrown during execution.
      Parameters:
        `attributes` - additional properties for the node on the parent builder.
        `builder` - the temporary builder to switch to as proxyBuilder.
        `name` - the node to build on the 'parent' builder.
        `closure` - the closure to be executed under the temporary builder.
      Returns:
        a node that responds to value of name with the closure's result as its value.