public class DhEnumeration
implements IEnumerator
Represents a collection of elements in the HTML document. You can either create a DhEnumeration object class directly (using new()) or call DhDocument.enumerate to get the collection.
Note As of this Beta release, there are only three types of collections: ELEMENTS, IMAGES, and HLINKS.
Many HTML tags do not map one-to-one to Java classes in this package. When enumerating through the return of next(), always check the result with an instanceof() call.
Fields
Name | Description |
---|---|
ELEMENTS | Used by either DhDocument.enumerate or the DhEnumeration constructor to indicate a collection of all elements on the page. |
HLINKS |
Used by either DhDocument.enumerate or the DhEnumeration constructor to indicate a collection of all link (A) elements on the page.
|
IMAGES | Used by either DhDocument.enumerate or the DhEnumeration constructor to indicate a collection of all Image (IMG) elements on the page. |
Constructors
Name | Description |
---|---|
DhEnumeration( DhDocument document, int enumType ) | Creates a DhEnumeration object. |
Methods
Name | Description |
---|---|
hasMoreItems() | Tests if this enumeration contains more elements. |
next() | Returns the next element of this enumeration. |
nextItem() | Returns the next element of this enumeration. |
reset() | Resets the enumerator to the beginning. |
Creates a DhEnumeration object. You can use this constructor or call DhDocument.enumerate to get the collection.
Returns true if this enumeration contains more elements; otherwise, returns false.
Tests if this enumeration contains more elements.
Returns the next element of this enumeration, or returns null if one does not exist.
Returns the next element of this enumeration. This override of IEnumerator.next() returns a DhElement object so there is no need to cast the result to a DhElement object. The result can be further cast (for example, to DhImage) depending on the type of enumeration this is.
Many HTML tags do not map one-to-one into Java classes in this package. When enumerating through the return of next(), always check the result with an instanceof() call.
Returns the next element of this enumeration.
Returns the next element of this enumeration.
NoSuchElementException thrown if no more elements exist.
Resets the enumerator to the beginning.