List of usage examples for java.lang Object toString
public String toString()
From source file:com.parse.ParseRESTQueryCommand.java
static <T extends ParseObject> Map<String, String> encode(ParseQuery.State<T> state, boolean count) { ParseEncoder encoder = PointerEncoder.get(); HashMap<String, String> parameters = new HashMap<>(); List<String> order = state.order(); if (!order.isEmpty()) { parameters.put("order", ParseTextUtils.join(",", order)); }/*from w w w . ja va2s . co m*/ ParseQuery.QueryConstraints conditions = state.constraints(); if (!conditions.isEmpty()) { JSONObject encodedConditions = (JSONObject) encoder.encode(conditions); parameters.put("where", encodedConditions.toString()); } // This is nullable since we allow unset selectedKeys as well as no selectedKeys Set<String> selectedKeys = state.selectedKeys(); if (selectedKeys != null) { parameters.put("keys", ParseTextUtils.join(",", selectedKeys)); } Set<String> includeds = state.includes(); if (!includeds.isEmpty()) { parameters.put("include", ParseTextUtils.join(",", includeds)); } if (count) { parameters.put("count", Integer.toString(1)); } else { int limit = state.limit(); if (limit >= 0) { parameters.put("limit", Integer.toString(limit)); } int skip = state.skip(); if (skip > 0) { parameters.put("skip", Integer.toString(skip)); } } Map<String, Object> extraOptions = state.extraOptions(); for (Map.Entry<String, Object> entry : extraOptions.entrySet()) { Object encodedExtraOptions = encoder.encode(entry.getValue()); parameters.put(entry.getKey(), encodedExtraOptions.toString()); } if (state.isTracingEnabled()) { parameters.put("trace", Integer.toString(1)); } return parameters; }
From source file:Main.java
/** * Convenience method for retrieving the UIDefault for a single property * of a particular class./*from w w w. j a va2 s . c o m*/ * * @param clazz the class of interest * @param property the property to query * @return the UIDefault property, or null if not found */ public static Object getUIDefaultOfClass(Class<?> clazz, String property) { Object retVal = null; UIDefaults defaults = getUIDefaultsOfClass(clazz); List<Object> listKeys = Collections.list(defaults.keys()); for (Object key : listKeys) { if (key.equals(property)) { return defaults.get(key); } if (key.toString().equalsIgnoreCase(property)) { retVal = defaults.get(key); } } return retVal; }
From source file:st.jigasoft.dbutil.util.ReportTheme.java
public static void circularTheme(JFreeChart chart, String... colunsName) { chart.setBackgroundPaint(//from ww w. jav a2s . co m new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); int iCount = 0; // use gradients and white borders for the section colours for (Object s : colunsName) { plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++))); if (iCount == MAX_COLUNS_COLOR) iCount = 0; } plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); }
From source file:com.datatorrent.stram.StringCodecs.java
public static <T> void register(final Class<? extends StringCodec<?>> codec, final Class<T> clazz) throws InstantiationException, IllegalAccessException { check();//w w w . ja v a2 s .co m final StringCodec<?> codecInstance = codec.newInstance(); ConvertUtils.register(new Converter() { @Override public Object convert(Class type, Object value) { return value == null ? null : codecInstance.fromString(value.toString()); } }, clazz); codecs.put(clazz, codec); }
From source file:costumetrade.common.util.HttpClientUtils.java
/** * @param url//from www . ja v a 2 s .com * @param ? * @return */ public static String doPost(String url, Map<String, Object> params) { List<BasicNameValuePair> nvps = new ArrayList<>(params.size()); for (String key : params.keySet()) { Object value = params.get(key); if (value != null) { nvps.add(new BasicNameValuePair(key, value.toString())); } } return doPost(url, new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8)); }
From source file:dev.meng.wikipedia.profiler.util.StringUtils.java
public static String replace(String string, Object... values) { String result = string;//from w w w . j av a2 s . c o m for (Object value : values) { if (string.contains("?")) { result = result.replaceFirst("\\?", value.toString()); } } return result; }
From source file:com.glaf.core.el.ExpressionTools.java
public static String evaluate(String expression, Map<String, Object> params) { if (expression == null || params == null) { return expression; }/*from ww w .ja v a 2 s . c o m*/ expression = StringTools.replaceIgnoreCase(expression, "${", "#{"); StringBuffer sb = new StringBuffer(expression.length() + 1000); int begin = 0; int end = 0; boolean flag = false; for (int i = 0; i < expression.length(); i++) { if (expression.charAt(i) == '#' && expression.charAt(i + 1) == '{') { sb.append(expression.substring(end, i)); begin = i + 2; flag = true; } if (flag && expression.charAt(i) == '}') { String temp = expression.substring(begin, i); String value = null; try { Object object = Mvel2ExpressionEvaluator.evaluate(temp, params); if (object != null) { value = object.toString(); } } catch (Exception ex) { // ex.printStackTrace(); } if (StringUtils.isNotEmpty(value)) { sb.append(value); end = i + 1; flag = false; } else { sb.append(""); end = i + 1; flag = false; } } if (i == expression.length() - 1) { sb.append(expression.substring(end, i + 1)); } } return sb.toString(); }
From source file:org.craftercms.commons.rest.RestClientUtils.java
/** * Adds a param value to a params map. If value is null, nothing is done. * * @param key the param key//from ww w .ja v a 2 s . c om * @param value the param value * @param params the params map */ public static void addValue(String key, Object value, MultiValueMap<String, String> params) { if (value != null) { params.add(key, value.toString()); } }
From source file:com.storageroomapp.client.util.JsonSimpleUtil.java
/** * Convenience method for pulling a String value off of a JSONObject * @param obj the JSONObject received from the server * @param key the String key of the value we want * @return the String value, or null if not found *//*ww w . j a v a 2 s . c o m*/ static public String parseJsonStringValue(JSONObject obj, String key) { if ((obj == null) || (key == null)) { return null; } String value = null; Object valueObj = obj.get(key); if (valueObj != null) { value = valueObj.toString(); } return value; }
From source file:com.storageroomapp.client.util.JsonSimpleUtil.java
/** * Convenience method for pulling a Boolean 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 Boolean to return if a value is not found (can be null) * @return the Boolean value, or null if not found or not an boolean */// w ww . j a va2 s. c o m static public Boolean parseJsonBooleanValue(JSONObject obj, String key, Boolean defaultValue) { if ((obj == null) || (key == null)) { return defaultValue; } String value = null; Object valueObj = obj.get(key); if (valueObj != null) { value = valueObj.toString(); } return "true".equals(value); }