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:com.alfaariss.oa.authentication.remote.saml2.idp.storage.jdbc.IDPJDBCStorage.java

/**
 * @see com.alfaariss.oa.engine.core.idp.storage.IIDPStorage#getAll()
 *//*  w  ww .  ja va  2  s  . c  om*/
public List<IIDP> getAll() throws OAException {
    Connection connection = null;
    PreparedStatement pSelect = null;
    ResultSet resultSet = null;
    List<IIDP> listIDPs = new Vector<IIDP>();

    IMetadataProviderManager oMPM = MdMgrManager.getInstance().getMetadataProviderManager(_sId);

    try {
        boolean dateLastModifiedExists = true;

        connection = _dataSource.getConnection();

        pSelect = connection.prepareStatement(_sQuerySelectAll);
        pSelect.setBoolean(1, true);
        resultSet = pSelect.executeQuery();
        while (resultSet.next()) {
            boolean bACSIndex = resultSet.getBoolean(COLUMN_ACS_INDEX);

            Boolean boolAllowCreate = null;
            String sAllowCreate = resultSet.getString(COLUMN_ALLOW_CREATE);
            if (sAllowCreate != null) {
                boolean bAllowCreate = resultSet.getBoolean(COLUMN_ALLOW_CREATE);
                boolAllowCreate = new Boolean(bAllowCreate);
            }

            boolean bScoping = resultSet.getBoolean(COLUMN_SCOPING);
            boolean bNameIDPolicy = resultSet.getBoolean(COLUMN_NAMEIDPOLICY);
            boolean bAvoidSubjectConfirmation = resultSet.getBoolean(COLUMN_AVOID_SUBJCONF);
            boolean bDisableSSOForIDP = resultSet.getBoolean(COLUMN_DISABLE_SSO);

            // Implement date_last_modified column as optional
            Date dLastModified = null;
            if (dateLastModifiedExists) {
                try {
                    dLastModified = resultSet.getTimestamp(COLUMN_DATELASTMODIFIED);
                } catch (Exception e) {
                    _oLogger.info("No " + COLUMN_DATELASTMODIFIED + " column found; ignoring.");
                    dateLastModifiedExists = false;
                }
            }

            SAML2IDP idp = new SAML2IDP(resultSet.getString(COLUMN_ID), resultSet.getBytes(COLUMN_SOURCEID),
                    resultSet.getString(COLUMN_FRIENDLYNAME), resultSet.getString(COLUMN_METADATA_FILE),
                    resultSet.getString(COLUMN_METADATA_URL), resultSet.getInt(COLUMN_METADATA_TIMEOUT),
                    bACSIndex, boolAllowCreate, bScoping, bNameIDPolicy,
                    resultSet.getString(COLUMN_NAMEIDFORMAT), bAvoidSubjectConfirmation, bDisableSSOForIDP,
                    dLastModified, oMPM.getId());
            listIDPs.add(idp);
        }
    } catch (Exception e) {
        _oLogger.fatal("Internal error during retrieval of all IDPs", e);
        throw new OAException(SystemErrors.ERROR_INTERNAL);
    } finally {
        try {
            if (pSelect != null)
                pSelect.close();
        } catch (Exception e) {
            _oLogger.error("Could not close select statement", e);
        }

        try {
            if (connection != null)
                connection.close();
        } catch (Exception e) {
            _oLogger.error("Could not close connection", e);
        }
    }
    return listIDPs;
}

From source file:is.idega.idegaweb.egov.gumbo.licenses.FishingLicenseUser.java

/**
 * used in forms: general fishing license, strandveidileyfi, grasleppa
 * <p>/*from w  w  w  .j  a va  2  s  . c  o  m*/
 * informs the user that he's in debt for fiskistofa (after he submits the
 * application)
 * </p>
 * 
 * @return string true or false
 */
public String getIsInDebt(String vesselId) {
    return new Boolean(getFJSClient().getIsInDebt(vesselId)).toString();
}

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.obo1_2.OBO2LGDynamicMapHolders.java

public void storeConceptAndRelations(OBOResourceReader oboReader, OBOTerm oboTerm, CodingScheme csclass) {
    try {/*from  www .ja v a  2 s.c om*/
        // OBO Term should not be null and either one of ID or term name
        // should be there.
        OBOContents contents = oboReader.getContents(false, false);
        if ((oboTerm != null)
                && ((!OBO2LGUtils.isNull(oboTerm.getId())) || (!OBO2LGUtils.isNull(oboTerm.getName())))) {
            propertyCounter = 0;

            Entity concept = new Entity();
            concept.setEntityType(new String[] { EntityTypes.CONCEPT.toString() });
            concept.setEntityCodeNamespace(csclass.getCodingSchemeName());

            if (!OBO2LGUtils.isNull(oboTerm.getId()))
                concept.setEntityCode(oboTerm.getId());
            else
                concept.setEntityCode(oboTerm.getName());

            String termDesc = "";

            if (!OBO2LGUtils.isNull(oboTerm.getName()))
                termDesc = oboTerm.getName();
            else
                termDesc = oboTerm.getId();

            EntityDescription ed = new EntityDescription();
            ed.setContent(termDesc);
            concept.setEntityDescription(ed);

            if (oboTerm.isObsolete()) {
                concept.setIsActive(new Boolean(false));
            }
            Presentation tp = new Presentation();
            Text txt = new Text();
            txt.setContent(termDesc);
            tp.setValue(txt);
            tp.setIsPreferred(new Boolean(true));
            tp.setPropertyName(OBO2LGConstants.PROPERTY_TEXTPRESENTATION);

            String preferredPresetationID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
            tp.setPropertyId(preferredPresetationID);
            concept.getPresentationAsReference().add(tp);

            if (!OBO2LGUtils.isNull(oboTerm.getComment())) {
                Comment comment = new Comment();
                txt = new Text();
                txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getComment(), null));
                comment.setValue(txt);
                comment.setPropertyName(OBO2LGConstants.PROPERTY_COMMENT);
                comment.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter));
                concept.getCommentAsReference().add(comment);
            }

            if (!OBO2LGUtils.isNull(oboTerm.getDefinition())) {
                Definition defn = new Definition();
                txt = new Text();
                txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getDefinition(), null));
                defn.setValue(txt);
                defn.setPropertyName(OBO2LGConstants.PROPERTY_DEFINITION);
                defn.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter));
                concept.getDefinitionAsReference().add(defn);

                OBOAbbreviations abbreviations = contents.getOBOAbbreviations();
                addOBODbxrefAsSource(defn, oboTerm.getDefinitionSources(), abbreviations);

            }

            addPropertyAttribute(oboTerm.getSubset(), concept, OBO2LGConstants.PROPERTY_SUBSET);
            Vector<String> dbxref_src_vector = OBODbxref.getSourceAndSubRefAsVector(oboTerm.getDbXrefs());
            addPropertyAttribute(dbxref_src_vector, concept, "xref");
            // Add Synonyms as presentations
            Vector<OBOSynonym> synonyms = oboTerm.getSynonyms();

            if ((synonyms != null) && (!synonyms.isEmpty())) {
                for (OBOSynonym synonym : synonyms) {
                    Presentation ip = new Presentation();
                    txt = new Text();
                    txt.setContent(synonym.getText());
                    ip.setValue(txt);
                    ip.setPropertyName(OBO2LGConstants.PROPERTY_SYNONYM);
                    String synPresID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
                    ip.setPropertyId(synPresID);
                    concept.getPresentationAsReference().add(ip);

                    String scope = synonym.getScope();
                    if (scope != null && scope.length() > 0)
                        ip.setDegreeOfFidelity(scope);

                    // Add source information
                    Vector<OBODbxref> dbxref = OBODbxref.parse(synonym.getDbxref());
                    OBOAbbreviations abbreviations = contents.getOBOAbbreviations();
                    addOBODbxrefAsSource(ip, dbxref, abbreviations);

                }
            }

            Vector<String> vec_altIds = oboTerm.getAltIds();

            if ((vec_altIds != null) && (!vec_altIds.isEmpty())) {
                for (String altId : vec_altIds) {

                    if (StringUtils.isNotBlank(altId)) {

                        Property emfProp = new Property();
                        emfProp.setPropertyName(OBO2LGConstants.PROPERTY_ALTID);
                        String prop_id = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter);
                        emfProp.setPropertyId(prop_id);

                        txt = new Text();
                        txt.setContent(altId);
                        emfProp.setValue(txt);

                        concept.getPropertyAsReference().add(emfProp);

                    }
                }
            }

            String created_by = oboTerm.getCreated_by();
            if (StringUtils.isNotBlank(created_by)) {
                addPropertyAttribute(created_by, concept, OBO2LGConstants.PROPERTY_CREATED_BY);

            }

            String creation_date = oboTerm.getCreation_date();
            if (StringUtils.isNotBlank(creation_date)) {
                addPropertyAttribute(creation_date, concept, OBO2LGConstants.PROPERTY_CREATION_DATE);
            }

            Hashtable<String, Vector<String>> relationships = oboTerm.getRelationships();
            if (relationships != null) {
                for (Enumeration<String> e = relationships.keys(); e.hasMoreElements();) {
                    String relName = e.nextElement();
                    OBORelations relations = contents.getOBORelations();
                    OBORelation relation = relations.getMemberById(relName);
                    Vector<String> targets = relationships.get(relName);
                    if (targets != null) {
                        addAssociationAttribute(concept, relation, targets);
                    }
                }
            }

            codedEntriesList.add(concept);

        }
    }

    catch (Exception e) {
        e.printStackTrace();
        messages_.info("Failed to store concept " + oboTerm.getName() + "(" + oboTerm.getId() + ")");
    }
}

From source file:com.splout.db.engine.MySQLOutputFormat.java

protected boolean autoTrim(Field f) {
    if (globalAutoTrim != null) {
        return globalAutoTrim;
    } else {/*from w  ww.j a v a2 s . c o m*/
        if (f.getProp(AUTO_TRIM_STRING_PANGOOL_FIELD_PROP) != null) {
            return new Boolean(f.getProp(AUTO_TRIM_STRING_PANGOOL_FIELD_PROP));
        }
    }
    return false;
}

From source file:com.google.feedserver.util.BeanCliHelper.java

/**
 * Loop through each registered class and create and parse command line
 * options for fields decorated with {@link Flag}.
 *//*ww  w.j ava2  s  .  c  o m*/
private void populateBeansFromCommandLine() {

    // Go through all registered beans.
    for (Object bean : beans) {

        // Search for all fields in the bean with Flag decorator.
        for (Field field : bean.getClass().getDeclaredFields()) {
            Flag flag = field.getAnnotation(Flag.class);
            if (flag == null) {
                // not decorated, continue.
                continue;
            }
            String argName = field.getName();
            // Boolean Flags
            if (field.getType().getName().equals(Boolean.class.getName())
                    || field.getType().getName().equals(Boolean.TYPE.getName())) {
                if (flags.hasOption(argName)) {
                    setField(field, bean, new Boolean(true));
                } else if (flags.hasOption("no" + argName)) {
                    setField(field, bean, new Boolean(false));
                }
                // Integer Flags
            } else if (field.getType().getName().equals(Integer.class.getName())
                    || field.getType().getName().equals(Integer.TYPE.getName())) {
                String argValue = flags.getOptionValue(argName, null);
                if (argValue != null) {
                    try {
                        setField(field, bean, Integer.valueOf(argValue));
                    } catch (NumberFormatException e) {
                        throw new RuntimeException(e);
                    }
                }
                // String Flag
            } else if (field.getType().getName().equals(String.class.getName())) {
                String argValue = flags.getOptionValue(argName, null);
                if (argValue != null) {
                    setField(field, bean, argValue);
                }
                // Repeated String Flag
            } else if (field.getType().getName().equals(String[].class.getName())) {
                String[] argValues = flags.getOptionValues(argName);
                if (argValues != null) {
                    setField(field, bean, argValues);
                }
            }
        }
    }
}

From source file:eu.europa.ec.eci.oct.admin.controller.SettingsController.java

@Override
protected String _doPost(Model model, SettingsBean bean, BindingResult result, SessionStatus status,
        HttpServletRequest request, HttpServletResponse response) throws OCTException {
    if (request.getParameter("saveSettings") != null) {
        ConfigurationParameter param;//from   w  w w . j a  v a2s .com

        // custom logo settings
        if (bean.isDeleteLogo()) {
            param = configurationService.getConfigurationParameter(Parameter.LOGO_PATH);

            // delete file from disk
            final String storagePath = systemManager.getSystemPreferences().getFileStoragePath();
            final File destFolder = new File(storagePath, "/custom");
            final File dest = new File(destFolder, param.getValue());
            dest.delete();

            // update db
            param.setValue(Parameter.LOGO_PATH.getDefaultValue());
            configurationService.updateParameter(param);
        } else {
            final CommonsMultipartFile file = bean.getLogoFile();
            if (file != null && !"".equals(file.getOriginalFilename())) {
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Uploaded new logo file: " + file.getFileItem().getName() + " / " + file.getSize());
                }

                // validate uploaded logo file
                final Map<MultipartFileValidator.RejectReason, String> rejectDetailsMap = new HashMap<MultipartFileValidator.RejectReason, String>();
                rejectDetailsMap.put(RejectReason.EMPTY_CONTENT, "oct.settings.error.logo.missing");
                rejectDetailsMap.put(RejectReason.EMPTY_NAME, "oct.settings.error.logo.missing");
                rejectDetailsMap.put(RejectReason.BAD_EXTENSION, "oct.settings.error.logo.badExtension");
                rejectDetailsMap.put(RejectReason.MAX_SIZE_EXCEEDED, "oct.settings.error.logo.toobig");

                final Validator validator = new MultipartFileValidator(getCurrentMessageBundle(request),
                        "oct.settings.error.logo.upload", rejectDetailsMap, uploadExtensionWhitelist, 150000);
                validator.validate(file, result);
                if (result.hasErrors()) {
                    return doGet(model, request, response);
                }

                // validation passed, save file to needed location and
                // update the db
                final String storagePath = systemManager.getSystemPreferences().getFileStoragePath();
                final File destFolder = new File(storagePath, "/custom");
                if (!destFolder.exists()) {
                    boolean dirCreated = destFolder.mkdirs();
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "Storage directory \"" + destFolder.getPath() + "\" created? => " + dirCreated);
                    }
                }

                final String extension = file.getOriginalFilename()
                        .substring(file.getOriginalFilename().lastIndexOf('.'));
                final String fileName = new StringBuilder().append("customlogo")
                        .append(System.currentTimeMillis()).append(extension).toString();

                final File dest = new File(destFolder, fileName);
                try {
                    file.transferTo(dest);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Uploaded logo file successfully transfered to the local file "
                                + dest.getAbsolutePath());
                    }
                } catch (IllegalStateException e) {
                    logger.error("illegal state error while uploading logo", e);
                    result.reject("oct.settings.error.logo.upload", "Error uploading logo");
                    return doGet(model, request, response);
                } catch (IOException e) {
                    logger.error("input/output error while uploading logo", e);
                    result.reject("oct.settings.error.logo.upload", e.getMessage());
                    return doGet(model, request, response);
                }

                param = new ConfigurationParameter();
                param.setParam(Parameter.LOGO_PATH.getKey());
                param.setValue(fileName);
                configurationService.updateParameter(param);
            }
        }

        // callback url
        final String callbackUrl = bean.getCallbackUrl();
        if (callbackUrl != null && !"".equals(callbackUrl)) {
            // validate url
            UrlValidator validator = UrlValidator.getInstance();
            if (!validator.isValid(callbackUrl)) {
                result.rejectValue("callbackUrl", "oct.settings.error.callback.invalidurl",
                        "An invalid URL has been specified.");
                return doGet(model, request, response);
            }
        }
        param = new ConfigurationParameter();
        param.setParam(Parameter.CALLBACK_URL.getKey());
        param.setValue(callbackUrl);
        configurationService.updateParameter(param);

        // optional validation
        param = new ConfigurationParameter();
        param.setParam(Parameter.OPTIONAL_VALIDATION.getKey());
        param.setValue(new Boolean(bean.getOptionalValidation()).toString());
        configurationService.updateParameter(param);

        // distribution map
        param = new ConfigurationParameter();
        param.setParam(Parameter.SHOW_DISTRIBUTION_MAP.getKey());
        param.setValue(new Boolean(bean.getDisplayMap()).toString());
        configurationService.updateParameter(param);
    }

    return "redirect:settings.do";
}

From source file:com.prowidesoftware.swift.model.SwiftBlock.java

/**
 * Only valid for block2, only when using hibernate for persistence
 * @return true if the message block type is <code>2I</code>
 * @deprecated use {@link #getBlockType()}
 *//* w  w w. j av  a  2 s.c  om*/
public Boolean getInput() {
    return new Boolean(StringUtils.equals(getBlockType(), "2I"));
}

From source file:com.zenoss.zenpacks.zenjmx.call.OperationCall.java

private static Object[] createParamValues(ConfigAdapter config) throws ConfigurationException {
    String[] params = config.getOperationParamValues();
    String[] paramTypes = config.getOperationParamTypes();

    if (params.length != paramTypes.length) {
        throw new ConfigurationException("Datasource " + config.getDatasourceId()
                + " number of parameter types and " + "parameter values does not match");
    }//from   w w  w  . j  a  v a2 s .c o  m
    Object[] values = new Object[params.length];
    for (int i = 0; i < params.length; i++) {

        String type = paramTypes[i].trim();
        String valueStr = params[i].trim();
        Object resultValue = null;
        try {
            if (INT_TYPES.contains(type)) {
                resultValue = Integer.valueOf(valueStr);
            } else if (DOUBLE_TYPES.contains(type)) {
                resultValue = Double.valueOf(valueStr);
            } else if (LONG_TYPES.contains(type)) {
                resultValue = Long.valueOf(valueStr);
            } else if (FLOAT_TYPES.contains(type)) {
                resultValue = Float.valueOf(valueStr);
            } else if (STRING_TYPES.contains(type)) {
                resultValue = valueStr;
            } else if (BOOLEAN_TYPES.contains(type)) {
                resultValue = new Boolean(valueStr);
            } else {
                throw new ConfigurationException("Datasource " + config.getDatasourceId() + " Type " + type
                        + " is not handled for operation calls");
            }
        } catch (NumberFormatException e) {
            throw new ConfigurationException(
                    String.format("Datasource %1$s; value %2$s could not be converted to %3$s",
                            config.getDatasourceId(), valueStr, type));
        }
        values[i] = resultValue;
    }

    return values;
}

From source file:com.duroty.application.files.manager.StoreManager.java

/**
 * DOCUMENT ME!/*from w w w  .  jav a  2 s  .  c  o  m*/
 *
 * @param hsession DOCUMENT ME!
 * @param username DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws Exception DOCUMENT ME!
 */
protected Users getUser(org.hibernate.Session hsession, String username) throws Exception {
    try {
        Criteria criteria = hsession.createCriteria(Users.class);
        criteria.add(Restrictions.eq("useUsername", username));
        criteria.add(Restrictions.eq("useActive", new Boolean(true)));

        return (Users) criteria.uniqueResult();
    } finally {
    }
}

From source file:com.mockey.ui.HomeServlet.java

public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    String action = req.getParameter(API_CONFIGURATION_PARAMETER_ACTION);
    String type = req.getParameter(API_CONFIGURATION_PARAMETER_TYPE);
    if (action != null && "init".equals(action)) {

        // Flush - clean slate.
        IMockeyStorage store = StorageRegistry.MockeyStorage;
        JSONObject jsonResultObject = new JSONObject();

        // Load with local file.
        String fileName = req.getParameter("file");
        Boolean transientState = new Boolean(true);
        try {/*  ww  w . ja  v  a2s. c o  m*/
            transientState = new Boolean(
                    req.getParameter(API_CONFIGURATION_PARAMETER_ACTION_VALUE_TRANSIENT_STATE));
            store.setReadOnlyMode(transientState);
            logger.debug("Read only mode? " + transientState);
        } catch (Exception e) {

        }
        try {
            File f = new File(fileName);
            if (f.exists()) {
                // Slurp it up and initialize definitions.
                FileInputStream fstream = new FileInputStream(f);
                BufferedReader br = new BufferedReader(
                        new InputStreamReader(fstream, Charset.forName(HTTP.UTF_8)));
                StringBuffer inputString = new StringBuffer();
                // Read File Line By Line
                String strLine = null;
                // READ FIRST
                while ((strLine = br.readLine()) != null) {
                    // Print the content on the console
                    inputString.append(new String(strLine.getBytes(HTTP.UTF_8)));
                }
                // DELETE SECOND
                store.deleteEverything();
                MockeyXmlFileManager reader = new MockeyXmlFileManager();

                reader.loadConfigurationWithXmlDef(inputString.toString());
                logger.info("Loaded definitions from " + fileName);
                jsonResultObject.put(SUCCESS, "Loaded definitions from " + fileName);
                jsonResultObject.put(API_CONFIGURATION_PARAMETER_FILE, fileName);
            } else {
                logger.info(fileName + " does not exist. doing nothing.");
                jsonResultObject.put(FAIL, fileName + " does not exist. doing nothing.");
            }
        } catch (Exception e) {
            logger.debug("Unable to load service definitions with name: '" + fileName + "'", e);
            try {
                jsonResultObject.put(FAIL, "Unable to load service definitions with name: '" + fileName + "'");
            } catch (Exception ef) {
                logger.error("Unable to produce a JSON response.", e);
            }
        }

        // OK, return JSON or HTML?

        if (type != null && type.trim().equalsIgnoreCase("json")) {
            resp.setContentType("application/json;");
            PrintWriter out = resp.getWriter();
            JSONObject jsonResponseObject = new JSONObject();

            try {
                jsonResponseObject.put("result", jsonResultObject);
            } catch (JSONException e) {
                logger.error("Unable to produce a JSON result.", e);
            }
            out.println(jsonResponseObject.toString());
            return;
        } else {
            String contextRoot = req.getContextPath();
            resp.sendRedirect(Url.getContextAwarePath("/home", contextRoot));

            return;
        }

    } else if (action != null && "deleteAllServices".equals(action)) {
        // Flush - clean slate.
        IMockeyStorage store = StorageRegistry.MockeyStorage;
        store.deleteEverything();
        if (type != null && type.trim().equalsIgnoreCase("json")) {
            resp.setContentType("application/json;");
            PrintWriter out = resp.getWriter();
            JSONObject jsonResponseObject = new JSONObject();
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put(SUCCESS, "All is deleted. You have a clean slate. Enjoy.");
                jsonResponseObject.put("result", jsonObject);
            } catch (JSONException e) {
                logger.error("Unable to produce a JSON result.", e);
            }
            out.println(jsonResponseObject.toString());
            return;
        } else {
            String contextRoot = req.getContextPath();
            resp.sendRedirect(Url.getContextAwarePath("/home", contextRoot));

            return;
        }
    }

    req.setAttribute("services", Util.orderAlphabeticallyByServiceName(store.getServices()));
    req.setAttribute("plans", Util.orderAlphabeticallyByServicePlanName(store.getServicePlans()));

    RequestDispatcher dispatch = req.getRequestDispatcher("home.jsp");
    dispatch.forward(req, resp);
}