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.
ALIGN
public static final String ALIGN
BGCOLOR
public static final String BGCOLOR
BOTTOM
public static final String BOTTOM
CENTER
public static final String CENTER
CLASS
public static final String CLASS
COLOR
public static final String COLOR
HEIGHT
public static final String HEIGHT
ID
public static final String ID
LEFT
public static final String LEFT
MIDDLE
public static final String MIDDLE
RIGHT
public static final String RIGHT
SIZE
public static final String SIZE
STYLE
public static final String STYLE
TOP
public static final String TOP
VALIGN
public static final String VALIGN
WIDTH
public static final String WIDTH
attributeMap
protected Hashtable attributeMap
noAttributes
public static final String noAttributes
attribute
public Element attribute(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
attributes
- String of HTML attributes to add to the element.
A null attribute clears the current attributes.
- This Element so calls can be chained.
attribute
public Element attribute(String attribute,
Object value)
Add quoted element Attributes and value.
attribute
- String of HTML attribute tagvalue
- String value of the attribute to be quoted
- This Element so calls can be chained.
attribute
public Element attribute(String attribute,
long value)
Add quoted element Attributes and value.
attribute
- String of HTML attribute tagvalue
- String value of the attribute to be quoted
- This Element so calls can be chained.
attributes
public String attributes()
attributes
public Element attributes(String attributes)
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
attributes
- String of HTML attributes to add to the element.
- This Element so calls can be chained.
bgColor
public Element bgColor(String color)
set BGCOLOR.
Convenience method equivalent to attribute("bgcolor",color). Not
applicable to all Elements.
bottom
public Element bottom()
Bottom align.
Convenience method equivalent to attribute("valign","bottom"). Not
applicable to all Elements.
center
public Element center()
Center.
Convenience method equivalent to attribute("align","center"). Not
applicable to all Elements.
color
public Element color(String color)
set color.
Convenience method equivalent to attribute("color",color). Not
applicable to all Elements.
cssClass
public Element cssClass(String c)
set CSS CLASS.
cssID
public Element cssID(String id)
set CSS ID.
Convenience method equivalent to attribute("id",id).
height
public int height()
height
public Element height(String h)
set height.
Convenience method equivalent to attribute("height",h). Not
applicable to all Elements.
height
public Element height(int h)
set height.
Convenience method equivalent to attribute("height",h). Not
applicable to all Elements.
left
public Element left()
left justify.
Convenience method equivalent to attribute("align","left"). Not
applicable to all Elements.
middle
public Element middle()
Middle align.
Convenience method equivalent to attribute("valign","middle"). Not
applicable to all Elements.
right
public Element right()
right justify.
Convenience method equivalent to attribute("align","right"). Not
applicable to all Elements.
setAttributesFrom
public Element setAttributesFrom(Element e)
Set attributes from another Element.
size
public Element size(String s)
set size.
Convenience method equivalent to attribute("size",s). Not
applicable to all Elements.
size
public Element size(int s)
set size.
Convenience method equivalent to attribute("size",s). Not
applicable to all Elements.
style
public Element style(String style)
set Style.
Convenience method equivalent to attribute("style",style).
toString
public String toString()
Convert Element to String.
Uses write() to convert the HTML Element to a string.
- String of the HTML element
top
public Element top()
Top align.
Convenience method equivalent to attribute("valign","top"). Not
applicable to all Elements.
width
public Element width(String w)
set width.
Convenience method equivalent to attribute("width",w). 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.
write
public void write(OutputStream out)
throws 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.
out
- OutputStream to write the element to.
write
public void write(OutputStream out,
String encoding)
throws 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.
out
- OutputStream to write the element to.
write
public abstract void write(Writer out)
throws 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.
out
- Writer to write the element to.