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

/**
 * Transforms a collection of Integers into a comma delimited String. If the
 * given collection of elements are null or is empty, an empty String is
 * returned./* w ww.j a v  a  2 s . c  o  m*/
 *
 * @param elements the collection of Integers
 * @return a comma delimited String.
 */
public static String getCommaDelimitedString(Collection<?> elements) {
    final StringBuilder builder = new StringBuilder();

    if (elements != null && !elements.isEmpty()) {
        for (Object element : elements) {
            builder.append(element.toString()).append(DELIMITER);
        }

        return builder.substring(0, builder.length() - DELIMITER.length());
    }

    return builder.toString();
}

From source file:com.netatmo.weatherstation.api.NetatmoUtils.java

private static String getStringFromObject(Object object) {
    String string = object.toString();

    if (string == null || string.equals("null")) {
        return Measures.STRING_NO_DATA;
    }//ww w .  j a  va2s.c o  m

    return string;
}

From source file:it.geosolutions.geobatch.jetty.Start.java

private static void setSystemProperties(final Properties prop) {
    Iterator<?> it = prop.keySet().iterator();
    while (it.hasNext()) {
        Object key = it.next();
        System.setProperty(key.toString(), prop.get(key).toString());
    }// w  w w. ja  v a2  s  .  c  o  m
}

From source file:com.github.sakserv.lslock.cli.LockListerCli.java

/**
 * Returns the inode of the supplied File
 *
 * @param lockFile      Retrieve inode for this File
 * @return      The inode of the supplied lockFile
 * @throws IOException      If the File can not be found
 *//* www .ja  va 2s .c om*/
public static int getInode(File lockFile) throws IOException {
    BasicFileAttributes basicFileAttributes = Files.readAttributes(lockFile.toPath(),
            BasicFileAttributes.class);
    Object fileKey = basicFileAttributes.fileKey();
    String fileAttrString = fileKey.toString();
    return Integer.parseInt(
            fileAttrString.substring(fileAttrString.indexOf("ino=") + 4, fileAttrString.indexOf(")")));
}

From source file:Main.java

public static Map<String, String> toMap(Object javaBean) {
    Map<String, String> result = new HashMap<String, String>();
    Method[] methods = javaBean.getClass().getDeclaredMethods();

    for (Method method : methods) {
        try {//from w  ww .j  a v a2 s  .c om
            if (method.getName().startsWith("get")) {
                String field = method.getName();
                field = field.substring(field.indexOf("get") + 3);
                field = field.toLowerCase().charAt(0) + field.substring(1);

                Object value = method.invoke(javaBean, (Object[]) null);
                if (value != null) {
                    result.put(field, value.toString());
                }
            }
        } catch (Exception e) {
        }
    }

    return result;
}

From source file:Main.java

public static void appendNewElement(Document doc, Element targetElement, String elementName, Object value) {

    if (value != null) {
        appendNewElement(doc, targetElement, elementName, value.toString());
    }/*  w w  w  .  j a  va  2 s . c o m*/

}

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

public static String getStringAttr(MBeanServer mBeanServer, ObjectName oName, String attrName)
        throws Exception {
    Object o = getAttribute(mBeanServer, oName, attrName);
    return o == null ? null : o.toString();
}

From source file:gov.nih.nci.eagle.util.EAGLEListLoader.java

public static UserListBean loadDefaultLists(UserListBean userListBean, HttpSession session)
        throws OperationNotSupportedException {
    ListManager listManager = new ListManager();

    //      use RBT stuff for testing
    //   this is obviously testing stuff
    //        String oligos = "E09264,E09358,E09448,E09503,E09661,E09664,E09690,E09804,E09811,E09860,E09867,E09885,E09893,HF0087,HF0251,HF0285,HF0291,HF0327,HF0329,HF0332,HF0434,HF0453,HF0471,HF0488,HF0510,HF0599,HF0615,HF0639,HF0670,HF0726,HF0749,HF0813,HF0816,HF0822,HF0828,HF0831,HF0835,HF0897,HF0899,HF0914,HF0920,HF0931,HF0960,HF0962,HF0966,HF0975,HF1136,HF1150,HF1156,HF1167,HF1185,HF1219,HF1227,HF1235,HF1264,HF1325,HF1334,HF1345,HF1348,HF1380,HF1381,HF1433,HF1489,HF1493,HF1502,HF1551,HF1553,HF1606,HF1613,HF1677,MD508984";
    //        String astros = "E09137,E09176,E09214,E09262,E09334,E09362,E09394,E09408,E09471,E09542,E09673,E09743,E09759,E09800,E09801,E09818,E09826,E09848,E09900,E09922,E09923,E09945,HF0017,HF0026,HF0108,HF0152,HF0189,HF0223,HF0450,HF0491,HF0608,HF0757,HF0778,HF0953,HF1000,HF1032,HF1114,HF1139,HF1232,HF1246,HF1269,HF1295,HF1316,HF1344,HF1366,HF1398,HF1407,HF1442,HF1463,HF1469,HF1487,HF1511,HF1568,HF1581,HF1587,HF1708,MD547038,MD554082";
    //first 5+ astros are not in rbinary
    //        String oligos = "IGC-10-1107,IGC-08-1053,IGC-02-1067,IGC-02-1059";
    //        String astros = "IGC-10-1051,IGC-12-1077,IGC-09-1090,IGC-03-1007";
    //        String ftest = "IGC-08-1094,IGC-09-1085,IGC-13-1106,IGC-04-1113";
    ReadablePropertyPlaceholder propBean = (ReadablePropertyPlaceholder) SpringContext.getBean("patientLists");
    Properties props = propBean.getProps();
    for (Object listName : props.keySet()) {
        if (listName.toString().indexOf("data.") != -1)
            continue;
        List<String> sampleList = new ArrayList<String>();
        String samples = props.getProperty(listName.toString());
        sampleList = Arrays.asList(StringUtils.split(samples, ","));
        EAGLEListValidator listValidator = new EAGLEListValidator(ListType.PatientDID, sampleList);
        UserList mySampleList = listManager.createList(ListType.PatientDID, listName.toString(), sampleList,
                listValidator);//from w w  w.j  av  a 2s .c o  m
        mySampleList.setListOrigin(ListOrigin.Default);
        userListBean.addList(mySampleList);
    }
    //        List<String> oligoSamplesList = new ArrayList<String>();
    //        oligoSamplesList = Arrays.asList( StringUtils.split(oligos, ",") );
    //
    //      
    //        EAGLEListValidator listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, oligoSamplesList);
    //        UserList myOligoSampleList = listManager.createList(ListType.PatientDID,"testOligo",oligoSamplesList,listValidator); 
    //        myOligoSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(myOligoSampleList);
    //        
    //        List<String> astroSamplesList = new ArrayList<String>();
    //        astroSamplesList = Arrays.asList( StringUtils.split(astros, ",") );
    //     
    //        listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, astroSamplesList);
    //        UserList myAstroSampleList = listManager.createList(ListType.PatientDID,"testAstro",astroSamplesList,listValidator); 
    //        myAstroSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(myAstroSampleList);
    //        
    //        List<String> ftestList = new ArrayList<String>();
    //        ftestList = Arrays.asList( StringUtils.split(ftest, ",") );
    //     
    //        listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, ftestList);
    //        UserList ftestSampleList = listManager.createList(ListType.PatientDID,"ftest",ftestList,listValidator); 
    //        ftestSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(ftestSampleList);

    return userListBean;
}

From source file:Main.java

public static String objToJSON(Object obj) {
    // We expect the object is JSONObject or primive type.
    if (obj == null)
        return "null";

    Object sObj = toSerializableObject(obj);
    return (sObj instanceof String) ? JSONObject.quote(sObj.toString()) : sObj.toString();
}

From source file:Main.java

public static Element createElement(String name, Object value, Document doc) {
    Element element = doc.createElement(name);
    element.appendChild(doc.createTextNode(value.toString()));
    return element;
}