Class RegexParser

  • All Implemented Interfaces:
    TagValueParser

    public class RegexParser
    extends Object
    implements TagValueParser

    A TagValueParser that splits a line based upon a regular expression. There are configuration parameters analgous to those in LineSplitParser for configuring parsing details.

    Since:
    1.3
    Author:
    Matthew Pocock, Keith James (enabled empty line EOR)
    • Constructor Detail

      • RegexParser

        public RegexParser()
        Create a new RegexParser with all boolean values set to false.
    • Method Detail

      • setPattern

        public void setPattern​(Pattern pattern)
        Set the Pattern used to split lines.
        Parameters:
        pattern - the Pattern used to split lines
      • getPattern

        public Pattern getPattern()
        Get the Pattern currently used to split lines.
        Returns:
        the current Pattern
      • setTagGroup

        public void setTagGroup​(int group)
        Set the group number that will match the tag.
        Parameters:
        group - the tag group number
      • getTagGroup

        public int getTagGroup()
        Get the group number that matches the tag.
        Returns:
        the tag group number
      • setValueGroup

        public void setValueGroup​(int group)
        Set the group number that will match the value.
        Parameters:
        group - the value group number
      • getValueGroup

        public int getValueGroup()
        Get the group number that matches the value.
        Returns:
        the value group number
      • setEndOfRecord

        public void setEndOfRecord​(String endOfRecord)
        Set the explicit end-of-record string.
        Parameters:
        endOfRecord - the new endOfRecord String
      • getEndOfRecord

        public String getEndOfRecord()
        Get the explicit end-of-record string.
        Returns:
        the current endOfRecord String
      • setTrimTag

        public void setTrimTag​(boolean trimTag)
        Enable trimming of the tag using String.trim().
        Parameters:
        trimTag - true if tags should be trimmed, false otherwise
      • getTrimTag

        public boolean getTrimTag()
        See if trimming of tags is enabled.
        Returns:
        true if tag trimming is enabled, false otherwise
      • setTrimValue

        public void setTrimValue​(boolean trimValue)
        Enable trimming of the value using String.trim().
        Parameters:
        trimValue - true if values should be trimmed, false otherwise
      • getTrimValue

        public boolean getTrimValue()
        See if trimming of values is enabled.
        Returns:
        true if value trimming is enabled, false otherwise
      • setContinueOnEmptyTag

        public void setContinueOnEmptyTag​(boolean continueOnEmptyTag)
        Decide whether to treat empty tags as continuations of the previous non -empty tag.
        Parameters:
        continueOnEmptyTag - true if empty tags should be replaced, false otherwise
      • getContinueOnEmptyTag

        public boolean getContinueOnEmptyTag()
        Report whether empty tags will be treated as continuations of the last non -empty tag.
        Returns:
        true if empty tags will be replaced, false otherwise
      • setMergeSameTag

        public void setMergeSameTag​(boolean mergeSameTag)
        Decide if multiple examples of a single tag should be merged into a single start/endTag pair with multiple values, or multiple start/endTag pairs each with a single value.
        Parameters:
        mergeSameTag - true if tags will be merged, false otherwise
      • getMergeSameTag

        public boolean getMergeSameTag()
        Report whether empty tags will be treated as continuations of the last non -empty tag.
        Returns:
        true if tags will be merged, false otherwise