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
.


Variable Index

 o child
 o endTag
 o parent
 o sibling
 o startTag

Constructor Index

 o Element(Tag, int)
Make an Element from a start tag and an end position.
 o Element(Tag, Tag)
Make an Element from a start tag and end tag.

Method Index

 o enumerateHTMLAttributes()
Enumerate the HTML attributes found on this tag.
 o getChild()
Get element's first child.
 o getEndTag()
Get end tag.
 o getHTMLAttribute(String)
Get an HTML attribute's value.
 o getHTMLAttribute(String, String)
Get an HTML attribute's value, with a default value if it doesn't exist.
 o getNext()
Return next element in an inorder walk of the tree, assuming this element and its children have been visited.
 o getParent()
Get element's parent.
 o getSibling()
Get element's next sibling.
 o getStartTag()
Get start tag.
 o getTagName()
Get tag name.
 o hasHTMLAttribute(String)
Test if tag has an HTML attribute.

Variables

 o startTag
 protected Tag startTag
 o endTag
 protected Tag endTag
 o sibling
 protected Element sibling
 o parent
 protected Element parent
 o child
 protected Element child

Constructors

 o 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)
 o 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

Methods

 o 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.
 o getStartTag
 public Tag getStartTag()
Get start tag.

Returns:
start tag of element
 o getEndTag
 public Tag getEndTag()
Get end tag.

Returns:
end tag of element, or null if element has no end tag.
 o getParent
 public Element getParent()
Get element's parent.

Returns:
element that contains this element, or null if at top-level.
 o getSibling
 public Element getSibling()
Get element's next sibling.

Returns:
element that follows this element, or null if at end of parent's children.
 o getChild
 public Element getChild()
Get element's first child.

Returns:
first element contained by this element, or null if no children.
 o 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
 o 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
 o 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.
 o 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.
 o 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