Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:cn.vlabs.duckling.vwb.ui.servlet.SimpleUploaderServlet.java

public void init(ServletConfig config) throws ServletException {

    debug = (new Boolean(config.getInitParameter("debug"))).booleanValue();
    log.debug("---- SimpleUploaderServlet initialization started ----");
    enabled = Boolean.valueOf(config.getInitParameter("enabled"));
    allowedExtensions = parseParams(config.getInitParameter("AllowedExtensionsFile"));
    deniedExtensions = parseParams(config.getInitParameter("DeniedExtensionsFile"));

    log.debug("---- SimpleUploaderServlet initialization completed ----");

}

From source file:gov.nih.nci.cacisweb.user.CacisUserService.java

@Override
public UserDetails loadUserByUsername(String arg0) throws UsernameNotFoundException {
    try {/* w w w  .ja va 2 s.  com*/
        log.debug("Loading User..");
        String userProperty = CaCISUtil.getProperty(arg0);
        if (userProperty == null) {
            log.error("User Not Found");
            throw new UsernameNotFoundException("User Not Found");
        }

        String[] userDetails = StringUtils.splitPreserveAllTokens(userProperty, ',');
        if (userDetails.length > 0 && userDetails.length < 5) {
            log.error("User Not Configured Properly");
            throw new UsernameNotFoundException("User Not Configured Properly");
        }
        Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        int i = 4;
        while (i < userDetails.length) {
            authorities.add(new SimpleGrantedAuthority(userDetails[i]));
            i++;
        }
        SimpleDateFormat sDateFormat = new SimpleDateFormat(CaCISWebConstants.COM_DATE_FORMAT);
        if (!StringUtils.isBlank(userDetails[3])) {
            Calendar lockOutTimeCalendar = Calendar.getInstance();
            lockOutTimeCalendar.setTime(sDateFormat.parse(userDetails[3]));
            long lockoutTimeMillis = lockOutTimeCalendar.getTimeInMillis();
            long currentTimeMillis = Calendar.getInstance().getTimeInMillis();
            long diffMinutes = (currentTimeMillis - lockoutTimeMillis) / (1000 * 60);
            if (diffMinutes > 60) {
                log.debug("Lockout Time greater than restricted time. Hence unlocking");
                return new CacisUser(arg0, userDetails[0], true, new Short("0").shortValue(), "", authorities);
            }
        }

        return new CacisUser(arg0, userDetails[0], new Boolean(userDetails[1]).booleanValue(),
                new Short(userDetails[2]).shortValue(), userDetails[3], authorities);

    } catch (CaCISWebException e) {
        log.error("User Not Found... " + e.getMessage());
        throw new UsernameNotFoundException("User Not Found. " + e.getMessage());
    } catch (ParseException e) {
        log.error("Lockout time not configured properly. " + e.getMessage());
        throw new UsernameNotFoundException("Lockout time not configured properly. " + e.getMessage());
    }
}

From source file:org.openregistry.core.service.DefaultDisclosureStrategyTests.java

private void setAllFlags(DisclosureSettings disclosure, boolean value) {
    Type homeType = this.referenceRepository.findType(Type.DataTypes.ADDRESS, Type.AddressTypes.HOME);
    Type officeType = this.referenceRepository.findType(Type.DataTypes.ADDRESS, Type.AddressTypes.OFFICE);
    Type facultyType = this.referenceRepository.findType(Type.DataTypes.AFFILIATION,
            Type.AffiliationTypes.FACULTY);
    Type staffType = this.referenceRepository.findType(Type.DataTypes.AFFILIATION, Type.AffiliationTypes.STAFF);
    Type landlineType = this.referenceRepository.findType(Type.DataTypes.PHONE, Type.PhoneTypes.LANDLINE);
    Type cellType = this.referenceRepository.findType(Type.DataTypes.PHONE, Type.PhoneTypes.CELL);

    // set all field-level settings to display
    HashMap<DisclosureSettings.PropertyNames, Object> props = new HashMap<DisclosureSettings.PropertyNames, Object>();
    props.put(DisclosureSettings.PropertyNames.BUILDING_IND, new Boolean(value));
    props.put(DisclosureSettings.PropertyNames.REGION_IND, new Boolean(value));
    props.put(DisclosureSettings.PropertyNames.ADDRESS_LINES_IND, new Boolean(value));

    disclosure.setAddressDisclousure(facultyType, homeType, props);
    disclosure.setAddressDisclousure(facultyType, officeType, props);
    disclosure.setAddressDisclousure(staffType, homeType, props);
    disclosure.setAddressDisclousure(staffType, officeType, props);

    disclosure.setEmailDisclosure(facultyType, homeType, value);
    disclosure.setEmailDisclosure(facultyType, officeType, value);
    disclosure.setEmailDisclosure(staffType, homeType, value);
    disclosure.setEmailDisclosure(staffType, officeType, value);

    disclosure.setPhoneDisclosure(facultyType, homeType, landlineType, value);
    disclosure.setPhoneDisclosure(facultyType, officeType, landlineType, value);
    disclosure.setPhoneDisclosure(facultyType, homeType, cellType, value);
    disclosure.setPhoneDisclosure(facultyType, officeType, cellType, value);
    disclosure.setPhoneDisclosure(staffType, homeType, cellType, value);
    disclosure.setPhoneDisclosure(staffType, officeType, cellType, value);
    disclosure.setPhoneDisclosure(staffType, homeType, landlineType, value);
    disclosure.setPhoneDisclosure(staffType, officeType, landlineType, value);

    disclosure.setUrlDisclosure(facultyType, homeType, value);
    disclosure.setUrlDisclosure(facultyType, officeType, value);
    disclosure.setUrlDisclosure(staffType, homeType, value);
    disclosure.setUrlDisclosure(staffType, officeType, value);
}

From source file:ControlQueryPApplet.java

/***************************************************************************
 * Initialise the applet by attempting to create and start a Player object
 * capable of playing the media specified in the applet tag.
 **************************************************************************/
public void init() {

    setLayout(new BorderLayout());
    setBackground(Color.lightGray);
    try {/*from w  ww  . j  a va2s.  c  o  m*/
        nameOfMedia2Play = (new URL(getDocumentBase(), getParameter(MEDIA_NAME_PROPERTY))).toExternalForm();
        locator = new MediaLocator(nameOfMedia2Play);
        Manager.setHint(Manager.PLUGIN_PLAYER, new Boolean(true));
        player = Manager.createPlayer(locator);
        player.addControllerListener(this);
        timer = new SystemTimeBase();
        player.start();
    } catch (Exception e) {
        throw new Error("Couldn't initialise BBPApplet: " + e.getMessage());
    }
}

From source file:de.willuhn.jameica.hbci.passports.pintan.server.PinTanConfigImpl.java

/**
 * @see de.willuhn.datasource.GenericObject#getAttribute(java.lang.String)
 *///from  w  w w  .  j  a  v  a  2  s .  c  om
public Object getAttribute(String attribute) throws RemoteException {
    if ("blz".equals(attribute))
        return getBLZ();
    if ("bank".equals(attribute))
        return HBCIProperties.getNameForBank(getBLZ());
    if ("url".equals(attribute))
        return getURL();
    if ("port".equals(attribute))
        return new Integer(getPort());
    if ("filtertype".equals(attribute))
        return getFilterType();
    if ("hbciversion".equals(attribute))
        return getHBCIVersion();
    if ("customerid".equals(attribute))
        return getCustomerId();
    if ("userid".equals(attribute))
        return getUserId();
    if ("bezeichnung".equals(attribute))
        return getBezeichnung();
    if ("showtan".equals(attribute))
        return new Boolean(getShowTan());
    if ("tanmedia".equals(attribute))
        return getTanMedia();
    if ("tanmedias".equals(attribute))
        return getTanMedias();
    return null;
}

From source file:nz.co.senanque.validationengine.ConvertUtils.java

public static Comparable<?> convertTo(Class<?> clazz, Object obj) {
    if (obj == null) {
        return null;
    }//from  w w  w  .  j a v  a2 s  .  c o m
    if (clazz.isAssignableFrom(obj.getClass())) {
        return (Comparable<?>) obj;
    }
    if (clazz.isPrimitive()) {
        if (clazz.equals(Long.TYPE)) {
            clazz = Long.class;
        } else if (clazz.equals(Integer.TYPE)) {
            clazz = Integer.class;
        } else if (clazz.equals(Float.TYPE)) {
            clazz = Float.class;
        } else if (clazz.equals(Double.TYPE)) {
            clazz = Double.class;
        } else if (clazz.equals(Boolean.TYPE)) {
            clazz = Boolean.class;
        }
    }
    if (Number.class.isAssignableFrom(clazz)) {
        if (obj.getClass().equals(String.class)) {
            obj = new Double((String) obj);
        }
        if (!Number.class.isAssignableFrom(obj.getClass())) {
            throw new RuntimeException(
                    "Cannot convert from " + obj.getClass().getName() + " to " + clazz.getName());
        }
        Number number = (Number) obj;
        if (clazz.equals(Long.class)) {
            return new Long(number.longValue());
        }
        if (clazz.equals(Integer.class)) {
            return new Integer(number.intValue());
        }
        if (clazz.equals(Float.class)) {
            return new Float(number.floatValue());
        }
        if (clazz.equals(Double.class)) {
            return new Double(number.doubleValue());
        }
        if (clazz.equals(BigDecimal.class)) {
            return new BigDecimal(number.doubleValue());
        }
    }
    final String oStr = String.valueOf(obj);
    if (clazz.equals(String.class)) {
        return oStr;
    }
    if (clazz.equals(java.util.Date.class)) {
        return java.sql.Date.valueOf(oStr);
    }
    if (clazz.equals(java.sql.Date.class)) {
        return java.sql.Date.valueOf(oStr);
    }
    if (clazz.equals(Boolean.class)) {
        return new Boolean(oStr);
    }
    throw new RuntimeException("Cannot convert from " + obj.getClass().getName() + " to " + clazz.getName());
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTreeCache.java

public void init(BaseTreeNode baseTree, Hashtable treeParams) throws Exception {
    log.info("Init start" + TimeUtils.getEasternTime());
    String contextExcludeListStr = (String) treeParams.get(TreeConstants.BR_CONTEXT_EXCLUDE_LIST_STR);
    allContextHolders = appServiceLocator.findTreeService().getContextNodeHolders(baseTree, idGen,
            contextExcludeListStr);/*from  w w w .j a  v a2s  .com*/
    allTemplatesByContext = appServiceLocator.findTreeService().getAllContextTemplateNodes(baseTree, idGen);

    List protocolNodes = appServiceLocator.findTreeService().getAllContextProtocolNodes(baseTree, idGen);
    allFormsWithNoProtocol = (Map) protocolNodes.get(0);
    allFormsWithProtocol = (Map) protocolNodes.get(1);

    //create classification nodes
    allClassificationNodes = appServiceLocator.findTreeService().getAllClassificationNodes(baseTree, idGen);
    CDEBrowserParams params = CDEBrowserParams.getInstance();

    boolean showFormsAlphebetically = new Boolean(params.getShowFormsAlphebetical()).booleanValue();

    //creating publishing nodes
    allPublishingNode = appServiceLocator.findTreeService().getAllPublishingNode(baseTree, idGen,
            showFormsAlphebetically);
    //setCtepTemplateCtepNodes(conn,baseTree);
    log.info("Init end" + TimeUtils.getEasternTime());
}

From source file:de.berlios.jedi.presentation.admin.LoginAction.java

/**
 * Handle server requests./*w w  w .j a va 2  s .  co  m*/
 * 
 * @param mapping
 *            The ActionMapping used to select this instance.
 * @param form
 *            The optional ActionForm bean for this request (if any).
 * @param request
 *            The HTTP request we are processing.
 * @param response
 *            The HTTP response we are creating.
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {
    Boolean isLoggedIn = (Boolean) request.getSession().getAttribute(AdminKeys.IS_LOGGED_IN);

    String password = request.getParameter("password");
    try {
        new AdminLogicService().login(password);
    } catch (IncorrectPasswordException e) {
        LogFactory.getLog(LoginAction.class).warn("An invalid password was used to try logging in", e);

        // Already logged in
        if (isLoggedIn != null && isLoggedIn.booleanValue()) {
            return errorForward(mapping, request, new ActionMessage("incorrectPassword"),
                    "loginIncorrectPassword", "logout");
        }

        return errorForward(mapping, request, new ActionMessage("incorrectPassword"), "loginIncorrectPassword");
    }

    // Already logged in
    if (isLoggedIn != null && isLoggedIn.booleanValue()) {
        return mapping.findForward("success");
    }

    request.getSession().setAttribute(AdminKeys.IS_LOGGED_IN, new Boolean(true));

    request.setAttribute(Keys.NEXT_FORWARD_NAME, "adminView");

    return mapping.findForward("success");
}

From source file:com.duroty.application.mail.actions.CreateIdentityAction.java

/**
 * DOCUMENT ME!/*from   ww w  .j  a  va  2s  . c  o m*/
 *
 * @param mapping DOCUMENT ME!
 * @param form DOCUMENT ME!
 * @param request DOCUMENT ME!
 * @param response DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws Exception DOCUMENT ME!
 */
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionMessages errors = new ActionMessages();

    try {
        Preferences preferencesInstance = getPreferencesInstance(request);

        PreferencesObj preferencesObj = preferencesInstance.getPreferences();

        DynaActionForm _form = (DynaActionForm) form;

        IdentityObj identityObj = new IdentityObj();

        identityObj.setEmail((String) _form.get("email"));

        Boolean important = (Boolean) _form.get("default");

        if (important == null) {
            important = new Boolean(false);
        }

        identityObj.setImportant(important.booleanValue());
        identityObj.setName((String) _form.get("name"));
        identityObj.setReplyTo((String) _form.get("replyTo"));

        String code = preferencesInstance.createIdentity(identityObj);

        String body = getEmailBody(request, preferencesObj.getLanguage());

        MessageResources message = getResources(request);
        String subject = message.getMessage("general.title");

        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path + "/mail/preferences/validateIdentity.drt?user=" + request.getUserPrincipal() + "&code="
                + code;

        body = body.replaceAll("\\$\\{email\\}", identityObj.getEmail());
        body = body.replaceAll("\\$\\{url\\}", basePath);

        IdentityObj identityDefault = preferencesInstance.getIdentityDefault();

        Send sendInstance = getSendInstance(request);
        sendInstance.sendIdentity(identityDefault.getEmail(), identityObj.getEmail(), subject, body);
    } catch (Exception ex) {
        String errorMessage = ExceptionUtilities.parseMessage(ex);

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

        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.squid.core.jdbc.formatter.DefaultJDBCDataFormatter.java

public String formatJDBCObject(final Object jdbcObject, final int colType) throws SQLException {
    String value = "";

    switch (colType) {
    case Types.BIT:
        if (jdbcObject != null) {
            value = String.valueOf(jdbcObject);
        }/*from www . ja v  a2  s.  c o m*/
        break;
    case Types.BOOLEAN:
        if (jdbcObject != null) {
            value = new Boolean(jdbcObject.toString()).toString();
        }
        break;
    case Types.BIGINT:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
    case Types.NUMERIC:
        if (jdbcObject != null) {
            value = "" + formatter.formatDecimal(jdbcObject);
        }
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        if (jdbcObject != null) {
            value = "" + formatter.formatDecimal(jdbcObject);
        }
        break;
    case Types.CLOB:
        if (jdbcObject != null) {
            try {
                value = read((Clob) jdbcObject);
            } catch (SQLException sqle) {
                value = "";
            } catch (IOException ioe) {
                value = "";
            }
        }
        break;
    case Types.ARRAY:
        try {
            ResultSet rs = ((Array) jdbcObject).getResultSet();
            int arrayType = ((Array) jdbcObject).getBaseType();
            boolean isNotNew = false;
            while (rs.next()) {
                String current = formatJDBCObject(rs.getObject(2), arrayType);
                if ("".equals(current.trim()) == false) {
                    if (isNotNew) {
                        value = value + ",";
                    } else {
                        isNotNew = !isNotNew;
                    }
                    value = value + current;
                }
            }
            if ("".equals(value) == false) {
                value = "{" + value + "}";
            }
        } catch (SQLException sqle) {
            value = "";
        }
        break;
    case Types.JAVA_OBJECT:
        if (jdbcObject != null) {
            value = String.valueOf(jdbcObject);
        }
        break;
    case Types.DATE:
        if (jdbcObject != null) {
            value = formatter.formatDate(jdbcObject);
        }
        break;
    case Types.TIME:
        if (jdbcObject != null) {
            value = ((Time) jdbcObject).toString();
        }
        break;
    case Types.TIMESTAMP:
        if (jdbcObject != null) {
            value = formatter.formatTimestamp(jdbcObject);
        }
        break;
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        if (jdbcObject != null) {
            value = jdbcObject.toString();
        } else {
            value = "NULL";
        }
        break;
    case Types.BINARY:
        value = new String((byte[]) jdbcObject);
        break;
    default:
        value = "";
    }
    if (value == null) {
        value = "";
    }
    return value;
}