public interface StringMatchIterator<MATCHRESULT>
extends java.util.Iterator<MATCHRESULT>
Iterator
that provides access to the pattern matches in a string
StringSearcher.searchString(String)
produces these.
Modifier and Type | Method and Description |
---|---|
int |
matchEndPosition()
Get the position of the end of the last match in the string.
|
MATCHRESULT |
matchResult()
Get the result of the last match.
|
int |
matchStartPosition()
Get the position of the start of the last match in the string.
|
java.lang.String |
matchValue()
Get the string value of the last match
|
boolean |
reposition(int pos)
rewind (or jump forward) to a given position in the source string
|
int matchStartPosition()
java.lang.IllegalStateException
- unless called after a valid call to {Iterator.next()
int matchEndPosition()
java.lang.IllegalStateException
- unless called after a valid call to {Iterator.next()
java.lang.String matchValue()
Note that a new string is allocated by the first call to this method for each match.
java.lang.IllegalStateException
- unless called after a valid call to {Iterator.next()
MATCHRESULT matchResult()
Iterator.next()
java.lang.IllegalStateException
- unless called after a valid call to {Iterator.next()
boolean reposition(int pos)
The next match returned will be the one (if any) that starts at a position >= pos
IMPORTANT: If this method returns true, you must call Iterator.next()
to get the result
of the next match. Until then calls to the the match accessor methods will continue to
return information from the previous call to Iterator.next()
.
pos
- new position in the source string to search fromIterator.hasNext()