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:ch.oakmountain.tpa.web.TpaWebPersistor.java

private static void writeMatrix(File file, IMatrix matrix) throws Exception {
    String intro = "{\"nodes\":[{}";
    String middle = "],\"links\":[{}";
    String end = "]}";
    FileUtils.writeStringToFile(file, intro, false);
    for (Object node : matrix.getNodes()) {
        String s = ",{\"name\":\"" + node.toString() + "\",\"group\":1}";
        FileUtils.writeStringToFile(file, s, true);
    }/*from   w  w  w.j  a  va 2  s.  c o  m*/
    FileUtils.writeStringToFile(file, middle, true);
    TpaWebPersistor persistor = new TpaWebPersistor(file);
    matrix.getEdges(persistor);
    FileUtils.writeStringToFile(file, end, true);

}

From source file:com.cubeia.backoffice.report.RequestBean.java

public static RequestBean parse(HttpServletRequest req) {
    /*//from   www.  j  av a  2 s .c o m
     * Trim the path (which becomes the report name)
     */
    String path = trim(req.getPathInfo());
    /*
     * check the format and do default if needed
     */
    String form = req.getParameter("format");
    if (form == null) {
        form = Format.CSV.name();
    }
    /*
     * Convert parameter map to a simple string-string map
     */
    @SuppressWarnings("rawtypes")
    Map params = req.getParameterMap();
    Map<String, String> tmp = new HashMap<String, String>(params.size());
    for (Object key : params.keySet()) {
        tmp.put(key.toString(), req.getParameter(key.toString()));
    }
    /*
     * Continue parsing
     */
    return parse(path, tmp, form);
}

From source file:eu.annocultor.analyzers.SolrPropertyHitsAnalyzer.java

static Collection<String> split(Object fieldValue) {
    List<String> words = new ArrayList<String>();
    for (String word : fieldValue.toString().split("[\\W]+")) {
        if (isLongEnoughToCount(word)) {
            words.add(word);//w  ww  .j  av a 2  s .  c o m
        }
    }
    return words;
}

From source file:Main.java

/**
 * Join objects using toString()//  ww w.j av a  2 s . c  om
 *
 * @param delimiter
 *            the delimiter
 * @param objects
 *            the objects
 * @return the string
 */
public static String joinObjects(String delimiter, Iterable<?> objects) {
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (Object object : objects) {
        if (first) {
            first = false;
        } else {
            sb.append(delimiter);
        }
        sb.append(object.toString());
    }
    return sb.toString();
}

From source file:Main.java

private static void toXMLCycle(Object element, StringBuffer xml, StringBuffer space) {
    if (element instanceof Map) {
        Map map = (Map) element;

        xml.append(space);/*from w  w w  . j a  va 2s.c  o  m*/
        xml.append("<dict>\r\n");
        space.append("  ");
        for (Object key : map.keySet()) {
            xml.append(space);
            xml.append("<key>");
            xml.append(key.toString());
            xml.append("</key>\r\n");

            Object value = map.get(key);
            toXMLCycle(value, xml, space);
        }

        space.delete(0, 2);
        xml.append(space);
        xml.append("</dict>\r\n");

    } else if (element instanceof List) {
        xml.append(space);
        xml.append("<array>\r\n");
        space.append("  ");

        List list = (List) element;
        for (Object item : list) {
            toXMLCycle(item, xml, space);
        }

        space.delete(0, 2);
        xml.append(space);
        xml.append("</array>\r\n");

    } else {
        xml.append(space);
        xml.append("<string>");
        xml.append(element.toString());
        xml.append("</string>\r\n");
    }
}

From source file:com.icesoft.faces.utils.MessageUtils.java

private static boolean nullOrEmptyString(Object ob) {
    return ((ob == null) || ((ob instanceof String) && (ob.toString().length() == 0)));
}

From source file:com.yahoo.sql4d.sql4ddriver.Joiner4All.java

/**
 * Extract fields(k,v) from json /*from  w w  w  .j a v  a 2  s. com*/
 * k = primary field(s) could be a composite key.
 * v = all fields . The first field is always timestamp.
 * Presumption is jsonRow object passed to this method should not have timestamp field.
 * @param timestamp
 * @param jsonRow (This is a jsonObject without timestamp(even for select query response though timestamp is present it is stripped off before passing it to this method)
 * @param joinFields
 * @return 
 */
private static Tuple2<Object, List<Object>> mapPkToRow(String timestamp, JSONObject jsonRow,
        List<String> joinFields) {
    Object joinValue = null;
    List<Object> rowValues = new ArrayList<>();
    rowValues.add(timestamp);
    for (Object key : jsonRow.keySet()) {
        String colName = key.toString();
        rowValues.add(jsonRow.get(colName));
        if (joinFields.contains(colName)) {
            joinValue = (joinValue == null) ? jsonRow.get(colName)
                    : (joinValue + "\u0001" + jsonRow.get(colName));
        }
    }
    if (joinFields.contains("timestamp")) {// Join field could contain timestamp(timestamp can be out of the actual data JSON, so we try this way)
        joinValue = (joinValue == null) ? timestamp : (joinValue + "\u0001" + timestamp);
    }
    //Though join field could be specified like (a,timestamp,b) the value of the join,
    //field will be (a.value^Ab.value^Atimestamp.value) if b appears after a in the json 
    //object. And timestamp value is always appended to last.
    return new Tuple2<>(joinValue, rowValues);
}

From source file:Main.java

public static Integer parseInt(Object value, Object defValue) {
    if (null == value) {
        return parseInt(defValue, 0);
    }//www  .  j  ava 2s  .c  o  m

    try {
        return Integer.parseInt(value.toString());
    } catch (Exception e) {
        Log.e("NumberFormatException", "Integer format Exception...");
        return parseInt(defValue, 0);
    }
}

From source file:com.threewks.thundr.view.jsonp.JsonpViewResolver.java

public static String getCallback(HttpServletRequest req) {
    Object callback = req.getParameter("callback");
    String callbackStr = callback == null ? null : StringUtils.trimToNull(callback.toString());
    callbackStr = callbackStr == null ? "callback" : callbackStr;
    return callbackStr;
}

From source file:com.bryan.crud.helper.TypesUtil.java

public static Long getDefaultLong(Object objValue) {
    if (objValue instanceof Long) {
        return (Long) objValue;
    }//from w w w .  j  a v a  2s. c  o  m
    try {
        if (objValue != null && StringUtils.isNotBlank(objValue.toString())
                && !objValue.toString().equals("null")) {
            return Long.valueOf(objValue.toString());
        }
    } catch (Exception e) {
        return null;
    }
    return null;
}