net.sf.jmatchparser.util
Class ExpectString

java.lang.Object
  extended by net.sf.jmatchparser.util.ExpectString

public class ExpectString
extends Object

A class that can "expect" parts at the start or end of a string, and get/set the remaining part (rest). In most cases, ExpectReader is more flexible, but sometimes this class might be more handy.


Constructor Summary
ExpectString(String rest)
          Create a new expect string
 
Method Summary
 String changeRest(String newRest)
          Change the rest that has not yet been parsed, and return the old rest.
 void expect(String start)
          Expect a fixed string at the beginning.
 void expectEnd(String end)
          Expect a fixed string at the end.
 List<Matcher> expectMultiRegexMatch(Pattern pattern, int restGroup)
          Match the given regex more than once against the rest.
 List<Matcher> expectMultiRegexMatch(String regex, int restGroup)
          Match the given regex more than once against the rest.
 Matcher expectRegex(Pattern pattern, int keptGroup)
          Expect a regex that matches the complete string.
 Matcher expectRegex(String regex)
          Expect a regex at the begin of the string and return a matcher for it.
 Matcher expectRegex(String pattern, int keptGroup)
          Expect a regex that matches the complete string.
 String expectStringAfterString(String s)
          Expect some fixed string followed by some variable text at the end of the rest.
 String expectStringBeforeString(String s)
          Expect some variable text before some fixed string.
 String getRest()
          Return the rest that has not yet been parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpectString

public ExpectString(String rest)
Create a new expect string

Parameters:
rest - The rest still to be matched
Method Detail

getRest

public String getRest()
Return the rest that has not yet been parsed.


changeRest

public String changeRest(String newRest)
Change the rest that has not yet been parsed, and return the old rest.


expectStringBeforeString

public String expectStringBeforeString(String s)
Expect some variable text before some fixed string.

Parameters:
s - the fixed string
Returns:
the variable text

expectStringAfterString

public String expectStringAfterString(String s)
Expect some fixed string followed by some variable text at the end of the rest.

Parameters:
s - the fixed string
Returns:
the variable text

expect

public void expect(String start)
Expect a fixed string at the beginning.


expectEnd

public void expectEnd(String end)
Expect a fixed string at the end.


expectRegex

public Matcher expectRegex(String regex)
Expect a regex at the begin of the string and return a matcher for it. The matcher will have an additional group containing the rest.


expectRegex

public Matcher expectRegex(String pattern,
                           int keptGroup)
Expect a regex that matches the complete string. The keptGroup will remain in the rest.


expectRegex

public Matcher expectRegex(Pattern pattern,
                           int keptGroup)
Expect a regex that matches the complete string. The keptGroup will remain in the rest.


expectMultiRegexMatch

public List<Matcher> expectMultiRegexMatch(String regex,
                                           int restGroup)
Match the given regex more than once against the rest.

See Also:
ExpectReader.ensureMultiRegexMatch(String, Pattern, Pattern, int)

expectMultiRegexMatch

public List<Matcher> expectMultiRegexMatch(Pattern pattern,
                                           int restGroup)
Match the given regex more than once against the rest.

See Also:
ExpectReader.ensureMultiRegexMatch(String, Pattern, Pattern, int)


Copyright © 2011. All Rights Reserved.