Class CommentMatches

java.lang.Object
org.supercsv.comment.CommentMatches
All Implemented Interfaces:
CommentMatcher

public class CommentMatches extends Object implements CommentMatcher
CommentMatcher that matches lines that match a specified regular expression.
  • Field Details

    • pattern

      private final Pattern pattern
  • Constructor Details

    • CommentMatches

      public CommentMatches(String regex)
      Constructs a new CommentMatches comment matcher. Ensure that the regex is efficient (ideally matching start/end characters) as a complex regex can significantly slow down reading.
      Parameters:
      regex - the regular expression a line must match to be a comment
      Throws:
      NullPointerException - if regex is null
      IllegalArgumentException - if regex is empty
      PatternSyntaxException - if the regex is invalid
  • Method Details

    • isComment

      public boolean isComment(String line)
      Determines whether a line of CSV is a comment.
      Specified by:
      isComment in interface CommentMatcher
      Parameters:
      line - the raw line of CSV
      Returns:
      true if it's a comment, otherwise false