List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
public static void writeToFile(Collection<?> collection, File file) throws IOException { if (collection != null && file != null) { file.getParentFile().mkdirs();/*from w w w .ja va2 s. co m*/ File tempFile = new File(file.getAbsolutePath() + ".tmp"); FileWriter fw = new FileWriter(tempFile); for (Object obj : collection) { fw.write(new StringBuilder(obj.toString()).append("\r\n").toString()); } fw.flush(); fw.close(); file.delete(); tempFile.renameTo(file); } }
From source file:com.github.ipaas.ifw.front.directive.DirectiveUtils.java
static String getRequiredParam(Map params, String key) throws TemplateException { Object value = params.get(key); if (value == null || StringUtils.isEmpty(value.toString())) { throw new TemplateModelException("not found required parameter:" + key + " for directive"); }/*from w w w . j a v a 2s. c om*/ return value.toString(); }
From source file:com.hangum.tadpole.commons.util.ENumberUtils.java
/** * Object to java.lang.int// w w w .j av a 2 s .c o m * * @param obj * @return */ public static int toInt(Object obj) { if (obj == null) return 0; try { return NumberUtils.toInt(obj.toString()); } catch (Exception nfe) { return 0; } }
From source file:Main.java
public static int isNull_Int(Object response) { if (response == null || response.equals(null)) return -1; else/*from w ww . j av a 2 s.c o m*/ return Integer.parseInt(response.toString().trim()); }
From source file:Main.java
public static double toDouble(Object srcStr, double defaultValue) { try {//from w w w . j a v a 2 s . c om if (srcStr != null) { return Double.valueOf(srcStr.toString().replaceAll(",", "")); } } catch (Exception e) { ; } return defaultValue; }
From source file:edu.harvard.med.screensaver.util.CollectionUtils.java
public static SortedSet<String> toUniqueStrings(Collection<?> c) { SortedSet<String> result = new TreeSet<String>(); for (Object e : c) { result.add(e.toString()); }// w w w . j a va2 s . co m return result; }
From source file:com.splunk.shuttl.server.mbeans.util.EndpointUtils.java
private static BasicNameValuePair createNameValuePair(Object name, Object value) { return new BasicNameValuePair(name.toString(), value.toString()); }
From source file:Main.java
/** * Gets the <code>toString</code> of an <code>Object</code> returning * an empty string ("") if <code>null</code> input. * /* ww w . jav a 2 s. c o m*/ * <pre> * ObjectUtils.toString(null) = "" * ObjectUtils.toString("") = "" * ObjectUtils.toString("bat") = "bat" * ObjectUtils.toString(Boolean.TRUE) = "true" * </pre> * * @see StringUtils#defaultString(String) * @see String#valueOf(Object) * @param obj the Object to <code>toString</code>, may be null * @return the passed in Object's toString, or nullStr if <code>null</code> input * @since 2.0 */ public static String toString(Object obj) { return obj == null ? "" : obj.toString(); }
From source file:gov.nih.nci.calims2.taglib.form.SingleSelectHelper.java
/** * Evaluate the given expression in the given context. * /*from ww w.jav a 2s. co m*/ * @param expression The expression to evaluate * @param context The evaluation context * @return The value of the expression as a string. */ static String evaluateExpression(Expression expression, EvaluationContext context) { try { Object value = expression.getValue(context); return (value != null) ? value.toString() : ""; } catch (EvaluationException e) { return ""; } }
From source file:com.hp.hpl.jena.sparql.util.StringUtils.java
/** Abbreviate, crudely, URI in strings, leaving only their last component. */ public static String printAbbrev(Object obj) { if (obj == null) return "<null>"; String x = obj.toString(); return p.matcher(x).replaceAll("::$1"); }