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.apptentive.android.sdk.storage.SdkManager.java

public static Sdk storeSdkAndReturnDiff(Context context) {
    Sdk stored = getStoredSdk(context);//from  w w  w . ja v  a2 s  .c  om
    Sdk current = generateCurrentSdk(context);

    Object diff = JsonDiffer.getDiff(stored, current);
    if (diff != null) {
        try {
            storeSdk(context, current);
            return new Sdk(diff.toString());
        } catch (JSONException e) {
            Log.e("Error casting to Sdk.", e);
        }
    }
    return null;
}

From source file:com.datatorrent.stram.StringCodecs.java

public static void check() {
    if (classLoaders.putIfAbsent(Thread.currentThread().getContextClassLoader(), Boolean.TRUE) == null) {
        loadDefaultConverters();/* www. jav  a2 s .  co  m*/
        for (Map.Entry<Class<?>, Class<? extends StringCodec<?>>> entry : codecs.entrySet()) {
            try {
                final StringCodec<?> codecInstance = entry.getValue().newInstance();
                ConvertUtils.register(new Converter() {
                    @Override
                    public Object convert(Class type, Object value) {
                        return value == null ? null : codecInstance.fromString(value.toString());
                    }

                }, entry.getKey());
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}

From source file:com.feilong.taglib.functions.ELFunctions.java

/**
 * format?json(?pretty,)./*from  ww w. j  a  va2s .c o  m*/
 *
 * @param obj
 *            the obj
 * @return the string
 * @see com.feilong.tools.jsonlib.JsonUtil#format(Object, int, int)
 */
public static String toJsonString(Object obj) {
    try {
        return JsonUtil.format(obj, 0, 0);
    } catch (Exception e) {
        LOGGER.error("json format:" + obj.toString(), e);
    }
    //jsp,,????, ??, ,,null
    return EMPTY;
}

From source file:com.storageroomapp.client.util.JsonSimpleUtil.java

/**
 * Convenience method for pulling a Integer value off of a JSONObject
 * @param obj the JSONObject received from the server
 * @param key the String key of the value we want
 * @param defaultValue the Integer to return if a value is not found (can be null)
 * @return the Integer value, or null if not found or not an int
 *//*  w  ww.  j av  a 2  s  .  co  m*/
static public Integer parseJsonIntValue(JSONObject obj, String key, Integer defaultValue) {
    if ((obj == null) || (key == null)) {
        return defaultValue;
    }
    Integer value = defaultValue;
    Object valueObj = obj.get(key);
    if (valueObj != null) {
        String valueStr = valueObj.toString();
        try {
            value = Integer.parseInt(valueStr);
        } catch (NumberFormatException nfe) {
            // TODO log
            value = defaultValue;
        }
    }
    return value;
}

From source file:com.apptentive.android.sdk.storage.SdkManager.java

private static Sdk generateCurrentSdk(Context context) {
    Sdk sdk = new Sdk();

    // First, get all the information we can load from static resources.
    sdk.setVersion(Constants.APPTENTIVE_SDK_VERSION);
    sdk.setPlatform("Android");

    // Distribution and distribution version are optionally set in the manifest by the wrapping platform (trigger, etc.)
    Object distribution = Util.getPackageMetaDataSingleQuotedString(context,
            Constants.MANIFEST_KEY_SDK_DISTRIBUTION);
    if (distribution != null && distribution.toString().length() != 0) {
        sdk.setDistribution(distribution.toString());
    }/*w w  w  .ja  v  a2  s .  co  m*/
    Object distributionVersion = Util.getPackageMetaDataSingleQuotedString(context,
            Constants.MANIFEST_KEY_SDK_DISTRIBUTION_VERSION);
    if (distributionVersion != null && distributionVersion.toString().length() != 0) {
        sdk.setDistributionVersion(distributionVersion.toString());
    }

    return sdk;
}

From source file:com.linkedin.pinot.common.utils.SegmentNameBuilder.java

public static String buildBasic(String tableName, Object minTimeValue, Object maxTimeValue, String prefix) {
    return StringUtil.join("_", tableName, minTimeValue.toString(), maxTimeValue.toString(), prefix);
}

From source file:com.storageroomapp.client.util.JsonSimpleUtil.java

/**
 * Convenience method for pulling a Float value off of a JSONObject
 * @param obj the JSONObject received from the server
 * @param key the String key of the value we want
 * @param defaultValue the Float to return if a value is not found (can be null)
 * @return the Float value, or null if not found or not a float
 *///from  ww  w  . ja v a  2 s. c  o  m
static public Float parseJsonFloatValue(JSONObject obj, String key, Float defaultValue) {
    if ((obj == null) || (key == null)) {
        return defaultValue;
    }
    Float value = defaultValue;
    Object valueObj = obj.get(key);
    if (valueObj != null) {
        String valueStr = valueObj.toString();
        try {
            value = Float.parseFloat(valueStr);
        } catch (NumberFormatException nfe) {
            // TODO log
            value = defaultValue;
        }
    }
    return value;

}

From source file:lee.util.jtap.JTapCli.java

protected static String dumpKey(String... keys) {
    String responseMessage = "Key dumped.";
    loadSession();//from w  ww .  ja v a  2 s  . c om
    if (keys.length > 0) {
        MemcachedClient memcachedClient = connectToMembase();
        Object object = memcachedClient.get(keys[0]);
        responseMessage = object.toString();
    } else {
        responseMessage = "Key not found.";
    }
    return responseMessage;
}

From source file:com.liferay.sync.engine.util.FileUtil.java

public static String getFileKey(Path filePath) {
    if (!Files.exists(filePath)) {
        return "";
    }/* w w w .ja  va  2  s.  c o  m*/

    try {
        BasicFileAttributes basicFileAttributes = Files.readAttributes(filePath, BasicFileAttributes.class);

        if (OSDetector.isWindows()) {
            return String.valueOf(basicFileAttributes.creationTime());
        } else {
            Object fileKey = basicFileAttributes.fileKey();

            return fileKey.toString();
        }
    } catch (Exception e) {
        _logger.error(e.getMessage(), e);

        return "";
    }
}