@Override
  public boolean shExpMatch(String str, String shexp) {
    StringTokenizer tokenizer = new StringTokenizer(shexp, "*");
    int startPos = 0;
    while (tokenizer.hasMoreTokens()) {
      String token = tokenizer.nextToken();
      int temp = str.indexOf(token, startPos);

      // Must start with first token
      if (startPos == 0 && !shexp.startsWith("*") && temp != 0) {
        return false;
      }
      // Last one ends with last token
      if (!tokenizer.hasMoreTokens() && !shexp.endsWith("*")
          && !str.endsWith(token)) {
        return false;
      }

      if (temp == -1) {
        return false;
      } else {
        startPos = temp + token.length();
      }
    }

    return true;
  }
@Override
  public boolean shExpMatch(String str, String shexp) {
    StringTokenizer tokenizer = new StringTokenizer(shexp, "*");
    int startPos = 0;
    while (tokenizer.hasMoreTokens()) {
      String token = tokenizer.nextToken();
      int temp = str.indexOf(token, startPos);

      
      if (startPos == 0 && !shexp.startsWith("*") && temp != 0) {
        return false;
      }
      
      if (!tokenizer.hasMoreTokens() && !shexp.endsWith("*")
          && !str.endsWith(token)) {
        return false;
      }

      if (temp == -1) {
        return false;
      } else {
        startPos = temp + token.length();
      }
    }

    return true;
  }
@ Override public boolean shExpMatch ( String str , String shexp ) { StringTokenizer tokenizer = new StringTokenizer ( shexp , "*" ) ; int startPos = 0 ; while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; int temp = str . indexOf ( token , startPos ) ; // Must start with first token if ( startPos == 0 && ! shexp . startsWith ( "*" ) && temp != 0 ) { return false ; } // Last one ends with last token if ( ! tokenizer . hasMoreTokens ( ) && ! shexp . endsWith ( "*" ) && ! str . endsWith ( token ) ) { return false ; } if ( temp == - 1 ) { return false ; } else { startPos = temp + token . length ( ) ; } } return true ; }
***********************************************************************
Returns true if the string matches the specified shell expression.
Actually, currently the patterns are shell expressions, not regular
expressions.

@param str
is any string to compare (e.g. the URL, or the host name).
@param shexp
is a shell expression to compare against.
@return true if the string matches, else false.
**********************************************************************
*********************************************************************** Returns true if the string matches the specified shell expression . Actually currently the patterns are shell expressions not regular expressions .