org.enhydra.barracuda.core.comp
Class AbstractBComponent

java.lang.Object
  |
  +--org.enhydra.barracuda.core.comp.AbstractBComponent
All Implemented Interfaces:
BContainer, StateMap
Direct Known Subclasses:
BComponent

public abstract class AbstractBComponent
extends java.lang.Object
implements BContainer, StateMap

This class provides the abstract implementation for BComponent. Typically, however, you would extend from BComponent, not this class.


Field Summary
protected  java.util.List children
           
protected  java.lang.Object dvc
           
protected  boolean isStepChild
           
protected static org.apache.log4j.Logger logger
           
protected  BContainer parent
           
protected  boolean preventCaching
           
protected  StateMap statemap
           
protected  java.util.List stepChildren
           
protected  java.util.List tempViews
           
protected  boolean validated
           
protected  java.util.List views
           
 
Constructor Summary
AbstractBComponent()
           
 
Method Summary
 void addChild(BContainer child)
          Add a child container to this one
 void addStepChild(BContainer child)
          Add a step child; step children are automatically removed after each render.
 void addStepChild(BContainer child, boolean inheritParentAttrs)
          Add a step child; step children are automatically removed after each render.
 void addTempView(View tview)
          Add a temporary view; temp views are automatically removed after each render
abstract  void addView(View view)
           
 void destroyCycle()
          Destroy cycle.
protected  java.util.Map findComponentMap(java.lang.Class cl)
          Look for a factory that can render either this class or its parent class.
protected  RendererFactory findRendererFactory(java.lang.Class cl, java.util.Map domMap)
          Look for a factory that can render either this class or its parent class.
abstract  java.lang.Object getAttr(java.lang.Object attr)
           
abstract  java.util.Map getAttrMap()
           
 BContainer getChild(int index)
          Get a child container at a given index
 java.util.List getChildren()
          Gets a list of all child BContainers.
 ViewContext getDefaultViewContext()
          Get the default ViewContext.
abstract  java.lang.String getName()
           
 BContainer getParent()
          Get the parent container.
 boolean getPreventCaching()
          Determine whether the root component is preventing DOM caching
 Renderer getRenderer(java.lang.Class domCl)
           
 Renderer getRenderer(View view)
          This method allows a component to get a reference to the appropriate renderer.
 AbstractBComponent getRootComponent()
           
 java.lang.Object getState(java.lang.Object key)
          get a property in this StateMap
 java.util.List getStateKeys()
          get a list of the keys for this StateMap
 java.util.Map getStateValues()
          get a copy of the underlying Map
abstract  java.util.List getViews()
           
 boolean hasChildren()
          Determine whether this container has any children
 boolean hasViews()
          Determine whether the component has any views (either regular or temp)
 void initCycle()
          Initialize cycle.
static void installRendererFactory(RendererFactory rf, java.lang.Class compCl, java.lang.Class domCl)
          This allows developers to install custom renderers for specific classes of components.
 void invalidate()
          Invalidates the container and all parent containers above it.
abstract  boolean isEnabled()
           
 boolean isStepChild()
          Determine whether this component is a step child
abstract  boolean isVisible()
           
 void printStackTrace(int depth, org.apache.log4j.Logger logger)
           
protected  void printStackTrace(int depth, org.apache.log4j.Logger logger, java.io.OutputStream out)
          For debugging purposes.
 void printStackTrace(int depth, java.io.OutputStream out)
           
 void putState(java.lang.Object key, java.lang.Object val)
          set a property in this StateMap
 void removeAll()
          Remove all child containers from this one
 void removeAllStepChildren()
          Remove all step children
abstract  void removeAllViews()
           
 BContainer removeChild(BContainer child)
          Remove a child container from this one
 BContainer removeChild(int index)
          Remove a child container for a given index
 java.lang.Object removeState(java.lang.Object key)
          remove a property in this StateMap
abstract  boolean removeView(View view)
           
abstract  void render(ViewContext vc)
           
abstract  void setAttr(java.lang.Object attr, java.lang.Object val)
           
 void setDefaultViewContext(ViewContext idvc)
          Set the default ViewContext.
abstract  void setEnabled(boolean val)
           
abstract  void setEnabled(boolean val, boolean recurse)
           
abstract  void setName(java.lang.String iname)
           
 void setParent(BContainer iparent)
          Set the parent container.
 void setPreventCaching(boolean val)
          Tell the root component to prevent the DOM from caching when rendered to the client
abstract  void setView(View view)
           
abstract  void setVisible(boolean val)
           
abstract  void setVisible(boolean val, boolean recurse)
           
abstract  boolean supports(ViewContext vc)
           
 java.lang.String toRef()
          Get the component reference
 java.lang.String toString()
          Get a String representation of the component
 java.lang.String toString(ViewContext vc)
          Provide a String representation of the component.
 void validate()
          Invalidates the container and all child containers below it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

parent

protected BContainer parent

children

protected java.util.List children

stepChildren

protected java.util.List stepChildren

isStepChild

protected boolean isStepChild

views

protected java.util.List views

tempViews

protected java.util.List tempViews

dvc

protected java.lang.Object dvc

preventCaching

protected boolean preventCaching

validated

protected boolean validated

statemap

protected StateMap statemap
Constructor Detail

AbstractBComponent

public AbstractBComponent()
Method Detail

setName

public abstract void setName(java.lang.String iname)
Specified by:
setName in interface BContainer

getName

public abstract java.lang.String getName()
Specified by:
getName in interface BContainer

setVisible

public abstract void setVisible(boolean val)

setVisible

public abstract void setVisible(boolean val,
                                boolean recurse)

isVisible

public abstract boolean isVisible()

setEnabled

public abstract void setEnabled(boolean val)

setEnabled

public abstract void setEnabled(boolean val,
                                boolean recurse)

isEnabled

public abstract boolean isEnabled()

setView

public abstract void setView(View view)

addView

public abstract void addView(View view)

removeView

public abstract boolean removeView(View view)

removeAllViews

public abstract void removeAllViews()

getViews

public abstract java.util.List getViews()

setAttr

public abstract void setAttr(java.lang.Object attr,
                             java.lang.Object val)

getAttr

public abstract java.lang.Object getAttr(java.lang.Object attr)

getAttrMap

public abstract java.util.Map getAttrMap()

render

public abstract void render(ViewContext vc)
                     throws RenderException
RenderException

supports

public abstract boolean supports(ViewContext vc)

setDefaultViewContext

public void setDefaultViewContext(ViewContext idvc)
Set the default ViewContext.


getDefaultViewContext

public ViewContext getDefaultViewContext()
Get the default ViewContext.

Returns:
the default ViewContext

setPreventCaching

public void setPreventCaching(boolean val)
Tell the root component to prevent the DOM from caching when rendered to the client


getPreventCaching

public boolean getPreventCaching()
Determine whether the root component is preventing DOM caching

Returns:
true if root component is preventing caching

getRootComponent

public AbstractBComponent getRootComponent()

installRendererFactory

public static void installRendererFactory(RendererFactory rf,
                                          java.lang.Class compCl,
                                          java.lang.Class domCl)
This allows developers to install custom renderers for specific classes of components. This should generally be done at startup.

Parameters:
rf - the RendererFactory to be registered
compCl - the target document class
domCl - the target dom class

getRenderer

public Renderer getRenderer(View view)
                     throws NoSuitableRendererException
This method allows a component to get a reference to the appropriate renderer. If an exact match does not exist, it will automatically look for renderers registered on parent classes.

NoSuitableRendererException

getRenderer

public Renderer getRenderer(java.lang.Class domCl)
                     throws NoSuitableRendererException
NoSuitableRendererException

findComponentMap

protected java.util.Map findComponentMap(java.lang.Class cl)
Look for a factory that can render either this class or its parent class.


findRendererFactory

protected RendererFactory findRendererFactory(java.lang.Class cl,
                                              java.util.Map domMap)
Look for a factory that can render either this class or its parent class.


initCycle

public void initCycle()
Initialize cycle. The component should use this to perform any initialization. Note that the component should be added to the overall component hierarchy before you invoke this method.


destroyCycle

public void destroyCycle()
Destroy cycle. The component should use this cycle to perform any special cleanup.


setParent

public void setParent(BContainer iparent)
Set the parent container. Null indicates its the root.

Specified by:
setParent in interface BContainer

getParent

public BContainer getParent()
Get the parent container. Returns null if it's the root.

Specified by:
getParent in interface BContainer
Returns:
the parent container

addChild

public void addChild(BContainer child)
Add a child container to this one

Specified by:
addChild in interface BContainer
Parameters:
child - the child container to be added

getChild

public BContainer getChild(int index)
Get a child container at a given index

Specified by:
getChild in interface BContainer

removeChild

public BContainer removeChild(BContainer child)
Remove a child container from this one

Specified by:
removeChild in interface BContainer
Parameters:
child - the a child container to be removed
Returns:
the child container that was removed

removeChild

public BContainer removeChild(int index)
Remove a child container for a given index

Specified by:
removeChild in interface BContainer
Parameters:
index - of the child container to be removed
Returns:
the child container that was removed

removeAll

public void removeAll()
Remove all child containers from this one

Specified by:
removeAll in interface BContainer

hasChildren

public boolean hasChildren()
Determine whether this container has any children

Specified by:
hasChildren in interface BContainer
Returns:
true if the container has child containers

getChildren

public java.util.List getChildren()
Gets a list of all child BContainers. Note, this method returns a copy of the underlying child list

Specified by:
getChildren in interface BContainer
Returns:
a list of all child components.

isStepChild

public boolean isStepChild()
Determine whether this component is a step child

Returns:
true if this component is a step child

addStepChild

public void addStepChild(BContainer child)
Add a step child; step children are automatically removed after each render.

Parameters:
child - the step child container to be added

addStepChild

public void addStepChild(BContainer child,
                         boolean inheritParentAttrs)
Add a step child; step children are automatically removed after each render.

Parameters:
child - the step child container to be added
inheritParentAttrs - true if we want the step child to inherit the parent's settings for visibility/enabled

removeAllStepChildren

public void removeAllStepChildren()
Remove all step children


addTempView

public void addTempView(View tview)
Add a temporary view; temp views are automatically removed after each render

Parameters:
tview - the temp view to be added

hasViews

public boolean hasViews()
Determine whether the component has any views (either regular or temp)

Returns:
true if the component has any views

invalidate

public void invalidate()
Invalidates the container and all parent containers above it. This essentially indicates the components need to be laid out (in the server side world, this is equivalent to rendering) again. After a component has been rendered, it will be marked valid again.

Specified by:
invalidate in interface BContainer

validate

public void validate()
Invalidates the container and all child containers below it. Calling validate on the root of a tree effectively invalidates the entire tree, forcing the whole tree to be revalidated the next time it is rendered. This call is more expensive than an invalidate because it has to hit every node in the hierarchy.

Specified by:
validate in interface BContainer

putState

public void putState(java.lang.Object key,
                     java.lang.Object val)
set a property in this StateMap

Specified by:
putState in interface StateMap
Parameters:
key - the state key object
val - the state value object

getState

public java.lang.Object getState(java.lang.Object key)
get a property in this StateMap

Specified by:
getState in interface StateMap
Parameters:
key - the state key object
Returns:
the value for the given key

removeState

public java.lang.Object removeState(java.lang.Object key)
remove a property in this StateMap

Specified by:
removeState in interface StateMap
Parameters:
key - the key object
Returns:
the object which was removed

getStateKeys

public java.util.List getStateKeys()
get a list of the keys for this StateMap

Specified by:
getStateKeys in interface StateMap
Returns:
a list the keys for this StateMap

getStateValues

public java.util.Map getStateValues()
get a copy of the underlying Map

Specified by:
getStateValues in interface StateMap
Returns:
a copy of the underlying state Map

toRef

public java.lang.String toRef()
Get the component reference

Returns:
a String representation of the component reference

toString

public java.lang.String toString()
Get a String representation of the component

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the component

toString

public java.lang.String toString(ViewContext vc)
Provide a String representation of the component. This will attempt to render the link as markup, which allows you to inline components along with text (a very useful feature!).

Returns:
a String representation of the component

printStackTrace

public void printStackTrace(int depth,
                            org.apache.log4j.Logger logger)

printStackTrace

public void printStackTrace(int depth,
                            java.io.OutputStream out)

printStackTrace

protected void printStackTrace(int depth,
                               org.apache.log4j.Logger logger,
                               java.io.OutputStream out)
For debugging purposes. Print the basic structure of the gateway.



Copyright © 2001 Enhydra.org