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:org.cloudfoundry.identity.uaa.util.UaaHttpRequestUtils.java

public static boolean isAcceptedInvitationAuthentication() {
    try {/*www . ja  v  a  2s . co m*/
        RequestAttributes attr = RequestContextHolder.currentRequestAttributes();
        if (attr != null) {
            Boolean result = (Boolean) attr.getAttribute("IS_INVITE_ACCEPTANCE",
                    RequestAttributes.SCOPE_SESSION);
            if (result != null) {
                return result.booleanValue();
            }
        }
    } catch (IllegalStateException x) {
        //nothing bound on thread.
        logger.debug("Unable to retrieve request attributes looking for invitation.");

    }
    return false;
}

From source file:net.sourceforge.fenixedu.presentationTier.validator.form.ValidateMultiBoxWithSelectAllCheckBox.java

public static boolean validate(Object bean, ValidatorAction va, Field field, ActionMessages errors,
        HttpServletRequest request, ServletContext application) {

    try {//from   w  w w. ja  v a  2 s.c  om

        DynaActionForm form = (DynaActionForm) bean;
        Boolean selectAllBox = (Boolean) form.get(field.getProperty());
        String sProperty2 = field.getVarValue("secondProperty");
        String[] multiBox = (String[]) form.get(sProperty2);

        if (((selectAllBox != null) && selectAllBox.booleanValue())
                || (multiBox != null) && (multiBox.length > 0)) {
            return true;
        }
        errors.add(field.getKey(), new ActionMessage("errors.required.checkbox", field.getArg(0).getKey()));
        return false;

    } catch (Exception e) {
        errors.add(field.getKey(), new ActionMessage("errors.required.checkbox", field.getArg(0).getKey()));
        return false;
    }

}

From source file:biz.wolschon.finance.jgnucash.actions.FileBugInBrowserAction.java

/**
        //from  w  ww  . j a  v  a 2s .  com
 * Open the given URL in the default-browser.
 * @param url the URL to open
 * @return false if it did not work
 */
@SuppressWarnings("unchecked")
public static boolean showDocument(final URL url) {

    if (myJNLPServiceManagerObject == null) {
        myJNLPServiceManagerObject = getJNLPServiceManagerObject();
    }

    // we cannot use JNLP -> make an educated guess
    if (myJNLPServiceManagerObject == null) {
        try {
            String osName = System.getProperty("os.name");
            if (osName.startsWith("Mac OS")) {
                Class fileMgr = Class.forName("com.apple.eio.FileManager");
                Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
                openURL.invoke(null, new Object[] { url });
            } else if (osName.startsWith("Windows")) {
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
            } else { //assume Unix or Linux
                String[] browsers = { "x-www-browser", "firefox", "iceweasle", "opera", "konqueror", "epiphany",
                        "mozilla", "netscape" };
                String browser = null;
                for (int count = 0; count < browsers.length && browser == null; count++) {
                    if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) {
                        browser = browsers[count];
                    }
                    if (browser == null) {
                        return false;
                    } else {
                        Runtime.getRuntime().exec(new String[] { browser, url.toString() });
                        return true;
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.error("Error attempting to launch web browser natively.", e);
            JOptionPane.showMessageDialog(null,
                    "Error attempting to launch web browser:\n" + e.getLocalizedMessage());
        }
    }

    if (myJNLPServiceManagerObject != null) {
        try {
            Method method = myJNLPServiceManagerObject.getClass().getMethod("showDocument",
                    new Class[] { URL.class });
            Boolean resultBoolean = (Boolean) method.invoke(myJNLPServiceManagerObject, new Object[] { url });
            return resultBoolean.booleanValue();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    "Error attempting to launch web browser:\n" + ex.getLocalizedMessage());
        }
    }

    return false;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.teachersBody.ReadProfessorshipsAndResponsibilitiesByExecutionDegreeAndExecutionPeriod.java

protected static List getDetailedProfessorships(List professorships, final List responsibleFors,
        final Integer teacherType) {
    List detailedProfessorshipList = (List) CollectionUtils.collect(professorships, new Transformer() {

        @Override/*from  w ww.j a v  a 2s  .  c  o  m*/
        public Object transform(Object input) {
            Professorship professorship = (Professorship) input;

            InfoProfessorship infoProfessorShip = InfoProfessorship.newInfoFromDomain(professorship);

            List executionCourseCurricularCoursesList = getInfoCurricularCourses(
                    professorship.getExecutionCourse());

            DetailedProfessorship detailedProfessorship = new DetailedProfessorship();

            Boolean isResponsible = Boolean.valueOf(professorship.getResponsibleFor());

            if ((teacherType.intValue() == 1) && (!isResponsible.booleanValue())) {
                return null;
            }

            detailedProfessorship.setResponsibleFor(isResponsible);

            detailedProfessorship.setInfoProfessorship(infoProfessorShip);
            detailedProfessorship.setExecutionCourseCurricularCoursesList(executionCourseCurricularCoursesList);

            return detailedProfessorship;
        }

        private List getInfoCurricularCourses(ExecutionCourse executionCourse) {

            List infoCurricularCourses = (List) CollectionUtils
                    .collect(executionCourse.getAssociatedCurricularCoursesSet(), new Transformer() {

                        @Override
                        public Object transform(Object input) {
                            CurricularCourse curricularCourse = (CurricularCourse) input;

                            InfoCurricularCourse infoCurricularCourse = InfoCurricularCourse
                                    .newInfoFromDomain(curricularCourse);
                            return infoCurricularCourse;
                        }
                    });
            return infoCurricularCourses;
        }
    });

    return detailedProfessorshipList;
}

From source file:AIR.Common.Configuration.AppSettingsHelper.java

private static boolean getBoolean(String key, Boolean defaultValue) {
    String rawValue = get(key);//  ww  w. j a  v  a 2  s .  co  m
    if (!StringUtils.isEmpty(rawValue)) {
        boolean value = Boolean.parseBoolean(rawValue);
        return value;
    }
    if (defaultValue != null)
        return defaultValue.booleanValue();
    else
        return false;
}

From source file:de.pribluda.android.jsonmarshaller.JSONMarshaller.java

/**
 * recursively marshall to JSON/*from   www.j a va  2s  .c o m*/
 *
 * @param sink
 * @param object
 */
static void marshallRecursive(JSONObject sink, Object object)
        throws JSONException, InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    // nothing to marshall
    if (object == null)
        return;
    // primitive object is a field and does not interes us here
    if (object.getClass().isPrimitive())
        return;
    // object not null,  and is not primitive - iterate through getters
    for (Method method : object.getClass().getMethods()) {
        // our getters are parameterless and start with "get"
        if ((method.getName().startsWith(GETTER_PREFIX) && method.getName().length() > BEGIN_INDEX
                || method.getName().startsWith(IS_PREFIX) && method.getName().length() > IS_LENGTH)
                && (method.getModifiers() & Modifier.PUBLIC) != 0 && method.getParameterTypes().length == 0
                && method.getReturnType() != void.class) {
            // is return value primitive?
            Class<?> type = method.getReturnType();
            if (type.isPrimitive() || String.class.equals(type)) {
                // it is, marshall it
                Object val = method.invoke(object);
                if (val != null) {
                    sink.put(propertize(method.getName()), val);
                }
                continue;
            } else if (type.isArray()) {
                Object val = marshallArray(method.invoke(object));
                if (val != null) {
                    sink.put(propertize(method.getName()), val);
                }
                continue;
            } else if (type.isAssignableFrom(Date.class)) {
                Date date = (Date) method.invoke(object);
                if (date != null) {
                    sink.put(propertize(method.getName()), date.getTime());
                }
                continue;
            } else if (type.isAssignableFrom(Boolean.class)) {
                Boolean b = (Boolean) method.invoke(object);
                if (b != null) {
                    sink.put(propertize(method.getName()), b.booleanValue());
                }
                continue;
            } else if (type.isAssignableFrom(Integer.class)) {
                Integer i = (Integer) method.invoke(object);
                if (i != null) {
                    sink.put(propertize(method.getName()), i.intValue());
                }
                continue;
            } else if (type.isAssignableFrom(Long.class)) {
                Long l = (Long) method.invoke(object);
                if (l != null) {
                    sink.put(propertize(method.getName()), l.longValue());
                }
                continue;
            } else {
                // does it have default constructor?
                try {
                    if (method.getReturnType().getConstructor() != null) {
                        Object val = marshall(method.invoke(object));
                        if (val != null) {
                            sink.put(propertize(method.getName()), val);
                        }
                        continue;
                    }
                } catch (NoSuchMethodException ex) {
                    // just ignore it here, it means no such constructor was found
                }
            }
        }
    }
}

From source file:com.jdom.junit.utils.AbstractFixture.java

/**
 * Get a randomized value.//  ww w.  j av a  2  s .c o  m
 * 
 * @param value
 *            the value to randomize
 * @param salt
 *            the randomizer to use
 * @return the randomized value
 */
public static Boolean getSaltedValue(Boolean value, int salt) {
    boolean retValuePrimative = value.booleanValue();

    if (salt % 2 != 0) {
        retValuePrimative = !retValuePrimative;
    }

    return new Boolean(retValuePrimative);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.teachersBody.ReadProfessorshipsAndResponsibilitiesByDepartmentAndExecutionPeriod.java

protected static List getDetailedProfessorships(List professorships, final List responsibleFors,
        final Integer teacherType) {

    List detailedProfessorshipList = (List) CollectionUtils.collect(professorships, new Transformer() {

        @Override//from  w  w w .  j a  v a 2s  . c  o m
        public Object transform(Object input) {

            Professorship professorship = (Professorship) input;

            InfoProfessorship infoProfessorShip = InfoProfessorship.newInfoFromDomain(professorship);

            List executionCourseCurricularCoursesList = getInfoCurricularCourses(
                    professorship.getExecutionCourse());

            DetailedProfessorship detailedProfessorship = new DetailedProfessorship();

            Boolean isResponsible = Boolean.valueOf(professorship.getResponsibleFor());

            if ((teacherType.intValue() == 1) && (!isResponsible.booleanValue())) {
                return null;
            }

            detailedProfessorship.setResponsibleFor(isResponsible);

            detailedProfessorship.setInfoProfessorship(infoProfessorShip);
            detailedProfessorship.setExecutionCourseCurricularCoursesList(executionCourseCurricularCoursesList);

            return detailedProfessorship;
        }

        private List getInfoCurricularCourses(ExecutionCourse executionCourse) {

            List infoCurricularCourses = (List) CollectionUtils
                    .collect(executionCourse.getAssociatedCurricularCoursesSet(), new Transformer() {

                        @Override
                        public Object transform(Object input) {

                            CurricularCourse curricularCourse = (CurricularCourse) input;

                            InfoCurricularCourse infoCurricularCourse = InfoCurricularCourse
                                    .newInfoFromDomain(curricularCourse);
                            return infoCurricularCourse;
                        }
                    });
            return infoCurricularCourses;
        }
    });

    return detailedProfessorshipList;
}

From source file:org.mytms.common.web.util.RequestUtil.java

/**
 * Broadleaf "Resolver" and "Filter" classes may need to know if they are allowed to utilize the session.
 * BLC uses a pattern where we will store an attribute in the request indicating whether or not the
 * session can be used.   For example, when using the REST APIs, we typically do not want to utilize the
 * session./* w  w w. ja va2s.co  m*/
 */
public static boolean isOKtoUseSession(WebRequest request) {
    Boolean useSessionForRequestProcessing = (Boolean) request.getAttribute(OK_TO_USE_SESSION,
            WebRequest.SCOPE_REQUEST);
    if (useSessionForRequestProcessing == null) {
        // by default we will use the session
        return true;
    } else {
        return useSessionForRequestProcessing.booleanValue();
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.manager.organizationalStructureManagement.MergeExternalUnits.java

@Atomic
public static void run(Unit fromUnit, Unit destinationUnit, Boolean sendMail) {
    check(RolePredicates.MANAGER_PREDICATE);

    if (fromUnit != null && destinationUnit != null) {

        String fromUnitName = fromUnit.getName();
        String fromUnitID = fromUnit.getExternalId();

        Unit.mergeExternalUnits(fromUnit, destinationUnit);

        if (sendMail != null && sendMail.booleanValue()) {

            String emails = FenixConfigurationManager.getConfiguration().getMergeUnitsEmails();
            if (!StringUtils.isEmpty(emails)) {

                Set<String> resultEmails = new HashSet<String>();
                String[] splitedEmails = emails.split(",");
                for (String email : splitedEmails) {
                    resultEmails.add(email.trim());
                }//from   w ww. j a v a  2 s  .  c  o  m

                // Foi efectuado um merge de unidades externas por {0}[{1}]
                // : Unidade Origem -> {2} [{3}] Unidade Destino -> {4}[{5}]
                final Person person = AccessControl.getPerson();
                final String subject = BundleUtil.getString(Bundle.GLOBAL, "mergeExternalUnits.email.subject");
                final String body = BundleUtil.getString(Bundle.GLOBAL, "mergeExternalUnits.email.body",
                        new String[] { person.getName(), person.getUsername(), fromUnitName, fromUnitID,
                                destinationUnit.getName(), destinationUnit.getExternalId().toString() });

                SystemSender systemSender = Bennu.getInstance().getSystemSender();
                new Message(systemSender, systemSender.getConcreteReplyTos(), Collections.EMPTY_LIST, subject,
                        body, resultEmails);
            }
        }
    }
}