com.mortbay.HTML
Class Composite

java.lang.Object
  |
  +--com.mortbay.HTML.Element
        |
        +--com.mortbay.HTML.Composite
Direct Known Subclasses:
Block, Comment, Page, Text

public class Composite
extends Element

HTML Composite Element

This class is can be used a either an abstract or concrete holder of other HTML elements. Used directly, it allow multiple HTML Elements to be added which are produced sequentially. Derived used of Composite may wrap each contain Element in special purpose HTML tags (e.g. list).

Notes
Elements are added to the Composite either as HTML Elements or as Strings. Other objects added to the Composite are converted to Strings

Version:
$Id: Composite.java,v 2.6 2000/05/15 18:04:01 gregw Exp $
Author:
Greg Wilkins
See Also:
Element

Field Summary
protected  java.util.Vector elements
          The vector of elements in this Composite
protected  Composite nest
           
 
Fields inherited from class com.mortbay.HTML.Element
ALIGN, attributeMap, BGCOLOR, BOTTOM, CENTER, CLASS, COLOR, HEIGHT, ID, LEFT, MIDDLE, noAttributes, RIGHT, SIZE, STYLE, TOP, VALIGN, WIDTH
 
Constructor Summary
Composite()
          Default constructor
Composite(java.lang.String attributes)
          Default constructor
 
Method Summary
 Composite add(java.lang.Object o)
          Add an Object to the Composite by converting it to a Element or String
 java.lang.String contents()
          Contents of the composite.
 Composite nest(Composite c)
          Nest a Composite within a Composite The passed Composite is added to this Composite.
 boolean replace(java.lang.Object oldObj, java.lang.Object newObj)
          Replace an object within the composite
 Composite reset()
          Empty the contents of this Composite
 Composite setNest(Composite c)
          Explicit set of the Nested component No add is performed.
 int size()
          The number of Elements in this Composite
 Composite unnest()
          Recursively unnest the composites
 void write(java.io.Writer out)
          Write the composite.
 
Methods inherited from class com.mortbay.HTML.Element
attribute, attribute, attribute, attributes, attributes, bgColor, bottom, center, color, cssClass, cssID, height, height, height, left, middle, right, setAttributesFrom, size, size, style, top, toString, width, width, width, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elements

protected java.util.Vector elements
The vector of elements in this Composite

nest

protected Composite nest
Constructor Detail

Composite

public Composite()
Default constructor

Composite

public Composite(java.lang.String attributes)
Default constructor
Method Detail

add

public Composite add(java.lang.Object o)
Add an Object to the Composite by converting it to a Element or String
Parameters:
o - The Object to add. If it is a String or Element, it is added directly, otherwise toString() is called.
Returns:
This Composite (for chained commands)

nest

public Composite nest(Composite c)
Nest a Composite within a Composite The passed Composite is added to this Composite. Adds to this composite are actually added to the nested Composite. Calls to nest are passed the nested Composite
Returns:
The Composite to unest on to return to the original state.

setNest

public Composite setNest(Composite c)
Explicit set of the Nested component No add is performed. setNest() obeys any current nesting and sets the nesting of the nested component.

unnest

public Composite unnest()
Recursively unnest the composites

size

public int size()
The number of Elements in this Composite
Overrides:
size in class Element
Returns:
The number of elements in this Composite

write

public void write(java.io.Writer out)
           throws java.io.IOException
Write the composite. The default implementation writes the elements sequentially. May be overridden for more specialized behaviour.
Overrides:
write in class Element
Parameters:
out - Writer to write the element to.

contents

public java.lang.String contents()
Contents of the composite.

reset

public Composite reset()
Empty the contents of this Composite

replace

public boolean replace(java.lang.Object oldObj,
                       java.lang.Object newObj)
Replace an object within the composite
Parameters:
oldObj -  
newObj -  
Returns: