Class StreamPatternMatches

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class StreamPatternMatches
    extends Object
    implements Closeable
    Iterates through multiple regular expression matches within a character stream.
    • Constructor Detail

      • StreamPatternMatches

        public StreamPatternMatches​(Reader input,
                                    Collection<Pattern> patterns,
                                    boolean discard)
        Constructs a new stream pattern match iterator. If discard is true, 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
        Returns true 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 interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException - if an I/O exception occurs.