Expresso 5-6

com.jcorporate.expresso.core.controller
Class ControllerElement

java.lang.Object
  extended bycom.jcorporate.expresso.core.controller.ControllerElement
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
Block, Input, Output, Transition

public class ControllerElement
extends Object
implements Cloneable, Serializable

A ControllerElement is the superclass for the three types of objects that are produced by a Controller when it transitions from one state to another. Output, Input and Transition objects all extend this class, and share the behaviors specified here. IMPORTANT NOTE: We don't use Logging (e.g. log4j) in this object, as it is sometimes stored in session when the server shuts down, and must be able to re-instantiate from the serialized form without needing to wait for ConfigManager to be initialized.

See Also:
Serialized Form

Constructor Summary
protected ControllerElement()
          Default constructor
 
Method Summary
 void addNested(ControllerElement e)
          Add a nested item to this element
 Vector allNested()
          Return the nested items from this item
 Object clone()
          Shouldn't be normally called directly.
static ControllerElement fromXML(org.w3c.dom.Node n)
          Base Class 'deserialization' from XML given a DOM Node N.
protected static ControllerElement fromXML(org.w3c.dom.Node n, ControllerElement ce)
          Return a controller element based upon the xml fragment
 String getAttribute(String att)
          Get the value of an "attribute" for this ControllerElement item.
 HashMap getAttributes()
          Return the entire Hashtable of attribute values for this ControllerElement
 HashMap getAttributesOrNull()
          Same as above but will return null if no attributes have ever been set.
 ControllerElement getContent(String name)
           
 Vector getContents()
          Returns the contents of this controller element
protected  ControllerResponse getControllerResponse()
           
 String getDescription()
          Get the description of this element
 int getDisplayLength()
          Get the display length suggested by the controller for this item.
 String getLabel()
          Get the label of this element
 int getLines()
          Get the suggested number of lines for this item
 String getName()
          Get the name of this element.
 Vector getNested()
          Return the entire Vector of nested elements in this element
 ControllerElement getNested(String nestedName)
          Return a specific Element nested within this Element
 int getNestedCount()
          A method to support JSTL 1.0 usage; returns the size of the nested controller elements.
 Iterator getNestedIterator()
          Retrieve the iterator to all tested objects.
 Map getNestedMap()
          Return a Map of all nested elements keyed by controllerElement name.
 Vector getNestedOrNull()
          Same as getNested.
 ControllerElement getParent()
          Return the "parent" of this element - e.g. the element that this element is nested within
 String getTitle()
          Get the name of this element.
 String getType()
          Returns whatever the type is
 void remove()
          Remove this item from the "nested" items of it's parent.
 void removeNested(ControllerElement elementToRemove)
          Remove an element from the nested elements for this item
 void setAttribute(String attrib, String val)
          Set the named attribute of this Output to the given value
 void setControllerResponse(ControllerResponse newResponse)
          Called by the ControllerResponse to hand itself back to this element so that it can be accessed by the elements as required
 void setDescription(String newDescription)
          Used by the controller to set the description of this element
 void setDisplayLength(int newLength)
          Set the suggested display length (in caracters) for this Controller element
 void setLabel(String newLabel)
          Set a label for this element
 void setLines(int newLines)
          Set the display number of lines suggested for this item
 void setName(String newName)
          Used by the controller to set the name of this element
 void setParent(ControllerElement t)
          Set the "parent" of this element - e.g. the element that this element is nested within
 void setType(String s)
          Sets the descriptive data type for this ControllerElement
 FastStringBuffer toXML(FastStringBuffer stream)
          Convert the object to an xml fragment.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerElement

protected ControllerElement()
Default constructor

Method Detail

getContents

public Vector getContents()
Returns the contents of this controller element

Returns:
Vector of nested content

addNested

public void addNested(ControllerElement e)
Add a nested item to this element

Parameters:
e - A ControllerElement to nest inside this element

allNested

public Vector allNested()
Return the nested items from this item

Returns:
java.util.Vector

clone

public Object clone()
             throws CloneNotSupportedException
Shouldn't be normally called directly.

Returns:
created or null of the creation fails.
Throws:
CloneNotSupportedException - as per the API spec.

fromXML

public static ControllerElement fromXML(org.w3c.dom.Node n)
                                 throws ControllerException
Base Class 'deserialization' from XML given a DOM Node N.

Parameters:
n - A DOM Node object.
Returns:
an instantiated ControllerElement
Throws:
ControllerException

fromXML

protected static ControllerElement fromXML(org.w3c.dom.Node n,
                                           ControllerElement ce)
                                    throws ControllerException
Return a controller element based upon the xml fragment

Parameters:
n - The DOM node that represents the controller-element
ce - The created controller element subclass
Returns:
an instantiated ControllerElement
Throws:
ControllerException - if fragment is not a controller element

getAttribute

public String getAttribute(String att)
Get the value of an "attribute" for this ControllerElement item. The attributes can be any set of named values that the client and Controller are both aware of.

Parameters:
att - The name of the attribute whose value is wanted
Returns:
The value of the specified attribtue, if it exists, else null

getAttributes

public HashMap getAttributes()
Return the entire Hashtable of attribute values for this ControllerElement

Returns:
A Hashtable of name/value pairs for this ControllerElement object

getAttributesOrNull

public HashMap getAttributesOrNull()
Same as above but will return null if no attributes have ever been set.

Returns:
HashMap or null

getContent

public ControllerElement getContent(String name)

getDescription

public String getDescription()
Get the description of this element

Returns:
A String description of this element as specified by the controller

getDisplayLength

public int getDisplayLength()
Get the display length suggested by the controller for this item.

Returns:
The display length suggested for this item

getLabel

public String getLabel()
Get the label of this element

Returns:
The label of this element

getLines

public int getLines()
Get the suggested number of lines for this item

Returns:
integer

getName

public String getName()
Get the name of this element. title and name are synonymous--easier for JSTL

Returns:
The name of this element

getTitle

public String getTitle()
Get the name of this element. title and name are synonymous--easier for JSTL

Returns:
The name of this element

getNested

public Vector getNested()
Return the entire Vector of nested elements in this element

Returns:
A Vector of the objects nested within this element

getNestedCount

public int getNestedCount()
A method to support JSTL 1.0 usage; returns the size of the nested controller elements.

In JSTL 1.0 it is not possible to the retrieve sizes of collections directly without using a wrapper or a custom tag action.

Returns:
size of all nested controller elements

getNestedOrNull

public Vector getNestedOrNull()
Same as getNested. But does not allocate a Vector if there aren't any values.

Returns:
java.util.Vector or null if nested Vector doesn't exist yet.

getNestedIterator

public Iterator getNestedIterator()
Retrieve the iterator to all tested objects.

Returns:

getParent

public ControllerElement getParent()
Return the "parent" of this element - e.g. the element that this element is nested within

Returns:
the parent element or possibly null if there is no parent

getType

public String getType()
Returns whatever the type is

Returns:
java.lang.String

remove

public void remove()
            throws ControllerException
Remove this item from the "nested" items of it's parent. After this method, the item is still valid, but is no longer nested within it's parent

Throws:
ControllerException - if the current item is not nested

removeNested

public void removeNested(ControllerElement elementToRemove)
                  throws ControllerException
Remove an element from the nested elements for this item

Parameters:
elementToRemove - The element to be removed from the list of nested items.
Throws:
ControllerException - if there is no such item nested in this item

setAttribute

public void setAttribute(String attrib,
                         String val)
Set the named attribute of this Output to the given value

Parameters:
attrib - The name of an "attribtue" for this ControllerElement item
val - The value for this attribute

setDescription

public void setDescription(String newDescription)
Used by the controller to set the description of this element

Parameters:
newDescription - The description being set by this object

setDisplayLength

public void setDisplayLength(int newLength)
Set the suggested display length (in caracters) for this Controller element

Parameters:
newLength - The specified length for display of this element

setLabel

public void setLabel(String newLabel)
Set a label for this element

Parameters:
newLabel - The new label for this element

setLines

public void setLines(int newLines)
Set the display number of lines suggested for this item

Parameters:
newLines - The number of lines to specify

setName

public void setName(String newName)
Used by the controller to set the name of this element

Parameters:
newName - The new name for this element

setParent

public void setParent(ControllerElement t)
Set the "parent" of this element - e.g. the element that this element is nested within

Parameters:
t - The ControllerElement that has this element as a nested item

setType

public void setType(String s)
Sets the descriptive data type for this ControllerElement

Parameters:
s - a new java.lang.String

toXML

public FastStringBuffer toXML(FastStringBuffer stream)
Convert the object to an xml fragment.

Parameters:
stream - a pre-allocated FastStringBuffer to append to
Returns:
the in parameter stream.

getNested

public ControllerElement getNested(String nestedName)
                            throws ControllerException
Return a specific Element nested within this Element

Parameters:
nestedName - the name of the element to retrieve
Returns:
An Element with the specified name or null if it doesn't exist
Throws:
ControllerException

getNestedMap

public Map getNestedMap()
Return a Map of all nested elements keyed by controllerElement name. Useful for JSTL iteration of the Map.


setControllerResponse

public void setControllerResponse(ControllerResponse newResponse)
Called by the ControllerResponse to hand itself back to this element so that it can be accessed by the elements as required

Parameters:
newResponse - the new Response.

getControllerResponse

protected ControllerResponse getControllerResponse()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.