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

/**
 * Gets the element name. The object is a long string that separated with
 * the separator "."/*  w  ww  .ja va  2 s .  co m*/
 * 
 * @param obj
 *            the object
 * @return the name behind the last separator "."
 */

public static String getElementName(Object obj) {
    if (obj instanceof Class) {
        obj = ((Class) obj).getName();
    }
    return obj.toString().substring(obj.toString().lastIndexOf(".") + 1); //$NON-NLS-1$
}

From source file:com.threewks.thundr.view.jsp.el.StringFunctions.java

public static String replace(Object arg, String regex, String replacement) {
    return arg == null ? ""
            : arg.toString().replaceAll(regex == null ? "" : regex, replacement == null ? "" : replacement);
}

From source file:Main.java

/**
 * Converts the seperators of the coords to the WKT from ts and cs
 *
 * @param coords the coords string to convert
 * @param ts the separator that separates 2 coordinates
 * @param cs the separator between 2 numbers in a coordinate
 *///from   w w w.  j  av  a  2  s  . co m
public static String toWktCoords(Object coords, Object ts, Object cs) {
    String coordsString = coords.toString();
    char tsString;
    if (ts == null || ts.toString().length() == 0) {
        tsString = TS_DEFAULT;
    } else {
        tsString = ts.toString().charAt(0);
    }
    char csString;
    if (cs == null || cs.toString().length() == 0) {
        csString = CS_DEFAULT;
    } else {
        csString = cs.toString().charAt(0);
    }

    if (tsString == TS_WKT && csString == CS_WKT) {
        return coordsString;
    }

    if (tsString == CS_WKT) {
        tsString = ';';
        coordsString = coordsString.replace(CS_WKT, tsString);
    }
    coordsString = coordsString.replace(csString, CS_WKT);
    String result = coordsString.replace(tsString, TS_WKT);
    char lastChar = result.charAt(result.length() - 1);
    if (result.charAt(result.length() - 1) == TS_WKT || lastChar == CS_WKT) {
        result = result.substring(0, result.length() - 1);
    }
    return result;
}

From source file:Main.java

/**
 * Generates the title of the DB document.
 *
 * @param primaryKeys primary keys of the database.
 * @param row row corresponding to the document.
 * @return title String./*  w w  w  .  j av a2  s.  co m*/
 */
private static String getTitle(List<String> primaryKeys, Map<String, Object> row) {
    StringBuilder title = new StringBuilder();
    title.append(DATABASE_TITLE_PREFIX);
    for (String primaryKey : primaryKeys) {
        Object keyValue = row.get(primaryKey);
        String strKeyValue;
        if (keyValue == null || keyValue.toString().trim().length() == 0) {
            strKeyValue = "";
        } else {
            strKeyValue = keyValue.toString();
        }
        title.append(" ").append(primaryKey).append("=").append(strKeyValue);
    }
    return title.toString();
}

From source file:com.github.ipaas.ifw.front.directive.DirectiveUtils.java

static String getParam(Map params, String key, String defaultValue) throws TemplateException {
    Object value = params.get(key);
    return value == null ? defaultValue : value.toString();
}

From source file:com.us.data.ContentTypeProcesser.java

/**
 * ?/*from w  ww.  j  av  a  2  s.  c o m*/
 * 
 * @param key
 * @return
 */
public static String findType(String key) {
    Object type = ALL_TYPES.get(key.toLowerCase());
    if (type != null)
        return type.toString();
    return "";
}

From source file:dk.statsbiblioteket.doms.licensemodule.solr.AbstractSolrJClient.java

public static ArrayList<String> getIdsFromResponse(QueryResponse response) {
    ArrayList<String> ids = new ArrayList<String>();

    for (SolrDocument current : response.getResults()) {
        Collection<Object> fieldValues = current.getFieldValues(filterField); //Multivalued
        for (Object idFound : fieldValues) {
            ids.add(idFound.toString());
        }/* w  ww .  j  ava2 s.  c  om*/
    }
    return ids;
}

From source file:logging.report.PGRecord.java

protected static void logField(StringBuilder builder, Object field) {
    logField(builder, field.toString());
}

From source file:Main.java

public static void printUIDefaults() {
    UIDefaults uiDefaults = UIManager.getDefaults();
    Enumeration<Object> e = uiDefaults.keys();
    while (e.hasMoreElements()) {
        Object key = e.nextElement();
        Object val = uiDefaults.get(key);
        System.out.println("[" + key.toString() + "]:[" + (null != val ? val.toString() : "(null)") + "]");
    }/* w w  w.j a v  a 2 s. co  m*/
}

From source file:com.googlecode.psiprobe.tools.JmxTools.java

public static String getStringAttr(CompositeData cds, String name) {
    Object o = cds.get(name);
    return o != null ? o.toString() : null;
}