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 void jlog(Object o) {
    Log.i(TAG, o.toString());
}

From source file:Main.java

public static void log(String key, Object value) {
    removeLog(key);
    debugOutput.put(key, value.toString());
}

From source file:Main.java

public static String maskDebugInfo(Object info) {
    if (info == null)
        return null;
    String s = info.toString();
    int length = Math.min(s.length(), MASK_STRING.length());
    return IS_DEBUG_BUILD ? s : MASK_STRING.substring(0, length);
}

From source file:Main.java

/**
 * Adds the attribute to the given node//from w  w w.j  a  va2 s. com
 * @param doc
 * @param node
 * @param attrName
 * @param attrValue
 */
public static void addAttr(Document doc, Node node, String attrName, Object attrValue) {
    Node attr = doc.createAttribute(attrName);
    attr.setNodeValue(attrValue.toString());
    node.getAttributes().setNamedItem(attr);
}

From source file:Main.java

/**
 * Converts the given instances into comma-separated elements of a string,
 * optionally escapes commas and double quotes with backslahses.
 *//*w  w  w  .j av  a2  s .com*/
public static String toCommaSeparatedList(Object[] o, boolean escapeCommas, boolean escapeDoubleQuotes) {
    if (o == null) {
        return "";
    }
    StringBuilder sb = new StringBuilder();
    for (Object obj : o) {
        String objString = obj.toString();
        objString = objString.replaceAll("\\\\", "\\\\\\\\"); // Replace one backslash with two (nice, eh?)
        if (escapeCommas) {
            objString = objString.replaceAll(",", "\\\\,");
        }
        if (escapeDoubleQuotes) {
            objString = objString.replaceAll("\"", "\\\"");
        }
        sb.append(objString).append(",");
    }
    if (sb.length() > 1) {
        sb.deleteCharAt(sb.length() - 1);
    }
    return sb.toString();

}

From source file:Main.java

/**
 * When the text is longer than the text box it gets centered, this
 * method ensures they all show the end of the text, eg the filename.
 *///from ww w  .j  ava  2  s .c om
public static void setCaretPosition(JComboBox comboBox) {
    Object item = comboBox.getSelectedItem();
    if (item != null) {
        String val = item.toString();
        JTextComponent c = (JTextComponent) comboBox.getEditor().getEditorComponent();
        c.setCaretPosition(val.length());
    }
}

From source file:Main.java

/**
 * Parses the integer value of the specified object.
 * /*from  w w w  .java 2  s  .  c o  m*/
 * @param s
 *            The source object.
 * @return An integer value parsed from the specified object.
 */
public static int parseInt(Object s) {
    return parseInt(s == null ? null : s.toString(), 0);
}

From source file:com.laex.cg2d.model.util.BooleanUtil.java

/**
 * To bool.//from   w ww.  j  a  v  a2  s . c om
 * 
 * @param value
 *          the value
 * @return the boolean
 */
public static Boolean toBool(Object value) {
    String val = value.toString();

    if (StringUtils.isNumeric(val)) {
        return parseInteger(value);
    }

    return Boolean.valueOf(value.toString());
}

From source file:com.ultrapower.eoms.common.plugin.ecside.common.HTMLOptionsUtil.java

 public static String convertString(Object obj,String nullTo){
   return obj==null?nullTo:obj.toString();
}

From source file:io.apicurio.hub.core.js.OaiScriptEngineFactory.java

public static void error(Object error) {
    logger.error(error.toString());
}