List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:Main.java
public static boolean getOptionalBoolean(Element element, String attribute, boolean defaultValue) { String s = element.getAttribute(attribute); if (s == null || "".equals(s)) { return defaultValue; } else {// w ww . ja v a2 s . c o m return Boolean.valueOf(s).booleanValue(); } }
From source file:Main.java
private static boolean getPreferenceBoolean(SharedPreferences sharedPref, Context context, int StrRes, int strResDefValue) { return sharedPref.getBoolean(context.getString(StrRes), Boolean.valueOf(context.getString(strResDefValue))); }
From source file:Main.java
public static ArrayList<Boolean> asBooleanList(String[] stringArray) { ArrayList<Boolean> result = new ArrayList<Boolean>(); if (stringArray != null) { for (String string : stringArray) { result.add(Boolean.valueOf(string)); }//from ww w . ja v a 2s. co m } return result; }
From source file:Main.java
public static boolean getAsBoolean(final ContentValues values, final String key, final boolean def) { if (values == null || key == null) return def; final Object value = values.get(key); if (value == null) return def; return Boolean.valueOf(value.toString()); }
From source file:Main.java
public static boolean readBoolAttribute(XMLStreamReader reader, String attributeName) { return Boolean.valueOf(reader.getAttributeValue(null, attributeName)); }
From source file:Main.java
static Boolean getBooleanValue(Element ele, String tagName) { String value = getTextValue(ele, tagName); // LOGGER.info("tagName: |" + tagName + "|"); // LOGGER.info("value: " + value); if (value != null) { if (isBoolean(value)) return Boolean.valueOf(value); }//from w ww . jav a2s. c o m return null; }
From source file:Main.java
/** * @param eElement element containing boolean attribute * @param atribute name of attribute in element * @return value of boolean or null if attribute not exists *//*from ww w .j av a2 s .c o m*/ public static Boolean getBooleanElementAtribute(Element eElement, String atribute) { String atr = eElement.getAttribute(atribute); if (atr != null && !atr.isEmpty()) { return Boolean.valueOf(atr); } return null; }
From source file:Main.java
public static boolean getElementBooleanValue(Element element, String attribute, boolean defaultValue) { if (!element.hasAttribute(attribute)) return defaultValue; return Boolean.valueOf(getElementStringValue(element, attribute)).booleanValue(); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T parse(Class<T> type, String stringValue) throws IllegalArgumentException { if (type.equals(String.class)) { return (T) stringValue; }/*from w w w . j a v a 2 s .c o m*/ if (type.equals(Boolean.class) || type.equals(boolean.class)) { return (T) Boolean.valueOf(stringValue); } try { if (type.equals(Integer.class) || type.equals(int.class)) { return (T) Integer.valueOf(stringValue); } if (type.equals(Long.class) || type.equals(long.class)) { return (T) Long.valueOf(stringValue); } if (type.equals(Short.class) || type.equals(short.class)) { return (T) Short.valueOf(stringValue); } if (type.equals(Byte.class) || type.equals(byte.class)) { return (T) Byte.valueOf(stringValue); } if (type.equals(Double.class) || type.equals(double.class)) { return (T) Double.valueOf(stringValue); } if (type.equals(Float.class) || type.equals(float.class)) { return (T) Float.valueOf(stringValue); } if (type.equals(File.class)) { return (T) new File(stringValue); } } catch (final NumberFormatException e) { throw new IllegalArgumentException(e.getMessage(), e); } if (type.isEnum()) { @SuppressWarnings("rawtypes") final Class enumType = type; return (T) Enum.valueOf(enumType, stringValue); } throw new IllegalArgumentException("Can't handle type " + type); }
From source file:Main.java
/** * Returns the boolean value of the named attribute for the given node * If no such attribute exists, returns false *///from w ww. ja v a 2s . c o m public static boolean getBoolValue(Node node, String name) { // Look for the attribute Node att = get_named_attribute(node, name); if (att != null) { // Return the value return Boolean.valueOf(att.getNodeValue()).booleanValue(); } else { // No such attribute return false; } }