private T matchTokens(String targetToken,String requestToken){
  int wildcardIndex=0;
  if (targetToken == null && requestToken == null) {
    return exactMatch;
  }
  if (targetToken == null || requestToken == null) {
    return noMatch;
  }
  int beginTargetIndex=0;
  int beginRequestIndex=0;
  String substr=null;
  int targetTokenLength=targetToken.length();
  int requestTokenLength=requestToken.length();
  if (targetToken.indexOf(oneLevelWildcard,beginTargetIndex) != -1) {
    while ((wildcardIndex=targetToken.indexOf(oneLevelWildcard,beginTargetIndex)) != -1) {
      if (wildcardIndex > beginTargetIndex) {
        substr=targetToken.substring(beginTargetIndex,wildcardIndex);
        if ((beginRequestIndex=requestToken.indexOf(substr,beginRequestIndex)) == -1) {
          return noMatch;
        }
        beginTargetIndex=beginTargetIndex + substr.length() + oneLevelWildcardLength;
        beginRequestIndex=beginRequestIndex + substr.length();
      }
 else {
        if (wildcardIndex == beginTargetIndex) {
          if (targetTokenLength == oneLevelWildcardLength) {
            return wildcardMatch;
          }
 else {
            beginTargetIndex=beginTargetIndex + oneLevelWildcardLength;
            continue;
          }
        }
      }
    }
    if (beginTargetIndex >= targetTokenLength) {
      return wildcardMatch;
    }
    String targetStr=targetToken.substring(beginTargetIndex,targetTokenLength);
    String remRequest=requestToken.substring(beginRequestIndex,requestTokenLength);
    int remRequestIndex=-1;
    if ((remRequestIndex=remRequest.lastIndexOf(targetStr,remRequest.length() - 1)) == -1) {
      return noMatch;
    }
 else {
      beginRequestIndex=beginRequestIndex + remRequestIndex;
      if (beginRequestIndex + targetStr.length() >= requestTokenLength) {
        return wildcardMatch;
      }
 else {
        return noMatch;
      }
    }
  }
 else {
    if (targetToken.equals(requestToken)) {
      return exactMatch;
    }
  }
  return noMatch;
}

private T matchTokens ( String targetToken , String requestToken ) { int wildcardIndex = 0 ; if ( targetToken == null && requestToken == null ) { return exactMatch ; } if ( targetToken == null || requestToken == null ) { return noMatch ; } int beginTargetIndex = 0 ; int beginRequestIndex = 0 ; String substr = null ; int targetTokenLength = targetToken . length ( ) ; int requestTokenLength = requestToken . length ( ) ; if ( targetToken . indexOf ( oneLevelWildcard , beginTargetIndex ) != - 1 ) { while ( ( wildcardIndex = targetToken . indexOf ( oneLevelWildcard , beginTargetIndex ) ) != - 1 ) { if ( wildcardIndex > beginTargetIndex ) { substr = targetToken . substring ( beginTargetIndex , wildcardIndex ) ; if ( ( beginRequestIndex = requestToken . indexOf ( substr , beginRequestIndex ) ) == - 1 ) { return noMatch ; } beginTargetIndex = beginTargetIndex + substr . length ( ) + oneLevelWildcardLength ; beginRequestIndex = beginRequestIndex + substr . length ( ) ; } else { if ( wildcardIndex == beginTargetIndex ) { if ( targetTokenLength == oneLevelWildcardLength ) { return wildcardMatch ; } else { beginTargetIndex = beginTargetIndex + oneLevelWildcardLength ; continue ; } } } } if ( beginTargetIndex >= targetTokenLength ) { return wildcardMatch ; } String targetStr = targetToken . substring ( beginTargetIndex , targetTokenLength ) ; String remRequest = requestToken . substring ( beginRequestIndex , requestTokenLength ) ; int remRequestIndex = - 1 ; if ( ( remRequestIndex = remRequest . lastIndexOf ( targetStr , remRequest . length ( ) - 1 ) ) == - 1 ) { return noMatch ; } else { beginRequestIndex = beginRequestIndex + remRequestIndex ; if ( beginRequestIndex + targetStr . length ( ) >= requestTokenLength ) { return wildcardMatch ; } else { return noMatch ; } } } else { if ( targetToken . equals ( requestToken ) ) { return exactMatch ; } } return noMatch ; }
matches individual request and target tokens . this method is used to compare tokens in one level wild card compare to compare tokens between delimiter boundaries .
