List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
/** * Returns the value for key in dictionary as a float or the given default * value if no value is defined for the key. * /*from w w w . java 2s .c o m*/ * @param dict * Dictionary that contains the key, value pairs. * @param key * Key whose value should be returned. * @param defaultValue * Default value to return if the key is undefined. * @return Returns the float value for key in dict. */ public static float getFloat(Map<String, Object> dict, String key, float defaultValue) { Object value = dict.get(key); if (value == null) { return defaultValue; } else { return Float.parseFloat(value.toString()); } }
From source file:com.gargoylesoftware.htmlunit.general.HostExtractor.java
private static void fillMDNJavaScriptGlobalObjects(final WebClient webClient, final Set<String> set) throws Exception { final HtmlPage page = webClient .getPage("https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects"); for (final Object o : page.getByXPath("//*[name()='code']/text()")) { String value = o.toString(); if (!value.isEmpty()) { if (value.endsWith("()")) { value = value.substring(0, value.length() - 2); }/*from w ww . j a va 2 s. c o m*/ set.add(value); } } }
From source file:it.unibas.spicy.persistence.Types.java
public static Object getTypedValue(String type, Object value) throws DAOException { if (value == null || value.toString().equalsIgnoreCase("NULL")) { return NullValueFactory.getNullValue(); }/* w w w . j a v a 2 s. com*/ if (type.equals(BOOLEAN)) { return Boolean.parseBoolean(value.toString()); } if (type.equals(STRING)) { return value.toString(); } if (type.equals(INTEGER)) { try { return Integer.parseInt(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(DOUBLE)) { try { return Double.parseDouble(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(FLOAT)) { try { return Float.parseFloat(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(DATE) || type.equals(DATETIME)) { return value.toString(); // try { // return DateFormat.getDateInstance().parse(value.toString()); // } catch (ParseException ex) { // logger.error(ex); // throw new DAOException(ex.getMessage()); // } } return value.toString(); }
From source file:Main.java
private static final void createElem(final String elemName, final Object o, final StringBuilder sb) { assert o != null; sb.append('<'); sb.append(elemName);/*ww w. j av a 2 s.co m*/ sb.append('>'); sb.append(o.toString()); sb.append("</"); sb.append(elemName); sb.append('>'); }
From source file:io.fabric8.mq.controller.util.BrokerJmxUtils.java
public static List<ObjectName> getDestinations(J4pClient client, ObjectName root, String type) throws Exception { List<ObjectName> list = new ArrayList<>(); String objectNameStr = root.toString() + ",destinationType=" + type + ",destinationName=*"; J4pResponse<J4pReadRequest> response = client .execute(new J4pReadRequest(new ObjectName(objectNameStr), "Name")); JSONObject value = response.getValue(); for (Object key : value.keySet()) { ObjectName objectName = new ObjectName(key.toString()); list.add(objectName);/* w w w .jav a 2 s. co m*/ } return list; }
From source file:Main.java
/** * Returns a token string from a collection. Uses {@code Object#toString()} * to get the collection elements strings. * * @param collection collection * @param delimiter delimiter * @param delimiterReplacement replacement for all delimiters contained in * a collection's element * @return token string *//*from www .ja v a 2 s. c om*/ public static String toTokenString(Collection<? extends Object> collection, String delimiter, String delimiterReplacement) { if (collection == null) { throw new NullPointerException("collection == null"); } if (delimiter == null) { throw new NullPointerException("delimiter == null"); } if (delimiterReplacement == null) { throw new NullPointerException("delimiterReplacement == null"); } StringBuilder tokenString = new StringBuilder(); int index = 0; for (Object o : collection) { tokenString.append(((index == 0) ? EMPTY_STRING : delimiter)); tokenString.append(o.toString().replace(delimiter, delimiterReplacement)); index++; } return tokenString.toString(); }
From source file:Main.java
public static Map toMap(Object javaBean) { Map result = new HashMap(); Method[] methods = javaBean.getClass().getDeclaredMethods(); for (Method method : methods) { try {/* ww w . j a v a 2s.c o m*/ 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); result.put(field, null == value ? "" : value.toString()); } } catch (Exception e) { e.printStackTrace(); } } return result; }
From source file:com.cubeia.backoffice.report.RequestBean.java
@SuppressWarnings("rawtypes") private static Map<String, String> checkParameters(Map p) { Map<String, String> m = new HashMap<String, String>(p.size()); for (Object o : p.keySet()) { String key = o.toString(); if (key.startsWith("param:")) { key = key.substring(6);//from w ww. jav a 2s .c o m Object v = p.get(o); m.put(key, v.toString()); } } return m; }
From source file:Main.java
public static void writeBoolean(ByteArrayOutputStream baos, Object o) { if (o instanceof Boolean) { writeBoolean(baos, Boolean.valueOf((Boolean) o)); } else {//from w w w . java 2 s . co m writeBoolean(baos, Boolean.valueOf(o.toString())); } }
From source file:Main.java
public static String applyXSLT(Source xml, URL xsltFilename, Map params) { try {/*from www. j av a 2 s . c o m*/ TransformerFactory f = TransformerFactory.newInstance(); StreamSource xsltSrc = new StreamSource(xsltFilename.openConnection().getInputStream()); StringWriter out = new StringWriter(); StreamResult res = new StreamResult(out); Transformer t = f.newTransformer(xsltSrc); if (params != null) { Iterator i = params.keySet().iterator(); while (i.hasNext()) { Object obj = i.next(); t.setParameter(obj.toString(), params.get(obj)); } } t.transform(xml, res); return out.toString(); } catch (Exception e) { return null; } }