@Override public T compare(String requestResource,String targetResource,boolean wildcardCompare){
  if (!wildcardCompare) {
    return super.compare(requestResource,targetResource,wildcardCompare);
  }
  String schemelessTarget=targetResource;
  String schemelessRequest=requestResource;
  if (schemelessTarget.contains(SCHEME_DELIMITER) && schemelessRequest.contains(SCHEME_DELIMITER)) {
    schemelessTarget=removeSchemeEnsureSlash(schemelessTarget);
    schemelessRequest=removeSchemeEnsureSlash(schemelessRequest);
  }
 else {
    return super.compare(requestResource,targetResource,wildcardCompare);
  }
  final int firstColon=schemelessTarget.indexOf(COLON);
  final int firstSlash=schemelessTarget.indexOf(SLASH);
  if (firstColon == -1) {
    return super.compare(requestResource,targetResource,wildcardCompare);
  }
 else {
    T schemeMatch=compareBeforeBreakpoint(requestResource,targetResource,SCHEME_DELIMITER);
    if (!isSuccessfulMatch(schemeMatch)) {
      return noMatch;
    }
    if (firstSlash >= 0 && firstSlash < firstColon) {
      return super.compare(schemelessRequest,schemelessTarget,wildcardCompare);
    }
    if (firstSlash >= 0 && firstSlash > firstColon) {
      T hostMatch=compareBeforeBreakpoint(schemelessRequest,schemelessTarget,COLON);
      if (!isSuccessfulMatch(hostMatch)) {
        return noMatch;
      }
      final String postColonRequest=schemelessRequest.substring(schemelessRequest.indexOf(COLON));
      final String postColonTarget=schemelessTarget.substring(schemelessTarget.indexOf(COLON));
      T portMatch=compareBeforeBreakpoint(postColonRequest,postColonTarget,SLASH);
      if (!isSuccessfulMatch(portMatch)) {
        return noMatch;
      }
      final String postSlashRequest=postColonRequest.substring(postColonRequest.indexOf(SLASH));
      final String postSlashTarget=postColonTarget.substring(postColonTarget.indexOf(SLASH));
      final int requestQueryStringIndex=postSlashRequest.indexOf(QUERY_DELIMITER);
      final int targetQueryStringIndex=postSlashTarget.indexOf(QUERY_DELIMITER);
      if (requestQueryStringIndex != -1) {
        if (targetQueryStringIndex == -1) {
          final String preQueryStringRequest=postSlashRequest.substring(0,requestQueryStringIndex);
          T pathMatch=super.compare(preQueryStringRequest,postSlashTarget,wildcardCompare);
          if (noMatch.equals(pathMatch) || subResourceMatch.equals(pathMatch)) {
            return noMatch;
          }
          return superResourceMatch;
        }
        T pathMatch=compareBeforeBreakpoint(postSlashRequest,postSlashTarget,QUERY_DELIMITER);
        if (!isSuccessfulMatch(pathMatch)) {
          return noMatch;
        }
        T queryMatch=super.compare(postSlashRequest.substring(requestQueryStringIndex),postSlashTarget.substring(targetQueryStringIndex),wildcardCompare);
        return wildcardResponseCombiner(hostMatch,portMatch,pathMatch,queryMatch);
      }
 else {
        T pathMatch=super.compare(postSlashRequest,postSlashTarget,wildcardCompare);
        return wildcardResponseCombiner(hostMatch,portMatch,pathMatch);
      }
    }
 else {
      return compareSplit(schemelessRequest,schemelessTarget,COLON);
    }
  }
}

@ Override public T compare ( String requestResource , String targetResource , boolean wildcardCompare ) { if ( ! wildcardCompare ) { return super . compare ( requestResource , targetResource , wildcardCompare ) ; } String schemelessTarget = targetResource ; String schemelessRequest = requestResource ; if ( schemelessTarget . contains ( SCHEME_DELIMITER ) && schemelessRequest . contains ( SCHEME_DELIMITER ) ) { schemelessTarget = removeSchemeEnsureSlash ( schemelessTarget ) ; schemelessRequest = removeSchemeEnsureSlash ( schemelessRequest ) ; } else { return super . compare ( requestResource , targetResource , wildcardCompare ) ; } final int firstColon = schemelessTarget . indexOf ( COLON ) ; final int firstSlash = schemelessTarget . indexOf ( SLASH ) ; if ( firstColon == - 1 ) { return super . compare ( requestResource , targetResource , wildcardCompare ) ; } else { T schemeMatch = compareBeforeBreakpoint ( requestResource , targetResource , SCHEME_DELIMITER ) ; if ( ! isSuccessfulMatch ( schemeMatch ) ) { return noMatch ; } if ( firstSlash >= 0 && firstSlash < firstColon ) { return super . compare ( schemelessRequest , schemelessTarget , wildcardCompare ) ; } if ( firstSlash >= 0 && firstSlash > firstColon ) { T hostMatch = compareBeforeBreakpoint ( schemelessRequest , schemelessTarget , COLON ) ; if ( ! isSuccessfulMatch ( hostMatch ) ) { return noMatch ; } final String postColonRequest = schemelessRequest . substring ( schemelessRequest . indexOf ( COLON ) ) ; final String postColonTarget = schemelessTarget . substring ( schemelessTarget . indexOf ( COLON ) ) ; T portMatch = compareBeforeBreakpoint ( postColonRequest , postColonTarget , SLASH ) ; if ( ! isSuccessfulMatch ( portMatch ) ) { return noMatch ; } final String postSlashRequest = postColonRequest . substring ( postColonRequest . indexOf ( SLASH ) ) ; final String postSlashTarget = postColonTarget . substring ( postColonTarget . indexOf ( SLASH ) ) ; final int requestQueryStringIndex = postSlashRequest . indexOf ( QUERY_DELIMITER ) ; final int targetQueryStringIndex = postSlashTarget . indexOf ( QUERY_DELIMITER ) ; if ( requestQueryStringIndex != - 1 ) { if ( targetQueryStringIndex == - 1 ) { final String preQueryStringRequest = postSlashRequest . substring ( 0 , requestQueryStringIndex ) ; T pathMatch = super . compare ( preQueryStringRequest , postSlashTarget , wildcardCompare ) ; if ( noMatch . equals ( pathMatch ) || subResourceMatch . equals ( pathMatch ) ) { return noMatch ; } return superResourceMatch ; } T pathMatch = compareBeforeBreakpoint ( postSlashRequest , postSlashTarget , QUERY_DELIMITER ) ; if ( ! isSuccessfulMatch ( pathMatch ) ) { return noMatch ; } T queryMatch = super . compare ( postSlashRequest . substring ( requestQueryStringIndex ) , postSlashTarget . substring ( targetQueryStringIndex ) , wildcardCompare ) ; return wildcardResponseCombiner ( hostMatch , portMatch , pathMatch , queryMatch ) ; } else { T pathMatch = super . compare ( postSlashRequest , postSlashTarget , wildcardCompare ) ; return wildcardResponseCombiner ( hostMatch , portMatch , pathMatch ) ; } } else { return compareSplit ( schemelessRequest , schemelessTarget , COLON ) ; } } }
specific comparison for urls , where a wildcard in the host / port should not match any of the path . strings should be canonicalized prior to entering this comparison , else they will be compared by the super class ' comparison function .
