Esempio n. 1
0
  /**
   * Returns true if the message bytes starts with the specified string.
   *
   * @param s the string
   * @param pos The start position
   */
  public boolean startsWithIgnoreCase(String s, int pos) {
    switch (type) {
      case T_STR:
        if (strValue == null) return false;
        if (strValue.length() < pos + s.length()) return false;

        for (int i = 0; i < s.length(); i++) {
          if (Ascii.toLower(s.charAt(i)) != Ascii.toLower(strValue.charAt(pos + i))) {
            return false;
          }
        }
        return true;
      case T_CHARS:
        return charC.startsWithIgnoreCase(s, pos);
      case T_BYTES:
        return byteC.startsWithIgnoreCase(s, pos);
      default:
        return false;
    }
  }
Esempio n. 2
0
 // hash ignoring case
 private int hashIgnoreCase() {
   int code = 0;
   switch (type) {
     case T_STR:
       for (int i = 0; i < strValue.length(); i++) {
         code = code * 37 + Ascii.toLower(strValue.charAt(i));
       }
       return code;
     case T_CHARS:
       return charC.hashIgnoreCase();
     case T_BYTES:
       return byteC.hashIgnoreCase();
     default:
       return 0;
   }
 }