import org.apache.commons.lang.StringUtils;
StringUtils.abbreviate(str, maxLength);
Showing posts with label apache commons. Show all posts
Showing posts with label apache commons. Show all posts
Truncate a string and add ellipsis as necessary.
The beanutils package contains a very useful class, PropertyUtils, that you can use to access member values. So in the code below if request was an HTTP request object and the propertyPath was 'request.attribute(myBean).myBeanValue'. The PropertyUtils class would obtain the myBean object from the request attribute map and then call its getter method for the myBeanValue member.
import org.apache.common.beanutils.PropertyUtils
Object obj = PropertyUtils.getNestedProperty(request, propertyPath)
Subscribe to:
Posts (Atom)