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 saveGlobalSetting(Context ctx, String name, Object value) {
    SharedPreferences setting = ctx.getSharedPreferences(ctx.getPackageName(), 0);
    setting.edit().putString(name, value.toString()).commit();
}

From source file:com.baidu.rigel.biplatform.ac.util.Md5Util.java

/**
 * /*from  ww  w  . j  a v  a  2s.c o m*/
 * ??
 * 
 * @param password 
 * @param salt ?
 * @return ?{?}
 */
private static String mergePasswordAndSalt(String password, Object salt) {
    if (salt == null || "".equals(salt.toString().trim())) {
        return password;
    }
    return password + "{" + salt.toString() + "}";
}

From source file:com.bstek.dorado.console.ConsoleConfigure.java

/**
 * String???//from   ww  w  . j  a v a 2 s  .  co  m
 * 
 * @param key
 *            ???
 */
public static String getString(String key) {
    Object value = get(key);
    return (value == null) ? null : value.toString();
}

From source file:com.qagen.osfe.core.utils.ValueToString.java

private static String formatTimestamp(Object value, String pattern) {
    if (pattern == null) {
        return value.toString();
    }//  w  w w.j  a  v a 2  s. c om

    final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(value);
}

From source file:Main.java

public static String toString(Object obj, String defaultStr) {
    if (null == obj) {
        return defaultStr;
    }//from w ww.  j  av  a  2 s .c om

    return obj.toString();
}

From source file:Main.java

private static String iso8859togbk(Object obj) {
    try {//from   w w  w .  ja  va  2  s.co  m
        if (obj == null)
            return "";
        else
            return new String(obj.toString().getBytes("iso-8859-1"), "GBK");
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

private static String gbktoiso8859(Object obj) {
    try {// w  w  w  .j  ava2s  . co m
        if (obj == null)
            return "";
        else
            return new String(obj.toString().getBytes("GBK"), "iso-8859-1");
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

public static String toFormXml(Object obj) {
    if (obj == null) {
        return "";
    }/* w  w  w  .j  a v a 2s  . c om*/
    String message = obj.toString();
    char content[] = new char[message.length()];
    message.getChars(0, message.length(), content, 0);
    StringBuffer result = new StringBuffer(content.length + 50);
    for (int i = 0; i < content.length; i++) {
        switch (content[i]) {
        case '<':
            result.append("&lt;");
            break;
        case '>':
            result.append("&gt;");
            break;
        case '&':
            result.append("&amp;");
            break;
        case '"':
            result.append("&quot;");
            break;
        default:
            result.append(content[i]);
        }
    }
    return (result.toString());
}

From source file:com.jivesoftware.sdk.util.JiveSDKUtils.java

/**
 * Check if all the items are presented and not empty
 *
 * @param items : Checked items/* w w  w.  j ava2 s.  c  o m*/
 * @return :
 * true -> if all the items are presented.
 * false -> if at least one is absent or empty.
 */
public static boolean isAllExist(Object... items) {
    if (items == null) {
        return false;
    }

    for (Object item : items) {
        if (item == null || item.toString().isEmpty()) {
            return false;
        }
    }

    return true;
}

From source file:Main.java

public static String join(final Iterable<?> iterable, String separator) {

    // handle null, zero and one elements before building a buffer
    if (iterable == null) {
        return null;
    }/*from   w w  w  . j av a 2s .co  m*/
    Iterator<?> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
        return "";
    }
    final Object first = iterator.next();
    if (!iterator.hasNext()) {
        return first.toString();
    }

    // two or more elements
    final StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
    if (first != null) {
        buf.append(first);
    }

    while (iterator.hasNext()) {
        buf.append(separator);
        final Object obj = iterator.next();
        if (obj != null) {
            buf.append(obj);
        }
    }

    return buf.toString();
}