Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r8495 r8510 89 89 // TODO: check for keyword collisions 90 90 if (factory instanceof SimpleMatchFactory) { 91 simpleMatchFactoryMap.put(keyword, (SimpleMatchFactory) factory);91 simpleMatchFactoryMap.put(keyword, (SimpleMatchFactory) factory); 92 92 } else if (factory instanceof UnaryMatchFactory) { 93 unaryMatchFactoryMap.put(keyword, (UnaryMatchFactory) factory);93 unaryMatchFactoryMap.put(keyword, (UnaryMatchFactory) factory); 94 94 } else if (factory instanceof BinaryMatchFactory) { 95 binaryMatchFactoryMap.put(keyword, (BinaryMatchFactory) factory);95 binaryMatchFactoryMap.put(keyword, (BinaryMatchFactory) factory); 96 96 } else 97 97 throw new AssertionError("Unknown match factory"); … … 326 326 super(match); 327 327 } 328 328 329 @Override 329 330 public boolean match(OsmPrimitive osm) { 330 331 return !match.match(osm); 331 332 } 333 332 334 @Override 333 335 public String toString() { 334 336 return "!" + match; 335 337 } 338 336 339 public Match getMatch() { 337 340 return match; … … 350 353 this.defaultValue = defaultValue; 351 354 } 355 352 356 @Override 353 357 public boolean match(OsmPrimitive osm) { … … 367 371 super(lhs, rhs); 368 372 } 373 369 374 @Override 370 375 public boolean match(OsmPrimitive osm) { 371 376 return lhs.match(osm) && rhs.match(osm); 372 377 } 378 373 379 @Override 374 380 public String toString() { … … 384 390 super(lhs, rhs); 385 391 } 392 386 393 @Override 387 394 public boolean match(OsmPrimitive osm) { 388 395 return lhs.match(osm) || rhs.match(osm); 389 396 } 397 390 398 @Override 391 399 public String toString() { … … 401 409 super(lhs, rhs); 402 410 } 411 403 412 @Override 404 413 public boolean match(OsmPrimitive osm) { 405 414 return lhs.match(osm) ^ rhs.match(osm); 406 415 } 416 407 417 @Override 408 418 public String toString() { … … 418 428 super(range); 419 429 } 430 420 431 public Id(PushbackTokenizer tokenizer) throws ParseError { 421 432 this(tokenizer.readRange(tr("Range of primitive ids expected"))); 422 433 } 434 423 435 @Override 424 436 protected Long getNumber(OsmPrimitive osm) { 425 437 return osm.isNew() ? 0 : osm.getUniqueId(); 426 438 } 439 427 440 @Override 428 441 protected String getString() { … … 438 451 super(range); 439 452 } 453 440 454 public ChangesetId(PushbackTokenizer tokenizer) throws ParseError { 441 455 this(tokenizer.readRange(tr("Range of changeset ids expected"))); 442 456 } 457 443 458 @Override 444 459 protected Long getNumber(OsmPrimitive osm) { 445 460 return (long) osm.getChangesetId(); 446 461 } 462 447 463 @Override 448 464 protected String getString() { … … 458 474 super(range); 459 475 } 476 460 477 public Version(PushbackTokenizer tokenizer) throws ParseError { 461 478 this(tokenizer.readRange(tr("Range of versions expected"))); 462 479 } 480 463 481 @Override 464 482 protected Long getNumber(OsmPrimitive osm) { 465 483 return (long) osm.getVersion(); 466 484 } 485 467 486 @Override 468 487 protected String getString() { … … 551 570 } else { 552 571 mv = osm.get(key); 553 if (!caseSensitive && mv == null) {572 if (!caseSensitive && mv == null) { 554 573 for (String k: osm.keySet()) { 555 if (key.equalsIgnoreCase(k)) {574 if (key.equalsIgnoreCase(k)) { 556 575 mv = osm.get(k); 557 576 break; … … 574 593 return false; 575 594 } 595 576 596 @Override 577 597 public String toString() { … … 628 648 throw new ParseError(tr("Key cannot be empty when tag operator is used. Sample use: key=value")); 629 649 this.key = key; 630 this.value = value == null ?"":value;650 this.value = value == null ? "" : value; 631 651 if ("".equals(this.value) && "*".equals(key)) { 632 652 mode = Mode.NONE; … … 800 820 return false; 801 821 } 822 802 823 @Override 803 824 public String toString() { … … 808 829 private static class ExactType extends Match { 809 830 private final OsmPrimitiveType type; 831 810 832 public ExactType(String type) throws ParseError { 811 833 this.type = OsmPrimitiveType.from(type); … … 814 836 type)); 815 837 } 838 816 839 @Override 817 840 public boolean match(OsmPrimitive osm) { 818 841 return type.equals(osm.getType()); 819 842 } 843 820 844 @Override 821 845 public String toString() { … … 829 853 private static class UserMatch extends Match { 830 854 private String user; 855 831 856 public UserMatch(String user) { 832 857 if ("anonymous".equals(user)) { … … 856 881 private static class RoleMatch extends Match { 857 882 private String role; 883 858 884 public RoleMatch(String role) { 859 885 if (role == null) { … … 871 897 if (m.getMember() == osm) { 872 898 String testRole = m.getRole(); 873 if (role.equals(testRole == null ? "" : testRole))899 if (role.equals(testRole == null ? "" : testRole)) 874 900 return true; 875 901 } … … 1068 1094 return "timestamp"; 1069 1095 } 1070 1071 1096 } 1072 1097 … … 1079 1104 return osm.isNew(); 1080 1105 } 1106 1081 1107 @Override 1082 1108 public String toString() { … … 1093 1119 return osm.isModified() || osm.isNewOrUndeleted(); 1094 1120 } 1121 1095 1122 @Override 1096 1123 public String toString() { … … 1107 1134 return Main.main.getCurrentDataSet().isSelected(osm); 1108 1135 } 1136 1109 1137 @Override 1110 1138 public String toString() { … … 1123 1151 return osm.isIncomplete(); 1124 1152 } 1153 1125 1154 @Override 1126 1155 public String toString() { … … 1139 1168 return !osm.isTagged() && !osm.isIncomplete(); 1140 1169 } 1170 1141 1171 @Override 1142 1172 public String toString() { … … 1153 1183 return osm instanceof Way && ((Way) osm).isClosed(); 1154 1184 } 1185 1155 1186 @Override 1156 1187 public String toString() { … … 1166 1197 super(m); 1167 1198 } 1199 1168 1200 @Override 1169 1201 public boolean match(OsmPrimitive osm) { … … 1171 1203 1172 1204 if (osm instanceof Way) { 1173 for (Node n : ((Way) osm).getNodes()) {1205 for (Node n : ((Way) osm).getNodes()) { 1174 1206 isParent |= match.match(n); 1175 1207 } 1176 1208 } else if (osm instanceof Relation) { 1177 for (RelationMember member : ((Relation) osm).getMembers()) {1209 for (RelationMember member : ((Relation) osm).getMembers()) { 1178 1210 isParent |= match.match(member.getMember()); 1179 1211 } … … 1181 1213 return isParent; 1182 1214 } 1215 1183 1216 @Override 1184 1217 public String toString() { … … 1204 1237 return isChild; 1205 1238 } 1239 1206 1240 @Override 1207 1241 public String toString() { … … 1271 1305 private abstract static class InArea extends Match { 1272 1306 1273 protected abstract Bounds getBounds();1274 1307 protected final boolean all; 1275 1308 … … 1280 1313 this.all = all; 1281 1314 } 1315 1316 protected abstract Bounds getBounds(); 1282 1317 1283 1318 @Override … … 1337 1372 super(msg); 1338 1373 } 1374 1339 1375 public ParseError(String msg, Throwable cause) { 1340 1376 super(msg, cause); 1341 1377 } 1378 1342 1379 public ParseError(Token expected, Token found) { 1343 1380 this(tr("Unexpected token. Expected {0}, found {1}", expected, found));
Note:
See TracChangeset
for help on using the changeset viewer.