Ticket #2803: validator2.patch
| File validator2.patch, 4.3 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java
old new 78 78 protected static ArrayList<String> ignoreDataEquals = new ArrayList<String>(); 79 79 protected static ArrayList<String> ignoreDataEndsWith = new ArrayList<String>(); 80 80 protected static ArrayList<IgnoreKeyPair> ignoreDataKeyPair = new ArrayList<IgnoreKeyPair>(); 81 protected static ArrayList<IgnoreTwoKeyPair> ignoreDataTwoKeyPair = new ArrayList<IgnoreTwoKeyPair>(); 81 82 82 83 /** The preferences prefix */ 83 84 protected static final String PREFIX = PreferenceEditor.PREFIX + "." + TagChecker.class.getSimpleName(); … … 252 253 tmp.value = line.substring(mid+1); 253 254 ignoreDataKeyPair.add(tmp); 254 255 } 256 else if(key.equals("T:")) 257 { 258 IgnoreTwoKeyPair tmp = new IgnoreTwoKeyPair(); 259 int mid = line.indexOf("="); 260 int split = line.indexOf("|"); 261 tmp.key1 = line.substring(0, mid); 262 tmp.value1 = line.substring(mid+1, split); 263 line = line.substring(split+1); 264 mid = line.indexOf("="); 265 tmp.key2 = line.substring(0, mid); 266 tmp.value2 = line.substring(mid+1); 267 ignoreDataTwoKeyPair.add(tmp); 268 } 255 269 continue; 256 270 } 257 271 else if(tagcheckerfile) … … 374 388 375 389 if(checkComplex) 376 390 { 391 Map<String, String> props = (p.keys == null) ? Collections.<String, String>emptyMap() : p.keys; 392 for(Entry<String, String> prop: props.entrySet() ) 393 { 394 boolean ignore = true; 395 String key1 = prop.getKey(); 396 String value1 = prop.getValue(); 397 398 for(IgnoreTwoKeyPair a : ignoreDataTwoKeyPair) 399 { 400 if(key1.equals(a.key1) && value1.equals(a.value1)) 401 { 402 ignore = false; 403 for(Entry<String, String> prop2: props.entrySet() ) 404 { 405 String key2 = prop2.getKey(); 406 String value2 = prop2.getValue(); 407 for(IgnoreTwoKeyPair b : ignoreDataTwoKeyPair) 408 { 409 if(key2.equals(b.key2) && value2.equals(b.value2)) 410 { 411 ignore = true; 412 break; 413 } 414 } 415 if(ignore) 416 break; 417 } 418 } 419 if(ignore) 420 break; 421 } 422 423 if(!ignore) 424 { 425 errors.add( new TestError(this, Severity.ERROR, tr("Illegal tag/value combinations"), 426 tr("Illegal tag/value combinations"), tr("Illegal tag/value combinations"), 1272, p) ); 427 withErrors.add(p, "TC"); 428 } 429 } 430 377 431 for(CheckerData d : checkerData) 378 432 { 379 433 if(d.match(p)) … … 471 525 ignore = true; 472 526 } 473 527 528 for(IgnoreTwoKeyPair a : ignoreDataTwoKeyPair) 529 { 530 if(key.equals(a.key2) && value.equals(a.value2)) 531 ignore = true; 532 } 533 474 534 if(!ignore) 475 535 { 476 536 String i = marktr("Value ''{0}'' for key ''{1}'' not in presets."); … … 777 837 return false; 778 838 } 779 839 840 private static class IgnoreTwoKeyPair { 841 public String key1; 842 public String value1; 843 public String key2; 844 public String value2; 845 } 846 780 847 private static class IgnoreKeyPair { 781 848 public String key; 782 849 public String value;
