Class Grep

java.lang.Object
ise.antelope.tasks.Grep

public class Grep extends Object
Borrowed from Antelope, modified to be a general purpose class instead of an Ant task.
Version:
$Revision: 132 $
  • Constructor Details

    • Grep

      public Grep()
  • Method Details

    • setIn

      public void setIn(String string)
      Where to look.
      Parameters:
      string - The new in value
    • setRegex

      public void setRegex(String regex)
      What to look for.
      Parameters:
      regex - The new regex value
    • setGroup

      public void setGroup(int g)
      Set a specific group from the regex.
      Parameters:
      g - The new group value
    • setDotall

      public void setDotall(boolean b)
      Sets the dotall attribute for the regex.
      Parameters:
      b - The new dotall value
    • setCaseinsensitive

      public void setCaseinsensitive(boolean b)
      Sets the caseinsensitive attribute for the regex.
      Parameters:
      b - The new caseinsensitive value
    • setMultiline

      public void setMultiline(boolean b)
      Sets the multiline attribute for the regex.
      Parameters:
      b - The new multiline value
    • setUnicodecase

      public void setUnicodecase(boolean b)
      Sets the unicodecase attribute for the regex.
      Parameters:
      b - The new unicodecase value
    • setCanoneq

      public void setCanoneq(boolean b)
      Sets the canoneq attribute for the regex.
      Parameters:
      b - The new canoneq value
    • setComments

      public void setComments(boolean b)
      Sets the comments attribute for the regex.
      Parameters:
      b - The new comments value
    • setUnixlines

      public void setUnixlines(boolean b)
    • setAllmatches

      public void setAllmatches(boolean b)
      If true, concatentates all matches into a single result, if false, only the first match is returned in the result.
      Parameters:
      b - default is false, only show the first match.
    • getCount

      public int getCount()
      Returns:
      the count of the matches found by the regular expression in the string
    • getMatch

      public String getMatch()
      Returns:
      the match found by the regular expression in the string. If 'all matches' was set to true, then each match will be contained in this string, separated by the separator specified in setSeparator
    • getMatches

      public Iterator getMatches()
      Returns:
      an Iterator over all matches found by the regular expression.
    • getMatch

      public String getMatch(int i)
      Returns:
      if there are multiple matches, return the ith match.
    • setSeparator

      public void setSeparator(String s)
      Used in conjunction with setAllmatches, this string will be placed between each match in the final result.
      Parameters:
      s - the separator, default is "".
    • grep

      public String grep()
      Do the grep