view.xhtml
Class ContainerElement

java.lang.Object
  extended by view.xhtml.HtmlObject
      extended by view.xhtml.HtmlElement
          extended by view.xhtml.ContainerElement
Direct Known Subclasses:
A, Body, Div, Form, H3, Head, Html, P, Pre, Script, Select, SelectOption, Span, Table, TableCell, Textarea, Title, Tr

public abstract class ContainerElement
extends HtmlElement


Field Summary
private  java.util.ArrayList<HtmlObject> content
           
private  boolean indentable
           
 
Constructor Summary
ContainerElement(java.lang.String tag_name)
          As above, but automatically sets 'indentable' to true.
ContainerElement(java.lang.String tag_name, boolean is_indentable)
          Constructs a ContainerElement.
 
Method Summary
 ContainerElement add(HtmlObject html)
          Adds an HTML object to this container element.
 ContainerElement add(java.lang.String text)
          As above, but accepts a String, which will be automatically converted to an HtmlText object.
private  java.lang.String getContent()
          Returns the HTML source code of the contained objects.
private  java.lang.String getContent(int indent_level, int indent_width)
          As above, but with indendation.
 java.lang.String getHtml()
          Returns the HTML source code of the container and its inner elements.
 java.lang.String getHtml(int indent_level, int indent_width)
          As above but with indentation by blocks, that is, the start and close tags of inner elements will have an indentation one level greater than the container element.
 
Methods inherited from class view.xhtml.HtmlElement
getCloseTag, getCloseTag, getStartTag, getStartTag, setAttribute, setClass, setId, setName
 
Methods inherited from class view.xhtml.HtmlObject
getHtml, getIndent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

content

private final transient java.util.ArrayList<HtmlObject> content

indentable

private final transient boolean indentable
Constructor Detail

ContainerElement

public ContainerElement(java.lang.String tag_name,
                        boolean is_indentable)
Constructs a ContainerElement.

Parameters:
tag_name - name of the element's tag.
is_indentable - 'indentable' flag if false, indentation isn't applied to this object.

ContainerElement

public ContainerElement(java.lang.String tag_name)
As above, but automatically sets 'indentable' to true.

Method Detail

getContent

private java.lang.String getContent()
Returns the HTML source code of the contained objects.


getContent

private java.lang.String getContent(int indent_level,
                                    int indent_width)
As above, but with indendation.

Parameters:
indent_level - the indentation level used at root level
indent_width - ... for inner elements.

add

public final ContainerElement add(HtmlObject html)
Adds an HTML object to this container element.

Parameters:
html - the element to be added. may be null, in which case adds nothing.
Returns:
this object, to allow multiple consecutive calls in a single statement, simplifying the caller code. subclasses with similar methods should do the same.

add

public final ContainerElement add(java.lang.String text)
As above, but accepts a String, which will be automatically converted to an HtmlText object. (See HtmlText.java). A null is not allowed here.


getHtml

public final java.lang.String getHtml()
Returns the HTML source code of the container and its inner elements. The inner elements appear in the code in the order they've been added.

Specified by:
getHtml in class HtmlObject

getHtml

public final java.lang.String getHtml(int indent_level,
                                      int indent_width)
As above but with indentation by blocks, that is, the start and close tags of inner elements will have an indentation one level greater than the container element. The indentation is applied recursively. If the element has been constructed with a 'no indentation' flag, indentation is omitted both from the element itself and its inner elements.

Specified by:
getHtml in class HtmlObject
Parameters:
indent_level - the indentation level used for the container itself
indent_width - the relative width of each indentation level (in spaces)