it.sauronsoftware.grab4j.html
Class HTMLElement

java.lang.Object
  extended by it.sauronsoftware.grab4j.html.HTMLElement
Direct Known Subclasses:
HTMLTag, HTMLText

public abstract class HTMLElement
extends java.lang.Object

Base abstract model for HTML elements.

Author:
Carlo Pelliccia

Method Summary
 HTMLDocument getDocument()
          This method returns the document owner of the element.
 HTMLElement getElement(int index)
          This method returns a sub-element.
 HTMLElement getElementById(java.lang.String id)
          This method explores recursively the element children, searching the first occurrence of an element with the given value in its "id" attribute.
 int getElementCount()
          This method returns the number of the sub-elements owned by the element.
 HTMLElement[] getElements()
          This method returns an array with the sub-elements.
 HTMLElement[] getElementsByAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          This method searches recursively inside the element children, selecting the ones whose have a given attribute with a given value.
 HTMLElement[] getElementsByTag(java.lang.String tagName)
          This method searches recursively inside the element children, selecting the ones whose name is equal to the given tag name.
 HTMLElement getNextElement()
          This method returns the next element.
 HTMLElement getParentElement()
          This method returns the parent element.
 HTMLElement getPreviousElement()
          This method returns the previous element.
 HTMLElement searchElement(Criteria searchCriteria)
          This method searches recursively inside the element children and returns the first occurrence of the results list.
 HTMLElement searchElement(java.lang.String searchCriteria)
          This method searches recursively inside the element children and returns the first occurrence of the results list.
 HTMLElement[] searchElements(Criteria searchCriteria)
          This method searches recursively inside the element children.
 HTMLElement[] searchElements(java.lang.String searchCriteria)
          This method searches recursively inside the element children.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocument

public HTMLDocument getDocument()
This method returns the document owner of the element.

Returns:
he document owner of the element.

getParentElement

public HTMLElement getParentElement()
This method returns the parent element.

Returns:
The parent element.

getNextElement

public HTMLElement getNextElement()
This method returns the next element.

Returns:
The next element (null if no more elements in the group).

getPreviousElement

public HTMLElement getPreviousElement()
This method returns the previous element.

Returns:
The previous element (null if this one is the first element in its group).

getElement

public HTMLElement getElement(int index)
This method returns a sub-element.

Parameters:
index - The index of the wanted sub-element, starting from 0 untill getElementCount() - 1.
Returns:
The suggested sub-element.

getElementCount

public int getElementCount()
This method returns the number of the sub-elements owned by the element.

Returns:
The number of the sub-elements.

getElements

public HTMLElement[] getElements()
This method returns an array with the sub-elements.

Returns:
An array with the sub-elements.

getElementById

public HTMLElement getElementById(java.lang.String id)
This method explores recursively the element children, searching the first occurrence of an element with the given value in its "id" attribute.

Parameters:
id - The id of the wanted sub-element.
Returns:
The element, or null if not found.

getElementsByTag

public HTMLElement[] getElementsByTag(java.lang.String tagName)
This method searches recursively inside the element children, selecting the ones whose name is equal to the given tag name.

Parameters:
tagName - The tag name.
Returns:
An array with the sub-elements that satisfy the search criteria.

getElementsByAttribute

public HTMLElement[] getElementsByAttribute(java.lang.String attributeName,
                                            java.lang.String attributeValue)
This method searches recursively inside the element children, selecting the ones whose have a given attribute with a given value.

Parameters:
attributeName - The attribute name.
attributeValue - The attribute value.
Returns:
An array with the sub-elements that satisfy the search criteria.

searchElements

public HTMLElement[] searchElements(java.lang.String searchCriteria)
                             throws InvalidCriteriaException
This method searches recursively inside the element children.

Parameters:
searchCriteria - The search criteria.
Returns:
An array with the sub-elements that satisfy the search criteria.
Throws:
InvalidCriteriaException - If the given criteria is invalid.
See Also:
Criteria

searchElement

public HTMLElement searchElement(java.lang.String searchCriteria)
                          throws InvalidCriteriaException
This method searches recursively inside the element children and returns the first occurrence of the results list.

Parameters:
searchCriteria - The search criteria.
Returns:
The first occurrence of the results list, or null if no result is found.
Throws:
InvalidCriteriaException - If the given criteria is invalid.
See Also:
Criteria

searchElements

public HTMLElement[] searchElements(Criteria searchCriteria)
This method searches recursively inside the element children.

Parameters:
searchCriteria - The search criteria.
Returns:
An array with the sub-elements that satisfy the search criteria.

searchElement

public HTMLElement searchElement(Criteria searchCriteria)
This method searches recursively inside the element children and returns the first occurrence of the results list.

Parameters:
searchCriteria - The search criteria.
Returns:
The first occurrence of the results list, or null if no result is found.