41 lines
1.0 KiB
Java
41 lines
1.0 KiB
Java
package org.gcube.portlets.widgets.wsthreddssync.client.view;
|
|
|
|
// TODO: Auto-generated Javadoc
|
|
/**
|
|
* The Class FormatUtil.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* Feb 16, 2018
|
|
*/
|
|
public class FormatUtil {
|
|
|
|
|
|
/**
|
|
* Truncate a string and add an ellipsis ('...') to the end if it exceeds the
|
|
* specified length.
|
|
*
|
|
* @param value the string to truncate
|
|
* @param len the maximum length to allow before truncating
|
|
* @return the converted text
|
|
*/
|
|
public static String ellipse(String value, int len) {
|
|
if (value != null && value.length() > len) {
|
|
return value.substring(0, len - 3) + "...";
|
|
}
|
|
return value;
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the folder title.
|
|
*
|
|
* @param folderName the folder name
|
|
* @param maxSize the max size
|
|
* @return the folder title
|
|
*/
|
|
public static String getFolderTitle(String folderName, int maxSize){
|
|
String title = folderName!=null&&folderName.length()>0?folderName:"";
|
|
return FormatUtil.ellipse(title, maxSize);
|
|
}
|
|
}
|