org.pietschy.command

Class AbstractBuilder

Known Direct Subclasses:
AbstractCommandBuilder, AbstractFaceBuilder

public class AbstractBuilder
extends java.lang.Object

Provides common methods required by all builders.
Version:
$Revision: 1.7 $
Author:
andrewp

Method Summary

protected String
getAttribute(Element element, String attributeName)
Gets an attribute from an element.
CommandManager
getCommandManager()
Gets the associated CommandManager for the builder to use as required.
String
getElementPath(Element element)
Returns a string representing the elements position in the command heirarchy.
protected String
getElementText(Element element)
Gets the textural value of an element.
protected boolean
isEmptyElement(Element element)
Checks if the specified element is empty.
protected boolean
isIncluded(Element e)
Tests if the specified element has been conditionally included.
protected void
populateProperties(Command command, Element commandRoot)
void
setCommandManager(CommandManager commandManager)
Sets the associated CommandManager for the builder to use as required.

Method Details

getAttribute

protected String getAttribute(Element element,
                              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.

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.

getElementPath

public String getElementPath(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.

getElementText

protected String getElementText(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

isEmptyElement

protected boolean isEmptyElement(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.

isIncluded

protected boolean isIncluded(Element e)
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,
                                  Element commandRoot)

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.