Package com.adobe.acs.commons.util
Class TextUtil
java.lang.Object
com.adobe.acs.commons.util.TextUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFirstNonEmpty(String... values) Returns the first non-null and non-empty String from the parameter list of strings.static <T> TgetFirstNonNull(T... values) Returns first non-null value from the parameter liststatic <T> TgetFirstProperty(org.apache.sling.api.resource.Resource resource, Class<T> klass, String... keys) Returns first non-null value from the resource property.static <T> TgetFirstProperty(org.apache.sling.api.resource.ValueMap valueMap, Class<T> klass, String... keys) Returns first non-null value from the resource property value map.static booleanisRichText(String str) Looks for <..> substrings in the parameter string.
-
Method Details
-
getFirstNonNull
public static <T> T getFirstNonNull(T... values) Returns first non-null value from the parameter listEx. TextUtil.getFirstNonNull(x.getLastModifiedDate(), x.getCreatedDate())
If getLastModifiedDate() returns null, and getCreatedDate() returns not-null, the value for getCreatedDate() is returned.
- Type Parameters:
T-- Parameters:
values-- Returns:
-
getFirstNonEmpty
Returns the first non-null and non-empty String from the parameter list of strings.Ex. TextUtil.getFirstNonEmpty(x.getPageTitle(), x.getNavigationTitle(), x.getTitle(), x.getName())
- Parameters:
values-- Returns:
-
getFirstProperty
public static <T> T getFirstProperty(org.apache.sling.api.resource.Resource resource, Class<T> klass, String... keys) Returns first non-null value from the resource property.- Type Parameters:
T-- Parameters:
resource-klass-keys-- Returns:
-
getFirstProperty
public static <T> T getFirstProperty(org.apache.sling.api.resource.ValueMap valueMap, Class<T> klass, String... keys) Returns first non-null value from the resource property value map.Ex. TextUtil.getFirstProperty(Date.class, "jcr:lastModified", "jcr:created")
If getLastModifiedDate() returns null, and getCreatedDate() returns not-null, the value for getCreatedDate() is returned.
- Type Parameters:
T-- Parameters:
valueMap- of resource propertiesklass- data type to returnkeys- list of property names to evaluate- Returns:
-
isRichText
Looks for <..> substrings in the parameter string. If any are found it assume Rich text.- Parameters:
str-- Returns:
-