Java Utililty Methods String Substritute

List of utility methods to do String Substritute

Description

The list of methods to do String Substritute are organized into topic(s).

Method

voidsubstituteToken(StringBuffer buf, String token, String value)
substitute Token
String from = getTokenString(token);
int fromLength = from.length();
for (int index = buf.indexOf(from); index != -1; index = buf.indexOf(from, index)) {
    buf.replace(index, index + fromLength, value);
StringsubstituteUserId(final long aUserId, final String aTemplate)
substitute User Id
return aTemplate.replace("@{userId}", Long.toString(aUserId));
StringsubstituteVars(String text, char[] names, Object[] values)
Equivalent to #substituteVars(String,char[],Object[],String[],String,boolean) substituteVars(text, names, values, null, null, false) .
return substituteVars(text, names, values, null, null, false);
StringsubstituteWhenEmpty(Object value, String valueWhenEmpty)
Similar to #nvl(Object,String) but returns valueWhenEmpty not only if value is null, but as well when the String representation of value is empty or contains only whitespaces.
String stringValue = nvl(value, null);
return hasText(stringValue) ? stringValue : valueWhenEmpty;