question: public T compare ( String requestResource , String targetResource , boolean wildcardCompare ) { if ( requestResource == null && targetResource == null ) { return exactMatch ; } if ( requestResource == null || targetResource == null ) { return noMatch ; } if ( ! caseSensitive ) { requestResource = requestResource . toLowerCase ( ) ; targetResource = targetResource . toLowerCase ( ) ; } requestResource = normalizeRequestResource ( requestResource ) ; targetResource = normalizeTargetResource ( targetResource ) ; if ( oneLevelWildcardEmbedded && targetResource . indexOf ( wildcard ) == - 1 ) { if ( targetResource . indexOf ( oneLevelWildcard ) != - 1 && wildcardCompare ) { debug . message ( "PrefixResourceName:compare():invoking one level compare" ) ; return oneLevelWildcardCompare ( requestResource , targetResource , wildcardCompare ) ; } } if ( wildcardEmbedded || ! ( wildcardEmbedded || oneLevelWildcardEmbedded ) ) { if ( targetResource . indexOf ( oneLevelWildcard ) != - 1 && wildcardCompare ) { debug . message ( "PrefixResourceName:compare():invoking one level compare" ) ; return oneLevelWildcardCompare ( requestResource , targetResource , wildcardCompare ) ; } } int reqBegin = 0 ; int reqEnd = 0 ; int tarBegin = 0 ; int tarEnd = 0 ; int reqLen = 0 ; int tarLen = 0 ; String subString = null ; reqLen = requestResource . length ( ) ; tarLen = targetResource . length ( ) ; tarEnd = targetResource . indexOf ( wildcard , tarBegin ) ; if ( ! wildcardCompare || tarEnd == - 1 ) { if ( requestResource . equals ( targetResource ) ) { return exactMatch ; } if ( targetResource . startsWith ( ( requestResource . endsWith ( delimiter ) ) ? requestResource : requestResource + delimiter ) ) { return subResourceMatch ; } if ( requestResource . startsWith ( ( targetResource . endsWith ( delimiter ) ) ? targetResource : targetResource + delimiter ) ) { return superResourceMatch ; } return noMatch ; } subString = targetResource . substring ( tarBegin , tarEnd ) ; if ( tarEnd > tarBegin ) { if ( ! ( requestResource . startsWith ( subString ) ) ) { if ( subString . startsWith ( ( requestResource . endsWith ( delimiter ) ) ? requestResource : requestResource + delimiter ) ) { return subResourceMatch ; } return noMatch ; } } reqBegin = tarEnd ; if ( tarEnd >= tarLen - 1 ) { return wildcardMatch ; } tarBegin = tarEnd + 1 ; while ( ( tarEnd = targetResource . indexOf ( wildcard , tarBegin ) ) != - 1 ) { subString = targetResource . substring ( tarBegin , tarEnd ) ; if ( tarEnd > tarBegin ) { if ( ( reqBegin = requestResource . indexOf ( subString , reqBegin ) ) == - 1 ) { return subResourceMatch ; } } if ( tarEnd >= tarLen - 1 ) { return wildcardMatch ; } reqBegin = reqBegin + ( tarEnd - tarBegin ) ; tarBegin = tarEnd + 1 ; } subString = targetResource . substring ( tarBegin , tarLen ) ; if ( ( reqEnd = requestResource . lastIndexOf ( subString , reqLen - 1 ) ) == - 1 ) { return subResourceMatch ; } if ( reqBegin > reqEnd ) { return subResourceMatch ; } reqBegin = reqEnd ; if ( ( reqLen - reqBegin ) == ( tarLen - tarBegin ) ) { return wildcardMatch ; } reqBegin = reqBegin + ( tarLen - tarBegin ) ; subString = requestResource . substring ( reqBegin , reqBegin + 1 ) ; if ( subString . equals ( delimiter ) ) { return superResourceMatch ; } return subResourceMatch ; }
target:  Compares two resources. Description: The targetResource may contain wildcard or one level wildcard pattern but not both  which matches zero or more characters. The wildcard character can show up anywhere within the string. The targetResource can contain any number of one type of wildcard characters. Based on the type of wild card in the resource either regular wildcard comparison is done or one level wild card comparison is done. One of the five possible match types is returned based on how the two resource strings are related. The comparison starts from the beginning of the resource strings. ResourceMatch.NO_MATCH means two resources don't match. ResourceMatch.EXACT_MATCH means two resources match. ResourceMatch.SUB_RESOURCE_MATCH means targetResource is the sub resource of the requestResource. ResourceMatch.SUPER_RESOURCE_MATCH means targetResource is the super resource of the requestResource. ResourceMatch.WILDCARD_MATCH means two resources match with respect to the wildcard.