org.pietschy.command
Class AbstractBuilder

java.lang.Object
  extended by org.pietschy.command.AbstractBuilder
Direct Known Subclasses:
AbstractCommandBuilder, AbstractFaceBuilder

public class AbstractBuilder
extends java.lang.Object

Provides common methods required by all builders.

Version:
$Revision: 1.7 $
Author:
andrewp

Constructor Summary
AbstractBuilder()
           
 
Method Summary
protected  java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String attributeName)
          Gets an attribute from an element.
 CommandManager getCommandManager()
          Gets the associated CommandManager for the builder to use as required.
 java.lang.String getElementPath(org.w3c.dom.Element element)
          Returns a string representing the elements position in the command heirarchy.
protected  java.lang.String getElementText(org.w3c.dom.Element element)
          Gets the textural value of an element.
protected  boolean isEmptyElement(org.w3c.dom.Element element)
          Checks if the specified element is empty.
protected  boolean isIncluded(org.w3c.dom.Element e)
          Tests if the specified element has been conditionally included.
protected  void populateProperties(Command command, org.w3c.dom.Element commandRoot)
           
 void setCommandManager(CommandManager commandManager)
          Sets the associated CommandManager for the builder to use as required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBuilder

public AbstractBuilder()
Method Detail

getCommandManager

public CommandManager getCommandManager()
Gets the associated CommandManager for the builder to use as required. This will be configured when the builder is installed. The CommandManager is typically used to gain access the the class loader and resource bundle.

Returns:
the associated CommandManager.
See Also:
CommandManager.getClassLoader()

setCommandManager

public void setCommandManager(CommandManager commandManager)
Sets the associated CommandManager for the builder to use as required. This will be configured when the builder is installed. The CommandManager is typically used to gain access the the class loader and resource bundle.

Parameters:
commandManager - the associated CommandManager.
See Also:
CommandManager.getClassLoader()

getElementText

protected java.lang.String getElementText(org.w3c.dom.Element element)
Gets the textural value of an element. If the element has Names.I18N_ATTRIBUTE then this method will attempt to load the value from the resource bundle.

Parameters:
element - the element whose text value is to be extracted.
Returns:
the text value of the element

getAttribute

protected java.lang.String getAttribute(org.w3c.dom.Element element,
                                        java.lang.String attributeName)
Gets an attribute from an element. If the attribute is prefixed with Names.I18N_ATTRIBUTE_PREFIX then this method will attempt to load the attribute from the resource bundle. This method returns null if the the requested attribute isn't present.

Parameters:
element - the element constaining the attribute
attributeName - the attribute name
Returns:
the attribute value, or null if the attribute doesn't exist.

isEmptyElement

protected boolean isEmptyElement(org.w3c.dom.Element element)
Checks if the specified element is empty. Emply elements are those that have no children (not even an empty text node). A empty node is specified in the form <text/>. Empty nodes are used to signify that a particular face element is null and that it shouldn't inherit from its parent.

Parameters:
element - the element to check.
Returns:
true if the element has no children and no attributes, false otherwise.

getElementPath

public java.lang.String getElementPath(org.w3c.dom.Element element)
Returns a string representing the elements position in the command heirarchy. This method is only intended to produce debug information.

Parameters:
element - the element to examine.
Returns:
a string representing the elements posistion in the configuration heirarchy.

isIncluded

protected boolean isIncluded(org.w3c.dom.Element e)
Tests if the specified element has been conditionally included.

This method will always return true if there is no include-if element. If present, this method will evaulate the exprerssion using ConditionEvaluator.evaluate(String) returning the result.

Parameters:
e - the element that may or may not have a include-if attriubte.
Returns:
false if and only if there is an include-if attribute and the expression evaluates to false.

populateProperties

protected void populateProperties(Command command,
                                  org.w3c.dom.Element commandRoot)