Changeset 2863 in josm for trunk/src/org
- Timestamp:
- 2010-01-15T21:58:46+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/PushbackTokenizer.java
r2777 r2863 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.actions.search; 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 import static org.openstreetmap.josm.tools.I18n.tr; 3 6 4 7 import java.io.IOException; … … 19 22 } 20 23 21 public enum Token {NOT, OR, LEFT_PARENT, RIGHT_PARENT, COLON, EQUALS, KEY, EOF} 24 public enum Token { 25 NOT(marktr("<not>")), OR(marktr("<or>")), LEFT_PARENT(marktr("<left parent>")), 26 RIGHT_PARENT(marktr("<right parent>")), COLON(marktr("<colon>")), EQUALS(marktr("<equals>")), 27 KEY(marktr("<key>")), QUESTION_MARK(marktr("<question mark>")), EOF(marktr("<end-of-file>")); 28 29 private Token(String name) { 30 this.name = name; 31 } 32 33 private final String name; 34 35 @Override 36 public String toString() { 37 return tr(name); 38 } 39 } 40 22 41 23 42 private void getChar() { … … 69 88 getChar(); 70 89 return Token.OR; 90 case '?': 91 getChar(); 92 return Token.QUESTION_MARK; 71 93 case '"': 72 94 { … … 90 112 { 91 113 StringBuilder s = new StringBuilder(); 92 while (!(c == -1 || Character.isWhitespace(c) || c == '"'|| c == ':' || c == '(' || c == ')' || c == '|' || c == '=' )) {114 while (!(c == -1 || Character.isWhitespace(c) || c == '"'|| c == ':' || c == '(' || c == ')' || c == '|' || c == '=' || c == '?')) { 93 115 s.append((char)c); 94 116 getChar(); -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r2857 r2863 122 122 + "<li>"+tr("<b>type=*</b> - key ''type'' with any value. Try also <b>*=value</b>, <b>type=</b>, <b>*=*</b>, <b>*=</b>") + "</li>" 123 123 + "<li>"+tr("<b>-name:Bak</b> - not ''Bak'' in the name.")+"</li>" 124 + "<li>"+tr("<b>oneway?</b> - oneway=yes, true, 1 or on")+"</li>" 124 125 + "<li>"+tr("<b>foot:</b> - key=foot set to any value.")+"</li>" 125 126 + "<li>"+tr("<u>Special targets:</u>")+"</li>" … … 321 322 public String toString() { 322 323 String cs = caseSensitive ? 323 /*case sensitive*/ trc("search", "CS") : 324 /*case sensitive*/ trc("search", "CS") : 324 325 /*case insensitive*/ trc("search", "CI"); 325 326 /*regex search*/ 326 String rx = regexSearch ? (", " + trc("search", "RX")) : "";327 return "\"" + text + "\" (" + cs + rx + ", " + mode + ")";327 String rx = regexSearch ? (", " + trc("search", "RX")) : ""; 328 return "\"" + text + "\" (" + cs + rx + ", " + mode + ")"; 328 329 } 329 330 -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r2791 r2863 7 7 import java.io.PushbackReader; 8 8 import java.io.StringReader; 9 import java.util.List;10 9 import java.util.Map.Entry; 11 10 import java.util.regex.Matcher; … … 17 16 import org.openstreetmap.josm.data.osm.Node; 18 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 import org.openstreetmap.josm.data.osm.OsmUtils; 19 19 import org.openstreetmap.josm.data.osm.Relation; 20 20 import org.openstreetmap.josm.data.osm.RelationMember; 21 import org.openstreetmap.josm.data.osm.User;22 21 import org.openstreetmap.josm.data.osm.Way; 23 22 import org.openstreetmap.josm.tools.DateUtils; … … 36 35 ( expression ) 37 36 -fact 37 term? 38 38 term=term 39 39 term:term … … 80 80 } 81 81 @Override public String toString() {return "!"+match;} 82 } 83 84 private static class BooleanMatch extends Match { 85 private final String key; 86 private final boolean defaultValue; 87 88 public BooleanMatch(String key, boolean defaultValue) { 89 this.key = key; 90 this.defaultValue = defaultValue; 91 } 92 @Override 93 public boolean match(OsmPrimitive osm) { 94 Boolean ret = OsmUtils.getOsmBoolean(osm.get(key)); 95 if (ret == null) 96 return defaultValue; 97 else 98 return ret; 99 } 82 100 } 83 101 … … 430 448 431 449 private static class UserMatch extends Match { 432 private Useruser;450 private String user; 433 451 public UserMatch(String user) { 434 452 if (user.equals("anonymous")) { 435 453 this.user = null; 436 454 } else { 437 List<User> users = User.getByName(user); 438 if (!users.isEmpty()) { 439 // selecting an arbitrary user 440 this.user = users.get(0); 441 } else { 442 this.user = User.createLocalUser(user); 443 } 444 } 445 } 446 447 @Override public boolean match(OsmPrimitive osm) { 448 if (osm.getUser() == null && user == null) return true; 449 if (osm.getUser() == null) return false; 450 return osm.getUser().equals(user); 455 this.user = user; 456 } 457 } 458 459 @Override public boolean match(OsmPrimitive osm) { 460 if (osm.getUser() == null) 461 return user == null; 462 else 463 return osm.getUser().hasName(user); 451 464 } 452 465 453 466 @Override public String toString() { 454 return "user=" + user == null ? "" : user .getName();467 return "user=" + user == null ? "" : user; 455 468 } 456 469 } … … 641 654 Match expression = parseExpression(); 642 655 if (!tokenizer.readIfEqual(Token.RIGHT_PARENT)) 643 throw new ParseError(tr(" Missing right parenthesis"));656 throw new ParseError(tr("Unexpected token. Expected {0}, found {1}", Token.RIGHT_PARENT, tokenizer.nextToken())); 644 657 return expression; 645 658 } else if (tokenizer.readIfEqual(Token.NOT)) … … 651 664 else if (tokenizer.readIfEqual(Token.COLON)) 652 665 return parseKV(key, tokenizer.readText()); 666 else if (tokenizer.readIfEqual(Token.QUESTION_MARK)) 667 return new BooleanMatch(key, false); 653 668 else if ("modified".equals(key)) 654 669 return new Modified(); -
trunk/src/org/openstreetmap/josm/data/osm/User.java
r2711 r2863 118 118 } 119 119 120 /* 120 /** 121 121 * Returns the list of user names 122 122 * … … 127 127 } 128 128 129 /* 129 /** 130 130 * Adds a user name to the list if it is not there, yet. 131 131 * … … 136 136 } 137 137 138 /* 138 /** 139 139 * Returns true if the name is in the names list 140 140 *
Note:
See TracChangeset
for help on using the changeset viewer.