|
HATS 7.5.1 Web API ReferencePublicly accessible methods not documented here are for IBM internal use only and may change in a future release of the product. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.hats.transform.html.HTMLElement
public class HTMLElement
HTMLElement is the parent class for all objects which represent an HTML tag or a set of HTML tags. HTMLElements should be used when generating HTML content to maintain a consistency across all of code generating HTML output, as well as encourage more object-oriented programming. Objects subclassing HTMLElement should only have state, and should not have any dependency on other packages. Rendering of specific HTMLElement descendants should be handled by this class. Construction of HTMLElements is facilitated through the use of a HTMLElementFactory.
Simple Example:
//obtain a StringBuffer called buffer
//create element
HTMLElement div = new HTMLElement("DIV");
//configure element
div.setStyle("background-color:green;");
//render element
div.render(buffer);
buffer.append("Hello World");
div.renderEndTag(buffer);
Output would look like:
HTMLElementFactory,
Widget| Field Summary | |
|---|---|
static String |
ATTR_ACCESS_KEY
Attribute map key |
static String |
ATTR_ACTION
|
static String |
ATTR_ALT
Attribute map key |
static String |
ATTR_CLASS_NAME
Attribute map key |
static String |
ATTR_DIR
Attribute map key |
static String |
ATTR_FOR
Attribute map key |
static String |
ATTR_HREF
Attribute map key |
static String |
ATTR_ID
Attribute map key |
static String |
ATTR_IMG_ALT
Attribute alt |
static String |
ATTR_MAX_LENGTH
Attribute map key |
static String |
ATTR_NAME
Attribute map key |
static String |
ATTR_ON_BLUR
Attribute map key |
static String |
ATTR_ON_CHANGE
Attribute map key |
static String |
ATTR_ON_CLICK
Attribute map key |
static String |
ATTR_ON_CUT
|
static String |
ATTR_ON_DROP
|
static String |
ATTR_ON_FOCUS
Attribute map key |
static String |
ATTR_ON_KEY_DOWN
|
static String |
ATTR_ON_KEY_PRESS
Attribute map key |
static String |
ATTR_ON_KEY_UP
|
static String |
ATTR_ON_MOUSEDOWN
Attribute map key |
static String |
ATTR_ON_MOUSEOVER
Attribute map key |
static String |
ATTR_ON_PASTE
|
static String |
ATTR_SIZE
Attribute map key |
static String |
ATTR_SRC
Attribute map key |
static String |
ATTR_STYLE
Attribute map key |
static String |
ATTR_TARGET
Attribute map key |
static String |
ATTR_TYPE
Attribute map key |
static String |
ATTR_VALUE
Attribute map key |
static String |
CLASSNAME
|
static String |
FLAG_CHECKED
Flag set key |
static String |
FLAG_DISABLED
Flag disabled key |
static String |
FLAG_MULTIPLE
Flag set key |
static String |
FLAG_READ_ONLY
Flag readonly |
static String |
FLAG_SELECTED
Flag set key |
protected String |
tagName
|
| Constructor Summary | |
|---|---|
HTMLElement()
Class constructor. |
|
HTMLElement(String tagName)
Class constructor which sets the name of the HTML tag. |
|
HTMLElement(String tagName,
boolean preserveAttributeOrder)
Class constructor which sets the name of the HTML tag. |
|
| Method Summary | |
|---|---|
void |
addFlag(String flag)
Adds the named flag to this HTMLElement |
void |
appendClassName(String className)
Sets the element's class name attribute. |
void |
appendStyle(String style)
Adds the specified style String to the current style value, separated with a semi-colon character. |
void |
buildTag(StringBuffer buffer)
Builds HTML output from the current state. |
void |
buildTag(StringBuffer buffer,
boolean closeTag)
Builds HTML output from the current state. |
String |
getAttribute(String name)
Gets the value of the specified attribute of this HTMLElement |
String |
getClassName()
Returns the CSS Class Name. |
String |
getDir()
Gets the direction. |
String |
getId()
Returns the id. |
String |
getName()
Returns the name. |
String |
getStyle()
Gets the style. |
String |
getTagName()
Gets the tag name for this HTMLElement. |
boolean |
hasFlag(String flag)
Determines whether or not this HTMLElement has the named flag set |
void |
removeFlag(String flag)
Removes the named flag from this HTMLElement |
String |
render()
Output this HTMLElement as a String. |
String |
render(boolean closeTag)
Output this HTMLElement as a String. |
void |
render(StringBuffer buffer)
Append this HTMLElement to the specified StringBuffer. |
void |
render(StringBuffer buffer,
boolean closeTag)
Append this HTMLElement to the specified StringBuffer. |
String |
renderEndTag()
Converts the closing tag for this HTMLElement to a string. |
void |
renderEndTag(StringBuffer buffer)
Appends the closing tag for this HTMLElement to specified StringBuffer. |
void |
setAlign(String dir)
Sets the direction ( dir) attribute. |
void |
setAttribute(String name,
String value)
Sets an named attribute on this HTMLElement. |
void |
setClassName(String className)
Sets the className. |
void |
setDir(String dir)
Sets the direction ( dir) attribute. |
void |
setId(String id)
Sets the id attribute. |
void |
setName(String name)
Sets the name. |
void |
setStyle(String style)
Sets the style attribute. |
void |
setTagName(String tagName)
Sets the tag name for this HTMLElement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CLASSNAME
protected String tagName
public static final String ATTR_NAME
public static final String ATTR_ID
public static final String ATTR_STYLE
public static final String ATTR_CLASS_NAME
public static final String ATTR_TYPE
public static final String ATTR_VALUE
public static final String ATTR_MAX_LENGTH
public static final String ATTR_SIZE
public static final String ATTR_ON_CHANGE
public static final String ATTR_ON_FOCUS
public static final String ATTR_ON_CLICK
public static final String ATTR_ON_MOUSEOVER
public static final String ATTR_ON_MOUSEDOWN
public static final String ATTR_ON_BLUR
public static final String ATTR_ON_KEY_PRESS
public static final String ATTR_ON_KEY_UP
public static final String ATTR_ON_KEY_DOWN
public static final String ATTR_ACTION
public static final String ATTR_ON_PASTE
public static final String ATTR_ON_DROP
public static final String ATTR_ON_CUT
public static final String ATTR_HREF
public static final String ATTR_TARGET
public static final String FLAG_MULTIPLE
public static final String FLAG_SELECTED
public static final String ATTR_ACCESS_KEY
public static final String FLAG_CHECKED
public static final String FLAG_DISABLED
public static final String FLAG_READ_ONLY
public static final String ATTR_SRC
public static final String ATTR_DIR
public static final String ATTR_ALT
public static final String ATTR_IMG_ALT
public static final String ATTR_FOR
| Constructor Detail |
|---|
public HTMLElement()
public HTMLElement(String tagName)
tagName -
public HTMLElement(String tagName,
boolean preserveAttributeOrder)
tagName - preserveAttributeOrder - preserves the ordering of the attributes on render, if true.| Method Detail |
|---|
public String render()
public String render(boolean closeTag)
closeTag - specifies whether to close the tag with a "/>"
public void render(StringBuffer buffer)
buffer -
public void render(StringBuffer buffer,
boolean closeTag)
buffer - closeTag - specifies whether to close the tag with a "/>"public void setTagName(String tagName)
tagName - the tag name for this elementpublic String getTagName()
null if no tag name.public String getClassName()
null if no class name.public String getId()
null if no ID.public String getName()
null if no name.public void appendClassName(String className)
className - The class name to set.public void setClassName(String className)
className - The className to setpublic void setId(String id)
id - The id to setpublic void setName(String name)
name - The name to setpublic void setDir(String dir)
dir) attribute. Replaces the existing value, if any.
dir - either "ltr" or "rtl"public void setAlign(String dir)
dir) attribute. Replaces the existing value, if any.
dir - either "ltr" or "rtl"public String getDir()
null if none set.public String getStyle()
null if none is set.public void setStyle(String style)
style - The style to setpublic void appendStyle(String style)
null.
style - the style value to set or append.public void buildTag(StringBuffer buffer)
buffer - to modify
public void buildTag(StringBuffer buffer,
boolean closeTag)
buffer - closeTag - terminate the built tag with a "/>" instead of just a ">"public String renderEndTag()
public void renderEndTag(StringBuffer buffer)
buffer -
public void setAttribute(String name,
String value)
null value to remove the attribute.
Replaces the named attribute, if it already exists, with the new value.
If this object was created to preserve attribute order, the attributes will be render in the order they were set.
Replacing an attribute value will not change its rendering order. To move an attribute to the end of the
rendering order, it must be removed with elem.setAttribute(name, null); and then set again.
name - attribute namevalue - value for the named attributepublic String getAttribute(String name)
name - name of the attribute, case sensitive
null if no such attribute is set.public boolean hasFlag(String flag)
flag - flag name
public void addFlag(String flag)
flag - flag namepublic void removeFlag(String flag)
flag - flag name
|
HATS 7.5.1 (201005110649) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||