org.apache.shale.clay.parser.builder
Class Builder

java.lang.Object
  extended by org.apache.shale.clay.parser.builder.Builder
Direct Known Subclasses:
CommandButtonBuilder, ElementBuilder, FormBuilder, InputTextareaBuilder, InputTextBuilder, JspIncludeDirectiveBuilder, MorphBuilder, OutputLabelBuilder, OutputLinkBuilder, SelectBooleanCheckboxBuilder, SelectItemBuilder, SelectItemsBuilder, SelectManyMenuBuilder, SelectOneMenuBuilder, SelectOneRadioBuilder, VerbatimBuilder, VoidBuilder

public abstract class Builder
extends Object

The abstract document node converter handles building meta components, ComponentBean, for a parsed html document fragment. The Parser loads the HTML document into a tree structure of Node. Each node in the parsed document tree is mapped to a Builder by a a subclass of BuilderRuleContext.


Field Summary
protected static org.apache.shale.util.Messages messages
           Message resources for this class.
 
Constructor Summary
Builder()
           
 
Method Summary
protected  void assignAttributes(Node node, ComponentBean target)
           This method applies the HTML attribute overrides to the declarative component, an object representation of the XML configuration.
protected  void assignNode(Node node, ElementBean target)
           This method resolves the jsfid attribute for an HTML element to a component definition in the XML configuration files.
protected  AttributeBean createAttribute(AttributeBean original, String value, ComponentBean target)
           Factory method that creates a AttributeBean from the original replacing the value.
 ElementBean createElement(Node node)
           Factory method that creates a ElementBean from a Node.
 void encode(Node node, ElementBean target, ComponentBean root)
           The call that begins the conversion of a Node to a ComponentBean.
protected  void encodeBegin(Node node, ElementBean target, ComponentBean root)
           Called to being building a ElementBean from a Node.
protected  void encodeChildren(Node node, ElementBean target, ComponentBean root)
           Recursively builds the clay meta component data from the parse document of Node's.
protected  void encodeEnd(Node node, ElementBean target, ComponentBean root)
           This call is invoked for any final processing.
 Builder getBuilder(Node node)
          Returns the Builder that is assigned the task of converting the html node to a corresponding component metadata used to construct a JSF resource.
protected  boolean getBuildNodeBody(Node node, ElementBean target)
           Returns true if the builder handles converting the node's children or false if it's handled by the parent.
protected abstract  String getComponentType(Node node)
           Returns the faces component type registered in the faces configuration or the fully qualified class name for ActionListeners and ValueChangeListeners.
protected abstract  String getJsfid(Node node)
           Returns a jsfid for the component.
protected  int getRenderId()
           Returns the next generated renderId.
 boolean isChildrenAllowed()
           This method returns true if the faces component that it builds allows children but the default is false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected static org.apache.shale.util.Messages messages

Message resources for this class.

Constructor Detail

Builder

public Builder()
Method Detail

isChildrenAllowed

public boolean isChildrenAllowed()

This method returns true if the faces component that it builds allows children but the default is false.

Returns:
false

getJsfid

protected abstract String getJsfid(Node node)

Returns a jsfid for the component.

Parameters:
node - markup
Returns:
jsfid

getComponentType

protected abstract String getComponentType(Node node)

Returns the faces component type registered in the faces configuration or the fully qualified class name for ActionListeners and ValueChangeListeners.

Parameters:
node - markup
Returns:
component type

getRenderId

protected int getRenderId()

Returns the next generated renderId.

Returns:
unique id

getBuildNodeBody

protected boolean getBuildNodeBody(Node node,
                                   ElementBean target)

Returns true if the builder handles converting the node's children or false if it's handled by the parent. The isBodyAllowed attribute can also be used to override the default option. This flag allows the HTML to be mocked up but the body ignored when converted into a ComponentBean graph.

Parameters:
node - markup
target - child config bean
Returns:
false if the node's children should be ignored

encodeBegin

protected void encodeBegin(Node node,
                           ElementBean target,
                           ComponentBean root)

Called to being building a ElementBean from a Node. This follows the JSF pattern used by the Components and Renders.

Parameters:
node - markup
target - child config bean
root - parent config bean

createAttribute

protected AttributeBean createAttribute(AttributeBean original,
                                        String value,
                                        ComponentBean target)

Factory method that creates a AttributeBean from the original replacing the value.

Parameters:
original - attribute being cloned
value - attribute property value override
target - owner of the attribute
Returns:
cloned original with the value overridden

encodeChildren

protected void encodeChildren(Node node,
                              ElementBean target,
                              ComponentBean root)

Recursively builds the clay meta component data from the parse document of Node's. A similar design pattern found in JSF.

Parameters:
node - markup
target - child config bean
root - parent config bean

encodeEnd

protected void encodeEnd(Node node,
                         ElementBean target,
                         ComponentBean root)

This call is invoked for any final processing.

Parameters:
node - markup
target - child config bean
root - parent config bean

createElement

public ElementBean createElement(Node node)

Factory method that creates a ElementBean from a Node.

Parameters:
node - markup
Returns:
target config bean from the markup node

encode

public void encode(Node node,
                   ElementBean target,
                   ComponentBean root)

The call that begins the conversion of a Node to a ComponentBean. Each element in the html document will be converted into a Clay meta component.

Parameters:
node - markup
target - child config bean
root - parent config bean

assignNode

protected void assignNode(Node node,
                          ElementBean target)

This method resolves the jsfid attribute for an HTML element to a component definition in the XML configuration files.

Parameters:
node - markup
target - child config bean

assignAttributes

protected void assignAttributes(Node node,
                                ComponentBean target)

This method applies the HTML attribute overrides to the declarative component, an object representation of the XML configuration.

Parameters:
node - markup
target - child config bean

getBuilder

public Builder getBuilder(Node node)

Returns the Builder that is assigned the task of converting the html node to a corresponding component metadata used to construct a JSF resource.

Parameters:
node - markup node
Returns:
builder that maps markup to config beans


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.