source: josm/trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java@ 2115

Last change on this file since 2115 was 2115, checked in by Gubaer, 15 years ago

new: reading open changesets from the server
new: reading user info from the server
new: any open changeset can be used when uploading
new: generic dialog for closing changesets
fixed #3427: JOSM can't keep many changesets open at once
fixed #3408: Allow continuing opened changeset even after restarting JOSM
fixed #3476: Default selection in upload dialog should be different for unclosed changesets. (Upload dialog now looks different)

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5public enum OsmPrimitiveType {
6
7 NODE ("node"),
8 WAY ("way"),
9 RELATION ("relation");
10
11 private String apiTypeName;
12
13 OsmPrimitiveType(String apiTypeName) {
14 this.apiTypeName = apiTypeName;
15 }
16
17 public String getAPIName() {
18 return apiTypeName;
19 }
20
21 public static OsmPrimitiveType fromApiTypeName(String typeName) {
22 for (OsmPrimitiveType type : OsmPrimitiveType.values()) {
23 if (type.getAPIName().equals(typeName)) return type;
24 }
25 throw new IllegalArgumentException(tr("parameter ''{0}'' is not a valid type name, got ''{1}''", "typeName", typeName));
26 }
27
28 public static OsmPrimitiveType from(OsmPrimitive obj) {
29 return from(obj.getClass());
30 }
31
32 public static OsmPrimitiveType from(Class cls) {
33 if (cls.equals(Node.class)) return NODE;
34 if (cls.equals(Way.class)) return WAY;
35 if (cls.equals(Relation.class)) return RELATION;
36 throw new IllegalArgumentException(tr("parameter ''{0}'' is not an acceptable class, got ''{1}''", "cls", cls.toString()));
37 }
38
39 public static OsmPrimitiveType from(String value) {
40 if (value == null) return null;
41 for (OsmPrimitiveType type: values()){
42 if (type.getAPIName().equalsIgnoreCase(value))
43 return type;
44 }
45 return null;
46 }
47
48}
Note: See TracBrowser for help on using the repository browser.