private void locateToken() {
    if (myTokenType != null || myState == 3) return;

    if (myState == 0) {
      myTokenEnd = myTokenStart + myPrefix.length();
      myTokenType = myPrefixType;
      myState = myTokenEnd < myBufferEnd ? 1 : 3;
      return;
    }

    if (myState == 1) {
      myTokenStart = myTokenEnd;
      final int suffixStart = myBufferEnd - mySuffix.length();
      myTokenType = myMiddleTokenType;
      if ( (myBufferArray != null && CharArrayUtil.regionMatches(myBufferArray, suffixStart, myBufferEnd, mySuffix)) ||
           (myBufferArray == null && CharArrayUtil.regionMatches(myBuffer, suffixStart, myBufferEnd, mySuffix))
         ) {
        myTokenEnd = suffixStart;
        if (myTokenStart < myTokenEnd) {
          myState = 2;
        }
        else {
          myState = 3;
          myTokenType = mySuffixType;
          myTokenEnd = myBufferEnd;
        }
      }
      else {
        myTokenEnd = myBufferEnd;
        myState = 3;
      }

      return;
    }

    if (myState == 2) {
      myTokenStart = myTokenEnd;
      myTokenEnd = myBufferEnd;
      myTokenType = mySuffixType;
      myState = 3;
    }
  }
private void locateToken()