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:com.github.consiliens.harv.run.test.util.CreateTest.java

public static void a(Object value, String code) {
    p("a(" + value.toString() + ", " + code + ");");
}

From source file:Main.java

/**
 * Returns the string representation of the object, or null if the object is
 * null./* w ww.  jav  a  2  s  .  co  m*/
 *
 * @param object the object.
 * @return the string representation.
 */
public static String toString(Object object) {
    return object != null ? object.toString() : null;
}

From source file:Main.java

public static HashMap<String, List<Object[]>> getUnitDataMap(List<Object[]> list, int index) {
    HashMap<String, List<Object[]>> dataMap = new HashMap<String, List<Object[]>>();
    for (int i = 0; i < list.size(); i++) {
        Object obj = list.get(i)[index];
        String unit = obj.toString();

        if (dataMap.containsKey(unit)) {
            dataMap.get(unit).add((Object[]) list.get(i));
        } else {/*w  ww  . java 2 s. c  o  m*/
            ArrayList<Object[]> rowdata = new ArrayList<Object[]>();
            rowdata.add((Object[]) list.get(i));
            dataMap.put(unit, rowdata);
        }
    }

    return dataMap;
}

From source file:org.tsm.concharto.web.util.ValidationHelper.java

public static void rejectIfTooLong(Errors errors, String field, int maxLength, String errorCode,
        Object[] errorArgs, String defaultMessage) {
    Object value = errors.getFieldValue(field);

    if (value.toString().length() > maxLength) {
        errors.rejectValue(field, errorCode, errorArgs, defaultMessage);
    }/*  w w w .  j  ava2 s. c  o m*/

}

From source file:Main.java

public final static int convertToInt(Object value, int defaultValue) {
    if (value == null || "".equals(value.toString().trim())) {
        return defaultValue;
    }//  ww  w. ja va  2  s . c  o m
    try {
        return Integer.valueOf(value.toString());
    } catch (Exception e) {
        try {
            return Double.valueOf(value.toString()).intValue();
        } catch (Exception e1) {
            return defaultValue;
        }
    }
}

From source file:Main.java

public static String nvl(Object o) {
    if (o == null)
        return "";
    return o.toString();
}

From source file:Main.java

private static String appendStrs(Object... msgs) {
    if (null == msgs) {
        return "";
    }//from  w w  w  .  ja v a2  s . c o  m
    StringBuilder str = new StringBuilder();
    for (Object msg : msgs) {
        if (null != msg) {
            str.append(msg.toString());
        }
    }
    return str.toString();
}

From source file:Main.java

public static boolean num(Object o) {
    int n = 0;/*from  w w  w.  ja v  a2 s.  c  o m*/
    try {
        n = Integer.parseInt(o.toString().trim());
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    if (n > 0) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

public static void addAttribute(Element parent, Object name, Object value) {
    if (value == null) {
        parent.setAttribute(name.toString(), "");
    } else {/*  w  w  w .  j  ava  2 s.c o m*/
        parent.setAttribute(name.toString(), value.toString());
    }
}

From source file:Main.java

/** Returns an alphabetically sorted copy of vector. */
public static void sortListAlphabetically(List list) {
    Collections.sort(list, new Comparator() {
        public int compare(Object a, Object b) {
            String textA = a.toString();
            String textB = b.toString();

            return textA.compareToIgnoreCase(textB);
        }//w w w. j  a  va 2s . co  m
    });
}