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 void
close()
Closes this character stream, as well as the the reader it its iterating over.boolean
hasNext()
Returnstrue
if the character stream has more matches.Matcher
next()
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. Ifdiscard
istrue
, 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
Matcher
from the character stream. - Throws:
IOException
- if an I/O exception occurs.NoSuchElementException
- if the reader has no more matches.
-
hasNext
public boolean hasNext() throws IOException
Returnstrue
if the character stream has more matches.- Returns:
true
if the character stream has more matches.- Throws:
IOException
- if an I/O exception occurs.
-
close
public void close() throws IOException
Closes this character stream, as well as the the reader it its iterating over.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O exception occurs.
-
-