Example usage for java.lang Object toString

List of usage examples for java.lang Object toString

Introduction

In this page you can find the example usage for java.lang Object toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:Main.java

public static String toString(Object object) {
    if (object == null) {
        return "null";
    }//  w ww. j  a v a2s . co  m
    return object.toString();
}

From source file:Main.java

/**
 * Converts collection to a string array by calling toString on each member.
 *
 * @param collection collection to convert
 * @return string array/*from   ww  w .jav  a2  s  .  c om*/
 */
public static String[] toStringArray(Collection collection) {
    String[] stringArray = new String[collection.size()];

    int i = 0;
    for (Object string : collection) {
        stringArray[i++] = string.toString();
    }

    return stringArray;
}

From source file:Main.java

public static String parseString(Context context, Object obj) {
    if (obj != null) {
        if (obj instanceof String) {
            return obj.toString();
        } else if (obj instanceof Integer) {
            return context.getString((Integer) obj);
        }//from w  ww.ja v  a2s  . co  m
    }
    return null;
}

From source file:com.threewks.thundr.view.jsp.el.StringFunctions.java

public static String capitalise(Object arg) {
    return arg == null ? null : WordUtils.capitalizeFully(arg.toString());
}

From source file:kilim.analysis.Utils.java

public static void pn(Object o) {
    pn((o == null) ? "null" : o.toString());
}

From source file:Main.java

public static String toString(Object obj) {
    if (null == obj) {
        return "";
    }//  w  w w  .  java2  s. c o  m

    return obj.toString();
}

From source file:com.thoughtworks.go.i18n.LocalizedKeyValueMessage.java

private static String makeKey(Object key) {
    return key.toString().toUpperCase().replace(" ", "_");
}

From source file:de.arraying.arraybot.util.UFormatting.java

/**
 * Formats an Object array to list.// w ww  . j  a va2 s .c om
 * This will not append anything called "UNKNOWN".
 * @param input The array to format.
 * @return A formatted list.
 */
public static String formatToList(Object[] input) {
    StringBuilder builder = new StringBuilder();
    for (Object object : input) {
        if (object.toString().equals("UNKNOWN")) {
            continue;
        }
        builder.append(UFormatting.displayableEnumField(object)).append(", ");
    }
    String value = builder.toString().trim();
    if (!value.isEmpty()) {
        value = value.substring(0, value.length() - 1);
    }
    return value;
}

From source file:de.arraying.arraybot.util.UFormatting.java

/**
 * Makes an enum field displayable.//from w ww  . java2  s .com
 * @param field The field.
 * @return A displayable string.
 */
public static String displayableEnumField(Object field) {
    return WordUtils.capitalize(field.toString().toLowerCase()).replace("_", "");
}

From source file:Main.java

public static String isNullToString(Object object) {
    String string = "";

    if (object != null) {
        string = object.toString().trim();
    }/*from  w w  w  .  jav a2 s .  c om*/

    return string;
}