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:de.iteratec.iteraplan.presentation.dialog.History.HistoryController.java

/**
 * URL Handler method that returns an HTML view of the history of one building block, narrowed down by provided criteria
 * @param bbId Building Block ID/*w  w w .j a  va 2  s . c o  m*/
 * @param bbType Building Block type code, which can be decoded by {@link TypeOfBuildingBlock#fromInitialCapString(String)}
 * @param page The number of the page to return, depending on {@code pageSize}. Zero-based. May be {@code null}, in which case the default value 0 is used.
 * @param pageSize The number of history events on the returned page. -1 is interpreted as "everything". May be {@code null}, in which case the default value -1 is used.
 * @param dateFromStr The start date of the time range to filter history events for. This is expected to be in ISO date format (pattern yyyy-MM-dd)!
 * @param dateToStr The end date (inclusive) of the time range to filter history events for. This is expected to be in ISO date format (pattern yyyy-MM-dd)!
 */
@SuppressWarnings("boxing")
@RequestMapping
public ModelAndView localHistory(@RequestParam(value = "id", required = true) String bbId,
        @RequestParam(value = "buildingBlockType", required = true) String bbType,
        @RequestParam(value = "page", required = false) String page,
        @RequestParam(value = "pageSize", required = false) String pageSize,
        @RequestParam(value = "dateFrom", required = false) String dateFromStr,
        @RequestParam(value = "dateTo", required = false) String dateToStr) {

    ModelAndView modelAndView = new ModelAndView("history/local");

    // Check if user may see history, and note so JSP can show a nice error. If not, return
    Boolean hasPermission = Boolean.valueOf(UserContext.getCurrentPerms().getUserHasFuncPermViewHistory());
    modelAndView.addObject("isHasViewHistoryPermission", hasPermission);
    if (!hasPermission.booleanValue()) {
        return modelAndView;
    }

    int id = parseInt(bbId, -1);

    // Default to showing page 0 (first page), if unspecified
    int curPage = parseInt(page, 0);
    // current page must not be negative
    curPage = Math.max(curPage, 0);

    // Default -1 means infinite results Per Page
    int pageSizeInt = parseInt(pageSize, -1);
    // make sure it's not 0, /0 error later; and make all values < -1 turn into -1
    if (pageSizeInt <= 0) {
        pageSizeInt = -1;
    }

    DateTimeFormatter isoDateFormatter = ISODateTimeFormat.date();
    DateTime dateFrom = null;
    DateTime dateTo = null;
    if (StringUtils.isNotEmpty(dateFromStr)) {
        try {
            LocalDate date = LocalDate.parse(dateFromStr, isoDateFormatter);
            dateFrom = date.toDateTimeAtStartOfDay();
        } catch (IllegalArgumentException ex) {
            // invalid date format, ignore
        }
    }

    if (StringUtils.isNotEmpty(dateToStr)) {
        try {
            // assumption: we parsed from a date with no time which gave us the beginning of that day, but
            // we want to include the whole day, so add 1 day
            LocalDate date = LocalDate.parse(dateToStr, isoDateFormatter).plusDays(1);
            dateTo = date.toDateTimeAtStartOfDay();
        } catch (IllegalArgumentException ex) {
            // invalid date format, ignore
        }
    }

    HistoryResultsPage resultsPage;
    try {
        resultsPage = historyService.getLocalHistoryPage(getClassFromTypeString(bbType), id, curPage,
                pageSizeInt, dateFrom, dateTo);
    } catch (Exception e) {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.HISTORY_RETRIEVAL_GENERAL_ERROR, e);
    }
    assert resultsPage != null;

    modelAndView.addObject("resultsPage", resultsPage);
    modelAndView.addObject("isHistoryEnabled", Boolean.valueOf(historyService.isHistoryEnabled()));

    return modelAndView;
}

From source file:de.xwic.sandbox.server.installer.XmlExport.java

/**
 * @param value/*from  ww  w . j ava2  s  .c om*/
 * @param value2
 */
private void addValue(Element elm, Object value, boolean addTypeInfo) {

    String typeInfo = value != null ? value.getClass().getName() : null;
    if (value == null) {
        elm.addElement(ELM_NULL);
    } else if (value instanceof String) {
        elm.setText((String) value);
    } else if (value instanceof Integer) {
        elm.setText(value.toString());
    } else if (value instanceof Boolean) {
        Boolean bo = (Boolean) value;
        elm.setText(bo.booleanValue() ? "true" : "false");
    } else if (value instanceof Long) {
        elm.setText(value.toString());
    } else if (value instanceof Double) {
        elm.setText(value.toString());
    } else if (value instanceof Date) {
        Date date = (Date) value;
        elm.setText(Long.toString(date.getTime()));

    } else if (value instanceof IEntity) {
        IEntity entity = (IEntity) value;
        typeInfo = entity.type().getName();
        elm.setText(Integer.toString(entity.getId()));

    } else if (value instanceof Set<?>) {
        Set<?> set = (Set<?>) value;
        Element elmSet = elm.addElement(ELM_SET);
        for (Iterator<?> it = set.iterator(); it.hasNext();) {
            Object o = it.next();
            Element entry = elmSet.addElement(ELM_ELEMENT);
            addValue(entry, o, true);
        }
    }

    if (addTypeInfo && typeInfo != null) {
        elm.addAttribute("type", typeInfo);
    }

}

From source file:com.aurel.track.itemNavigator.ItemNavigatorFilterBL.java

private static View createQueryView(TPersonBean personBean, List<ILabelBean> usedStatusList, Locale locale) {
    View queryView = new View();
    queryView.setName(getText("common.lbl.queries", locale));
    queryView.setObjectID(101);/*  www .ja  v  a 2 s.  co m*/
    queryView.setIconCls("queryView");

    Map<Integer, Boolean> userLevelMap = personBean.getUserLevelMap();

    Boolean hasAccessFiltersWorkspacesBoolean = userLevelMap
            .get(UserLevelBL.USER_LEVEL_ACTION_IDS.MAIN_FILTER_PROJECT);
    Boolean hasAccessFiltersFiltersBoolean = userLevelMap
            .get(UserLevelBL.USER_LEVEL_ACTION_IDS.MAIN_FILTER_FILTER);
    Boolean hasAccessFiltersBasketsBoolean = userLevelMap
            .get(UserLevelBL.USER_LEVEL_ACTION_IDS.MAIN_FILTER_BASKET);
    Boolean hasAccessFiltersStatesBoolean = userLevelMap
            .get(UserLevelBL.USER_LEVEL_ACTION_IDS.MAIN_FILTER_STATUS);

    boolean hasAccessFiltersWorkspaces = hasAccessFiltersWorkspacesBoolean != null
            && hasAccessFiltersWorkspacesBoolean.booleanValue();
    boolean hasAccessFiltersFilters = hasAccessFiltersFiltersBoolean != null
            && hasAccessFiltersFiltersBoolean.booleanValue();
    boolean hasAccessFiltersBaskets = hasAccessFiltersBasketsBoolean != null
            && hasAccessFiltersBasketsBoolean.booleanValue();
    boolean hasAccessFiltersStates = hasAccessFiltersStatesBoolean != null
            && hasAccessFiltersStatesBoolean.booleanValue();

    List<Section> sections = new ArrayList<Section>();

    if (hasAccessFiltersWorkspaces) {
        Section projectSection = createProjectSection(personBean, locale);
        if (projectSection != null) {
            sections.add(projectSection);
        }
    }

    if (hasAccessFiltersFilters) {
        sections.add(createQuerySection(personBean, locale));
    }

    if (hasAccessFiltersStates) {
        sections.add(createStatusSection(personBean, usedStatusList, locale));
    }
    if (hasAccessFiltersBaskets) {
        Section basketSection = createBasketSection(userLevelMap, locale);
        if (basketSection != null) {
            sections.add(basketSection);
        }
    }

    queryView.setSections(sections);
    return queryView;
}

From source file:org.springmodules.validation.valang.javascript.ValangJavaScriptTranslatorTests.java

protected boolean validate(Object target, String text, MessageSourceAccessor messageSource) {
    try {/*from  www . ja v a2 s.c o  m*/
        Collection rules = parseRules(text);
        StringWriter code = new StringWriter();
        new ValangJavaScriptTranslator().writeJavaScriptValangValidator(code, "someName", false, rules,
                messageSource);
        code.write(".validate()");
        ScriptableObject.putProperty(scope, "formObject", Context.javaToJS(target, scope));
        System.out.println(code.toString());
        Object evaluateString = cx.evaluateString(scope, code.toString(), "code", 1, null);
        Boolean result = (Boolean) cx.jsToJava(evaluateString, Boolean.class);
        return result.booleanValue();
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage());
    }
}

From source file:ListProperties.java

public int compareRowsByColumn(int row1, int row2, int column) {
    Class type = model.getColumnClass(column);
    TableModel data = model;//  w  ww  . j av  a  2 s.c om

    // Check for nulls

    Object o1 = data.getValueAt(row1, column);
    Object o2 = data.getValueAt(row2, column);

    // If both values are null return 0
    if (o1 == null && o2 == null) {
        return 0;
    } else if (o1 == null) { // Define null less than everything.
        return -1;
    } else if (o2 == null) {
        return 1;
    }

    if (type.getSuperclass() == Number.class) {
        Number n1 = (Number) data.getValueAt(row1, column);
        double d1 = n1.doubleValue();
        Number n2 = (Number) data.getValueAt(row2, column);
        double d2 = n2.doubleValue();

        if (d1 < d2)
            return -1;
        else if (d1 > d2)
            return 1;
        else
            return 0;
    } else if (type == String.class) {
        String s1 = (String) data.getValueAt(row1, column);
        String s2 = (String) data.getValueAt(row2, column);
        int result = s1.compareTo(s2);

        if (result < 0)
            return -1;
        else if (result > 0)
            return 1;
        else
            return 0;
    } else if (type == java.util.Date.class) {
        Date d1 = (Date) data.getValueAt(row1, column);
        long n1 = d1.getTime();
        Date d2 = (Date) data.getValueAt(row2, column);
        long n2 = d2.getTime();

        if (n1 < n2)
            return -1;
        else if (n1 > n2)
            return 1;
        else
            return 0;
    } else if (type == Boolean.class) {
        Boolean bool1 = (Boolean) data.getValueAt(row1, column);
        boolean b1 = bool1.booleanValue();
        Boolean bool2 = (Boolean) data.getValueAt(row2, column);
        boolean b2 = bool2.booleanValue();

        if (b1 == b2)
            return 0;
        else if (b1) // Define false < true
            return 1;
        else
            return -1;
    } else {
        Object v1 = data.getValueAt(row1, column);
        String s1 = v1.toString();
        Object v2 = data.getValueAt(row2, column);
        String s2 = v2.toString();
        int result = s1.compareTo(s2);

        if (result < 0)
            return -1;
        else if (result > 0)
            return 1;
        else
            return 0;
    }
}

From source file:org.apache.archiva.redback.policy.DefaultUserSecurityPolicy.java

public boolean isEnabled() {
    Boolean bool = (Boolean) PolicyContext.getContext().get(ENABLEMENT_KEY);
    return bool == null || bool.booleanValue();
}

From source file:com.duroty.application.admin.actions.UpdateUserAction.java

protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionMessages errors = new ActionMessages();

    try {//from   w  w w . j a  va2s .c o m
        DynaActionForm _form = (DynaActionForm) form;

        Admin adminInstance = getAdminInstance(request);

        UserObj userObj = new UserObj();

        String password = (String) _form.get("password");
        String confirmPassword = (String) _form.get("confirmPassword");

        if (!StringUtils.isBlank(password)) {
            adminInstance.confirmPassword(password, confirmPassword);
            userObj.setPassword(password);
        }

        userObj.setIdint(((Integer) _form.get("idint")).intValue());

        Boolean active = new Boolean(false);

        if (_form.get("active") != null) {
            active = (Boolean) _form.get("active");
        }

        userObj.setActive(active.booleanValue());

        userObj.setEmail((String) _form.get("email"));
        userObj.setEmailIdentity((String) _form.get("emailIdentity"));

        Boolean htmlMessages = new Boolean(false);

        if (_form.get("htmlMessages") != null) {
            htmlMessages = (Boolean) _form.get("htmlMessages");
        }

        userObj.setHtmlMessages(htmlMessages.booleanValue());

        userObj.setLanguage((String) _form.get("language"));
        userObj.setMessagesByPage(((Integer) _form.get("byPage")).intValue());
        userObj.setName((String) _form.get("name"));
        userObj.setQuotaSize(((Integer) _form.get("quotaSize")).intValue());
        userObj.setRegisterDate(new Date());
        userObj.setRoles((Integer[]) _form.get("roles"));
        userObj.setSignature((String) _form.get("signature"));

        Boolean spamTolerance = new Boolean(false);

        if (_form.get("spamTolerance") != null) {
            spamTolerance = (Boolean) _form.get("spamTolerance");
        }

        userObj.setSpamTolerance(spamTolerance.booleanValue());

        userObj.setVacationBody((String) _form.get("vacationBody"));
        userObj.setVacationSubject((String) _form.get("vacationSubject"));

        Boolean vacationActive = new Boolean(false);

        if (_form.get("vacationActive") != null) {
            vacationActive = (Boolean) _form.get("vacationActive");
        }

        userObj.setVactionActive(vacationActive.booleanValue());

        adminInstance.updateUser(userObj);
    } catch (Exception ex) {
        if (ex instanceof ChatException) {
            if (ex.getCause() instanceof NotOnlineException) {
                request.setAttribute("result", "not_online");
            } else if (ex.getCause() instanceof NotLoggedInException) {
                request.setAttribute("result", "not_logged_in");
            } else if (ex.getCause() instanceof NotAcceptChatException) {
                request.setAttribute("result", "not_accept_chat");
            } else {
                request.setAttribute("result", ex.getMessage());
            }
        } else {
            String errorMessage = ExceptionUtilities.parseMessage(ex);

            if (errorMessage == null) {
                errorMessage = "NullPointerException";
            }

            request.setAttribute("result", errorMessage);

            errors.add("general",
                    new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage));
            request.setAttribute("exception", errorMessage);
            doTrace(request, DLog.ERROR, getClass(), errorMessage);
        }
    } finally {
    }

    if (errors.isEmpty()) {
        doTrace(request, DLog.INFO, getClass(), "OK");

        return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD);
    } else {
        saveErrors(request, errors);

        return mapping.findForward(Constants.ACTION_FAIL_FORWARD);
    }
}

From source file:com.bibisco.manager.CharacterManager.java

private static List<CharacterDTO> loadCharacters(Boolean pBlnMain) {

    List<CharacterDTO> lCharacterDTOList = null;

    mLog.debug("Start loadMainCharacters(" + pBlnMain + ")");

    SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject();
    SqlSession lSqlSession = lSqlSessionFactory.openSession();
    try {/*from  w w  w . ja v  a 2s .  co m*/

        // create select criteria
        CharactersMapper lCharactersMapper = lSqlSession.getMapper(CharactersMapper.class);
        CharactersExample lCharactersExample = new CharactersExample();
        if (pBlnMain != null && pBlnMain.booleanValue()) {
            lCharactersExample.createCriteria().andMainCharacterEqualTo("Y");
        } else if (pBlnMain != null && !pBlnMain.booleanValue()) {
            lCharactersExample.createCriteria().andMainCharacterEqualTo("N");
        }
        lCharactersExample.setOrderByClause("POSITION");

        List<Characters> lCharactersList = lCharactersMapper.selectByExample(lCharactersExample);
        if (lCharactersList != null && lCharactersList.size() > 0) {
            lCharacterDTOList = new ArrayList<CharacterDTO>();
            for (Characters lCharacters : lCharactersList) {

                // create CharacterDTO
                CharacterDTO lCharacterDTO;
                if (pBlnMain) {
                    lCharacterDTO = createMainCharacterDTOFromCharacters(lCharacters);
                } else {
                    lCharacterDTO = createSecondaryCharacterDTOFromCharacters(lCharacters);
                }

                // add character to list
                lCharacterDTOList.add(lCharacterDTO);
            }
        }

    } catch (Throwable t) {
        mLog.error(t);
        throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION);
    } finally {
        lSqlSession.close();
    }

    mLog.debug("End loadMainCharacters(" + pBlnMain + ")");

    return lCharacterDTOList;

}

From source file:com._17od.upm.transport.HTTPTransport.java

public HTTPTransport() {

    client = new HttpClient();

    Boolean acceptSelfSignedCerts = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS));
    if (acceptSelfSignedCerts.booleanValue()) {
        // Create a Protcol handler which contains a HTTPS socket factory
        // capable of accepting self signed and otherwise invalid certificates.
        Protocol httpsProtocol = new Protocol("https",
                (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443);
        Protocol.registerProtocol("https", httpsProtocol);
    }//from  ww  w.  ja  v  a 2 s. c  o  m

    //Get the proxy settings
    Boolean proxyEnabled = new Boolean(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED));
    if (proxyEnabled.booleanValue()) {
        String proxyHost = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_HOST);
        String proxyPortStr = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PORT);
        String proxyUserName = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME);
        String proxyPassword = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD);
        String decodedPassword = new String(Base64.decodeBase64(proxyPassword.getBytes()));

        if (isNotEmpty(proxyHost)) {
            int proxyPort = 0;
            if (isNotEmpty(proxyPortStr)) {
                proxyPort = Integer.parseInt(proxyPortStr);
                client.getHostConfiguration().setProxy(proxyHost, proxyPort);
                if (isNotEmpty(proxyUserName) && isNotEmpty(proxyPassword)) {
                    client.getState().setProxyCredentials(AuthScope.ANY,
                            new UsernamePasswordCredentials(proxyUserName, decodedPassword));
                }
            }
        }
    }

}

From source file:com.duroty.application.admin.utils.AdminDefaultAction.java

/**
 * DOCUMENT ME!/*from w ww  .  j  a v a 2 s .  co  m*/
 *
 * @param request DOCUMENT ME!
 * @param response DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws LanguageControlException DOCUMENT ME!
 */
protected Locale languageControl(HttpServletRequest request, HttpServletResponse response)
        throws LanguageControlException {
    Preferences preferences = null;
    String language = null;
    String name = Configuration.properties.getProperty(Configuration.COOKIE_LANGUAGE);
    int maxAge = Integer.parseInt(Configuration.properties.getProperty(Configuration.COOKIE_MAX_AGE));

    Cookie cookie = CookieManager.getCookie(name, request);

    if (cookie != null) {
        language = cookie.getValue();
        cookie.setMaxAge(maxAge);
        CookieManager.setCookie("/", cookie, response);
    } else {
    }

    try {
        preferences = getPreferencesInstance(request);
        language = preferences.getPreferences().getLanguage();
    } catch (RemoteException e) {
    } catch (NamingException e) {
    } catch (CreateException e) {
    } catch (MailException e) {
    }

    Boolean b = new Boolean(Configuration.properties.getProperty(Configuration.AUTO_LOCALE));
    boolean autoLocale = b.booleanValue();

    if (language == null) {
        if (!autoLocale) {
            throw new LanguageControlException("Choose Language. The language is empty", null);
        } else {
            language = Configuration.properties.getProperty(Configuration.DEFAULT_LANGUAGE);
        }
    }

    cookie = new Cookie(name, language);
    cookie.setMaxAge(maxAge);
    CookieManager.setCookie("/", cookie, response);

    return new Locale(language);
}