Java Utililty Methods Object to String

List of utility methods to do Object to String

Description

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

Method

StringcastString(Object o)
cast String
return String.valueOf(o);
StringcastString(Object obj)
cast String
return castString(obj, "");
StringcastString(Object obj, String defaultValue)
cast String
return obj != null ? String.valueOf(obj) : defaultValue;
StringcastString(Object val)
cast String
try {
    return val != null ? val.toString() : "null";
} catch (Exception e) {
    return "<ERR: " + e.getMessage() + ">";
StringcastToString(Object inValue)
cast To String
return cast(inValue, (String) null);
StringcastToString(Object object)
Sometimes ELP's version of cast is misbehaving
return object == null ? null : object.toString();
StringcastToString(Object value)
cast To String
if (value == null) {
    return null;
return value.toString();
String[]castToStringArray(Object[] array)
EPL has embedded cast method, but it doesn't cover arrays
if (array != null) {
    String[] retArray = new String[array.length];
    int i = 0;
    for (Object element : array) {
        retArray[i] = element == null ? null : element.toString();
        i++;
    return retArray;
...
StringobjectToString(final Object value)
For Visual Studio compatibility.
if (value instanceof Double) {
    return doubleToString((Double) value);
} else {
    return value.toString();
StringobjectToString(Object a_Object)
Makes object to string if it is null then empty string "" is returned
Advantage of this is that it is handling nulls correctly
if (a_Object != null) {
    return a_Object.toString();
} else {
    return "";