Example usage for java.lang Boolean booleanValue

List of usage examples for java.lang Boolean booleanValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public boolean booleanValue() 

Source Link

Document

Returns the value of this Boolean object as a boolean primitive.

Usage

From source file:com.icesoft.faces.context.effects.CurrentStyle.java

/**
 * Apply css changes to rendered component
 *
 * @param facesContext/*from ww w . j  av  a 2s  . c om*/
 * @param uiComponent
 * @param targetElement
 * @param style
 */
public static void apply(FacesContext facesContext, UIComponent uiComponent, Element targetElement,
        String style, ResponseWriter writer) {
    if (targetElement == null && writer == null) {
        DOMContext domContext = DOMContext.getDOMContext(facesContext, uiComponent);
        Object node = domContext.getRootNode();
        if (node == null || !(node instanceof Element)) {
            return;
        }
        Element root = (Element) node;
        targetElement = root;
    }
    String jspStyle = (String) uiComponent.getAttributes().get("style");
    if (log.isTraceEnabled()) {
        if (jspStyle != null) {
            log.trace("Existing style [" + jspStyle + "]");
        }
    }

    if (style != null) {
        if (jspStyle == null) {
            jspStyle = "";
        }
        jspStyle += style;
    }

    Boolean visibility = (Boolean) uiComponent.getAttributes().get("visible");
    // default to true if visibility is null
    boolean visible = true;
    if (visibility != null) {
        visible = visibility.booleanValue();
    }
    CurrentStyle currentStyle = (CurrentStyle) uiComponent.getAttributes().get("currentStyle");
    if (currentStyle != null) {
        String appendedStyle = currentStyle.cssString;

        currentStyle.lastCssString = currentStyle.cssString;
        if (appendedStyle != null) {
            if (jspStyle == null) {
                jspStyle = appendedStyle;
            } else {
                jspStyle += ";" + appendedStyle;
            }
        }

    }

    if (visible) {
        if (jspStyle != null) {
            int startI = jspStyle.indexOf(DISPLAY_OFF);
            if (startI != -1) {
                String start = "";
                if (startI > 0) {
                    start = jspStyle.substring(0, startI);
                }
                int endI = startI + DISPLAY_OFF.length();
                String end = "";
                if (endI < jspStyle.length()) {
                    end = jspStyle.substring(endI);
                }
                jspStyle = start + end;
            }
        }
    } else {

        if (jspStyle == null) {
            jspStyle = DISPLAY_OFF;
        } else {
            jspStyle += DISPLAY_OFF;
        }
    }
    if (log.isTraceEnabled()) {
        if (jspStyle != null) {
            log.trace("JSP Style [" + jspStyle + "]");
        }
    }
    if (targetElement != null) {
        if (jspStyle != null && jspStyle.length() > 0)
            targetElement.setAttribute(HTML.STYLE_ATTR, jspStyle);
        else
            targetElement.removeAttribute(HTML.STYLE_ATTR);
    }
    if (writer != null && jspStyle != null) {
        try {
            writer.writeAttribute(HTML.STYLE_ATTR, jspStyle, null);
        } catch (IOException exception) {
            if (log.isErrorEnabled()) {
                log.error("Exception setting style attribute", exception);
            }
        }
    }
}

From source file:gridool.replication.ReplicationManager.java

public static boolean waitForReplicationToFinish(final GridTask task, final GridJobFuture<Boolean> future) {
    final Boolean succeed;
    try {//  www.  ja va  2s.c  om
        succeed = future.get();
    } catch (InterruptedException e) {
        LOG.warn(e);
        return false;
    } catch (ExecutionException e) {
        LOG.error(e);
        return false;
    }
    if (succeed == null || !succeed.booleanValue()) {
        return false;
    }
    return true;
}

From source file:com.borqs.sync.server.contact.MergeUtils.java

/**
 *
 *//*from w w  w  .j  av a2  s.  co  m*/
public static MergeResult compareBoolean(Boolean booleanA, Boolean booleanB) {

    MergeResult result = null;

    if (booleanA == null && booleanB == null) {
        return new MergeResult(false, false);
    }

    if (booleanA != null && booleanB == null) {
        result = new MergeResult();
        result.addPropertyB("Boolean", booleanA.booleanValue() + ", null");
        return result;
    }

    if (booleanA == null && booleanB != null) {
        result = new MergeResult();
        result.addPropertyA("Boolean", "null, " + booleanB.booleanValue());
        return result;
    }

    if (booleanA.booleanValue() != booleanB.booleanValue()) {
        //
        // The values are different so
        // an update on booleanB is required
        //
        result = new MergeResult();
        result.addPropertyB("Boolean", booleanA.booleanValue() + ", " + booleanB.booleanValue());
        return result;
    }

    return new MergeResult(false, false);
}

From source file:com.evolveum.liferay.usercreatehook.service.CustomUserLocalServiceImpl.java

private static void internalUpdatePassword(User user, String password) throws SystemException, PortalException {
    LOG.info("internalUpdatePassword u:" + user.getScreenName());
    Boolean userExists = callWSToCheckUserExistency(user.getScreenName(), user.getCompanyId());
    if (userExists != null) {
        if (userExists.booleanValue()) {
            // user already exists in midpoint - just change his password
            try {
                callWSForPasswordChange(user.getScreenName(), password, user.getCompanyId());
            } catch (Exception e) {
                if (e instanceof WSException) {
                    LOG.error("Retrying user creation", e);
                    createUserInMidpoint(user);
                } else {
                    LOG.error(e);/*from   w ww. j  ava2s.c om*/
                }
            }
        } else {
            // user doesn't exist - create him in midpoint
            createUserInMidpoint(user);
        }
    }
}

From source file:de.cosmocode.collections.utility.Convert.java

/**
 * Parses a value of a generic type// www  .j a v  a 2s  .com
 * into a boolean.
 * 
 * @param value the value being parsed
 * @param defaultValue the default value if value can't be parsed into a boolean
 * @return the parsed boolean or the defaultValue if value can't be parsed into a boolean
 */
public static boolean intoBoolean(Object value, boolean defaultValue) {
    final Boolean b = doIntoBoolean(value);
    return b == null ? defaultValue : b.booleanValue();
}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

/**
 * INTERNAL: Returns true if the form is read-only.
 * @param request The current request object
 * @return a boolean object indicating whether the form is read-only or not
 *///from   ww  w. j ava  2 s.  c  o  m
public static boolean isFormReadOnly(ServletRequest request) {
    Boolean value = (Boolean) request.getAttribute(Constants.OKS_FORM_READONLY);
    return value != null && value.booleanValue();
}

From source file:com.alkacon.opencms.newsletter.CmsNewsletterManager.java

/**
 * Returns if the given user is active to receive newsletter emails for the given group.<p>
 * /*from w  w w. j a va2  s  .c o  m*/
 * @param user the user to check
 * @param groupName the name of the group the user is a member of
 * @return true if the given user is active to receive newsletter emails, otherwise false
 */
public static boolean isActiveUser(CmsUser user, String groupName) {

    Boolean active = (Boolean) user.getAdditionalInfo(USER_ADDITIONALINFO_ACTIVE + groupName);
    return (((active != null) && active.booleanValue()) || (active == null)) && user.isEnabled();
}

From source file:com.aurel.track.admin.customize.scripting.GroovyScriptExecuter.java

/**
 * Executes the Groovy script guard. If the guard is not satisfied then the
 * script should set the guardPassed boolean value to false in the return
 * binding//from  w  w w  .  j av  a  2  s.c  om
 *
 * @param handlerClass
 * @param workItemBean
 * @param personID
 * @param inputBinding
 *            context coming from specific source (e-mail)
 * @return
 */
public static boolean executeGuardScript(String handlerClass, TWorkItemBean workItemBean, Integer personID,
        Map<String, Object> inputBinding) {
    if (inputBinding == null) {
        inputBinding = new HashMap<String, Object>();
    }
    inputBinding.put(BINDING_PARAMS.USER_ID, personID);
    inputBinding.put(BINDING_PARAMS.ISSUE, workItemBean);
    inputBinding.put(BINDING_PARAMS.ISSUE_ORIGINAL, workItemBean);
    Map<String, Object> returnBinding = executeGroovyHandler(handlerClass, inputBinding);
    Boolean guardPassed = null;
    if (returnBinding != null) {
        guardPassed = (Boolean) returnBinding.get(BINDING_PARAMS.GUARD_PASSED);
        if (guardPassed != null) {
            LOGGER.debug("Guard " + handlerClass + " passed: " + guardPassed.booleanValue());
        }
    } else {
        LOGGER.debug("Guard " + handlerClass + " does not exists");
    }
    if (guardPassed == null) {
        return true;
    }
    return guardPassed.booleanValue();
}

From source file:com.evolveum.midpoint.prism.xml.XmlTypeConverter.java

public static String toXmlTextContent(Object val, QName elementName) {
    if (val == null) {
        // if no value is specified, do not create element
        return null;
    }/*from w ww . j  a  v a 2  s  . co m*/
    Class type = XsdTypeMapper.getTypeFromClass(val.getClass());
    if (type == null) {
        throw new IllegalArgumentException(
                "No type mapping for conversion: " + val.getClass() + "(element " + elementName + ")");
    }
    if (type.equals(String.class)) {
        return (String) val;
    }
    if (type.equals(PolyString.class)) {
        return ((PolyString) val).getNorm();
    } else if (type.equals(char.class) || type.equals(Character.class)) {
        return ((Character) val).toString();
    } else if (type.equals(File.class)) {
        return ((File) val).getPath();
    } else if (type.equals(int.class) || type.equals(Integer.class)) {
        return ((Integer) val).toString();
    } else if (type.equals(long.class) || type.equals(Long.class)) {
        return ((Long) val).toString();
    } else if (type.equals(byte.class) || type.equals(Byte.class)) {
        return ((Byte) val).toString();
    } else if (type.equals(float.class) || type.equals(Float.class)) {
        return ((Float) val).toString();
    } else if (type.equals(double.class) || type.equals(Double.class)) {
        return ((Double) val).toString();
    } else if (type.equals(byte[].class)) {
        byte[] binaryData = (byte[]) val;
        return Base64.encodeBase64String(binaryData);
    } else if (type.equals(Boolean.class)) {
        Boolean bool = (Boolean) val;
        if (bool.booleanValue()) {
            return XsdTypeMapper.BOOLEAN_XML_VALUE_TRUE;
        } else {
            return XsdTypeMapper.BOOLEAN_XML_VALUE_FALSE;
        }
    } else if (type.equals(BigInteger.class)) {
        return ((BigInteger) val).toString();
    } else if (type.equals(BigDecimal.class)) {
        return ((BigDecimal) val).toString();
    } else if (type.equals(GregorianCalendar.class)) {
        XMLGregorianCalendar xmlCal = createXMLGregorianCalendar((GregorianCalendar) val);
        return xmlCal.toXMLFormat();
    } else if (XMLGregorianCalendar.class.isAssignableFrom(type)) {
        return ((XMLGregorianCalendar) val).toXMLFormat();
    } else if (Duration.class.isAssignableFrom(type)) {
        return ((Duration) val).toString();
    } else if (type.equals(ItemPath.class)) {
        XPathHolder xpath = new XPathHolder((ItemPath) val);
        return xpath.getXPath();
    } else {
        throw new IllegalArgumentException(
                "Unknown type for conversion: " + type + "(element " + elementName + ")");
    }
}

From source file:de.cosmocode.collections.utility.Convert.java

/**
 * Parses a value of a generic type//from w w  w . ja  v  a2 s  .  com
 * into a boolean.
 * 
 * @param value the value being parsed
 * @return the parsed boolean
 * @throws IllegalArgumentException if conversion failed
 */
public static boolean intoBoolean(Object value) {
    final Boolean b = doIntoBoolean(value);
    if (b == null) {
        throw fail(value, boolean.class);
    } else {
        return b.booleanValue();
    }
}