com.ibm.wbi.markuplanguage.html
Class HtmlTag

java.lang.Object
  |
  +--com.ibm.wbi.markuplanguage.html.HtmlItem
        |
        +--com.ibm.wbi.markuplanguage.html.HtmlTag

public class HtmlTag
extends HtmlItem

Specialized class to represent HTML tags, such as <BODY>.


Field Summary
static java.lang.Object NULL
          indicates a null value for a given attribute
 
Fields inherited from class com.ibm.wbi.markuplanguage.html.HtmlItem
string
 
Constructor Summary
HtmlTag()
          Creates a new instance of Htmltag, with an empty tag name.
 
Method Summary
protected  void buildString()
          Build the String representation of the HTMLItem.
 java.lang.String getAttribute(java.lang.String attribute)
          Get the value of an attribute by its name.
 java.util.Hashtable getAttributes()
          Get the attributes of the Html tag.
 java.lang.String getId()
          Get the tag ID.
 boolean hasAttribute(java.lang.String attribute)
          Tell whether the tag contains the named attribute.
static void main(java.lang.String[] argv)
           
protected  void parseTag()
          Extract ID and attributes from the tag string.
 java.lang.String removeAttribute(java.lang.String attribute)
          Remove the attribute with the specified name.
 void setAttribute(java.lang.String attribute, java.lang.String value)
          Set an attribute/value pair inside of a TAG HTMLItem.
 void setId(java.lang.String id)
          Set the tag ID.
 void setString(java.lang.String s)
          Sets the text of an Html tag.
 java.lang.String toString()
          Get a string representation of an HTML tag.
 
Methods inherited from class com.ibm.wbi.markuplanguage.html.HtmlItem
getString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final java.lang.Object NULL
indicates a null value for a given attribute
Constructor Detail

HtmlTag

public HtmlTag()
Creates a new instance of Htmltag, with an empty tag name.
Method Detail

setString

public void setString(java.lang.String s)
Sets the text of an Html tag.
Overrides:
setString in class HtmlItem
Parameters:
s - String representation of an HTML tag.

toString

public java.lang.String toString()
Get a string representation of an HTML tag.
Overrides:
toString in class HtmlItem
Returns:
The Html tag.

getId

public java.lang.String getId()
Get the tag ID.
Returns:
The tag ID; always be returned in lower-case

setId

public void setId(java.lang.String id)
Set the tag ID.
Parameters:
The - tag ID

getAttributes

public java.util.Hashtable getAttributes()
Get the attributes of the Html tag. Note that the null value for an attribute is represented as HtmlTag.NULL
Returns:
Hashtable containing the attribute/attribute-value pairs.

getAttribute

public java.lang.String getAttribute(java.lang.String attribute)
Get the value of an attribute by its name.
Parameters:
attribute - Name of the attribute.
Returns:
The value of the specified attribute or null if the specified attribute does not exist. @see #hasAttribute for the case where the attribute exists but its value is null.

hasAttribute

public boolean hasAttribute(java.lang.String attribute)
Tell whether the tag contains the named attribute. This is useful for testing for attributes with no value (e.g., "selected" in the tag
Parameters:
attribute - Name of the attribute
Returns:
whether the attribute exists

removeAttribute

public java.lang.String removeAttribute(java.lang.String attribute)
Remove the attribute with the specified name.
Parameters:
attribute - The name of the attribute to remove
Returns:
The old value of the attribute or null

setAttribute

public void setAttribute(java.lang.String attribute,
                         java.lang.String value)
Set an attribute/value pair inside of a TAG HTMLItem. This method does nothing if the HTMLItem type is other than TAG. Note that the attribute is converted to lowercase. When the HTMLItem is converted into a string, the order of attributes will not necessarily be maintained. Attribute values will be enclosed in double-quotes. For example, <a href="foo">.
Parameters:
attibute - Name of the attribute.
value - Value of the attribute.

buildString

protected void buildString()
Build the String representation of the HTMLItem. This only needs to be done for a TAG item that has had an attribute change performed on it with the setAttribute(...) method.

parseTag

protected void parseTag()
Extract ID and attributes from the tag string. The ID and all attribute names are stored in lower case.

main

public static void main(java.lang.String[] argv)