source: josm/trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java @ 5241

Revision 3083, 1.5 KB checked in by bastiK, 2 years ago (diff)

added svn:eol-style=native to source files

  • Property svn:eol-style set to native
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.Locale;
7
8public class OsmUtils {
9
10    static ArrayList<String> TRUE_VALUES = new ArrayList<String>(Arrays
11            .asList(new String[] { "true", "yes", "1", "on" }));
12    static ArrayList<String> FALSE_VALUES = new ArrayList<String>(Arrays
13            .asList(new String[] { "false", "no", "0", "off" }));
14    static ArrayList<String> REVERSE_VALUES = new ArrayList<String>(Arrays
15            .asList(new String[] { "reverse", "-1" }));
16
17    public static final String trueval = "yes";
18    public static final String falseval = "no";
19    public static final String reverseval = "-1";
20
21    public static Boolean getOsmBoolean(String value) {
22        if(value == null) return null;
23        String lowerValue = value.toLowerCase(Locale.ENGLISH);
24        if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE;
25        if (FALSE_VALUES.contains(lowerValue)) return Boolean.FALSE;
26        return null;
27    }
28
29    public static String getNamedOsmBoolean(String value) {
30        Boolean res = getOsmBoolean(value);
31        return res == null ? value : (res ? trueval : falseval);
32    }
33
34    public static boolean isReversed(String value) {
35        return REVERSE_VALUES.contains(value);
36    }
37
38    public static boolean isTrue(String value) {
39        return TRUE_VALUES.contains(value);
40    }
41
42    public static boolean isFalse(String value) {
43        return FALSE_VALUES.contains(value);
44    }
45}
Note: See TracBrowser for help on using the repository browser.