Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

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

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:com.apexxs.neonblack.setup.Configuration.java

private Configuration() {
    Properties configFile = new Properties();
    try {//www . j a  va  2  s. c  o m
        configFile.load(Configuration.class.getClassLoader().getResourceAsStream("NB.properties"));

        this.stanfordModel = configFile.getProperty("ner.detector.stanford.model");
        this.maxHits = Integer.parseInt(configFile.getProperty("solr.search.maxHits"));
        this.sortOnPopulation = Boolean.parseBoolean(configFile.getProperty("solr.populationSort"));
        this.removeStopWords = Boolean.parseBoolean(configFile.getProperty("ner.detector.removeStopWords"));
        this.removeDemonyms = Boolean.parseBoolean(configFile.getProperty("ner.detector.removeDemonyms"));
        this.replaceSynonyms = Boolean.parseBoolean(configFile.getProperty("ner.detector.replaceSynonyms"));
        this.polygonType = configFile.getProperty("polygon.type");
        this.polygonDirectory = configFile.getProperty("polygon.directory");
        if (!StringUtils.endsWith(this.polygonDirectory, "/")) {
            this.polygonDirectory += "/";
        }
        this.solrURL = configFile.getProperty("solr.url");
        if (!StringUtils.endsWith(this.solrURL, "/")) {
            this.solrURL += "/";
        }
        this.proximalDistance = configFile.getProperty("coords.proximalDistanceKM");
        this.numProximalHits = Integer.parseInt(configFile.getProperty("coords.numProximalHits"));
        this.numAlternates = Integer.parseInt(configFile.getProperty("results.numAlternates"));
        this.resultFormat = configFile.getProperty("results.format");

        this.resourceDirectory = configFile.getProperty("resource.directory");
        if (!StringUtils.endsWith(this.resourceDirectory, "/")) {
            this.resourceDirectory += "/";
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:cc.aileron.accessor.TypeConvertorImpl.java

@Override
public Object convert(final Object value, final Class<?> from, final Class<?> to) {
    /*/* ww  w . j a v  a  2  s .co m*/
     * to boolean
     */
    if (Boolean.class.isAssignableFrom(to) || to == Boolean.TYPE) {
        if (value == null) {
            return false;
        }
        if (Boolean.class.isAssignableFrom(from) || Boolean.TYPE == from) {
            return value;
        }
        if (Number.class.isAssignableFrom(from) || from.isPrimitive()) {
            return ((Number) value).intValue() != 0;
        }
        if (BooleanGetAccessor.class.isAssignableFrom(from)) {
            final BooleanGetAccessor accessor = (BooleanGetAccessor) value;
            return accessor.toBoolean();
        }
        if (String.class == from) {
            return Boolean.parseBoolean(String.class.cast(value));
        }
        return true;
    }

    /*
     * to primitive is null
     */
    if (to.isPrimitive() && value == null) {
        return 0;
    }

    /*
     * value is null
     */
    if (value == null) {
        return null;
    }

    /*
     * to primitive from string
     */
    if (to.isPrimitive() && String.class == from) {
        if (StringUtils.isEmpty((String) value)) {
            return 0;
        }
        final Integer number = Integer.valueOf((String) value);
        return numberToPrimitive(number, to);
    }

    /*
     * to primitive from number
     */
    if (to.isPrimitive() && Number.class.isAssignableFrom(from)) {
        final Number number = (Number) value;
        return numberToPrimitive(number, to);
    }

    /*
     * to number from string
     */
    if (Number.class.isAssignableFrom(to) && String.class == from) {
        final String string = (String) value;
        if (Boolean.TYPE == to) {
            return Boolean.parseBoolean(string);
        }
        if (Character.TYPE == to) {
            throw new UnsupportedOperationException();
        }
        final Number number = Integer.valueOf(string);
        return numberToPrimitive(number, to);
    }

    /*
     * to number from number-get-accessor
     */
    if (Number.class.isAssignableFrom(to) && value instanceof NumberGetAccessor) {
        final NumberGetAccessor accessor = (NumberGetAccessor) value;
        return accessor.toNumber();
    }

    /*
     * to string from not string
     */
    if (to == String.class && !(value instanceof String)) {
        return value.toString();
    }

    return value;
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.server.FileTemplateServiceServlet.java

@Override
protected FileContent getFileContent(final HttpServletRequest request) throws Exception {
    final String kind = request.getParameter(GenericConstants.ENTITY_KIND_KEY_PARAMETER);
    final String type = request.getParameter(GenericConstants.ENTITY_TYPE_KEY_PARAMETER);
    final String autoGenerate = request.getParameter(GenericConstants.AUTO_GENERATE);
    final String withExperimentsParameter = request.getParameter(GenericConstants.WITH_EXPERIMENTS);
    final boolean withExperiments = withExperimentsParameter != null
            && Boolean.parseBoolean(withExperimentsParameter) ? true : false;
    if (StringUtils.isNotBlank(kind) && StringUtils.isNotBlank(type)) {
        String fileContent = service.getTemplate(EntityKind.valueOf(kind), type,
                Boolean.parseBoolean(autoGenerate), withExperiments);
        byte[] value = fileContent.getBytes();
        String fileName = kind + "-" + type + "-template.tsv";
        return new FileContent(value, fileName);
    } else {//from  w ww .  j a  v a  2  s. co m
        return null;
    }
}

From source file:com.bluexml.side.framework.alfresco.commons.configurations.PropertiesConfiguration.java

public boolean getAsBooleanValue(String key) {
    return Boolean.parseBoolean(getValue(key).trim());
}

From source file:fr.unistra.di.metier.dip.ent.portal.portlets.aboutiframe.ConfigDAO.java

/**
 * Read Web Form from {@link PortletPreferences}
 * @param preferences/*from  w  w  w .ja v  a  2s .  com*/
 * @return
 * @see PortletPreferences#getValue(String, String)
 */
protected ConfigForm getForm(PortletPreferences preferences) {

    log.debug("Get PortletPreferences");

    ConfigForm form = new ConfigForm();
    Map<String, String> attrs = AboutIFramePortletController.IFRAME_ATTRS;
    for (String key : attrs.keySet()) {
        if ("url".equalsIgnoreCase(key) || "src".equalsIgnoreCase(key))
            continue;
        String value = preferences.getValue(key, null);
        if (value != null)
            form.setAttr(key, value);
    }
    form.setUrl(preferences.getValue("url", ""));
    form.setAbout(preferences.getValue("about", ""));
    form.setOpenExternal(Boolean.parseBoolean(preferences.getValue("openExternal", "false")));

    // retro-compatibility (move iFrameName  id)
    String iFrameName = preferences.getValue("iFrameName", null);
    if (iFrameName != null) {
        form.setAttr("iFrameName", iFrameName);
        form.delAttr("iFrameName");
        form.setAttr("id", iFrameName);
    }

    return form;
}

From source file:org.orderofthebee.addons.support.tools.share.LogFileGet.java

/**
 *
 * {@inheritDoc}/*from  ww  w .  j  a  v a2  s  .  c o m*/
 */
@Override
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException {
    final String servicePath = req.getServicePath();
    final String matchPath = req.getServiceMatch().getPath();
    final String filePath = servicePath.substring(servicePath.indexOf(matchPath) + matchPath.length());

    final Map<String, Object> model = new HashMap<>();
    final Status status = new Status();
    final Cache cache = new Cache(this.getDescription().getRequiredCache());
    model.put("status", status);
    model.put("cache", cache);

    final String attachParam = req.getParameter("a");
    final boolean attach = attachParam != null && Boolean.parseBoolean(attachParam);

    final File file = this.validateFilePath(filePath);

    // chances are log file is text/plain but might also be a compressed file (i.e. via logrotate)
    final String mimetype = "application/octet-stream";
    this.streamContent(req, res, file, file.lastModified(), attach, file.getName(), model, mimetype);
}

From source file:com.vangent.hieos.services.xds.bridge.mock.MockXConfigActor.java

/**
 * Method description/*from w w  w  .  j  a v a 2s  . co m*/
 *
 *
 * @param propKey
 * @param defaultValue
 *
 * @return
 */
@Override
public boolean getPropertyAsBoolean(String propKey, boolean defaultValue) {

    boolean result = defaultValue;
    String value = this.properties.getProperty(propKey);

    if (StringUtils.isNotBlank(value)) {

        result = Boolean.parseBoolean(value);
    }

    return result;
}

From source file:com.blazemeter.bamboo.plugin.api.HttpUtility.java

public HttpUtility() {
    this.httpClient = HttpClients.createDefault();
    useProxy = Boolean.parseBoolean(System.getProperty(Constants.USE_PROXY));
    proxyHost = System.getProperty(Constants.PROXY_HOST);

    try {/*from ww w .j a  va 2  s.com*/
        this.proxyPort = Integer.parseInt(System.getProperty(Constants.PROXY_PORT));
    } catch (NumberFormatException nfe) {
        logger.error("Failed to read http.proxyPort: ", nfe);
    }
    if (useProxy && !org.apache.commons.lang3.StringUtils.isBlank(this.proxyHost)) {
        this.proxy = new HttpHost(proxyHost, proxyPort);

        this.proxyUser = System.getProperty(Constants.PROXY_USER);
        this.proxyPass = System.getProperty(Constants.PROXY_PASS);
        if (!org.apache.commons.lang3.StringUtils.isEmpty(this.proxyUser)
                && !org.apache.commons.lang3.StringUtils.isEmpty(this.proxyPass)) {
            Credentials cr = new UsernamePasswordCredentials(proxyUser, proxyPass);
            AuthScope aus = new AuthScope(proxyHost, proxyPort);
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(aus, cr);
            this.httpClient = HttpClients.custom().setProxy(proxy).setDefaultCredentialsProvider(credsProvider)
                    .build();
        } else {
            this.httpClient = HttpClients.custom().setProxy(proxy).build();
        }
    }
}

From source file:org.usergrid.rest.security.shiro.filters.BasicAuthSecurityFilter.java

@Override
public ContainerRequest filter(ContainerRequest request) {
    Map<String, String> auth_types = getAuthTypes(request);
    if ((auth_types == null) || !auth_types.containsKey(AUTH_BASIC_TYPE)) {
        return request;
    }/*from w ww .ja  v  a 2  s  . c o m*/

    String[] values = Base64.decodeToString(auth_types.get(AUTH_BASIC_TYPE)).split(":");
    if (values.length < 2) {
        return request;
    }
    String name = values[0].toLowerCase();
    String password = values[1];

    String sysadmin_login_name = properties.getProperty("usergrid.sysadmin.login.name");
    String sysadmin_login_password = properties.getProperty("usergrid.sysadmin.login.password");
    boolean sysadmin_login_allowed = Boolean
            .parseBoolean(properties.getProperty("usergrid.sysadmin.login.allowed"));
    if (name.equals(sysadmin_login_name) && password.equals(sysadmin_login_password)
            && sysadmin_login_allowed) {
        request.setSecurityContext(new SysAdminRoleAuthenticator());
        logger.info("System administrator access allowed");
        return request;
    }

    return request;
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.TwinColumnLoader.java

@Override
public void loadComponent() {
    super.loadComponent();

    String captionProperty = element.attributeValue("captionProperty");
    if (!StringUtils.isEmpty(captionProperty)) {
        resultComponent.setCaptionMode(CaptionMode.PROPERTY);
        resultComponent.setCaptionProperty(captionProperty);
    }/*from   ww w .j ava  2  s.  c om*/

    String columns = element.attributeValue("columns");
    if (!StringUtils.isEmpty(columns)) {
        resultComponent.setColumns(Integer.parseInt(columns));
    }

    String rows = element.attributeValue("rows");
    if (StringUtils.isNotEmpty(rows)) {
        resultComponent.setRows(Integer.parseInt(rows));
    }

    String addBtnEnabled = element.attributeValue("addAllBtnEnabled");
    if (StringUtils.isNotEmpty(addBtnEnabled)) {
        resultComponent.setAddAllBtnEnabled(Boolean.parseBoolean(addBtnEnabled));
    }

    String rightColumnCaption = element.attributeValue("rightColumnCaption");
    if (StringUtils.isNotEmpty(rightColumnCaption)) {
        resultComponent.setRightColumnCaption(loadResourceString(rightColumnCaption));
    }

    String leftColumnCaption = element.attributeValue("leftColumnCaption");
    if (StringUtils.isNotEmpty(leftColumnCaption)) {
        resultComponent.setLeftColumnCaption(loadResourceString(leftColumnCaption));
    }

    String multiselect = element.attributeValue("multiselect");
    if (StringUtils.isNotEmpty(multiselect)) {
        resultComponent.setMultiSelect(Boolean.parseBoolean(multiselect));
    }

    loadTabIndex(resultComponent, element);
}