Sharkysoft home

lava.text.html
Class HtmlOpenTag

java.lang.Object
  |
  +--lava.text.html.HtmlComponent
        |
        +--lava.text.html.HtmlRegularTag
              |
              +--lava.text.html.HtmlOpenTag

public class HtmlOpenTag
extends HtmlRegularTag

Opening HTML tag.

Details: This class represents opening HTML tags that have been parsed from an HTML source stream. Instances of this class are returned by the HtmlParser.parse method.

Since:
1999
Version:
2000.12.22
See Also:
HtmlParser.parse()

Field Summary
static java.lang.String NO_VALUE
          Represents undefined value.
 
Constructor Summary
HtmlOpenTag(java.lang.String type)
           
 
Method Summary
 void deleteAttribute(java.lang.String name)
          Deletes attribute.
 java.lang.String getAttribute(java.lang.String name)
          Returns attribute.
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets attribute.
 java.lang.String toString()
          Generates string representation.
 
Methods inherited from class lava.text.html.HtmlRegularTag
getType
 
Methods inherited from class lava.text.html.HtmlComponent
getOriginalSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUE

public static final java.lang.String NO_VALUE
Represents undefined value.

Details: NO_VALUE indicates that a property was declared but that it was not given any value.

Constructor Detail

HtmlOpenTag

public HtmlOpenTag(java.lang.String type)
Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Sets attribute.

Details: setAttribute sets the given attribute of this tag (name) to the given value (value). To declare an attribute without assigning it a value, set value to null or NO_VALUE. To remove an attribute, use deleteAttribute.

Parameters:
name - attribute name
value - attribute value
Since:
2000.09

deleteAttribute

public void deleteAttribute(java.lang.String name)
Deletes attribute.

Details: deleteAttribute removes the named attribute (name) from this tag. Note that this is entirely different from simply setting the attribute value to null. (See setAttribute.)

Parameters:
-  
Returns:
 
Throws:
-  
Since:
2000.09

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns attribute.

Details: This method returns the attribute value associated with the given attribute name (name). In cases where the original tag from the HTML stream declares an attribute name without a value, the value for that name is NO_VALUE (compare with ==, not String.equals!). If a tag declares more than one value for a name, only the last value is recorded. If a tag does not have the named attribute, null is returned.

For example, suppose this instance was formed by parsing the following (malformed) tag:

<table cellpadding=10 align=right border cellpadding=20>

Then, getAttribute, given the following names, will return the following values:

name value explanation
"TABLE" null TABLE is the tag type, but is not the name of an attribute in the tag
"CELLPADDING" "20" While parsing, only the last value given for attribute CELLPADDING is stored in this instance.
"ALIGN" "right" Clearly this was the assigned value.
"BORDER" "" No value was given, so the object NO_VALUE is returned.
Parameters:
name - the attribute name
Returns:
the attribute value

toString

public java.lang.String toString()
Generates string representation.

Details: toString returns a string representation of this closing tag. The string returned may not be exactly the same as the original text that was parsed to form this tag, but it should be equivalent by HTML standards. Also, the attribute list may be reconstructed in an order that is different from order in which it appeared in the original HTML source.

Overrides:
toString in class HtmlComponent
Returns:
the string representation

Sharkysoft home