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

Last change on this file since 6792 was 6792, checked in by Don-vip, 10 years ago

Sonar - fix various issues

  • Property svn:eol-style set to native
File size: 1.6 KB
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.List;
7import java.util.Locale;
8
9public final class OsmUtils {
10
11 private OsmUtils() {
12 // Hide default constructor for utils classes
13 }
14
15 static final List<String> TRUE_VALUES = new ArrayList<String>(Arrays
16 .asList(new String[] { "true", "yes", "1", "on" }));
17 static final List<String> FALSE_VALUES = new ArrayList<String>(Arrays
18 .asList(new String[] { "false", "no", "0", "off" }));
19 static final List<String> REVERSE_VALUES = new ArrayList<String>(Arrays
20 .asList(new String[] { "reverse", "-1" }));
21
22 public static final String trueval = "yes";
23 public static final String falseval = "no";
24 public static final String reverseval = "-1";
25
26 public static Boolean getOsmBoolean(String value) {
27 if(value == null) return null;
28 String lowerValue = value.toLowerCase(Locale.ENGLISH);
29 if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE;
30 if (FALSE_VALUES.contains(lowerValue)) return Boolean.FALSE;
31 return null;
32 }
33
34 public static String getNamedOsmBoolean(String value) {
35 Boolean res = getOsmBoolean(value);
36 return res == null ? value : (res ? trueval : falseval);
37 }
38
39 public static boolean isReversed(String value) {
40 return REVERSE_VALUES.contains(value);
41 }
42
43 public static boolean isTrue(String value) {
44 return TRUE_VALUES.contains(value);
45 }
46
47 public static boolean isFalse(String value) {
48 return FALSE_VALUES.contains(value);
49 }
50}
Note: See TracBrowser for help on using the repository browser.