All Packages Class Hierarchy This Package Previous Next Index
Class websphinx.Element
java.lang.Object
|
+----websphinx.Region
|
+----websphinx.Element
- public class Element
- extends Region
Element in an HTML page. An element runs from a start tag
(like <ul>) to its matching end tag (</ul>),
inclusive.
An element may have an optional end tag (like <p>),
in which case the element runs up to (but not including)
the tag that implicitly closes it. For example:
<p>Paragraph 1<p>Paragraph 2
contains two elements, <p>Paragraph 1
and <p>Paragraph 2
.
-
child
-
-
endTag
-
-
parent
-
-
sibling
-
-
startTag
-
-
Element(Tag, int)
-
Make an Element from a start tag and an end position.
-
Element(Tag, Tag)
-
Make an Element from a start tag and end tag.
-
enumerateHTMLAttributes()
- Enumerate the HTML attributes found on this tag.
-
getChild()
- Get element's first child.
-
getEndTag()
- Get end tag.
-
getHTMLAttribute(String)
- Get an HTML attribute's value.
-
getHTMLAttribute(String, String)
- Get an HTML attribute's value, with a default value if it doesn't exist.
-
getNext()
- Return next element in an inorder walk of the tree,
assuming this element and its children have been visited.
-
getParent()
- Get element's parent.
-
getSibling()
- Get element's next sibling.
-
getStartTag()
- Get start tag.
-
getTagName()
- Get tag name.
-
hasHTMLAttribute(String)
- Test if tag has an HTML attribute.
startTag
protected Tag startTag
endTag
protected Tag endTag
sibling
protected Element sibling
parent
protected Element parent
child
protected Element child
Element
public Element(Tag startTag,
Tag endTag)
- Make an Element from a start tag and end tag. The tags
must be on the same Page.
- Parameters:
- startTag - Start tag of element
- endTag - End tag of element (may be null)
Element
public Element(Tag startTag,
int end)
- Make an Element from a start tag and an end position. Used
when the end tag has been omitted (like <p>, frequently).
- Parameters:
- startTag - Start tag of element
- end - Ending offset of element
getTagName
public String getTagName()
- Get tag name.
- Returns:
- tag name (like "p"), in lower-case, String.intern()'ed form.
Thus you can compare tag names with ==, as in:
getTagName() == Tag.IMG.
getStartTag
public Tag getStartTag()
- Get start tag.
- Returns:
- start tag of element
getEndTag
public Tag getEndTag()
- Get end tag.
- Returns:
- end tag of element, or null if element has no end tag.
getParent
public Element getParent()
- Get element's parent.
- Returns:
- element that contains this element, or null if at top-level.
getSibling
public Element getSibling()
- Get element's next sibling.
- Returns:
- element that follows this element, or null if at end of
parent's children.
getChild
public Element getChild()
- Get element's first child.
- Returns:
- first element contained by this element, or null if no children.
getNext
public Element getNext()
- Return next element in an inorder walk of the tree,
assuming this element and its children have been visited.
- Returns:
- next element
hasHTMLAttribute
public boolean hasHTMLAttribute(String name)
- Test if tag has an HTML attribute.
- Parameters:
- name - Name of HTML attribute (e.g. "HREF"). Doesn't have to be
converted with toHTMLAttributeName().
- Returns:
- true if tag has the attribute, false if not
getHTMLAttribute
public String getHTMLAttribute(String name)
- Get an HTML attribute's value.
- Parameters:
- name - Name of HTML attribute (e.g. "HREF"). Doesn't have to be
converted with toHTMLAttributeName().
- Returns:
- value of attribute if it exists, TRUE if the attribute exists but has no value, or null if tag lacks the attribute.
getHTMLAttribute
public String getHTMLAttribute(String name,
String defaultValue)
- Get an HTML attribute's value, with a default value if it doesn't exist.
- Parameters:
- name - Name of HTML attribute (e.g. "HREF"). Doesn't have to be
converted with toHTMLAttributeName().
- defaultValue - default value to return if the attribute
doesn't exist
- Returns:
- value of attribute if it exists, TRUE if the attribute exists but has no value, or defaultValue if tag lacks the attribute.
enumerateHTMLAttributes
public Enumeration enumerateHTMLAttributes()
- Enumerate the HTML attributes found on this tag.
- Returns:
- enumeration of the attribute names found on this tag.
All Packages Class Hierarchy This Package Previous Next Index