com.arsdigita.bebop
Class SimpleContainer

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.SimpleContainer
All Implemented Interfaces:
Cloneable, Component, Container, Lockable
Direct Known Subclasses:
AdminPane, BoxPanel, CategoryPanel, ColumnPanel, ConfigList, ControlEditor, DimensionalNavbar, GridPanel, ListPanel, MetaObjectProperties, ModalContainer, Multiple, Paginator, PermissionsPane, Portal, Portlet, ProcessListenerEditor, PropertiesEditor, PropertyEditor, QueryComponent, RecoverPasswordPanel, ResourceConfigComponent, SecurityContainer, SegmentedPanel, SegmentedPanel.Segment, SiteMapAdminPane, SplitPanel, TabbedPane, UserInfo

public class SimpleContainer
extends BlockStylable
implements Container

A basic implementation of the Container interface.

By default, renders all of its children directly, without wrapping them in any kind of tag. However, the SimpleContainer(String, String) constructor and/or the setTag(String) method can be used to cause the container to wrap the XML for its children in an arbitrary tag. This functionality is useful for XSL templating. For example, a template rule might be written to arrange the children of this component in paragraphs:

// Java Code:
 m_container = new SimpleContainer("cms:foo", CMS_XML_NS);

 // XSL code:
 <xsl:template match="cms:foo">
   <xsl:for-each select="*">
     <p>
     <xsl:apply-templates select="."/>
     </p>
   </xsl:for-each>
 </xsl:template>
 

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/SimpleContainer.java#12 $
Author:
David Lutterkort, Stanislav Freidin, Rory Solomon, Uday Mathur

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
SimpleContainer()
          Constructs a new, empty SimpleContainer.
SimpleContainer(String tag, String ns)
          Constructs a new, empty SimpleContainer that will wrap its children in the specified tag.
 
Method Summary
 void add(Component pc)
          Adds a component to this container.
 void add(Component c, int constraints)
          Adds a component to this container.
 Iterator children()
          Returns all the components of this container.
 boolean contains(Object o)
          Determines membership.
 void generateChildrenXML(PageState state, Element p)
          Generates the XML for this container.
protected  Element generateParent(Element p)
          Generates the containing element.
 void generateXML(PageState state, Element p)
          Generates the XML for this container.
 Component get(int index)
          Gets the component at the specified position.
 String getNamespace()
          Retrieves the name of the XML namespace for the tag that will be used to wrap the child components.
 String getTag()
          Retrieves the name of the XML tag that will be used to wrap the child components.
 int indexOf(Component pc)
           
 boolean isEmpty()
          Determines whether the container is empty.
protected  void setNamespace(String ns)
          Sets the XML namespace for the tag that will be used to wrap the children of this container.
protected  void setTag(String tag)
          Sets the XML tag that will be used to wrap the children of this container.
 int size()
          Returns the number of children inside this container.
 
Methods inherited from class com.arsdigita.bebop.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, register, respond, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked, lock
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

SimpleContainer

public SimpleContainer()
Constructs a new, empty SimpleContainer.


SimpleContainer

public SimpleContainer(String tag,
                       String ns)
Constructs a new, empty SimpleContainer that will wrap its children in the specified tag.

Parameters:
tag - the name of the XML element that will be used to wrap the children of this container
ns - the namespace for the tag
Method Detail

add

public void add(Component pc)
Adds a component to this container.

Specified by:
add in interface Container
Parameters:
pc - the component to be added

add

public void add(Component c,
                int constraints)
Adds a component to this container.

Specified by:
add in interface Container
Parameters:
constraints - this parameter is ignored. Child classes should override the add method if they wish to provide special handling of constraints.

contains

public boolean contains(Object o)
Determines membership.

Specified by:
contains in interface Container
Parameters:
o - the object type, typically a component. Type Object allows slicker code when o comes from any kind of collection.
Returns:
true if the specified object is in this container; false otherwise.

isEmpty

public boolean isEmpty()
Determines whether the container is empty.

Specified by:
isEmpty in interface Container
Returns:
false if the container has any children; true otherwise.

indexOf

public int indexOf(Component pc)
Specified by:
indexOf in interface Container
Parameters:
pc - component to search for
Returns:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

size

public int size()
Returns the number of children inside this container.

Specified by:
size in interface Container
Returns:
the number of children inside this container.

get

public Component get(int index)
Description copied from interface: Container
Gets the component at the specified position. Each call to the add method increments the index. Since the user has no control over the index of added components (other than counting each call to the add method), this method should be used in conjunction with indexOf.

Specified by:
get in interface Container
Parameters:
index - the index of the item to be retrieved from this container
Returns:
the component at the specified position in this container.

children

public Iterator children()
Returns all the components of this container.

Specified by:
children in interface Component
Overrides:
children in class SimpleComponent
Returns:
all the components of this container.

setTag

protected final void setTag(String tag)
Sets the XML tag that will be used to wrap the children of this container.

Parameters:
tag - the XML tag, or null if children will not be wrapped in any manner.

setNamespace

protected final void setNamespace(String ns)
Sets the XML namespace for the tag that will be used to wrap the children of this container.

Parameters:
ns - the XML namespace

getTag

public final String getTag()
Retrieves the name of the XML tag that will be used to wrap the child components.

Returns:
the name of the XML tag that will be used to wrap the child components, or null if no tag was specified.

getNamespace

public final String getNamespace()
Retrieves the name of the XML namespace for the tag that will be used to wrap the child components.

Returns:
the name of the XML namespace for the tag that will be used to wrap the child components, or null if no namespace was specified.

generateParent

protected Element generateParent(Element p)
Generates the containing element. It is added with this component's tag below the specified parent element. If the passed in element is null, the method passes through p.

Parameters:
p - the parent XML element
Returns:
the element to which the children will be added.

generateChildrenXML

public void generateChildrenXML(PageState state,
                                Element p)
Generates the XML for this container. If the tag property is nonempty, wraps the children in the specified XML tag.

Parameters:
state - represents the current request
p - the parent XML element
See Also:
setTag(String), setNamespace(String)

generateXML

public void generateXML(PageState state,
                        Element p)
Generates the XML for this container. If the tag property is nonempty, wraps the children in the specified XML tag.

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleComponent
Parameters:
state - represents the current request
p - the parent XML element
See Also:
setTag(String), setNamespace(String)


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC