List of utility methods to do String Abbreviate
String | abbr(String str, int length) abbr if (str == null) { return ""; try { StringBuilder sb = new StringBuilder(); int currentLength = 0; for (char c : str.toCharArray()) { currentLength += String.valueOf(c).getBytes("GBK").length; ... |
String | abbrev(String longString, int size) Returns the first size characters of the given string. return longString.length() <= size ? longString : longString.substring(0, size);
|
String | abbrev(String result, int maxLength, String separator) Make sure a string stays within a certain length, by cutting a bit from the middle. int mid = maxLength / 2; if (result.length() > maxLength) result = result.substring(0, mid - 1) + separator + result.substring(result.length() - mid); return result; |
String | abbreviate(final String str) abbreviate return abbreviate(str, DEFAULT_ABBREVIATE_MAX_WIDTH);
|
String | abbreviate(final String str, final int maxWidth) abbreviate return str != null && str.length() > maxWidth ? str.substring(0, maxWidth - 3) + "..." : str; |
String | abbreviate(final String str, int lower, int upper, final String appendToEnd) see WordUtils#abbreviate. if (str == null) { return null; if (str.length() == 0) { return ""; if (lower > str.length()) { lower = str.length(); ... |
String | abbreviate(final String value, final int maxLength) abbreviate assert maxLength > 4; if (value.length() > maxLength) { return value.substring(0, maxLength - 3) + "..."; } else { return value; |
String | abbreviate(final String value, int max) Abbreviates the given value to max characters (if necessary). If the value is abbreviated, the result ends with " ... if (value == null) { return null; if (max < 0) { max = 0; return value.length() > max ? value.substring(0, max) + "..." : value; |
String | abbreviate(String _str, int _length) Abbreviates a String using ellipses. if (_str == null) { return null; if (_str.length() <= _length) { return _str; String abbr = _str.substring(0, _length - 3) + "..."; return abbr; ... |
String | abbreviate(String content, int maxWidth, String enc, String suffix) abbreviate if (content == null) return ""; if (maxWidth < suffix.length()) throw new IllegalArgumentException(); int ptr = maxWidth - suffix.length(); String str = null; try { byte bytes[] = content.getBytes(enc); ... |