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

/**
 * Change something to string/*  w ww .  j av  a2 s  .co m*/
 * @param obj
 * @return
 */
public static String str(Object obj) {
    return obj == null ? null : obj.toString();
}

From source file:Main.java

public static String getDebugInfo() {
    Object v = get("DEBUG");
    return v == null ? null : v.toString();
}

From source file:Main.java

public static boolean isFieldValid(Object field) {
    if (field != null) {
        if (!field.toString().equals("") && !field.toString().equals("null")) {
            return true;
        }//  ww  w  .  j  a v a2  s.  c om
    }

    return false;
}

From source file:Main.java

/**
 * @author DUYPT/*  w ww.jav a 2  s.  c o  m*/
 * @param data
 * @return
 */
public static String toString(Object data) {
    if (data != null) {
        return data.toString();
    }
    return null;
}

From source file:Main.java

public static int getFormatDoubleIntValye(Object o) {
    try {//from w w w  .  j a v  a  2 s.co m
        double v = (o != null && !o.toString().equals("")) ? Double.parseDouble(o.toString()) : 0;
        return (int) v;
    } catch (Exception ex) {
        return 0;
    }
}

From source file:Main.java

public static String appendWithSeparator(final Collection<?> items, final String sep,
        final boolean separatorAtEnd) {
    StringBuilder sb = new StringBuilder();
    for (Object o : items) {
        sb.append(o.toString());
        sb.append(sep);/*from   ww w . j  a v  a2 s  . c  o m*/
    }
    if (sb.length() > 0 && !separatorAtEnd) {
        sb.delete(sb.length() - sep.length(), sb.length());
    }
    return sb.toString();
}

From source file:Main.java

public static Integer parseInt(Object value) {
    return parseInt(value.toString(), 0);
}

From source file:Main.java

/**
 * //w w w  .ja  v  a2 s.  co m
 * @param lista
 * @return 
 */
public static AbstractListModel initListModel(List lista) {
    DefaultListModel<String> model = new DefaultListModel<>();

    for (Object item : lista) {
        model.addElement(item.toString());
    }

    return model;
}

From source file:edu.stanford.muse.util.VizUtils.java

public static String getGroups(JSONObject data) {
    try {//from  ww w . j  a  v a2 s .  co  m
        Object groups = data.get("groups");
        return groups.toString();
    } catch (JSONException e) {
        System.out.println(e.getStackTrace());
        return "null";
    }
}

From source file:Main.java

public static long doLong(Object obj, long defValue) {
    return obj != null ? Long.parseLong(obj.toString()) : defValue;
}