Ignore:
Timestamp:
2015-09-13T22:45:59+02:00 (11 years ago)
Author:
simon04
Message:

fix #10023 - Add history of Overpass queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8734 r8756  
    646646
    647647    /**
     648     * Replaces some HTML reserved characters (<, > and &) by their equivalent entity (<, > and &);
     649     * @param s The unescaped string
     650     * @return The escaped string
     651     */
     652    public static String escapeReservedCharactersHTML(String s) {
     653        return s == null ? "" : s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
     654    }
     655
     656    /**
    648657     * Represents a function that can be applied to objects of {@code A} and
    649658     * returns objects of {@code B}.
     
    11841193        } else {
    11851194            return s;
     1195        }
     1196    }
     1197
     1198    /**
     1199     * If the string {@code s} is longer than {@code maxLines} lines, the string is cut and a "..." line is appended.
     1200     * @param s String to shorten
     1201     * @param maxLines maximum number of lines to keep (including including the "..." line)
     1202     * @return the shortened string
     1203     */
     1204    public static String restrictStringLines(String s, int maxLines) {
     1205        if (s == null) {
     1206            return null;
     1207        } else {
     1208            final List<String> lines = Arrays.asList(s.split("\\n"));
     1209            if (lines.size() > maxLines) {
     1210                return join("\n", lines.subList(0, maxLines - 1)) + "\n" + "...";
     1211            } else {
     1212                return s;
     1213            }
    11861214        }
    11871215    }
Note: See TracChangeset for help on using the changeset viewer.