Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

In this page you can find the example usage for java.lang Boolean valueOf.

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:Utils.java

public static boolean getElementBooleanValue(Document document, Element parent, String element) {
    return Boolean.valueOf(getElementStringValue(document, parent, element)).booleanValue();
}

From source file:Main.java

public static boolean isMeizuSecurity(Context context) {
    if (!isSecVer(context)) {
        return false;
    }/*from w  ww.  j av a  2  s .c  o  m*/
    Boolean valueOf = Boolean.valueOf(false);
    try {
        Boolean bool;
        Class cls = Class.forName("android.os.Build");
        Field field = cls.getField("MeizuSecurity");
        field.setAccessible(true);
        bool = (Boolean) field.get(cls);
        return bool;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (Error e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return valueOf.booleanValue();
}

From source file:Main.java

/**
 * Utility method that puts the named boolean value to the given map.
 *
 * @param properties map of properties (String -> Object)
 * @param name       property name//from  ww  w .  j a va  2  s . c om
 * @param value      property value
 */
private static void putBoolean(Map<String, Object> properties, String name, boolean value) {
    properties.put(name, Boolean.valueOf(value));
}

From source file:Main.java

public static Object getPropertyValue(Element element) {
    NamedNodeMap map = element.getAttributes();
    map.removeNamedItem(NAME_ATTR);/*from   w  ww  .j  a va 2s  .com*/

    if (map.item(0).getNodeName().equals(STRING_ATTR))
        return map.item(0).getNodeValue();
    else if (map.item(0).getNodeName().equals(INTEGER_ATTR))
        return new Integer(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(DOUBLE_ATTR))
        return new Double(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(FLOAT_ATTR))
        return new Float(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(BOOLEAN_ATTR))
        return Boolean.valueOf(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(COLOR_ATTR)) {
        String[] rgb = map.item(0).getNodeValue().split(",");
        return new Color(new Integer(rgb[0]), new Integer(rgb[1]), new Integer(rgb[2]));
    } else if (map.item(0).getNodeName().equals(FONT_ATTR)) {
        String[] font = map.item(0).getNodeValue().split(",");
        return new Font(font[0], new Integer(font[1]), new Integer(font[2]));
    } else {
        return null;
    }
}

From source file:com.sixt.service.framework.FeatureFlags.java

public static boolean shouldExposeErrorsToHttp(ServiceProperties serviceProps) {
    String value = serviceProps.getProperty(FLAG_EXPOSE_ERRORS_HTTP);
    if (StringUtils.isNotEmpty(value) && Boolean.valueOf(value)) {
        return true;
    } else {//  w  w  w  . j a  v a  2  s  .  co  m
        return false;
    }
}

From source file:edu.isi.misd.tagfiler.security.TagFilerSecurity.java

/**
 * Loads any security settings into the current environment.
 *///from w  w w.j av  a 2  s . com
@SuppressWarnings("deprecation")
public static void loadSecuritySettings() {

    // Read whether or not to allow self-signed certificates to be
    // authenticated,
    // if so then load a custom socket factory that allows them to be
    // trusted
    if (Boolean.valueOf(TagFilerProperties.getProperty("tagfiler.security.AllowSelfSignedCerts"))) {
        Protocol https = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
        Protocol.registerProtocol("https", https);
    }
}

From source file:Main.java

public static Object getPropertyValue(Element element) {
    NamedNodeMap map = element.getAttributes();
    map.removeNamedItem(NAME_ATTR);/*from   w  ww .java 2s  . com*/

    if (map.item(0).getNodeName().equals(STRING_ATTR)) {
        return map.item(0).getNodeValue();
    } else if (map.item(0).getNodeName().equals(INTEGER_ATTR)) {
        return new Integer(map.item(0).getNodeValue());
    } else if (map.item(0).getNodeName().equals(DOUBLE_ATTR)) {
        return new Double(map.item(0).getNodeValue());
    } else if (map.item(0).getNodeName().equals(FLOAT_ATTR)) {
        return new Float(map.item(0).getNodeValue());
    } else if (map.item(0).getNodeName().equals(BOOLEAN_ATTR)) {
        return Boolean.valueOf(map.item(0).getNodeValue());
    } else if (map.item(0).getNodeName().equals(COLOR_ATTR)) {
        String[] rgb = map.item(0).getNodeValue().split(",");
        return new Color(new Integer(rgb[0]), new Integer(rgb[1]), new Integer(rgb[2]));
    } else if (map.item(0).getNodeName().equals(FONT_ATTR)) {
        String[] font = map.item(0).getNodeValue().split(",");
        return new Font(font[0], new Integer(font[1]), new Integer(font[2]));
    } else {
        return null;
    }
}

From source file:Main.java

public static Set<Boolean> toSet(boolean... array) {
    if (isEmpty(array)) {
        return new HashSet<>(0);
    }//  w w w  .j  a  v a2  s  .c om
    Set<Boolean> set = new HashSet<>(array.length);
    for (boolean b : array) {
        set.add(Boolean.valueOf(b));
    }
    return set;
}

From source file:Main.java

/**
 * Returns an attribute value as a boolean value.
 * @param attributes the Attributes object
 * @param name the name of the attribute
 * @param defaultValue the default value if the attribute is not specified
 * @return the attribute value as a boolean
 *//*from   www .j a  va2 s . c om*/
public static boolean getAttributeAsBoolean(Attributes attributes, String name, boolean defaultValue) {
    String s = attributes.getValue(name);
    if (s == null) {
        return defaultValue;
    } else {
        return Boolean.valueOf(s).booleanValue();
    }
}

From source file:Main.java

/**
 * Decodes a String into an object of the specified type. If the object
 * type is not supported, null will be returned.
 *
 * @param type the type of the property.
 * @param value the encode String value to decode.
 * @return the String value decoded into the specified type.
 * @throws Exception If decoding failed due to an error.
 *//*from  w  ww. j av  a 2  s  . co m*/
private static Object decode(Class type, String value) throws Exception {
    if (type.getName().equals("java.lang.String")) {
        return value;
    }
    if (type.getName().equals("boolean")) {
        return Boolean.valueOf(value);
    }
    if (type.getName().equals("int")) {
        return Integer.valueOf(value);
    }
    if (type.getName().equals("long")) {
        return Long.valueOf(value);
    }
    if (type.getName().equals("float")) {
        return Float.valueOf(value);
    }
    if (type.getName().equals("double")) {
        return Double.valueOf(value);
    }
    if (type.getName().equals("java.lang.Class")) {
        return Class.forName(value);
    }
    return null;
}