Ignore:
Timestamp:
2017-05-15T22:57:02+02:00 (3 years ago)
Author:
michael2402
Message:

Add javadoc to OsmUtils, fix constant naming.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java

    r10674 r12187  
    1212import org.openstreetmap.josm.tools.TextTagParser;
    1313
     14/**
     15 * Utility methods/constants that are useful for generic OSM tag handling.
     16 */
    1417public final class OsmUtils {
    1518
     
    2124            .asList("reverse", "-1"));
    2225
    23     public static final String trueval = "yes";
    24     public static final String falseval = "no";
    25     public static final String reverseval = "-1";
     26    /**
     27     * A value that should be used to indicate true
     28     * @since 12186
     29     */
     30    public static final String TRUE_VALUE = "yes";
     31    /**
     32     * A value that should be used to indicate false
     33     * @since 12186
     34     */
     35    public static final String FALSE_VALUE = "no";
     36    /**
     37     * A value that should be used to indicate that a property applies reversed on the way
     38     * @since 12186
     39     */
     40    public static final String REVERSE_VALUE = "-1";
     41
     42    /**
     43     * Discouraged synonym for {@link #TRUE_VALUE}
     44     */
     45    public static final String trueval = TRUE_VALUE;
     46    /**
     47     * Discouraged synonym for {@link #FALSE_VALUE}
     48     */
     49    public static final String falseval = FALSE_VALUE;
     50    /**
     51     * Discouraged synonym for {@link #REVERSE_VALUE}
     52     */
     53    public static final String reverseval = REVERSE_VALUE;
    2654
    2755    private OsmUtils() {
     
    2957    }
    3058
     59    /**
     60     * Converts a string to a boolean value
     61     * @param value The string to convert
     62     * @return {@link Boolean#TRUE} if that string represents a true value,
     63     *         {@link Boolean#FALSE} if it represents a false value,
     64     *         <code>null</code> otherwise.
     65     */
    3166    public static Boolean getOsmBoolean(String value) {
    3267        if (value == null) return null;
     
    3772    }
    3873
     74    /**
     75     * Normalizes the OSM boolean value
     76     * @param value The tag value
     77     * @return The best true/false value or the old value if the input cannot be converted.
     78     * @see #TRUE_VALUE
     79     * @see #FALSE_VALUE
     80     */
    3981    public static String getNamedOsmBoolean(String value) {
    4082        Boolean res = getOsmBoolean(value);
     
    4284    }
    4385
     86    /**
     87     * Check if the value is a value indicating that a property applies reversed.
     88     * @param value The value to check
     89     * @return true if it is reversed.
     90     */
    4491    public static boolean isReversed(String value) {
    4592        return REVERSE_VALUES.contains(value);
    4693    }
    4794
     95    /**
     96     * Check if a tag value represents a boolean true value
     97     * @param value The value to check
     98     * @return true if it is a true value.
     99     */
    48100    public static boolean isTrue(String value) {
    49101        return TRUE_VALUES.contains(value);
    50102    }
    51103
     104    /**
     105     * Check if a tag value represents a boolean false value
     106     * @param value The value to check
     107     * @return true if it is a true value.
     108     */
    52109    public static boolean isFalse(String value) {
    53110        return FALSE_VALUES.contains(value);
Note: See TracChangeset for help on using the changeset viewer.