geoportal-data-viewer-app/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java

32 lines
697 B
Java
Raw Normal View History

2020-11-19 15:19:27 +01:00
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
/**
* The Class StringUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
*/
public class StringUtil {
/**
* Ellipsize.
*
2020-11-20 18:10:43 +01:00
* @param input the input string that may be subjected to shortening
* @param maxCharacters the maximum characters that must be returned for the input string
2020-11-19 15:19:27 +01:00
* @return the string
* @throws Exception the exception
*/
2020-11-20 18:10:43 +01:00
public static String ellipsize(String input, int maxCharacters) {
2020-11-19 15:19:27 +01:00
if (input == null || input.length() < maxCharacters) {
return input;
}
return input.substring(0, maxCharacters)+"...";
}
}