org.jwarp.flow.form.model
Class Component

java.lang.Object
  |
  +--org.jwarp.flow.form.model.Component
All Implemented Interfaces:
IComponent
Direct Known Subclasses:
Container

public abstract class Component
extends java.lang.Object
implements IComponent

A generic JWeb container object is a component that can contain other element components.

Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container, it will be added to the end of the list (and hence to the bottom of the stacking order).

Version:
1.0, 02/01/01
Author:
Anatole Tresch
See Also:
Container

Field Summary
protected  java.util.Vector componentListeners
           
protected  java.lang.String description
           
protected  boolean enabled
           
protected  int id
           
protected  java.util.Locale locale
           
protected  java.lang.String name
           
protected  IContainer parent
           
 
Constructor Summary
protected Component(int id, java.lang.String name, IContainer parent)
           
protected Component(java.lang.String name, IContainer parent)
           
 
Method Summary
 void addComponentListener(IComponentListener l)
          Adds the specified container listener to receive container events from this container.
 java.lang.String getDescription()
          Return the current description.
 java.lang.String getFullName()
          Returns the name of this component container.
 int getID()
          Return the model's id.
 java.util.Iterator getListeners(java.lang.Class listenerType)
          Return an array of all the listeners that were added to the Container with addXXXListener(), where XXX is the name of the listenerType argument.
 java.util.Locale getLocale()
          Gets the locale of this component.
 java.lang.String getName()
          Returns the name of this component container.
 IContainer getParent()
          Get the parents component (if any)
 org.jdom.Element getXMLTree()
          Get the actual XML result.
 void handleEvent(ComponentEvent e)
          Take an event
 boolean isEnabled()
          Returns true if the component is enabled.
 void removeComponentListener(IComponentListener l)
          Removes the specified container listener so it no longer receives container events from this container.
 void setDescription(java.lang.String description)
          Sets the description.
 void setEnabled(boolean val)
          Enable/disable a component.
 void setFlowData(IFlowData data)
          Set the flow data.
 void setLocale(java.util.Locale l)
          Sets the locale of this component.
 void setName(java.lang.String name)
          Sets the name of this component container.
 void setParent(IContainer parent)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enabled

protected boolean enabled

componentListeners

protected java.util.Vector componentListeners

locale

protected java.util.Locale locale

id

protected int id

name

protected java.lang.String name

description

protected java.lang.String description

parent

protected IContainer parent
Constructor Detail

Component

protected Component(int id,
                    java.lang.String name,
                    IContainer parent)

Component

protected Component(java.lang.String name,
                    IContainer parent)
Method Detail

getID

public int getID()
Description copied from interface: IComponent
Return the model's id. This is an internal id used for referncing concrete model implementations.
Specified by:
getID in interface IComponent
Following copied from interface: org.jwarp.flow.form.model.IComponent
Returns:
The model's id

getParent

public IContainer getParent()
Description copied from interface: IComponent
Get the parents component (if any)
Specified by:
getParent in interface IComponent
Following copied from interface: org.jwarp.flow.form.model.IComponent
Returns:
The parent

setParent

public void setParent(IContainer parent)

getLocale

public java.util.Locale getLocale()
Gets the locale of this component.
Specified by:
getLocale in interface IComponent
Returns:
This component's locale. If this component does not have a locale, the locale of its parent is returned.
Throws:
IllegalComponentStateException - If the Component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent.
See Also:
setLocale(java.util.Locale)

setLocale

public void setLocale(java.util.Locale l)
Sets the locale of this component.
Specified by:
setLocale in interface IComponent
Parameters:
l - The locale to become this component's locale.
See Also:
getLocale()

setEnabled

public void setEnabled(boolean val)
Enable/disable a component.
Specified by:
setEnabled in interface IComponent
Parameters:
true - to enable the component, false otherwise

isEnabled

public boolean isEnabled()
Returns true if the component is enabled.
Specified by:
isEnabled in interface IComponent
Returns:
enabled or not

addComponentListener

public void addComponentListener(IComponentListener l)
Adds the specified container listener to receive container events from this container.
Specified by:
addComponentListener in interface IComponent
Parameters:
l - the container listener

removeComponentListener

public void removeComponentListener(IComponentListener l)
Removes the specified container listener so it no longer receives container events from this container. If l is null, no exception is thrown and no action is performed.
Specified by:
removeComponentListener in interface IComponent
Parameters:
l - the container listener

getListeners

public java.util.Iterator getListeners(java.lang.Class listenerType)
Return an array of all the listeners that were added to the Container with addXXXListener(), where XXX is the name of the listenerType argument. For example, to get all of the ContainerListener(s) for the given Container c, one would write:
 ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class))
 
If no such listener list exists, then an empty array is returned.
Specified by:
getListeners in interface IComponent
Parameters:
listenerType - Type of listeners requested
Returns:
all of the listeners of the specified type supported by this container
Since:
1.3

handleEvent

public void handleEvent(ComponentEvent e)
Take an event
Specified by:
handleEvent in interface IComponent
Following copied from interface: org.jwarp.flow.form.model.IComponent
Parameters:
event - The event to be handled

getName

public java.lang.String getName()
Returns the name of this component container. This string is useful for debugging.
Specified by:
getName in interface IComponent
Returns:
the parameter string of this container.

getFullName

public java.lang.String getFullName()
Returns the name of this component container. This string is useful for debugging.
Specified by:
getFullName in interface IComponent
Returns:
the parameter string of this container.

getDescription

public java.lang.String getDescription()
Return the current description.
Specified by:
getDescription in interface IComponent
Returns:
The description

setName

public void setName(java.lang.String name)
Sets the name of this component container. This string is useful for debugging.
Parameters:
name - The name

setDescription

public void setDescription(java.lang.String description)
Sets the description.
Parameters:
The - description

setFlowData

public void setFlowData(IFlowData data)
Description copied from interface: IComponent
Set the flow data. This merges the actual data (XML tree) into the current component. The resulting component is then an abstract form that will be mapped to a concrete implementation thru the mapping service. This abstract version can be get through the getXMLTree method.
Specified by:
setFlowData in interface IComponent
Following copied from interface: org.jwarp.flow.form.model.IComponent
Parameters:
data - The flow data
Throws:
FormInitException - If the component could be initialised

getXMLTree

public org.jdom.Element getXMLTree()
                            throws FormInitException
Description copied from interface: IComponent
Get the actual XML result.
Specified by:
getXMLTree in interface IComponent
Following copied from interface: org.jwarp.flow.form.model.IComponent
Returns:
The valid XML tree for this object
Throws:
FormInitException - If the component is not initialised with any neded data

©   O R C A   S y s t e m s