List of utility methods to do String Shorten
String | shortenMiddle(String msg, int maxLen) Inserts "..." if (msg.length() <= maxLen) return msg; int half = (maxLen - 3) / 2; return msg.substring(0, half) + "..." + msg.substring(msg.length() - half); |
String | shortenName(final String fullName) shorten Name String result; if (fullName.isEmpty()) { result = ""; } else { result = removePrefix(fullName); result = cleanSuffix(result); return result; ... |
String | shortenName(final String name, final int toBeAdded) shorten Name if (name == null) return ""; final int symbols = Math.max(10, 20 - toBeAdded); if (name.length() < symbols) return name; else return name.substring(0, symbols) + "..."; |
String | shortenName(String name) shorten Name int i = name.lastIndexOf('.'); if (i >= 0 && i <= name.length() - 1) { name = name.substring(i + 1); return name; |
String | shortenOperationName(String operation) Shortens full qualified method names. String mainPart = operation.substring(0, operation.indexOf("(")); String[] packages = mainPart.split("\\."); String result = ""; for (int i = 0; i < packages.length - 2; i++) { result += packages[i].substring(0, 1); result += "."; result += packages[packages.length - 2] + "." + packages[packages.length - 1]; ... |
String | shortenPackageName(String name, boolean remove) Shortens package part of the name of a class. final String[] comp = name.split("\\."); final int last = comp.length - 1; if (remove) { return comp[last]; final StringBuilder s = new StringBuilder(); for (int i = 0; i < last; i++) { s.append(comp[i].substring(0, 1)).append("."); ... |
char | shortenPart(String currentPart) shorten Part return currentPart.charAt(0);
|
String | shortenPath(final String path) Shortens the path to a maximum of 4 path elements. return shortenPath(path, DEFAULT_SHORTENER_THRESHOLD);
|
String | shortenPrefix(String prefix) shorten Prefix String result = null; int idx = prefix.lastIndexOf('/'); if (idx > 0) { result = prefix.substring(0, idx); return result; |
String | shortenRemoteRef(final String origin, final String ref) Cut the origin part off a remote ref. if (!ref.startsWith(origin + "/")) { return ref; return ref.substring(origin.length() + 1); |