com.ge.research.html
Class HTMLTag

java.lang.Object
  extended bycom.ge.research.html.HTMLTag
Direct Known Subclasses:
AppletTag, ContentWrapperTag, ImageTag, InputTag, OptionTag, ParamTag, SelectTag, TableElement, TextAreaTag

public abstract class HTMLTag
extends java.lang.Object

Abstract class which represents an HTML 4.0 tag. Constructs an HTML tag by writing the tag attributes with values within the beggining tag, writes any tag contents between the open and close tags, and terminates the tag. Ex. <A HREF="javascript:void(0)" TARGET="_blank">Tag Content</A> This class provides the common HTML attributes available to all HTML 4.0 tags. Subclasses need only implement the writeTagSpecificAttributes() method, to write inline attributes as part of the tag, and the writeTagSpecificData() method, to write the tag content between the open and closing tags. The toString() method creates the tag from the attribute and content data. Once a tag is created, it is flagged to not be recreated unless the content or attribute information is modified. This is done for efficiency. Each attribute setter method, therefore should intelligently update the value of the reconstructTag flag.

Version:
$Revision: 1.2 $ $Date: 2006/11/15 22:25:49 $
Author:
garbiras
Created on:
Sep 9, 2002

Field Summary
static java.lang.String HORIZONTAL_LINE
          HTML horizontal line tag
static java.lang.String LINEBREAK
          HTML break tag
protected  boolean reconstructTag
          Flag indicating whether or not the tag's attributes need to be inspected to construct the HTML tag string for this object.
protected  java.lang.StringBuffer tag
          The HTML tag StringBuffer for this tag.
static java.lang.String WHITESPACE
          HTML whitespace
 
Constructor Summary
protected HTMLTag(java.lang.String tagName)
          Default constructor.
 
Method Summary
 void addAttribute(java.lang.String name)
          Adds a user defined attribute to the tag without a value, which will cause the attribute to be handled as a boolean attribute.
 void addAttribute(java.lang.String name, java.lang.Object value)
          Adds a user defined attribute to the tag with the appropriate value Sets the value of the reconstructTag to true.
 java.lang.String getId()
          Returns the current HTML Tag ID attribute for the tag.
 java.lang.String getOnClick()
          Returns the current value of the HTML Tag onClick behavior.
 java.lang.String getOnContextMenu()
          Returns the current value of the HTML Tag onContextMenu behavior.
 java.lang.String getOnDblClick()
          Returns the current value of the HTML Tag onDblClick behavior.
 java.lang.String getOnDrag()
          Returns the current value of the HTML Tag onDrag behavior.
 java.lang.String getOnDragEnd()
          Returns the current value of the HTML Tag onDragEnd behavior.
 java.lang.String getOnDragStart()
          Returns the current value of the HTML Tag onDragStart behavior.
 java.lang.String getOnFocus()
          Returns the current value of the HTML Tag onFocus behavior.
 java.lang.String getOnFocusOut()
          Returns the current value of the HTML Tag onFocusOut behavior.
 java.lang.String getOnKeyDown()
          Returns the current value of the HTML Tag onKeyDown behavior.
 java.lang.String getOnKeyPress()
          Returns the current value of the HTML Tag onKeyPress behavior.
 java.lang.String getOnKeyUp()
          Returns the current value of the HTML Tag onKeyUp behavior.
 java.lang.String getOnMouseDown()
          Returns the current value of the HTML Tag onMouseDown behavior.
 java.lang.String getOnMouseMove()
          Returns the current value of the HTML Tag onMouseMove behavior.
 java.lang.String getOnMouseOut()
          Returns the current value of the HTML Tag onMouseOut behavior.
 java.lang.String getOnMouseOver()
          Returns the current value of the HTML Tag onMouseOver behavior.
 java.lang.String getOnMouseUp()
          Returns the current value of the HTML Tag onMouseUp behavior.
 java.lang.String getOnMoveEnd()
          Returns the current value of the HTML Tag onMoveEnd behavior.
 java.lang.String getOnMoveStart()
          Returns the current value of the HTML Tag onMoveStart behavior.
 java.lang.String getStyle()
          Returns the current HTML Tag CSS Style settings for the tag.
 java.lang.String getStyleClass()
          Returns the current HTML Tag CSS Style Class for the tag
 java.lang.String getTitle()
          Returns the current value of the HTML Tag TITLE attribute.
 void removeAttribute(java.lang.String name)
          Removes the user defined attribute specified by the name argument Sets the value of the reconstructTag to true if the removal was successful.
 void reset()
          Sets all attributes to their default values by calling the resetTagSpecificInformation() method.
protected  void resetTagSpecificInformation()
          Resets the tag attributes and content of the HTML Tag to their default values.
 void setId(java.lang.String attribute)
          Sets the HTML Tag ID attribute Sets the value of the reconstructTag to true.
 void setOnClick(java.lang.String attribute)
          Sets the HTML Tag onClick behavior.
 void setOnContextMenu(java.lang.String attribute)
          Sets the HTML Tag onContextMenu behavior.
 void setOnDblClick(java.lang.String attribute)
          Sets the HTML Tag onDblClick behavior.
 void setOnDrag(java.lang.String attribute)
          Sets the HTML Tag onDrag behavior.
 void setOnDragEnd(java.lang.String attribute)
          Sets the HTML Tag onDragEnd behavior.
 void setOnDragStart(java.lang.String attribute)
          Sets the HTML Tag onDragStart behavior.
 void setOnFocus(java.lang.String attribute)
          Sets the HTML Tag onFocus behavior.
 void setOnFocusOut(java.lang.String attribute)
          Sets the HTML Tag onFocusOut behavior.
 void setOnKeyDown(java.lang.String attribute)
          Sets the HTML Tag onKeyDown behavior.
 void setOnKeyPress(java.lang.String attribute)
          Sets the HTML Tag onKeyPress behavior.
 void setOnKeyUp(java.lang.String attribute)
          Sets the HTML Tag onKeyUp behavior.
 void setOnMouseDown(java.lang.String attribute)
          Sets the HTML Tag onMouseDown behavior.
 void setOnMouseMove(java.lang.String attribute)
          Sets the HTML Tag onMouseMove behavior.
 void setOnMouseOut(java.lang.String attribute)
          Sets the HTML Tag onMouseOut behavior.
 void setOnMouseOver(java.lang.String attribute)
          Sets the HTML Tag onMouseOver behavior.
 void setOnMouseUp(java.lang.String attribute)
          Sets the HTML Tag onMouseUp behavior.
 void setOnMoveEnd(java.lang.String attribute)
          Sets the HTML Tag onMoveEnd behavior.
 void setOnMoveStart(java.lang.String attribute)
          Sets the HTML Tag onMoveSTart behavior.
 void setStyle(java.lang.String attribute)
          Sets the HTML Tag CSS Style settings.
 void setStyleClass(java.lang.String attribute)
          Sets the HTML Tag CSS Style Class attribute.
 void setTitle(java.lang.String attribute)
          Sets the HTML Tag TITLE attribute.
 java.lang.String toString()
          Overrides the Object.toString() method and produces the HTML tag represented by this object.
protected  void writeAttribute(java.lang.String value)
          Convienence method for adding an attribute string to the HTML Tag.
protected  void writeAttribute(java.lang.String attributeName, boolean value)
          Convienence method for adding a boolean attribute to the HTML Tag.
protected  void writeAttribute(java.lang.String attributeName, double value)
          Convienence method for adding an attribute and its value to the HTML Tag.
protected  void writeAttribute(java.lang.String attributeName, int value)
          Convienence method for adding an attribute and its value to the HTML Tag.
protected  void writeAttribute(java.lang.String attributeName, java.lang.Object value)
          Convienence method for adding an Object attribute to the HTML Tag.
protected  void writeAttribute(java.lang.String attributeName, java.lang.String value)
          Convienence method for adding an attribute and its value to the HTML Tag.
protected  void writeTagSpecificAttributes()
          Adds the tag specific attribute information to the HTML Tag.
protected  void writeTagSpecificData()
          Adds the tag content to the HTML Tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINEBREAK

public static final java.lang.String LINEBREAK
HTML break tag

See Also:
Constant Field Values

HORIZONTAL_LINE

public static final java.lang.String HORIZONTAL_LINE
HTML horizontal line tag

See Also:
Constant Field Values

WHITESPACE

public static final java.lang.String WHITESPACE
HTML whitespace

See Also:
Constant Field Values

tag

protected java.lang.StringBuffer tag
The HTML tag StringBuffer for this tag. Once it is produced it is only reproduced if an attribute value changes, thus setting the reconstructTag to true.


reconstructTag

protected boolean reconstructTag
Flag indicating whether or not the tag's attributes need to be inspected to construct the HTML tag string for this object. Each time an attribute value is modified, the value is set to true. Each time the tag string is constructed it is set to false.

Constructor Detail

HTMLTag

protected HTMLTag(java.lang.String tagName)
Default constructor. Initializes the tag StringBuffer. Sets the type of HTML tag, using the tagName argument. Calls the reset() method. This constructor is called by subclasses to initialize the HTML tag type correctly.

Parameters:
tagName - the HTML type of this tag
Method Detail

addAttribute

public final void addAttribute(java.lang.String name)
Adds a user defined attribute to the tag without a value, which will cause the attribute to be handled as a boolean attribute. Calls the addAttribute(java.lang.String, java.lang.Object) method with null as the second argument.

Parameters:
name - the name of the user defined attribute
See Also:
addAttribute(java.lang.String, java.lang.Object)

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Object value)
Adds a user defined attribute to the tag with the appropriate value Sets the value of the reconstructTag to true.

Parameters:
name - the name of the user defined attribute
value - the value of the user defined attribute. If null the attribute is assumed to be a boolean attribute, and it's existence will result in the attribute name written to the inline tag.
See Also:
reconstructTag

getId

public final java.lang.String getId()
Returns the current HTML Tag ID attribute for the tag.

Returns:
The current HTML Tag ID attribute for the tag

getStyle

public final java.lang.String getStyle()
Returns the current HTML Tag CSS Style settings for the tag.

Returns:
The current HTML Tag CSS Style settings for the tag

getStyleClass

public final java.lang.String getStyleClass()
Returns the current HTML Tag CSS Style Class for the tag

Returns:
The current HTML Tag CSS Style Class for the tag

getOnClick

public final java.lang.String getOnClick()
Returns the current value of the HTML Tag onClick behavior.

Returns:
The current value of the HTML Tag onClick behavior

getOnContextMenu

public final java.lang.String getOnContextMenu()
Returns the current value of the HTML Tag onContextMenu behavior.

Returns:
The current value of the HTML Tag onContextMenu behavior

getOnDblClick

public final java.lang.String getOnDblClick()
Returns the current value of the HTML Tag onDblClick behavior.

Returns:
The current value of the HTML Tag onDblClick behavior

getOnDrag

public final java.lang.String getOnDrag()
Returns the current value of the HTML Tag onDrag behavior.

Returns:
The current value of the HTML Tag onDrag behavior

getOnDragEnd

public final java.lang.String getOnDragEnd()
Returns the current value of the HTML Tag onDragEnd behavior.

Returns:
The current value of the HTML Tag onDragEnd behavior

getOnDragStart

public final java.lang.String getOnDragStart()
Returns the current value of the HTML Tag onDragStart behavior.

Returns:
The current value of the HTML Tag onDragStart behavior

getOnKeyDown

public final java.lang.String getOnKeyDown()
Returns the current value of the HTML Tag onKeyDown behavior.

Returns:
The current value of the HTML Tag onKeyDown behavior

getOnKeyPress

public final java.lang.String getOnKeyPress()
Returns the current value of the HTML Tag onKeyPress behavior.

Returns:
The current value of the HTML Tag onKeyPress behavior

getOnKeyUp

public final java.lang.String getOnKeyUp()
Returns the current value of the HTML Tag onKeyUp behavior.

Returns:
The current value of the HTML Tag onKeyUp behavior

getOnMouseDown

public final java.lang.String getOnMouseDown()
Returns the current value of the HTML Tag onMouseDown behavior.

Returns:
The current value of the HTML Tag onMouseDown behavior

getOnMouseMove

public final java.lang.String getOnMouseMove()
Returns the current value of the HTML Tag onMouseMove behavior.

Returns:
The current value of the HTML Tag onMouseMove behavior

getOnMouseOut

public final java.lang.String getOnMouseOut()
Returns the current value of the HTML Tag onMouseOut behavior.

Returns:
The current value of the HTML Tag onMouseOut behavior

getOnMouseOver

public final java.lang.String getOnMouseOver()
Returns the current value of the HTML Tag onMouseOver behavior.

Returns:
The current value of the HTML Tag onMouseOver behavior

getOnMouseUp

public final java.lang.String getOnMouseUp()
Returns the current value of the HTML Tag onMouseUp behavior.

Returns:
The current value of the HTML Tag onMouseUp behavior

getOnMoveEnd

public final java.lang.String getOnMoveEnd()
Returns the current value of the HTML Tag onMoveEnd behavior.

Returns:
The current value of the HTML Tag onMoveEnd behavior

getOnMoveStart

public final java.lang.String getOnMoveStart()
Returns the current value of the HTML Tag onMoveStart behavior.

Returns:
The current value of the HTML Tag onMoveStart behavior

getTitle

public final java.lang.String getTitle()
Returns the current value of the HTML Tag TITLE attribute.

Returns:
The current value of the HTML Tag TITLE attribute

getOnFocus

public final java.lang.String getOnFocus()
Returns the current value of the HTML Tag onFocus behavior.

Returns:
The current value of the HTML Tag onFocus behavior

getOnFocusOut

public final java.lang.String getOnFocusOut()
Returns the current value of the HTML Tag onFocusOut behavior.

Returns:
The current value of the HTML Tag onFocusOut behavior

removeAttribute

public final void removeAttribute(java.lang.String name)
Removes the user defined attribute specified by the name argument Sets the value of the reconstructTag to true if the removal was successful.

Parameters:
name - the name of the user defined attribute
See Also:
reconstructTag

reset

public final void reset()
Sets all attributes to their default values by calling the resetTagSpecificInformation() method.

See Also:
resetTagSpecificInformation()

setId

public final void setId(java.lang.String attribute)
Sets the HTML Tag ID attribute Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag ID attribute
See Also:
reconstructTag

setOnClick

public final void setOnClick(java.lang.String attribute)
Sets the HTML Tag onClick behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML TAG onClick behavior
See Also:
reconstructTag

setOnContextMenu

public final void setOnContextMenu(java.lang.String attribute)
Sets the HTML Tag onContextMenu behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML TAG onContextMenu behavior
See Also:
reconstructTag

setOnDblClick

public final void setOnDblClick(java.lang.String attribute)
Sets the HTML Tag onDblClick behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onDblClick behavior
See Also:
reconstructTag

setOnDrag

public final void setOnDrag(java.lang.String attribute)
Sets the HTML Tag onDrag behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onDrag behavior
See Also:
reconstructTag

setOnDragEnd

public final void setOnDragEnd(java.lang.String attribute)
Sets the HTML Tag onDragEnd behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onDragEnd behavior
See Also:
reconstructTag

setOnDragStart

public final void setOnDragStart(java.lang.String attribute)
Sets the HTML Tag onDragStart behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onDragStart behavior
See Also:
reconstructTag

setOnKeyDown

public final void setOnKeyDown(java.lang.String attribute)
Sets the HTML Tag onKeyDown behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onKeyDown behavior
See Also:
reconstructTag

setOnKeyPress

public final void setOnKeyPress(java.lang.String attribute)
Sets the HTML Tag onKeyPress behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onKeyPress behavior
See Also:
reconstructTag

setOnKeyUp

public final void setOnKeyUp(java.lang.String attribute)
Sets the HTML Tag onKeyUp behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onKeyUp behavior
See Also:
reconstructTag

setOnMouseDown

public final void setOnMouseDown(java.lang.String attribute)
Sets the HTML Tag onMouseDown behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMouseDown behavior
See Also:
reconstructTag

setOnMouseMove

public final void setOnMouseMove(java.lang.String attribute)
Sets the HTML Tag onMouseMove behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMouseMove behavior
See Also:
reconstructTag

setOnMouseOut

public final void setOnMouseOut(java.lang.String attribute)
Sets the HTML Tag onMouseOut behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMouseOut behavior
See Also:
reconstructTag

setOnMouseOver

public final void setOnMouseOver(java.lang.String attribute)
Sets the HTML Tag onMouseOver behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMouseOver behavior
See Also:
reconstructTag

setOnMouseUp

public final void setOnMouseUp(java.lang.String attribute)
Sets the HTML Tag onMouseUp behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMouseUp behavior
See Also:
reconstructTag

setOnMoveEnd

public final void setOnMoveEnd(java.lang.String attribute)
Sets the HTML Tag onMoveEnd behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMoveEnd behavior
See Also:
reconstructTag

setOnMoveStart

public final void setOnMoveStart(java.lang.String attribute)
Sets the HTML Tag onMoveSTart behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onMoveStart behavior
See Also:
reconstructTag

setStyle

public final void setStyle(java.lang.String attribute)
Sets the HTML Tag CSS Style settings. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new HTML Tag CSS Style settings
See Also:
reconstructTag

setStyleClass

public final void setStyleClass(java.lang.String attribute)
Sets the HTML Tag CSS Style Class attribute. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag CSS Style Class attribute
See Also:
reconstructTag

setTitle

public final void setTitle(java.lang.String attribute)
Sets the HTML Tag TITLE attribute. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag TITLE attribute
See Also:
reconstructTag

setOnFocus

public final void setOnFocus(java.lang.String attribute)
Sets the HTML Tag onFocus behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onFocus behavior
See Also:
reconstructTag

setOnFocusOut

public final void setOnFocusOut(java.lang.String attribute)
Sets the HTML Tag onFocusOut behavior. Sets the value of the reconstructTag to true.

Parameters:
attribute - the new value for the HTML Tag onFocusOut behavior
See Also:
reconstructTag

toString

public final java.lang.String toString()
Overrides the Object.toString() method and produces the HTML tag represented by this object. If the value of the reconstructTag is false, then the last constructed tag string is returned. If the value of the reconstructTag is true, then the tag is constructed as follows. The opening tag is created by calling the writeTagSpecificAttributes() method which writes the tag attributes inline with the tag name in the opening tag. The tag content (if any) is written by calling the writeTagSpecificData() method. The tag is then properly closed with a terminating tag sequence. Sets the value of the reconstructTag to false.

Returns:
The HTML tag represented by this object.
See Also:
writeTagSpecificAttributes(), writeTagSpecificData(), reconstructTag

resetTagSpecificInformation

protected void resetTagSpecificInformation()
Resets the tag attributes and content of the HTML Tag to their default values. Called by reset(). This method is not implemented in HTMLTag. Subclasses that contain tag content information should implement this method to set their information to their default values.

See Also:
reset()

writeAttribute

protected final void writeAttribute(java.lang.String value)
Convienence method for adding an attribute string to the HTML Tag.

Parameters:
value - the attribue string to add to the HTML Tag

writeAttribute

protected final void writeAttribute(java.lang.String attributeName,
                                    boolean value)
Convienence method for adding a boolean attribute to the HTML Tag. If the value of the attribute is true, then calls the writeAttribute(java.lang.String) method with argument attributeName.

Parameters:
attributeName - the attribue that is added to the HTML Tag
value - true or false value of the attribute
See Also:
writeAttribute(java.lang.String)

writeAttribute

protected final void writeAttribute(java.lang.String attributeName,
                                    double value)
Convienence method for adding an attribute and its value to the HTML Tag. The name value pair is constructed as NAME folloed by an equals sign followed by the attribute value enclosed in double quotes. That entire string is prepended with a space and then added to the HTML Tag at the current position.

Parameters:
attributeName - the name of the attribue whose name value pair is added to the HTML Tag
value - the value add to the HTML Tag as the value of the attribute

writeAttribute

protected final void writeAttribute(java.lang.String attributeName,
                                    int value)
Convienence method for adding an attribute and its value to the HTML Tag. The name value pair is constructed as NAME folloed by an equals sign followed by the attribute value enclosed in double quotes. That entire string is prepended with a space and then added to the HTML Tag at the current position.

Parameters:
attributeName - the name of the attribue whose name value pair is added to the HTML Tag
value - the value add to the HTML Tag as the value of the attribute

writeAttribute

protected final void writeAttribute(java.lang.String attributeName,
                                    java.lang.Object value)
Convienence method for adding an Object attribute to the HTML Tag. The type of the value attribute is inspected and then converted to a primirtive format and delegated to the appropriate writeAttribute method.

Parameters:
attributeName - the attribue that is added to the HTML Tag
value - the attribute
See Also:
writeAttribute(java.lang.String, boolean), writeAttribute(java.lang.String, int), writeAttribute(java.lang.String, double), writeAttribute(java.lang.String, java.lang.String)

writeAttribute

protected final void writeAttribute(java.lang.String attributeName,
                                    java.lang.String value)
Convienence method for adding an attribute and its value to the HTML Tag. The name value pair is constructed as NAME folloed by an equals sign followed by the attribute value. The attribute value is inspected, and if no double quotes are found within it, the value is enclosed by double quotes. If it is found to contain double quotes it is then inspected for single quotes. If no single quotes are found then the value is enclosed in single quotes, otherwise the value is appended as is. That entire string is prepended with a space and then added to the HTML Tag at the current position.

Parameters:
attributeName - the name of the attribue whose name value pair is added to the HTML Tag
value - the value add to the HTML Tag as the value of the attribute

writeTagSpecificAttributes

protected void writeTagSpecificAttributes()
Adds the tag specific attribute information to the HTML Tag. Called by toString(). This method is not implemented in HTMLTag. Subclasses that contain additional attribute information should implement this method to write those attributes in the inline tag.

See Also:
toString()

writeTagSpecificData

protected void writeTagSpecificData()
Adds the tag content to the HTML Tag. Called by toString(). This method is not implemented in HTMLTag. Subclasses that contain tag content information should implement this method to writeout that content in between the opening and closing tags.

See Also:
toString()