view.xhtml
Class HtmlElement

java.lang.Object
  extended by view.xhtml.HtmlObject
      extended by view.xhtml.HtmlElement
Direct Known Subclasses:
ContainerElement, EmptyElement

public abstract class HtmlElement
extends HtmlObject


Nested Class Summary
private  class HtmlElement.ElementAttribute
          A private class for HTML element attributes.
 
Field Summary
private  java.util.ArrayList<HtmlElement.ElementAttribute> attributes
           
private  java.lang.String tag_name
           
 
Constructor Summary
HtmlElement(java.lang.String element_tag_name)
          Constructs the element.
 
Method Summary
private  java.lang.String getAttributeList()
          Returns the HTML source code the element's attribute list.
protected  java.lang.String getCloseTag()
          Constructs and returns the close tag of the element.
protected  java.lang.String getCloseTag(int indent_level)
          As above but with indentation.
protected  java.lang.String getStartTag(boolean close)
          Constructs and returns the start tag of the element.
protected  java.lang.String getStartTag(int indent_level, boolean close)
          As above but with indendation.
 HtmlElement setAttribute(java.lang.String attribute_name, java.lang.String attribute_value)
          Sets the value of an attribute of the element.
 HtmlElement setClass(java.lang.String class_name)
          A short method for setting the 'class' attribute.
 HtmlElement setId(java.lang.String id)
          A short method for setting the 'id' attribute.
 HtmlElement setName(java.lang.String name)
          A short method for setting the 'name' attribute.
 
Methods inherited from class view.xhtml.HtmlObject
getHtml, getHtml, getHtml, getIndent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tag_name

private final transient java.lang.String tag_name

attributes

private final transient java.util.ArrayList<HtmlElement.ElementAttribute> attributes
Constructor Detail

HtmlElement

public HtmlElement(java.lang.String element_tag_name)
Constructs the element.

Parameters:
element_tag_name - the name of the element's tag.
Method Detail

getAttributeList

private java.lang.String getAttributeList()
Returns the HTML source code the element's attribute list.


setAttribute

public final HtmlElement setAttribute(java.lang.String attribute_name,
                                      java.lang.String attribute_value)
Sets the value of an attribute of the element.

Parameters:
attribute_name - the name of the attribute to set.
attribute_value - the value to set for the attribute.
Returns:
itself, subclasses with similar methods should do the same to simplify the usage.

getStartTag

protected final java.lang.String getStartTag(boolean close)
Constructs and returns the start tag of the element.

Parameters:
close - if true, the tag is also closed, this is required for empty elements.

getStartTag

protected final java.lang.String getStartTag(int indent_level,
                                             boolean close)
As above but with indendation. (See HtmlObject.java for parameters).


getCloseTag

protected final java.lang.String getCloseTag()
Constructs and returns the close tag of the element.


getCloseTag

protected final java.lang.String getCloseTag(int indent_level)
As above but with indentation. (See HtmlObject.java for parameters).


setName

public final HtmlElement setName(java.lang.String name)
A short method for setting the 'name' attribute.

Parameters:
name - a value for 'name'.

setId

public final HtmlElement setId(java.lang.String id)
A short method for setting the 'id' attribute.

Parameters:
id - a value for 'id'.

setClass

public final HtmlElement setClass(java.lang.String class_name)
A short method for setting the 'class' attribute.

Parameters:
class_name - a value for 'class'.