private boolean doesMatch(String pattern,int pp,String result,int rp){
  for (; ; ) {
    if (pp == pattern.length() && rp == result.length())     return true;
    if (pp == pattern.length())     return false;
    char pc=pattern.charAt(pp);
    if (pc == '_') {
      if (rp == result.length())       return false;
      pp++;
      rp++;
    }
 else     if (pc == '%') {
      if (pp == pattern.length() - 1) {
        return true;
      }
      for (int sp=rp; sp < result.length(); sp++) {
        if (doesMatch(pattern,pp + 1,result,sp)) {
          return true;
        }
      }
      return false;
    }
 else {
      if (rp == result.length())       return false;
      if (pc != result.charAt(rp)) {
        return false;
      }
      pp++;
      rp++;
    }
  }
}

private boolean doesMatch ( String pattern , int pp , String result , int rp ) { for ( ; ; ) { if ( pp == pattern . length ( ) && rp == result . length ( ) ) return true ; if ( pp == pattern . length ( ) ) return false ; char pc = pattern . charAt ( pp ) ; if ( pc == '_' ) { if ( rp == result . length ( ) ) return false ; pp ++ ; rp ++ ; } else if ( pc == '%' ) { if ( pp == pattern . length ( ) - 1 ) { return true ; } for ( int sp = rp ; sp < result . length ( ) ; sp ++ ) { if ( doesMatch ( pattern , pp + 1 , result , sp ) ) { return true ; } } return false ; } else { if ( rp == result . length ( ) ) return false ; if ( pc != result . charAt ( rp ) ) { return false ; } pp ++ ; rp ++ ; } } }
see if a string matches the pattern as defined by databasemetadata . by passing in non - zero values can check sub - sets of the pattern against the sub strings of the result . < br > _ matches a single character < br > % matches zero or more characters < br > other characters match themselves .
