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:org.alfresco.extension.scripting.webscripts.JavascriptServicePost.java

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    Boolean shellEnabled = Boolean.valueOf(req.getParameter("shellEnabled"));
    if (!shellEnabled.equals(getJavascriptShellService().isRunning())) {
        getJavascriptShellService().toggleEnabled();
    }/*from   w  w  w.  j  a  v  a2s . c o  m*/
    return super.executeImpl(req, status);
}

From source file:com.arvato.thoroughly.util.security.impl.AES128AttributeEncryptionStrategy.java

@Override
public boolean isEnabled() {
    return (Boolean.valueOf((getKeySpec() != null) && ((isEncryptionAndDecryptionWorking()))).booleanValue());
}

From source file:com.glaf.core.util.ParamUtils.java

public static Boolean getBoolean(Map<String, Object> dataMap, String key) {
    Boolean result = null;/*w w w . jav a  2s  .com*/
    if (dataMap == null || key == null) {
        return result;
    }
    Object value = dataMap.get(key);
    if (value == null) {
        value = dataMap.get(key.toLowerCase());
    }
    if (value == null) {
        value = dataMap.get(key.toUpperCase());
    }
    if (value != null) {
        if (value instanceof Boolean) {
            result = (Boolean) value;
        } else if (value instanceof String) {
            result = Boolean.valueOf(value.toString());
        } else {
            result = Boolean.valueOf(value.toString());
        }
    }
    return result;
}

From source file:com.alibaba.jstorm.client.ConfigExtension.java

public static void setTopologyDebugRecvTuple(Map conf, boolean debug) {
    conf.put(TOPOLOGY_DEBUG_RECV_TUPLE, Boolean.valueOf(debug));
}

From source file:com.github.xdcrafts.flower.spring.impl.xml.PredicateSelectorBeanDefinitionHandler.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {
    final String required = element.getAttribute("required");
    if (required != null && !required.isEmpty()) {
        bean.addPropertyValue("required", Boolean.valueOf(required));
    }/* w w w  . ja  v  a  2 s  .c  o  m*/
}

From source file:com.bfd.harpc.main.ConfigHelper.java

/**
 * ??/*from  w w w.  j  ava  2 s .  c  o m*/
 * <p>
 * 
 * @param configObject
 *            ?
 * @param configPrefix
 *            ??
 * @param configuration
 *            {@link PropertiesConfiguration}
 * @throws RpcException
 */
public static void initConfig(Object configObject, String configPrefix, PropertiesConfiguration configuration)
        throws RpcException {
    Method[] methods = configObject.getClass().getMethods();
    for (Method method : methods) {
        if (method.getName().length() > 3 && method.getName().startsWith("set")
                && method.getParameterTypes().length == 1) {
            String attribute = method.getName().substring(3);
            char ch = attribute.charAt(0);
            attribute = Character.toLowerCase(ch) + attribute.substring(1);
            String value = configuration.getProperty(configPrefix + attribute, "");

            try {
                if (StringUtils.isNotEmpty(value)) {
                    Type type = method.getParameterTypes()[0];
                    if (type == boolean.class) {
                        method.invoke(configObject, Boolean.valueOf(value));
                    } else if (type == int.class) {
                        method.invoke(configObject, Integer.valueOf(value));
                    } else if (type == long.class) {
                        method.invoke(configObject, Long.valueOf(value));
                    } else {
                        method.invoke(configObject, value);
                    }
                }
            } catch (Exception e) {
                LOGGER.error("Init config error", e);
                throw new RpcException(RpcException.CONFIG_EXCEPTION, e);
            }
        }
    }
}

From source file:org.jsconf.core.tag.ConfigFactoryBeanParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addPropertyValue("resourceName", element.getAttribute("resource"));
    bean.addPropertyValue("scanPackage", element.getAttribute("scanPackage"));
    bean.addPropertyValue("format", element.getAttribute("format"));
    bean.addPropertyValue("strict", Boolean.valueOf(element.getAttribute("strict")));
    bean.addPropertyValue("definition", Boolean.valueOf(element.getAttribute("definition")));
    bean.addPropertyValue("profiles", Boolean.valueOf(element.getAttribute("profiles")));
}

From source file:com.vaadin.sass.internal.visitor.IfElseNodeHandler.java

public static void traverse(IfElseDefNode node) throws Exception {

    for (final Node child : node.getChildren()) {
        if (child instanceof IfNode) {
            try {
                String expression = ((IfElseNode) child).getExpression();
                // We need to add ' ' for strings in the expression for
                // jexl to understand that is should do a string
                // comparison
                expression = replaceStrings(expression);
                Expression e = evaluator.createExpression(expression);
                try {
                    Object eval = e.evaluate(null);

                    Boolean result = false;
                    if (eval instanceof Boolean) {
                        result = (Boolean) eval;
                    } else if (eval instanceof String) {
                        result = Boolean.valueOf((String) eval);
                    }//from   w w w. java2  s .  co  m

                    if (result) {
                        replaceDefNodeWithCorrectChild(node, node.getParentNode(), child);
                        break;
                    }
                } catch (ClassCastException ex) {
                    throw new ParseException(
                            "Invalid @if/@else in scss file, not a boolean expression : " + child.toString());
                } catch (NullPointerException ex) {
                    throw new ParseException(
                            "Invalid @if/@else in scss file, not a boolean expression : " + child.toString());
                }
            } catch (JexlException e) {
                throw new ParseException("Invalid @if/@else in scss file for " + child.toString());
            }
        } else {
            if (!(child instanceof ElseNode)
                    && node.getChildren().indexOf(child) == node.getChildren().size() - 1) {
                throw new ParseException("Invalid @if/@else in scss file for " + node);
            } else {
                replaceDefNodeWithCorrectChild(node, node.getParentNode(), child);
                break;
            }
        }
    }

    node.getParentNode().removeChild(node);
}

From source file:com.qualogy.qafe.web.ContextLoaderHelper.java

private static boolean checkValueOfContextParameter(String field) {
    if (ApplicationCluster.getInstance().getConfigurationItem(field) != null) {
        if (Boolean.valueOf(ApplicationCluster.getInstance().getConfigurationItem(field))) {
            return true;
        } else {/*from   w  w w  .j a  v a2  s.co m*/
            return false;
        }
    } else {
        return true;
    }
}

From source file:com.alibaba.napoli.metamorphosis.utils.DiamondUtils.java

/**
 * ?zk??NPE//  w w  w. j  av  a  2s  .c o  m
 * 
 * @param diamondManager
 * @param timeout
 * @return
 */
// public static ZKConfig getZkConfig(final DiamondManager diamondManager,
// final long timeout) {
// final Properties props =
// diamondManager.getAvailablePropertiesConfigureInfomation(timeout);
// if (props != null) {
// log.info("diamondzk?" + props);
// return getZkConfig(props);
// }
// return null;
// }

public static ZKConfig getZkConfig(final Properties props) {
    if (props != null) {
        boolean zkEnable = true;
        if (!com.alibaba.napoli.gecko.core.util.StringUtils.isBlank(props.getProperty("zk.zkEnable"))) {
            zkEnable = Boolean.valueOf(props.getProperty("zk.zkEnable"));
        }
        String zkRoot = "/meta";
        if (!com.alibaba.napoli.gecko.core.util.StringUtils.isBlank(props.getProperty("zk.zkRoot"))) {
            zkRoot = props.getProperty("zk.zkRoot");
        }
        final ZKConfig rt = new ZKConfig(zkRoot, props.getProperty("zk.zkConnect"),
                Integer.parseInt(props.getProperty("zk.zkSessionTimeoutMs")),
                Integer.parseInt(props.getProperty("zk.zkConnectionTimeoutMs")),
                Integer.parseInt(props.getProperty("zk.zkSyncTimeMs")), zkEnable);

        return rt;
    } else {
        throw new NullPointerException("Null zk config");
    }
}