org.pf.text
Class StringExaminer

java.lang.Object
  extended by org.pf.text.StringScanner
      extended by org.pf.text.StringExaminer

public class StringExaminer
extends StringScanner

As a subclass of StringScanner this class allows more advanced navigation over the underlying string.
That includes moving to positions of specific substrings etc.

Version:
1.0
Author:
Manfred Duchrow

Field Summary
 
Fields inherited from class org.pf.text.StringScanner
buffer, END_REACHED, length, pos_marker, position
 
Constructor Summary
StringExaminer(java.lang.String stringToExamine)
          Initialize the new instance with the string to examine.
StringExaminer(java.lang.String stringToExamine, boolean ignoreCase)
          Initialize the new instance with the string to examine.
 
Method Summary
protected  boolean charsAreEqual(char char1, char char2)
           
protected  boolean ignoreCase()
           
protected  void ignoreCase(boolean newValue)
           
 java.lang.String peekUpToEnd()
          Returns the a string containing all characters from the current position up to the end of the examined string.
 boolean skipAfter(java.lang.String matchString)
          Increments the position pointer up to the last character that matched the character sequence in the given matchString.
 boolean skipBefore(java.lang.String matchString)
          Increments the position pointer up to the first character before the character sequence in the given matchString.
 java.lang.String upToEnd()
          Returns the a string containing all characters from the current position up to the end of the examined string.
protected  java.lang.String upToEnd(boolean peek)
          Returns the a string containing all characters from the current position up to the end of the examined string.
 
Methods inherited from class org.pf.text.StringScanner
atEnd, endNotReached, endReached, getPosition, hasNext, length, markPosition, nextChar, nextNoneWhitespaceChar, peek, restorePosition, setPosition, skip, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringExaminer

public StringExaminer(java.lang.String stringToExamine)
Initialize the new instance with the string to examine.
The string will be treated case-sensitive.

Parameters:
stringToExamine - The string that should be examined

StringExaminer

public StringExaminer(java.lang.String stringToExamine,
                      boolean ignoreCase)
Initialize the new instance with the string to examine.

Parameters:
stringToExamine - The string that should be examined
ignoreCase - Specified whether or not treating the string case insensitive
Method Detail

ignoreCase

protected boolean ignoreCase()

ignoreCase

protected void ignoreCase(boolean newValue)

skipAfter

public boolean skipAfter(java.lang.String matchString)
Increments the position pointer up to the last character that matched the character sequence in the given matchString. Returns true, if the matchString was found, otherwise false.

If the matchString was found, the next invocation of method nextChar() returns the first character after that matchString.

Parameters:
matchString - The string to look up

skipBefore

public boolean skipBefore(java.lang.String matchString)
Increments the position pointer up to the first character before the character sequence in the given matchString. Returns true, if the matchString was found, otherwise false.

If the matchString was found, the next invocation of method nextChar() returns the first character of that matchString from the position where it was found inside the examined string.

Parameters:
matchString - The string to look up

peekUpToEnd

public java.lang.String peekUpToEnd()
Returns the a string containing all characters from the current position up to the end of the examined string.
The character position of the examiner is not changed by this method.


upToEnd

public java.lang.String upToEnd()
Returns the a string containing all characters from the current position up to the end of the examined string.
The character position is put to the end by this method. That means the next invocation of nextChar() returns END_REACHED.


charsAreEqual

protected boolean charsAreEqual(char char1,
                                char char2)

upToEnd

protected java.lang.String upToEnd(boolean peek)
Returns the a string containing all characters from the current position up to the end of the examined string.
Depending on the peek flag the character position of the examiner is unchanged (true) after calling this method or points behind the strings last character.