org.anadix.html
Class HtmlElement

java.lang.Object
  extended by org.anadix.html.HtmlElement
All Implemented Interfaces:
Comparable<HtmlElement>, Element
Direct Known Subclasses:
BasefontTag, BaseTag, CoreAttributes, HeadTag, HTMLElementFactory.DefaultElement, HtmlTag, MetaTag, ParamTag, ScriptTag, StyleTag, TitleTag

public abstract class HtmlElement
extends Object
implements Element, Comparable<HtmlElement>

Abstract class representing any HTML element. It has generic method to retrieve element's attribute by name. It also stores id of an element, name of the tag it represents and parent element. The optional attributes are position of the element in document, source and text content. The mandatory attributes are unmodifiable as they define the element. The optional ones ones can be assigned and changed as necessary. The only constructor is package protected as instances of HTML element should only be created through HTMLElementFactory.

Version:
$Id: $
Author:
tomason

Method Summary
 int compareTo(HtmlElement o)
          Compares this object with the specified object for order.
 boolean equals(Object obj)
          
 String getAttribute(String name)
          Gets value of attribute by name
 Attributes getAttributes()
          Gets the list of attributes of the element
 BigInteger getId()
          Gets the id of the element (not the attribute id but the id as assigned by pasrser)
 String getName()
          Gets the name of the element (not the attribute name but the name of the tag)
 HtmlElement getParent()
          Gets the parent of the element
 Position getPosition()
          Gets the position of the element
 String getSource()
          Gets the source of the element
 String getTextContent()
          Gets the text content of the element
 int hashCode()
          
 void setPosition(Position position)
          Sets the position of the element
 void setSource(String source)
          Sets the source of the element
 void setTextContent(String textContent)
          Sets the text content of the element
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getId

public BigInteger getId()
Gets the id of the element (not the attribute id but the id as assigned by pasrser)

Returns:
id of the element

getName

public String getName()
Gets the name of the element (not the attribute name but the name of the tag)

Specified by:
getName in interface Element
Returns:
name of the element

getParent

public HtmlElement getParent()
Gets the parent of the element

Returns:
enclosing HtmlElement

getAttributes

public Attributes getAttributes()
Gets the list of attributes of the element

Returns:
list of attributes of the element

getAttribute

public String getAttribute(String name)
Gets value of attribute by name

Parameters:
name - attribute which value should be returned
Returns:
value of requested attribute or null if attribute is not set

setSource

public void setSource(String source)
Sets the source of the element

Parameters:
source - source of the element

getSource

public String getSource()
Gets the source of the element

Specified by:
getSource in interface Element
Returns:
source of the element

setPosition

public void setPosition(Position position)
Sets the position of the element

Parameters:
position - position of the element

getPosition

public Position getPosition()
Gets the position of the element

Returns:
position of the element

getTextContent

public String getTextContent()
Gets the text content of the element

Returns:
text content of the element

setTextContent

public void setTextContent(String textContent)
Sets the text content of the element

Parameters:
textContent - text content of the element

compareTo

public int compareTo(HtmlElement o)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable<HtmlElement>
Parameters:
o - HtmlElement to compare this with
Returns:
negative integer if this object is less than, zero if this object is equal to, or a positive integer if this object is greater than the specified object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.