List of utility methods to do String Ellipse
String | ellipsisString(String text, int ellipsisAt) ellipsis String if (text.length() > ellipsisAt) { return text.substring(0, ellipsisAt) + "..."; } else { return text; |
String | ellipsisText(String text, int maxLength) ellipsis Text return text.length() <= maxLength ? text : text.substring(0, maxLength - 3) + "..."; |
String | ellipsize(String input, int maxLength) ellipsize String ellip = "..."; if (input == null || input.length() <= maxLength || input.length() < ellip.length()) { return input; return input.substring(0, maxLength - ellip.length()).concat(ellip); |
String | ellipsize(String s, int maxChars) ellipsize if (s == null) return null; if (maxChars < 4) return (s.substring(0, maxChars)); if (s.length() > maxChars) return s.substring(0, maxChars - 3) + "..."; else return s; ... |
String | ellipsize(String string, int length) Ellipsize a string, keeping it readable String ellipsis = "..."; if (length >= string.length()) { return string; int trim = length - ellipsis.length(); return string.substring(0, trim / 2) + ellipsis + string.substring(string.length() - trim / 2); |
String | ellipsize(String text, int max) ellipsize return cut(text, max, "...", false); |
String | ellipsize(String text, int max) From StackOverflow if (textWidth(text) <= max) return text; int end = text.lastIndexOf(' ', max - 3); if (end == -1) return text.substring(0, max - 3) + "..."; int newEnd = end; do { end = newEnd; ... |
String | ellipsize(String text, int maxLength) Cuts the string at the end if it's longer than maxLength and appends "..." if (text != null && text.length() > maxLength) { return text.substring(0, maxLength - 3) + "..."; return text; |
String | ellipsizeKeepingExtension(String s, int maxChars) converts a very long name.doc -> a very lon...g.doc. if (s.length() <= maxChars) return s; int idx = s.lastIndexOf("."); if (idx <= 0) return ellipsize(s, maxChars); int MAX_EXTENSION_LENGTH = 6; if (s.length() - idx > MAX_EXTENSION_LENGTH) return ellipsize(s, maxChars); ... |