379 // used for substring comparisons (where proto has "*" wildcards
380 private boolean substringMatch(String proto, String value) {
381 // simple case 1: "*" means attribute presence is being tested
382 if(proto.equals(new Character(WILDCARD_TOKEN).toString())) {
383 if(debug) {System.out.println("simple presence assertion");}
384 return true;
385 }
386
387 // simple case 2: if there are no wildcards, call String.equals()
388 if(proto.indexOf(WILDCARD_TOKEN) == -1) {
389 return proto.equalsIgnoreCase(value);
390 }
391
392 if(debug) {System.out.println("doing substring comparison");}
393 // do the work: make sure all the substrings are present
394 int currentPos = 0;
395 StringTokenizer subStrs = new StringTokenizer(proto, "*", false);
396
397 // do we need to begin with the first token?
398 if(proto.charAt(0) != WILDCARD_TOKEN &&
399 !value.toString().toLowerCase(Locale.ENGLISH).startsWith(
400 subStrs.nextToken().toLowerCase(Locale.ENGLISH))) {
401 if(debug) {
402 System.out.println("faild initial test");
403 }
404 return false;
405 }
406
407 while(subStrs.hasMoreTokens()) {
408 String currentStr = subStrs.nextToken();
409 if (debug) {System.out.println("looking for \"" +
410 currentStr +"\"");}
411 currentPos = value.toLowerCase(Locale.ENGLISH).indexOf(
412 currentStr.toLowerCase(Locale.ENGLISH), currentPos);
413
414 if(currentPos == -1) {
415 return false;
416 }
417 currentPos += currentStr.length();
418 }
419
|
379 // used for substring comparisons (where proto has "*" wildcards
380 private boolean substringMatch(String proto, String value) {
381 // simple case 1: "*" means attribute presence is being tested
382 if(proto.equals(new Character(WILDCARD_TOKEN).toString())) {
383 if(debug) {System.out.println("simple presence assertion");}
384 return true;
385 }
386
387 // simple case 2: if there are no wildcards, call String.equals()
388 if(proto.indexOf(WILDCARD_TOKEN) == -1) {
389 return proto.equalsIgnoreCase(value);
390 }
391
392 if(debug) {System.out.println("doing substring comparison");}
393 // do the work: make sure all the substrings are present
394 int currentPos = 0;
395 StringTokenizer subStrs = new StringTokenizer(proto, "*", false);
396
397 // do we need to begin with the first token?
398 if(proto.charAt(0) != WILDCARD_TOKEN &&
399 !value.toLowerCase(Locale.ENGLISH).startsWith(
400 subStrs.nextToken().toLowerCase(Locale.ENGLISH))) {
401 if(debug) {
402 System.out.println("faild initial test");
403 }
404 return false;
405 }
406
407 while(subStrs.hasMoreTokens()) {
408 String currentStr = subStrs.nextToken();
409 if (debug) {System.out.println("looking for \"" +
410 currentStr +"\"");}
411 currentPos = value.toLowerCase(Locale.ENGLISH).indexOf(
412 currentStr.toLowerCase(Locale.ENGLISH), currentPos);
413
414 if(currentPos == -1) {
415 return false;
416 }
417 currentPos += currentStr.length();
418 }
419
|