public boolean scanBoolean() throws StringScanException {
    StringScanException exception = null;
    int idxSave = idx;
    String testStr = "false"; // MUST BE LOWERCASE
    boolean testval = false;
    char c;
    
    skipWhiteSpace();
    if (Character.toLowerCase(buf[idx]) == 't') {
      testStr = "true";
      testval = true;
    } else {
      testval = false;
    }
    int i = 0;
    for (i = 0; i < testStr.length(); i++) {
      if (testStr.charAt(i) != Character.toLowerCase(buf[idx])) {
        if (idx == len) {
          exception = new StringScanException(idx, "end of input");
        }
        break;
      }
      idx++;
    }
    if (exception == null) {
      if (i < testStr.length() || Character.isLetterOrDigit(c = buf[idx])
          || c == '_') {
        exception = new StringScanException(idx, "illegal boolean");
      }
    }
    if (exception != null) {
      idx = idxSave;
      throw exception;
    }
    return testval;
  }