List of utility methods to do String Truncate
String | truncateByCharLength(String string, int maxLength) truncate By Char Length return string.length() > maxLength ? string.substring(0, maxLength) : string;
|
String | truncateByCharLengthWithEllipsis(String string, int maxLength) truncate By Char Length With Ellipsis return string.length() <= maxLength ? string : truncateByCharLength(string, maxLength - 3) + "..."; |
String | truncateCellValue(String x, int maxChars) truncate Cell Value if (x.length() > maxChars) { return x.substring(0, Math.max(3, maxChars)) + " ..."; } else { return x; |
String | truncateCodeStringIfNeeded(String codeString) truncate Code String If Needed if (codeString != null && codeString.length() > CODE_LENGTH) { return codeString.substring(0, CODE_LENGTH); } else { return codeString; |
String | truncateData(String data, int idLength) truncate Data String truncateData = data; if (data != null && data.length() > idLength) { truncateData = data.substring(0, (idLength - 1)); return truncateData; |
String | truncateDatabaseName(String db) truncate Database Name if (db.length() <= 27) { return db; int underscoreIndex = db.indexOf("_"); String genusLetter = db.substring(0, 1); String result = genusLetter + "_" + db.substring(underscoreIndex + 1); if (result.length() > 27) { result = result.replaceAll("otherfeatures", "other..."); ... |
String | truncatedStr(String s, int maxLength) Truncates s string if it is longer than maxLength . if (s.length() <= maxLength) return s; else return s.substring(0, maxLength); |
String | truncateExtension(String name) Truncates the extension of the file name. return name.lastIndexOf('.') == -1 ? name : name.substring(0, name.lastIndexOf('.')); |
String | truncateFileName(String agent, String s) Used for parsing uploaded file names. if (agent == null) { return s; } else { if (agent.contains("MSIE")) { if (s.contains("\\")) { int pos = s.lastIndexOf("\\"); return s.substring(pos + 1); } else { ... |
String | truncateFileType(String p) truncate File Type int indexOfPeriod = p.lastIndexOf("."); if (indexOfPeriod < 0) return p; else { return p.substring(0, indexOfPeriod); |