org.nanocontainer.script.groovy.buildernodes
Class AbstractBuilderNode

java.lang.Object
  extended byorg.nanocontainer.script.groovy.buildernodes.AbstractBuilderNode
All Implemented Interfaces:
BuilderNode, java.io.Serializable
Direct Known Subclasses:
AppendContainerNode, BeanNode, ChildContainerNode, ClassLoaderNode, ClasspathNode, ComponentNode, DecoratingPicoContainerNode, DoCallNode, GrantNode, NewBuilderNode

public abstract class AbstractBuilderNode
extends java.lang.Object
implements BuilderNode, java.io.Serializable

Abstract base class for custom nodes. Also provides basic services and construction capabilities.

Version:
$Revision: 2443 $
Author:
James Strachan, Paul Hammant, Aslak Hellesøy, Michael Rimov, Mauro Talevi
See Also:
Serialized Form

Constructor Summary
AbstractBuilderNode(java.lang.String nodeName)
          Constructs a custom node builder.
 
Method Summary
protected  AbstractBuilderNode addAttribute(java.lang.String name)
          Add an attribute to the list of ones supported by this node.
 java.lang.String getNodeName()
          Retrieve the name of the node.
 java.util.Set getSupportedAttributes()
          Retrieve a map of supported attribute names.
protected  boolean isAttribute(java.util.Map attributes, java.lang.String key)
          Checks that an attribute actually exists in the attirbute map.
 java.lang.String toString()
           
 void validateScriptedAttributes(java.util.Map specifiedAttributes)
          Validates a given map of attributes as supplied by the GroovyNodeBuilder against the node's supported attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nanocontainer.script.groovy.BuilderNode
createNewNode
 

Constructor Detail

AbstractBuilderNode

public AbstractBuilderNode(java.lang.String nodeName)
Constructs a custom node builder. In derived classes you would typically create a default constructor and call addPossibleParent()/addAttribute() to customize the validation capabilities of the Node.

Parameters:
nodeName - the name of the node we're constructing.
Method Detail

addAttribute

protected AbstractBuilderNode addAttribute(java.lang.String name)
Add an attribute to the list of ones supported by this node.

Parameters:
name - String the name of the attribute we support.
Returns:
AbstractBuilderNode (this) to allow for method chaining.

getNodeName

public java.lang.String getNodeName()
Description copied from interface: BuilderNode
Retrieve the name of the node. Examples could be 'container' or 'component'.

Specified by:
getNodeName in interface BuilderNode
Returns:
String

getSupportedAttributes

public java.util.Set getSupportedAttributes()
Description copied from interface: BuilderNode
Retrieve a map of supported attribute names.

note:Supported attributes are currently unverified by the GroovyNodeBuilder as this would result in a change of behavior.

Specified by:
getSupportedAttributes in interface BuilderNode
Returns:
Set of Strings.

toString

public java.lang.String toString()

isAttribute

protected boolean isAttribute(java.util.Map attributes,
                              java.lang.String key)
Checks that an attribute actually exists in the attirbute map. (The key exists and the value is non-null)

Parameters:
attributes - Map the current node's attributes.
key - String the attribute key we're looking for.
Returns:
boolean true if the attribute exists for the current node.

validateScriptedAttributes

public void validateScriptedAttributes(java.util.Map specifiedAttributes)
                                throws org.nanocontainer.script.NanoContainerMarkupException
Validates a given map of attributes as supplied by the GroovyNodeBuilder against the node's supported attributes.

This particular implementation checks all specified attribute keynames against the names supported in the node type. It does not type checking against the values passed in via the attributes.

Specified by:
validateScriptedAttributes in interface BuilderNode
Parameters:
specifiedAttributes - the attributes as passed in by the groovy script.
Throws:
org.nanocontainer.script.NanoContainerMarkupException - if an attribute is specified that is not recognized.


Copyright © 2003-2007 Codehaus. All Rights Reserved.