Changeset 8756 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2015-09-13T22:45:59+02:00 (11 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/tools/Utils.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r8734 r8756 646 646 647 647 /** 648 * Replaces some HTML reserved characters (<, > and &) by their equivalent entity (&lt;, &gt; and &amp;); 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("&", "&").replace("<", "<").replace(">", ">"); 654 } 655 656 /** 648 657 * Represents a function that can be applied to objects of {@code A} and 649 658 * returns objects of {@code B}. … … 1184 1193 } else { 1185 1194 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 } 1186 1214 } 1187 1215 }
Note:
See TracChangeset
for help on using the changeset viewer.
