List of utility methods to do String Abbreviate
String | abbreviateLeft(String s, int width) Abbreviates a String using ellipses inserted at left. int length = s.length(); if (length > width) { if (width < 4) { throw new IllegalArgumentException("Minimal width is 4"); return "..." + s.substring(length - (width - 3)); return s; ... |
String | abbreviateMessage(String messageBody) abbreviate Message Integer start; Integer end; StringBuffer cutBody = new StringBuffer(""); while (messageBody.contains("<blockquote>") && messageBody.contains("</blockquote>")) { start = messageBody.indexOf("<blockquote>"); end = messageBody.indexOf("</blockquote>"); cutBody.append(messageBody.substring(0, start)); cutBody.append(messageBody.substring(end + 13, messageBody.length())); ... |
String | abbreviateMiddle(String str, String middle, int length) Abbreviates a String to the length passed, replacing the middle characters with the supplied replacement String.
This abbreviation only occurs if the following criteria is met:
if (isEmpty(str) || isEmpty(middle)) { return str; if (length >= str.length() || length < (middle.length() + 2)) { return str; int targetSting = length - middle.length(); int startOffset = targetSting / 2 + targetSting % 2; ... |
String | abbreviateMiddle(String string, int maxLength) abbreviate Middle if (string == null || maxLength >= string.length()) { return string; final int targetSting = maxLength - ELLIPSIS.length(); final int startOffset = targetSting / 2 + targetSting % 2; final int endOffset = string.length() - targetSting / 2; return string.substring(0, startOffset) + ELLIPSIS + string.substring(endOffset); |
Object | abbreviateObj(Object value, int maxWidth) abbreviate Obj return (value != null) ? abbreviate(value.toString(), maxWidth) : null;
|
String | abbreviateScript(String script) Abbreviates this script to a length that will fit in the database. if (script == null) { return null; if (script.length() <= 1000) { return script; return "..." + script.substring(3, 1000); |
String | abbreviateText(final String text, final int numberOfCharacters, final String appendText) Abbreviate a text to _approximately_ some number of characters, trying to find a nice word end and then appending some string (defaulting to three dots). int nrChars = numberOfCharacters; if (nrChars > 0 && text != null && text.length() > nrChars) { int spaceIndex = text.lastIndexOf(' ', nrChars); int dotIndex = text.lastIndexOf('.', nrChars); int commaIndex = text.lastIndexOf(',', nrChars); int questionIndex = text.lastIndexOf('?', nrChars); int exclamationIndex = text.lastIndexOf('!', nrChars); nrChars = spaceIndex; ... |
String | abbreviateText(String text, int maxLength) Abbreviates a long string using ellipsis. return (text != null && text.length() > maxLength) ? text.substring(0, maxLength) + "..." : text; |
String | abbreviation(String description) Given a string description , returns description if its length is no greater than 10, or description + "..."
return "\"" + description.substring(0, Math.min(10, description.length())) + (description.length() > 10 ? "(...)" : "") + "\""; |
String | abbreviationtoLetter(String mutation) abbreviationto Letter return mutation.replaceAll("Ala", "A").replaceAll("Cys", "C").replaceAll("Glu", "E").replaceAll("Phe", "F") .replaceAll("Gly", "G").replaceAll("His", "H").replaceAll("Ile", "I").replaceAll("Lys", "K") .replaceAll("Leu", "L").replaceAll("Met", "M").replaceAll("Asn", "N").replaceAll("Hyp", "O") .replaceAll("Pro", "P").replaceAll("Gln", "Q").replaceAll("Arg", "R").replaceAll("Ser", "S") .replaceAll("Thr", "T").replaceAll("Glp", "U").replaceAll("Val", "V").replaceAll("Trp", "W") .replaceAll("Ter", "X").replaceAll("Tyr", "Y"); |