Class RegexLineIterator

All Implemented Interfaces:
Iterator<String>

public class RegexLineIterator extends TransformingIteratorWrapper<String,String>
Utility class providing an Iterator interface over line-oriented text input. By providing regexs indicating lines to ignore (such as pure whitespace or comments), lines to consider input, and what to return from the input lines (such as a whitespace-trimmed non-whitespace token with optional trailing comment), this can be configured to handle a number of formats. The public static members provide pattern configurations that will be helpful in a wide variety of contexts.
Author:
gojomo
  • Field Details

  • Constructor Details

  • Method Details

    • transform

      protected String transform(String line)
      Loads next item into lookahead spot, if available. Skips lines matching ignoreLine; extracts desired portion of lines matching extractLine; informationally reports any lines matching neither.
      Specified by:
      transform in class TransformingIteratorWrapper<String,String>
      Parameters:
      line - Object to transform.
      Returns:
      whether any item was loaded into next field