Package Torello.HTML.NodeSearch
Class HNLIInclusive
- java.lang.Object
-
- Torello.HTML.NodeSearch.AbstractHNLI<TagNode,java.util.Vector<HTMLNode>>
-
- Torello.HTML.NodeSearch.HNLIInclusive
-
- All Implemented Interfaces:
java.util.Iterator<java.util.Vector<HTMLNode>>
,java.util.ListIterator<java.util.Vector<HTMLNode>>
public class HNLIInclusive extends AbstractHNLI<TagNode,java.util.Vector<HTMLNode>>
HNLIInclusive: HTMLNode List Iterator, Inclusive - Documentation.
This interface builds on Java's interface ListIterator<E>
, which itself is an extension of theinterface java.util.Iterator<E>
.
This is anIterator
class that has been heavily improved to allow for all types of updates, additions, removals, etc... to a vectorized-html web-page. The methods that are provided allow a user to request anIterator
from the Inclusive Iterator retrieval classes in this Node-Search Package.
The concept of'Inclusive'
, as explained quite thoroughly in the classes that contain this word,'Inclusive'
means that in this hereIterator
, sub-lists of (Vectors
) of'HTMLNode'
will be returned from thenextElement()
methods in this class. EachVector
or sublist ofHTMLNode
will begin with an opening HTML Element, for example'<DIV ...>'
and end, the last element in the vector that's returned, will be an HTML Closing Element, for example'</DIV>'
HNLIInclusive (Inclusive Iterator) Generator Class:- Class: InnerTagInclusiveIterator
- Class: TagNodeInclusiveIterator
public interface java.util.Iterator<E>
has these methods:
1 2 3 4 5 6 7 8 9 10 11
// Performs the given action for each remaining element until all elements have been processed or the action throws an exception. default void forEachRemaining(Consumer<? super E> action) // Returns true if the iteration has more elements. boolean hasNext() // Returns the next element in the iteration. E next() // Removes from the underlying collection the last element returned by this iterator (optional operation). default void remove()
public interface java.util.ListIterator<E>
extends the previousIterator
with these methods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// Inserts the specified element into the list (optional operation). // IMPORTANT NOTE: The HTML Node-Search Engine implements this method slightly differently. This method // performs an insert at the specified index of the last result returned by the iterator. // Java's JDK adds the nodes at the index that would be returned by a call to nextIndex(). // This difference allows the programmer to analyze the last data returned in making the decision // to perform an insert / add operation. void add(E e) // Returns true if this list iterator has more elements when traversing the list in the forward direction. boolean hasNext() // Returns true if this list iterator has more elements when traversing the list in the reverse direction. boolean hasPrevious() // Returns the next element in the list and advances the cursor position. E next() // Returns the index of the element that would be returned by a subsequent call to next(). int nextIndex() // Returns the previous element in the list and moves the cursor position backwards. E previous() // Returns the index of the element that would be returned by a subsequent call to previous(). int previousIndex() // Removes from the list the last element that was returned by next() or previous() (optional operation). void remove() // Replaces the last element returned by next() or previous() with the specified element (optional operation). void set(E e)
NOTE: ThisIterator
class further extends Java'sListIterator<E>
to add severalHTMLNode
andVector<HTMLNode>
specific insertion, deletion, and replacement operations. These methods are listed below in the 'Methods' section of this class documentation page.
THE WISDOM OF AN ITERATOR: Generally, it is sometimes apparent that Java's introduction of the concept of generics - and particularly theIterator<E>
andListIterator<E>
has been somewhat down-played in some circles. The value of anIterator
is sometimes over-looked when applied to data-modification. 4 out of 6 of thestatic
method-based class-types in this package:Find, Get, Peek, Count
andCount
provide only "data-observation" of the underlying vectorized-HTML. The other twoPoll
andRemove
, however, modify the underlyingVector
. All of these work fine without an using anIterator
, however, there may be cases where node-replacement and node-removal on a case-by-case basis will be necessary. And that can lead to problems caused by stale data pointers.
STALE DATA POINTERS: If an array of index pointers is requested:int[] posArr = TagNodeFind.all(...)
and the user begins replacing and removing nodes using this array... if at any point the size of theVector
is changed, the entire pointer-array will immediately contain stale-data! This can be overcome by maintaining a'Vector-size delta'
value, and offsetting each value in the pointer-array. Indeed, however, this is exactly what theHNLI
andHNLIInclusive
iterators do internally! If a programmer employs theset(...), add(...)
andremove(...)
methods provided by theIterator
-classes both in this package, and the java-interfaces they inherit, internally a size-delta and acursor
are maintained by theIterator
when & if elements are added, updated and removed. As long long as the underlyingVector
is not modified by code outside of theIterator
methods, stale and invalid data-pointers will never be returned by the getter methods of this class. Index-Pointer Arrays are often useful, but less-so when the user plans on changing or adding sections ofHTMLNode
that change how many nodes are in the underlyingVector
.
Hi-Lited Source-Code:
- View Here: Torello/HTML/NodeSearch/HNLIInclusive.java
- Open New Browser-Tab: Torello/HTML/NodeSearch/HNLIInclusive.java
-
-
Field Summary
-
Fields inherited from class Torello.HTML.NodeSearch.AbstractHNLI
c, cursor, expectedSize, maxCursor, minCursor, modifiedSince, p, v
-
-
Method Summary
Method: Next & Previous Modifier and Type Method boolean
hasNext()
boolean
hasPrevious()
Retrieve Vector-Indices (Pointers) Modifier and Type Method DotPair
firstDotPair()
DotPair
lastDotPair()
DotPair
nextDotPair()
int
nextIndex()
DotPair
previousDotPair()
int
previousIndex()
Retrieve HTMLNode's Modifier and Type Method Vector<HTMLNode>
first()
Vector<HTMLNode>
last()
Vector<HTMLNode>
next()
Vector<HTMLNode>
previous()
-
Methods inherited from class Torello.HTML.NodeSearch.AbstractHNLI
add, add, add, addHTMLNode, CHECK_CME, CHECK_EXCEPTIONS, CHECK_EXCEPTIONS, CHECK_EXCEPTIONS, CHECK_EXCEPTIONS, clearCursorBounds, cursorLocation, insertAt, insertAt, insertAt, MODIFIED, moveCursor, moveCursorToEnd, moveCursorToStart, remove, removeElementAt, removeElements, removeRange, removeRange, replaceRange, replaceRange, restrictCursor, restrictCursor, restrictCursor, set, set, set, setHTMLNode
-
-
-
-
Method Detail
-
hasPrevious
public boolean hasPrevious()
Use this method to find out whether the underlyingVector
and currentcursor
position would retrieve another match if'previous'
or'previousIndex'
were called.- Returns:
- This shall return TRUE if calling the
previous()
, orpreviousIndex()
methods would return another inclusive / sub-list node-match. This method shall return FALSE if callingprevious()
would generate / throw a'NoSuchElementException'
- because there are no more sub-list matches in the underlyingVector
, given the currentcursor
position. - Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.- See Also:
Util.Inclusive.subSectionOPT(Vector, int, int)
,TagNode.isClosing
,SubSection
- Code:
- Exact Method Body:
1 2 3 4 5 6 7 8 9 10 11 12 13
CHECK_CME(); if (hasPrevDP != null) return true; int LOOP_BOUNDARY = (minCursor == -1) ? 0 : minCursor; if (cursor == -1) cursor = LOOP_BOUNDARY; // will return false while (--cursor >= LOOP_BOUNDARY) if ((hasPrevDP = TEST_CURSOR_INCLUSIVE()) != null) return true; return false;
-
previous
public java.util.Vector<HTMLNode> previous()
Returns the nearest sub-list match in the underlyingVector
, given the currentcursor
position - when searching in the left-direction, or in the direction of decreasingVector
-indices.- Returns:
- This shall return the sub-list match that is directly previous to the current
cursor
position. - Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.java.util.NoSuchElementException
- If there are not more matches, this exception shall throw. Avoid having to catch this exception by always calling method'hasPrevious'
, and only invoking'previous'
if that method returned TRUE.- Code:
- Exact Method Body:
1
return Util.cloneRange(v, previousDotPair());
-
previousDotPair
public DotPair previousDotPair()
This method, in-some-ways but-not-others, "overrides" the originalListIterator<E> public int previousIndex()
method. Sincepublic class HNLIInclusive
is anIterator
over "sub-lists" - not individual nodes - this means that whenever aVector
-index position is expected, the programmer should be expecting thisIterator
to return two values: both a sub-list start-position, and also a sublist ending-Vector
-position. This is the purpose ofclass DotPair
- it allows pointers (indices) rather than copies of the nodes themselves to be saved, copied or evaluated.
NOTE: Java'spublic int 'previousIndex()'
method requires that an integer be returned in order for this class to properly implement thepublic interface ListIterator<E>
. This method, however, is offered as a "better substitution for" the original'previousIndex'
method. The originalpreviousIndex()
method in the ancestorinterface ListIterator
may still be used, but the actual intention (finding sublists matches in a vectorized-html webpage) could be misunderstood by a novice. MethodpreviousIndex()
, which is mandatory, will return an integer that points to the beginning index of the next sub-list match, but will (obviously) leave off the ending-position of the next sub-list match. Remember that the concept behind the key-word "Inclusive" is that aVector
-sublist shall searched, found, and returned, not just the first HTML ElementTagNode
found.
SUMMARY OF ISSUE: The methodpreviousDotPair()
returns a value that is more-exactly in-line with the notion of an HTML Node List Iterator than the methodpreviousIndex()
. The latter will return an integer index-pointer (into the underlying vectorized-HTML page-Vector
) that identifies the first element of the previous-match, but leave off completely information about where that sublist ends.- Returns:
- The previous integer-pointer pair to the starting-index and ending-index of the previous "inclusive-sublist match" found on the vectorized-html webpage.
- Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.- See Also:
Util.Inclusive.subSectionOPT(Vector, int, int)
,TagNode.isClosing
- Code:
- Exact Method Body:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
CHECK_CME(); lastReturned = hasPrevDP; hasNextDP = hasPrevDP = null; modifiedSince = false; if (lastReturned != null) return lastReturned; int LOOP_BOUNDARY = (minCursor == -1) ? 0 : minCursor; if (cursor == -1) cursor = LOOP_BOUNDARY; // Will throw exception while (--cursor >= LOOP_BOUNDARY) if ((lastReturned = TEST_CURSOR_INCLUSIVE()) != null) return lastReturned; throw new NoSuchElementException("There are no more previous elements available.");
-
hasNext
public boolean hasNext()
Use this method to find out whether the underlyingVector
and currentcursor
position would retrieve another match if'next'
or'nextIndex'
were called.- Returns:
- This shall return TRUE if calling the
next()
, ornextIndex()
methods would return another inclusive / sub-list match. This method shall return FALSE if calling'next'
would generate / throw a'NoSuchElementException'
- because there are no more sub-list matches in the underlyingVector
, given the currentcursor
position. - Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.- See Also:
AbstractHNLI.CHECK_CME()
,Util.Inclusive.subSectionOPT(Vector, int, int)
,TagNode.isClosing
,SubSection
- Code:
- Exact Method Body:
1 2 3 4 5 6 7 8 9 10 11 12
CHECK_CME(); if (hasNextDP != null) return true; int LOOP_BOUNDARY = (maxCursor == -1) ? (v.size() - 1) : maxCursor; if (cursor == -1) cursor = (minCursor == -1) ? -1 : (minCursor-1); while (++cursor <= LOOP_BOUNDARY) if ((hasNextDP = TEST_CURSOR_INCLUSIVE()) != null) return true; return false;
-
next
public java.util.Vector<HTMLNode> next()
Returns the nearest node-match in the underlyingVector
, given the currentcursor
position - when searching in the right-direction, or in the direction of increasingVector
-indices.- Returns:
- This shall return the sub-list match that is directly next to the current
cursor
position. - Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.java.util.NoSuchElementException
- If there are not more matches, this exception shall throw. Avoid having to catch this exception by always calling method'hasNext'
, and only invoking'next'
if that method returned TRUE.- See Also:
AbstractHNLI.CHECK_CME()
,Util.Inclusive.subSectionOPT(Vector, int, int)
,TagNode.isClosing
,SubSection
- Code:
- Exact Method Body:
1
return Util.cloneRange(v, nextDotPair());
-
nextDotPair
public DotPair nextDotPair()
This method, in-some-ways but-not-others, "overrides" the originalListIterator<E>.nextIndex()
method. Sincepublic class HNLIInclusive
is anIterator
over "sub-lists" - not individual nodes - this means that whenever aVector
-index position is expected, the programmer should be expecting thisIterator
to return two values: both a sub-list start-position, and also a sublist ending-Vector
-position. This is the purpose ofclass DotPair
- it allows pointers (indices) rather than copies of the nodes themselves to be saved, copied or evaluated.
NOTE: Java'spublic int nextIndex()
method requires that an integer be returned in order for this class to properly implement thepublic interface ListIterator<>
. This method, however, is offered as a "better substitution for" the original'nextIndex'
method. The originalnextIndex()
method in the ancestorclass ListIterator
may still be used, but the actual intention (finding sublists matches in a vectorized-html webpage) could be misunderstood by a novice. Methodnext()
, which is mandatory, will return an integer that points to the begin index of the next sub-list match, but will (obviously) leave off the ending-position of the next sub-list match. Remember that the concept behind the key-word "Inclusive" is that aVector
-sublist shall searched, found, and returned, not just the first HTML ElementTagNode
found.
SUMMARY OF ISSUE: The methodnextDotPair()
returns a value that is more-exactly in-line with the notion of an HTML Node List Iterator than the methodnextIndex()
. The latter will return an integer index-pointer (into the underlying vectorized-HTML page-Vector
) that identifies the first element of the next-match, but leave off completely information about where that sublist ends.- Returns:
- The next integer-pointer pair to the starting-index and ending-index of the next "inclusive-sublist match" found on the vectorized-html webpage.
- Throws:
java.util.ConcurrentModificationException
- Internal to thisIterator's
state, there is a privateint 'expectedSize'
maintained. If modifications are made to the underlying vectorized-html, from outside of theadd(...), set(...)
orremove(...)
variants provided by thisinterface
then the value of this internal-fieldint 'expectedSize'
will not be consistent with the actual size of theVector
. When this situation arises, both classHNLI
and alsoHNLIInclusive
will throw aConcurrentModificationException
.
NOTE: Changes to the underlyingVector
that do not modify thesize
will simply not be detected. This is due to 'a bug' in the JDK implementation ofAbstractList
which keeps an integer-field named'modCount'
stored as'protected'
- and (unfortunately) unavailable to implementers ofAbstractList
(rendering it useless).
ALSO: Any call made to a variant of the providedfirst(...)
orlast(...)
methods will cause the internalint 'expected-size'
field to reset. This would, therefore, preventConcurrentModificationException
from throwing - even if code from outside theIterator
had modified the size of the underlyingVector
.- See Also:
AbstractHNLI.CHECK_CME()
,Util.Inclusive.subSectionOPT(Vector, int, int)
,TagNode.isClosing
,SubSection
- Code:
- Exact Method Body:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
CHECK_CME(); lastReturned = hasNextDP; hasNextDP = hasPrevDP = null; modifiedSince = false; if (lastReturned != null) return lastReturned; int LOOP_BOUNDARY = (maxCursor == -1) ? (v.size() - 1) : maxCursor; if (cursor == -1) cursor = (minCursor == -1) ? -1 : (minCursor-1); while (++cursor <= LOOP_BOUNDARY) if ((lastReturned = TEST_CURSOR_INCLUSIVE()) != null) return lastReturned; throw new NoSuchElementException("There are no more next elements available.");
-
firstDotPair
public DotPair firstDotPair()
This adds methodpublic DotPair firstIDotPair()
to the javapublic interface ListIterator<E>.
This, actually, returns an instance ofDotPair
. Because thisIterator
iteratesVector
-sublists, not individual HTML nodes, the first-index of the first match will be aDotPair
, not an integer. This (hopefully-obvious) is because thepublic class DotPair
encapsulates two needed numbers (aVector
-position start-index, and an ending-index) into a single-data-class.
NOTE: This method is somewhat of a "reset method" - because the internal-cursor
is moved to the beginning of the underlying-Vector
. Whenever the cursor is moved (or restricted), the logic that checks for aConcurrentModificationException
is reset.
In normal situations, when statements or method's from outside the update methods in this class, modify the underlying html-Vector
aConcurrentModificationException
shall throw. However, whenever anHTML Node List Iterator
method moves the cursor, the logic for checking Concurrent Modification will reset (by setting the internal'expectedSize'
field tov.size()
). This shall prevent an exception throw if outside modification of the underlyingVector
has occurred.- Returns:
- Out of the entire vectorized-html webpage, this method resets the internal
cursor
, and returns the first'DotPair'
match - the starting-index and ending-index - of the first "inclusive-sublist match" - See Also:
nextDotPair()
,lastDotPair()
- Code:
- Exact Method Body:
1 2 3 4 5 6 7
cursor = 0; hasNextDP = hasPrevDP = null; // Calls to first, last, firstIndex, or lastIndex "reset" the CME Monitor-Logic expectedSize = v.size(); return nextDotPair();
-
lastDotPair
public DotPair lastDotPair()
This does the same asfirstIDotPair()
but returns the last list match index-pair found within the inputVector
.
This adds methodpublic DotPair lastIDotPair()
to the javapublic interface ListIterator<E>.
This, actually, returns an instance ofDotPair
. Because thisIterator
iteratesVector
-sublists, not individual HTML nodes, the last-index of the last match will be a'DotPair'
not an integer. This (hopefully obviously) is because thepublic class DotPair
encapsulates two needed numbers (aVector
-position start-index, and an ending-index) into a single-data-class.
NOTE: This method is somewhat of a "reset method" - because the internal-cursor
is moved to the beginning of the underlying-Vector
. Whenever the cursor is moved (or restricted), the logic that checks for aConcurrentModificationException
is reset.
In normal situations, when statements or method's from outside the update methods in this class, modify the underlying html-Vector
aConcurrentModificationException
shall throw. However, whenever anHTML Node List Iterator
method moves the cursor, the logic for checking Concurrent Modification will reset (by setting the internal'expectedSize'
field tov.size()
). This shall prevent an exception throw if outside modification of the underlyingVector
has occurred.- Returns:
- Out of the entire vectorized-html webpage, this method resets the internal pointer,
and returns the last
'DotPair'
match - the starting-index and ending-index - of the last "inclusive-sublist match" - See Also:
previousDotPair()
,firstDotPair()
- Code:
- Exact Method Body:
1 2 3 4 5 6 7
cursor = v.size() - 1; hasNextDP = hasPrevDP = null; // Calls to first, last, firstIndex, or lastIndex "reset" the CME Monitor-Logic expectedSize = v.size(); return previousDotPair();
-
first
public java.util.Vector<HTMLNode> first()
This adds to theListIterator<E>
class by providing afirst()
method that resets thisIterator
back to the first match that is found in the underlying html-Vector
. The internal-cursor
will be moved back to the beginning of theVector
.
NOTE: If the underlying web-pageVector
has been modified, then this method shall return the updated first match. There is no "match memory." Rather, if the underlyingVector
changes, further calls tonext(), previous(), first()
andlast()
could also change.
NOTE: This method is somewhat of a "reset method" - because the internal-cursor
is moved to the beginning of the underlying-Vector
. Whenever the cursor is moved (or restricted), the logic that checks for aConcurrentModificationException
is reset.
In normal situations, when statements or method's from outside the update methods in this class, modify the underlying html-Vector
aConcurrentModificationException
shall throw. However, whenever anHTML Node List Iterator
method moves the cursor, the logic for checking Concurrent Modification will reset (by setting the internal'expectedSize'
field tov.size()
). This shall prevent an exception throw if outside modification of the underlyingVector
has occurred.- Returns:
- This returns the first "inclusive" sub-list (open-tag / start-tag up to the next close-tag) match as a vectorized-html sublist.
- See Also:
next()
- Code:
- Exact Method Body:
1 2 3 4 5 6 7
cursor = 0; hasNextDP = hasPrevDP = null; // Calls to first, last, firstIndex, or lastIndex "reset" the CME Monitor-Logic expectedSize = v.size(); return next();
-
last
public java.util.Vector<HTMLNode> last()
This adds to theListIterator<E>
class by providing alast()
method that moves thisIterator
to the last match that is found in the underlying html-Vector
. The internal-cursor
will be moved directly to the end of theVector
.
NOTE: If the underlying web-pageVector
has been modified, then this method shall return the updated last match. There is no "match memory." Rather, if the underlyingVector
changes, further calls tonext(), previous(), first()
andlast()
could also change.
NOTE: This method is somewhat of a "reset method" - because the internal-cursor
is moved to the beginning of the underlying-Vector
. Whenever the cursor is moved (or restricted), the logic that checks for aConcurrentModificationException
is reset.
In normal situations, when statements or method's from outside the update methods in this class, modify the underlying html-Vector
aConcurrentModificationException
shall throw. However, whenever anHTML Node List Iterator
method moves the cursor, the logic for checking Concurrent Modification will reset (by setting the internal'expectedSize'
field tov.size()
). This shall prevent an exception throw if outside modification of the underlyingVector
has occurred.- Returns:
- This returns the last "inclusive" sub-list (open-tag / start-tag up to the next close-tag) match as an vectorized-html sublist.
- See Also:
previous()
- Code:
- Exact Method Body:
1 2 3 4 5 6 7
cursor = v.size() - 1; hasNextDP = hasPrevDP = null; // Calls to first, last, firstIndex, or lastIndex "reset" the CME Monitor-Logic expectedSize = v.size(); return previous();
-
previousIndex
public int previousIndex()
The veracity of using this method has been eclipsed by methodpublic previoustDotPair()
. Nothing problematic should happen, that is unless you forget that thisIterator
is an 'inclusive'Iterator
. The word "Inclusive" is intended to indicate that a 'range' or 'sublist' (demarcated by a'start'
and'end'
Vector
-index pair) are involved. This is usually-but-not-always expressed using an instance of class'DotPair'
. The starting and ending indices are meant to point to HTML opening and closing element tags such as:<DIV>
and</DIV>
, or maybe<A>
and</A>
Because this method only returns a single integer, and that is the index of the previous opening HTML Tag matching the iterator's constraints (but leaves off the closing-tag) this method'previousIndex()'
may seem out of place.- Returns:
- Returns the index of the beginning of the previous matched sub-section.
- Code:
- Exact Method Body:
1
return previousDotPair().start;
-
nextIndex
public int nextIndex()
The veracity of using this method has been eclipsed by methodpublic nextDotPair()
Nothing problematic should happen, that is unless you forget that thisIterator
is an 'inclusive'Iterator
. The word "Inclusive" is intended to indicate that a 'range' or 'sublist' (demarcated by a'start'
and'end'
Vector
-index pair) are involved. This is usually-but-not-always expressed using an instance of class'DotPair'
. The starting and ending indices are meant to point to HTML opening and closing element tags such as:<DIV>
and</DIV>
, or maybe<A>
and</A>
Because this method only returns a single integer, and that is the index of the next opening HTML Tag matching the iterator's constraints (but leaves off the closing-tag) this method'nextIndex()'
may seem out of place.- Returns:
- Returns the index of the beginning of the next matched sub-section.
- Code:
- Exact Method Body:
1
return nextDotPair().start;
-
-