List of usage examples for java.lang Object toString
public String toString()
From source file:com.boozallen.cognition.ingest.storm.util.ConfigurationMapEntryUtils.java
/** * Extracts map entries from configuration. * * @param conf//from w ww . java 2s . com * @param mappingEntry * @param fields first field should be unique and exist in all entries, other fields are optional from map * @return */ public static Map<String, Map<String, String>> extractMapList(final Configuration conf, final String mappingEntry, final String... fields) { String keyField = fields[0]; List<Object> keys = conf.getList(mappingEntry + "." + keyField); Map<String, Map<String, String>> maps = new HashMap<>(keys.size()); for (int i = 0; i < keys.size(); i++) { Map<String, String> map = new HashMap<>(); Object key = keys.get(i); map.put(keyField, key.toString()); for (int j = 1; j < fields.length; j++) { String field = fields[j]; String fieldPath = String.format("%s(%s).%s", mappingEntry, i, field); String value = conf.getString(fieldPath); if (value != null) map.put(field, value); } maps.put(key.toString(), map); } return maps; }
From source file:Main.java
/** * /* w w w . j a v a 2 s .c om*/ * @param array * @param index * @param defaultString * @return */ public static String getArrayString(JSONArray array, int index, String defaultString) { Object value = getArrayValue(array, index, defaultString); String string = (value == null) ? ("") : (value.toString()); return string; }
From source file:Main.java
public static void mapToAndroidLayoutMapper(Class classObj, Map map, String prefixStr, View view) { for (Object keyObj : map.keySet().toArray()) { String keyStr = keyObj.toString(); Field fieldObj = null;//w w w . j a v a 2 s.com try { fieldObj = classObj.getField(prefixStr + "_" + keyStr); } catch (NoSuchFieldException e) { continue; } Object layoutObj = null; try { layoutObj = fieldObj.get(fieldObj); } catch (IllegalAccessException e) { continue; } Integer layoutIntvalue = (Integer) layoutObj; View selectedView = view.findViewById(layoutIntvalue); if (selectedView instanceof TextView) { TextView textView = (TextView) selectedView; textView.setText(String.valueOf(map.get(keyStr))); } else if (selectedView instanceof ImageView) { ImageView imageView = (ImageView) selectedView; } } }
From source file:Main.java
/** * Returns the value for key in dictionary as a string or the given default * value if no value is defined for the key. * /* w w w .j ava2 s . 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 string value for key in dict. */ public static String getString(Map<String, Object> dict, String key, String defaultValue) { Object value = dict.get(key); if (value == null) { return defaultValue; } else { return value.toString(); } }
From source file:Main.java
private static Object getValue4Field(Object orginalValue, String typeName) { Log.i("YunMing", typeName); Object value = orginalValue.toString(); if (typeName.equals(BYTE) || typeName.equals(VALUE_BYTE)) { value = Byte.class.cast(orginalValue); }/*from w w w.ja va 2 s . com*/ if (typeName.equals(INTEGER) || typeName.equals(VALUE_INTEGER)) { value = Integer.class.cast(orginalValue); } if (typeName.equals(SHORT) || typeName.equals(VALUE_SHORT)) { value = Short.class.cast(orginalValue); } if (typeName.equals(LONG) || typeName.equals(VALUE_LONG)) { value = Long.class.cast(orginalValue); } if (typeName.equals(BOOLEAN) || typeName.equals(VALUE_BOOLEAN)) { value = Boolean.class.cast(orginalValue); } if (typeName.equals(CHAR) || typeName.equals(VALUE_CHAR)) { value = Character.class.cast(orginalValue); } if (typeName.equals(FLOAT) || typeName.equals(VALUE_FLOAT)) { value = Float.class.cast(orginalValue); } if (typeName.equals(DOUBLE) || typeName.equals(VALUE_DOUBLE)) { value = Double.class.cast(orginalValue); } return value; }
From source file:Main.java
public static String encode(Object string) { if (string == null) { return ""; }//from w ww .j av a 2 s. c om char[] chars = string.toString().toCharArray(); StringBuffer out = new StringBuffer(); for (int i = 0; i < chars.length; i++) { switch (chars[i]) { case '&': out.append("&"); break; case '<': out.append("<"); break; case '>': out.append(">"); break; case '\"': out.append("""); break; default: out.append(chars[i]); } } return out.toString(); }
From source file:Main.java
public static final String join(final Collection<?> list, final String inbetween) { final StringBuilder builder = new StringBuilder(); for (final Object object : list) { if (builder.length() > 0) { builder.append(inbetween);//from www . j av a2s . co m } builder.append(object.toString()); } return builder.toString(); }
From source file:Main.java
static void appendProp(Map<String, Object> properties, String key, Object valueToAppend) { properties.putIfAbsent(key, new LinkedHashSet<String>()); ((Collection<String>) properties.get(key)).add(valueToAppend.toString()); }
From source file:net.bafeimao.umbrella.support.util.json.JsonUtil.java
public static JsonNode toJsonNode(Object json) { try {//from w ww. ja v a 2 s . c o m return objectMapper.readValue(json.toString(), JsonNode.class); } catch (IOException e) { LOGGER.error("50003", "JSON????,:IO", e); } return null; }
From source file:Main.java
public static boolean toBoolean(Object srcStr, boolean defaultValue) { try {//from w w w . ja v a2s.co m if (srcStr != null) { return Boolean.parseBoolean(trim1(srcStr.toString())); } } catch (Exception e) { ; } return defaultValue; }