|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.text.html.HtmlComponent | +--lava.text.html.HtmlRegularTag | +--lava.text.html.HtmlOpenTag
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.
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 |
public static final java.lang.String NO_VALUE
Details: NO_VALUE
indicates that a property was declared but that it was not given any value.
Constructor Detail |
public HtmlOpenTag(java.lang.String type)
Method Detail |
public void setAttribute(java.lang.String name, java.lang.String value)
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
.
name
- attribute namevalue
- attribute valuepublic void deleteAttribute(java.lang.String name)
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
.)
-
- public java.lang.String getAttribute(java.lang.String name)
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. |
name
- the attribute namepublic java.lang.String toString()
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.
toString
in class HtmlComponent
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |