Changeset 8899 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-18T18:56:56+02:00 (4 years ago)
Author:
simon04
Message:

Refactoring in SearchCompiler: parse type, user, role as any other keyword

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r8898 r8899  
    106106
    107107    public class CoreSimpleMatchFactory implements SimpleMatchFactory {
    108         private Collection<String> keywords = Arrays.asList("id", "version",
     108        private Collection<String> keywords = Arrays.asList("id", "version", "type", "user", "role",
    109109                "changeset", "nodes", "ways", "tags", "areasize", "waylength", "modified", "selected",
    110110                "incomplete", "untagged", "closed", "new", "indownloadedarea",
     
    141141                    case "version":
    142142                        return new Version(tokenizer);
     143                    case "type":
     144                        return new ExactType(tokenizer.readTextOrNumber());
     145                    case "user":
     146                        return new UserMatch(tokenizer.readTextOrNumber());
     147                    case "role":
     148                        return new RoleMatch(tokenizer.readTextOrNumber());
    143149                    case "changeset":
    144150                        return new ChangesetId(tokenizer);
     
    15831589
    15841590                // key:value form where value is a string (may be OSM key search)
    1585                 return parseKV(key, tokenizer.readTextOrNumber());
     1591                final String value = tokenizer.readTextOrNumber();
     1592                return new KeyValue(key, value != null ? value : "", regexSearch, caseSensitive);
    15861593            } else if (tokenizer.readIfEqual(Token.QUESTION_MARK))
    15871594                return new BooleanMatch(key, false);
     
    16101617    }
    16111618
    1612     private Match parseKV(String key, String value) throws ParseError {
    1613         if (value == null) {
    1614             value = "";
    1615         }
    1616         switch(key) {
    1617         case "type":
    1618             return new ExactType(value);
    1619         case "user":
    1620             return new UserMatch(value);
    1621         case "role":
    1622             return new RoleMatch(value);
    1623         default:
    1624             return new KeyValue(key, value, regexSearch, caseSensitive);
    1625         }
    1626     }
    1627 
    16281619    private static int regexFlags(boolean caseSensitive) {
    16291620        int searchFlags = 0;
Note: See TracChangeset for help on using the changeset viewer.