List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:Main.java
/** * Enable debug logging for unit tests./*from w w w. j ava2 s.c om*/ */ //@VisibleForTesting static void setDebugLoggingEnabledForTests(boolean enabled) { sDebugLoggingEnabledForTests = Boolean.valueOf(enabled); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getPref(Context _context, String prefKey, T defValue, Class<T> clazz) { final SharedPreferences pref = getDefaultSharedPreferences(_context); if (Long.class == clazz) { return (T) (Long.valueOf(pref.getLong(prefKey, (Long) defValue))); } else if (Integer.class == clazz) { return (T) (Integer.valueOf(pref.getInt(prefKey, (Integer) defValue))); } else if (defValue instanceof String) { return (T) (pref.getString(prefKey, String.valueOf(defValue))); } else if (defValue instanceof Boolean) { return (T) (Boolean.valueOf(pref.getBoolean(prefKey, (Boolean) defValue))); }//from w w w . j a v a 2s . c o m throw new UnsupportedOperationException("Class " + clazz + " not supported"); }
From source file:Main.java
public static ContentValues listToContentValues(List<String> values, String type) { ContentValues contentvalues = new ContentValues(); //Place values into contentvalue structure for (int i = 0; i < values.size(); i++) { String current = values.get(i); try {/*from w w w.j a va2 s . c om*/ //Separate the value by = in order to get key:value Integer indexOfEquals = current.indexOf("="); String key = current.substring(0, indexOfEquals); String value = current.substring(indexOfEquals + 1); if (type.toUpperCase().equals("STRING")) contentvalues.put(key, value); if (type.toUpperCase().equals("BOOLEAN")) contentvalues.put(key, Boolean.valueOf(value)); if (type.toUpperCase().equals("INTEGER")) contentvalues.put(key, new Integer(value)); if (type.toUpperCase().equals("DOUBLE")) contentvalues.put(key, new Double(value)); if (type.toUpperCase().equals("FLOAT")) contentvalues.put(key, new Float(value)); if (type.toUpperCase().equals("LONG")) contentvalues.put(key, new Long(value)); if (type.toUpperCase().equals("SHORT")) contentvalues.put(key, new Short(value)); } catch (Exception e) { Log.e("mercury", "Error with argument " + current); } } return contentvalues; }
From source file:Main.java
/** * Gets the boolean property from the properties object. * @param key the key of the boolean property * @param defaultValue the default value if the property doesn't exist * @param properties the properties object to get the property from * @return the property value, defaultValue if the property doesn't exist *//*from w w w . j av a2s . co m*/ public static boolean getBoolean(String key, boolean defaultValue, Properties properties) { if (properties.containsKey(key)) { return Boolean.valueOf(properties.getProperty(key, "false")); } else { return defaultValue; } }
From source file:com.laex.cg2d.model.util.BooleanUtil.java
/** * To bool./*from ww w.j ava 2 s . c o m*/ * * @param value * the value * @return the boolean */ public static Boolean toBool(Object value) { String val = value.toString(); if (StringUtils.isNumeric(val)) { return parseInteger(value); } return Boolean.valueOf(value.toString()); }
From source file:Main.java
public static boolean getBooleanValue(Element booleanElement) { String elementValue = getTextContent(booleanElement); return Boolean.valueOf(elementValue); }
From source file:Main.java
private static Map<String, Boolean> parseFeatures(String features) { Map<String, Boolean> map = new HashMap<>(); String[] featuresList = features.split("\\n"); int len$ = featuresList.length; for (int i$ = 0; i$ < len$; ++i$) { String element = featuresList[i$]; String[] keyValue = element.split("\\s"); if (keyValue.length != 2) { throw new IllegalArgumentException("Wrong format for \'features\' input field!"); }//from w ww. j av a2 s .co m map.put(keyValue[0], Boolean.valueOf(keyValue[1])); } return map; }
From source file:Main.java
/** * //from w ww.jav a 2 s . c o m * @param account * @param accountManager * @return true if Salt was saved on the server */ public static boolean isSaltSaved(Account account, AccountManager accountManager) { return Boolean.valueOf(accountManager.getUserData(account, PRIVATE_KEY_SALTSAVED)); }
From source file:Main.java
/** * Returns attribute as boolean for class * * @param elem//from w w w.j ava 2 s . c o m * @param attribName * @param defaultVal * @return */ public static boolean getAttributeAsBoolean(Element elem, String attribName, boolean defaultVal) { String atribVal = elem.getAttribute(attribName); boolean retVal = defaultVal; try { retVal = Boolean.valueOf(atribVal).booleanValue(); } catch (Exception e) { } return retVal; }
From source file:Main.java
private static boolean getElementBooleanValue(Element element, String attribute, boolean defaultValue) { if (!element.hasAttribute(attribute)) return defaultValue; return Boolean.valueOf(getElementStringValue(element, attribute)).booleanValue(); }