Changeset 12187 in josm for trunk


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

Add javadoc to OsmUtils, fix constant naming.

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java

    r11069 r12187  
    142142            if (key.startsWith("oneway") || key.endsWith("oneway")) {
    143143                if (OsmUtils.isReversed(value)) {
    144                     newValue = OsmUtils.trueval;
     144                    newValue = OsmUtils.TRUE_VALUE;
    145145                } else if (OsmUtils.isTrue(value)) {
    146                     newValue = OsmUtils.reverseval;
     146                    newValue = OsmUtils.REVERSE_VALUE;
    147147                }
    148148                newKey = COMBINED_SWITCHERS.apply(key);
     
    264264    static Map<OsmPrimitive, List<TagCorrection>> getTagCorrectionsMap(Way way) {
    265265        Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = new HashMap<>();
    266         List<TagCorrection> tagCorrections = getTagCorrections((Tagged) way);
     266        List<TagCorrection> tagCorrections = getTagCorrections(way);
    267267        if (!tagCorrections.isEmpty()) {
    268268            tagCorrectionsMap.put(way, tagCorrections);
  • 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);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r12042 r12187  
    762762                    } else if ("BOOLEAN_TRUE".equals(n)) {
    763763                        valueBool = true;
    764                         value = OsmUtils.trueval;
     764                        value = OsmUtils.TRUE_VALUE;
    765765                    } else if ("BOOLEAN_FALSE".equals(n)) {
    766766                        valueBool = true;
    767                         value = OsmUtils.falseval;
     767                        value = OsmUtils.FALSE_VALUE;
    768768                    } else {
    769769                        value = n.startsWith("/") ? getPattern(n) : n;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java

    r11452 r12187  
    2323    public String locale_text; // NOSONAR
    2424    /** the value to set when checked (default is "yes") */
    25     public String value_on = OsmUtils.trueval; // NOSONAR
     25    public String value_on = OsmUtils.TRUE_VALUE; // NOSONAR
    2626    /** the value to set when unchecked (default is "no") */
    27     public String value_off = OsmUtils.falseval; // NOSONAR
     27    public String value_off = OsmUtils.FALSE_VALUE; // NOSONAR
    2828    /** whether the off value is disabled in the dialog, i.e., only unset or yes are provided */
    2929    public boolean disable_off; // NOSONAR
Note: See TracChangeset for help on using the changeset viewer.