Ignore:
Timestamp:
2014-01-12T10:41:20+01:00 (10 years ago)
Author:
simon04
Message:

Make strings like foo relation/123 and way/345 but also node/789 paste-able in "Download object", some refactoring of related code

File:
1 edited

Legend:

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

    r6429 r6674  
    2222import org.openstreetmap.josm.data.osm.Node;
    2323import org.openstreetmap.josm.data.osm.OsmPrimitive;
     24import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2425import org.openstreetmap.josm.data.osm.OsmUtils;
    2526import org.openstreetmap.josm.data.osm.Relation;
     
    746747    }
    747748
    748     // TODO: change how we handle this
    749749    private static class ExactType extends Match {
    750         private final Class<?> type;
     750        private final OsmPrimitiveType type;
    751751        public ExactType(String type) throws ParseError {
    752             if ("node".equals(type)) {
    753                 this.type = Node.class;
    754             } else if ("way".equals(type)) {
    755                 this.type = Way.class;
    756             } else if ("relation".equals(type)) {
    757                 this.type = Relation.class;
    758             } else
     752            this.type = OsmPrimitiveType.from(type);
     753            if (this.type == null)
    759754                throw new ParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation",
    760755                        type));
    761756        }
    762757        @Override public boolean match(OsmPrimitive osm) {
    763             return osm.getClass() == type;
     758            return type.equals(osm.getType());
    764759        }
    765760        @Override public String toString() {return "type="+type;}
Note: See TracChangeset for help on using the changeset viewer.