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 toStringCollection(Collection list, String sep) {
    StringBuilder sb = new StringBuilder();
    for (Object s : list) {
        sb.append(s.toString());
        sb.append(sep);//from w  ww.  j a va  2  s. c  o  m
    }
    return sb.toString();
}

From source file:Main.java

/**
 * Returns 'true' if the pattern matches the src
 *///  w  w w.j a  va  2s.  c o m
public static String countryMatch(Object src, Object pattern) {
    if (src.toString().trim().length() == 0) {
        return "false";
    }
    boolean result = src.toString().toLowerCase().contains(pattern.toString().toLowerCase());
    return String.valueOf(result);
}

From source file:Main.java

public static List<String> toStrings(Collection<?> c) {
    List<String> result = new ArrayList<String>(c.size());
    for (Object e : c) {
        result.add(e.toString());
    }/*w w  w  .  ja  v  a 2 s  .  co  m*/
    return result;
}

From source file:Main.java

public static final boolean objectToBoolean(Object o) {
    return o != null ? Boolean.valueOf(o.toString()).booleanValue() : false;
}

From source file:Main.java

public static List<String> asStringList(List<Object> list) {
    List<String> newList = Lists.transform(list, new Function<Object, String>() {
        @Override//from   ww w .  j  ava  2 s  .  co  m
        public String apply(Object input) {
            return input.toString();
        }
    });
    return newList;
}

From source file:Main.java

public static boolean isEmpty(Object obj) {

    return null == obj || "".equals(obj.toString().trim()) || "null".equals(obj.toString().trim());
}

From source file:Main.java

static void out(Object s) {
    android.util.Log.d("", s.toString());
}

From source file:Main.java

public static String getSetAsDelimitedString(Set<?> list, String delimiter) {
    String r = "";

    for (Object o : list)
        r += delimiter + o.toString();

    return r.replaceFirst(delimiter, "");
}

From source file:Main.java

/**
 * get minimum length of contained objects toString()
 *
 * @param c list of objects//  w  w  w  . jav  a 2s.  c o  m
 * @return the minimum length
 */
public static int getStringLengthMin(Collection<?> c) {
    int min = 0;
    int len;
    for (Object o : c) {
        len = o.toString().length();
        if (len < min) {
            min = len;
        }
    }
    return min;
}

From source file:Main.java

/**
 * Safely converts an object into string (used because sometimes
 * JSONObject's get() method returns null).
 *
 * @param obj/*from w w w  .j av a 2 s  . c  o m*/
 *            The object to convert.
 * @return The string.
 */
public static String safeJsonToString(Object obj) {
    return (obj == null ? null : obj.toString());
}