Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.html
Class Element  view Element download Element.java

java.lang.Object
  extended byorg.mortbay.html.Element
Direct Known Subclasses:
Composite, DefList, Include, Tag

public abstract class Element
extends java.lang.Object

HTML Element.

This abstract class is the base for all HTML Elements. The feature of an abstract HTML Element is that it can be added to HTML Pages, HTML Composites and several other HTML Elements derivations. Elements may also have attributes set, which are handled by the derived Element.

Version:
$Id: Element.java,v 1.7 2003/10/05 23:46:20 gregwilkins Exp $

Field Summary
static java.lang.String ALIGN
           
protected  java.util.Hashtable attributeMap
           
private  java.lang.String attributes
          The space separated string of HTML element attributes.
static java.lang.String BGCOLOR
           
static java.lang.String BOTTOM
           
static java.lang.String CENTER
           
static java.lang.String CLASS
           
static java.lang.String COLOR
           
private  int height
           
static java.lang.String HEIGHT
           
static java.lang.String ID
           
static java.lang.String LEFT
           
private static org.apache.commons.logging.Log log
           
static java.lang.String MIDDLE
           
static java.lang.String noAttributes
           
static java.lang.String RIGHT
           
private  int size
           
static java.lang.String SIZE
           
static java.lang.String STYLE
           
static java.lang.String TOP
           
static java.lang.String VALIGN
           
private  int width
          Dimensions >=0 if set
static java.lang.String WIDTH
           
 
Constructor Summary
Element()
          Default constructor.
Element(java.lang.String attributes)
          Construct with attributes.
 
Method Summary
 Element attribute(java.lang.String attributes)
          Add element Attributes.
 Element attribute(java.lang.String attribute, long value)
          Add quoted element Attributes and value.
 Element attribute(java.lang.String attribute, java.lang.Object value)
          Add quoted element Attributes and value.
 java.lang.String attributes()
           
 Element attributes(java.lang.String attributes)
          Deprecated. Use attribute(String).
 Element bgColor(java.lang.String color)
          set BGCOLOR.
 Element bottom()
          Bottom align.
 Element center()
          Center.
 Element color(java.lang.String color)
          set color.
 Element cssClass(java.lang.String c)
          set CSS CLASS.
 Element cssID(java.lang.String id)
          set CSS ID.
 int height()
           
 Element height(int h)
          set height.
 Element height(java.lang.String h)
          set height.
 Element left()
          left justify.
 Element middle()
          Middle align.
 Element right()
          right justify.
 Element setAttributesFrom(Element e)
          Set attributes from another Element.
 int size()
           
 Element size(int s)
          set size.
 Element size(java.lang.String s)
          set size.
 Element style(java.lang.String style)
          set Style.
 Element top()
          Top align.
 java.lang.String toString()
          Convert Element to String.
 int width()
           
 Element width(int w)
          set width.
 Element width(java.lang.String w)
          set width.
 void write(java.io.OutputStream out)
          Write Element to an OutputStream.
 void write(java.io.OutputStream out, java.lang.String encoding)
          Write Element to an OutputStream.
abstract  void write(java.io.Writer out)
          Write element to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

noAttributes

public static final java.lang.String noAttributes
See Also:
Constant Field Values

ALIGN

public static final java.lang.String ALIGN
See Also:
Constant Field Values

LEFT

public static final java.lang.String LEFT
See Also:
Constant Field Values

RIGHT

public static final java.lang.String RIGHT
See Also:
Constant Field Values

CENTER

public static final java.lang.String CENTER
See Also:
Constant Field Values

VALIGN

public static final java.lang.String VALIGN
See Also:
Constant Field Values

TOP

public static final java.lang.String TOP
See Also:
Constant Field Values

BOTTOM

public static final java.lang.String BOTTOM
See Also:
Constant Field Values

MIDDLE

public static final java.lang.String MIDDLE
See Also:
Constant Field Values

WIDTH

public static final java.lang.String WIDTH
See Also:
Constant Field Values

HEIGHT

public static final java.lang.String HEIGHT
See Also:
Constant Field Values

SIZE

public static final java.lang.String SIZE
See Also:
Constant Field Values

COLOR

public static final java.lang.String COLOR
See Also:
Constant Field Values

BGCOLOR

public static final java.lang.String BGCOLOR
See Also:
Constant Field Values

STYLE

public static final java.lang.String STYLE
See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
See Also:
Constant Field Values

ID

public static final java.lang.String ID
See Also:
Constant Field Values

width

private int width
Dimensions >=0 if set


height

private int height

size

private int size

attributes

private java.lang.String attributes
The space separated string of HTML element attributes.


attributeMap

protected java.util.Hashtable attributeMap
Constructor Detail

Element

public Element()
Default constructor.


Element

public Element(java.lang.String attributes)
Construct with attributes.

Method Detail

write

public abstract void write(java.io.Writer out)
                    throws java.io.IOException
Write element to a Writer. This abstract method is called by the Page or other containing Element to write the HTML for this element. This must be implemented by the derived Element classes.


write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Write Element to an OutputStream. Calls print(Writer) and checks errors Elements that override this method should also override write(Writer) to avoid infinite recursion.


write

public void write(java.io.OutputStream out,
                  java.lang.String encoding)
           throws java.io.IOException
Write Element to an OutputStream. Calls print(Writer) and checks errors Elements that override this method should also override write(Writer) to avoid infinite recursion.


attributes

public java.lang.String attributes()

attributes

public Element attributes(java.lang.String attributes)
Deprecated. Use attribute(String).

Add element Attributes. The attributes are added to the Element attributes (separated with a space). The attributes are available to the derived class in the protected member String attributes


setAttributesFrom

public Element setAttributesFrom(Element e)
Set attributes from another Element.


attribute

public Element attribute(java.lang.String attributes)
Add element Attributes. The attributes are added to the Element attributes (separated with a space). The attributes are available to the derived class in the protected member String attributes


attribute

public Element attribute(java.lang.String attribute,
                         java.lang.Object value)
Add quoted element Attributes and value.


attribute

public Element attribute(java.lang.String attribute,
                         long value)
Add quoted element Attributes and value.


toString

public java.lang.String toString()
Convert Element to String. Uses write() to convert the HTML Element to a string.


left

public Element left()
left justify. Convenience method equivalent to attribute("align","left"). Not applicable to all Elements.


right

public Element right()
right justify. Convenience method equivalent to attribute("align","right"). Not applicable to all Elements.


center

public Element center()
Center. Convenience method equivalent to attribute("align","center"). Not applicable to all Elements.


top

public Element top()
Top align. Convenience method equivalent to attribute("valign","top"). Not applicable to all Elements.


bottom

public Element bottom()
Bottom align. Convenience method equivalent to attribute("valign","bottom"). Not applicable to all Elements.


middle

public Element middle()
Middle align. Convenience method equivalent to attribute("valign","middle"). Not applicable to all Elements.


width

public Element width(int w)
set width. Convenience method equivalent to attribute("width",w). Not applicable to all Elements.


width

public Element width(java.lang.String w)
set width. Convenience method equivalent to attribute("width",w). Not applicable to all Elements.


width

public int width()

height

public Element height(int h)
set height. Convenience method equivalent to attribute("height",h). Not applicable to all Elements.


height

public Element height(java.lang.String h)
set height. Convenience method equivalent to attribute("height",h). Not applicable to all Elements.


height

public int height()

size

public Element size(int s)
set size. Convenience method equivalent to attribute("size",s). Not applicable to all Elements.


size

public Element size(java.lang.String s)
set size. Convenience method equivalent to attribute("size",s). Not applicable to all Elements.


size

public int size()

color

public Element color(java.lang.String color)
set color. Convenience method equivalent to attribute("color",color). Not applicable to all Elements.


bgColor

public Element bgColor(java.lang.String color)
set BGCOLOR. Convenience method equivalent to attribute("bgcolor",color). Not applicable to all Elements.


cssClass

public Element cssClass(java.lang.String c)
set CSS CLASS.


cssID

public Element cssID(java.lang.String id)
set CSS ID. Convenience method equivalent to attribute("id",id).


style

public Element style(java.lang.String style)
set Style. Convenience method equivalent to attribute("style",style).