Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.Arrays;
|
---|
6 | import java.util.Locale;
|
---|
7 |
|
---|
8 | public 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 |
|
---|
15 | public static final String trueval = "yes";
|
---|
16 | public static final String falseval = "no";
|
---|
17 |
|
---|
18 | public static Boolean getOsmBoolean(String value) {
|
---|
19 | if(value == null) return null;
|
---|
20 | String lowerValue = value.toLowerCase(Locale.ENGLISH);
|
---|
21 | if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE;
|
---|
22 | if (FALSE_VALUES.contains(lowerValue)) return Boolean.FALSE;
|
---|
23 | return null;
|
---|
24 | }
|
---|
25 | public static String getNamedOsmBoolean(String value) {
|
---|
26 | Boolean res = getOsmBoolean(value);
|
---|
27 | return res == null ? value : (res ? trueval : falseval);
|
---|
28 | }
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.