private String transformKey ( String key , String src , String tgt ) { StringBuilder sb = new StringBuilder ( ) ; String [ ] srcTokens = src . split ( WILDCARD_DELIM_REGEX ) ; String [ ] tgtTokens = tgt . split ( WILDCARD_DELIM_REGEX ) ; int len = Math . max ( srcTokens . length , tgtTokens . length ) ; int pos = 0 ; int start = 0 ; for ( int i = 0 ; i <= len ; i ++ ) { String srcx = i >= srcTokens . length ? "" : srcTokens [ i ] ; String tgtx = i >= tgtTokens . length ? "" : tgtTokens [ i ] ; pos = i == len ? key . length ( ) : pos ; if ( "*" . equals ( srcx ) || "?" . equals ( srcx ) ) { start = pos ; } else { pos = key . indexOf ( srcx , pos ) ; if ( pos > start ) { sb . append ( key . substring ( start , pos ) ) ; } start = pos += srcx . length ( ) ; sb . append ( tgtx ) ; } } return sb . toString ( ) ; }
Uses the source and target wildcard masks to transform an input key .