Package org.forgerock.openig.regex
Class StreamPatternMatches
- java.lang.Object
-
- org.forgerock.openig.regex.StreamPatternMatches
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class StreamPatternMatches extends Object implements Closeable
Iterates through multiple regular expression matches within a character stream.
-
-
Constructor Summary
Constructors Constructor Description StreamPatternMatches(Reader input, Collection<Pattern> patterns, boolean discard)Constructs a new stream pattern match iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this character stream, as well as the the reader it its iterating over.booleanhasNext()Returnstrueif the character stream has more matches.Matchernext()Returns the next match from the character stream.
-
-
-
Constructor Detail
-
StreamPatternMatches
public StreamPatternMatches(Reader input, Collection<Pattern> patterns, boolean discard)
Constructs a new stream pattern match iterator. Ifdiscardistrue, then a pattern is discarded after it is first matched.- Parameters:
input- the character stream to match regular expression patterns against.patterns- a collection of regular expression patterns to match.discard- indicates patterns be discarded after they yield a match.
-
-
Method Detail
-
next
public Matcher next() throws IOException
Returns the next match from the character stream. Matches are returned in the order they are encountered in the character stream, then by the order they are expressed in the supplied patterns collection.- Returns:
- the next
Matcherfrom the character stream. - Throws:
IOException- if an I/O exception occurs.NoSuchElementException- if the reader has no more matches.
-
hasNext
public boolean hasNext() throws IOExceptionReturnstrueif the character stream has more matches.- Returns:
trueif the character stream has more matches.- Throws:
IOException- if an I/O exception occurs.
-
close
public void close() throws IOExceptionCloses this character stream, as well as the the reader it its iterating over.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O exception occurs.
-
-