Ignore:
Timestamp:
2014-01-16T02:42:49+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9547 - Remove multiple whitespaces inside values

File:
1 edited

Legend:

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

    r6513 r6699  
    33
    44import org.openstreetmap.josm.tools.CheckParameterUtil;
     5import org.openstreetmap.josm.tools.Utils;
    56
    67/**
     
    1718     * Create an empty tag whose key and value are empty.
    1819     */
    19     public Tag(){
     20    public Tag() {
    2021        this("", "");
    2122    }
     
    119120        return key + "=" + value;
    120121    }
     122
     123    /**
     124     * Removes leading, trailing, and multiple inner whitespaces from the given string, to be used as a key or value.
     125     * @param s The string
     126     * @return The string without leading, trailing or multiple inner whitespaces
     127     * @since 6699
     128     */
     129    public static String removeWhiteSpaces(String s) {
     130        if (s == null || s.isEmpty()) {
     131            return s;
     132        }
     133        return Utils.strip(s).replaceAll("\\s+", " ");
     134    }
    121135}
Note: See TracChangeset for help on using the changeset viewer.