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:de.mpg.imeji.presentation.beans.PropertyBean.java

/**
  * Default constructor// ww w. java2 s.  c  o m
  */
public PropertyBean() {
    try {
        this.digilibEnabled = Boolean.parseBoolean(PropertyReader.getProperty("imeji.digilib.enable"));
        this.internalStorageBase = FilenameUtils.getBaseName(
                FilenameUtils.normalizeNoEndSeparator(PropertyReader.getProperty("imeji.storage.path")));
        applicationURL = StringHelper.normalizeURI(PropertyReader.getProperty("imeji.instance.url"));
        css_default = PropertyReader.getProperty("imeji.layout.css_default");
        css_alternate = PropertyReader.getProperty("imeji.layout.css_alternate");
        readBaseUri();
        this.appName = PropertyReader.getProperty("imeji.instance.name");
    } catch (Exception e) {
        throw new RuntimeException("Error reading properties: ", e);
    }
}

From source file:io.cloudslang.content.httpclient.build.URIBuilder.java

public URI buildURI() {
    try {/*w  w  w. j  av a  2s  .c om*/
        //validate as URL
        new URL(url);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("the value '" + url + "' is not a valid URL", e);
    }
    org.apache.http.client.utils.URIBuilder uriBuilder;
    try {
        uriBuilder = new org.apache.http.client.utils.URIBuilder(url);
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("the value '" + url + "' is not a valid URI", e);
    }

    boolean bEncodeQueryParams = !Boolean.parseBoolean(queryParamsAreURLEncoded);
    boolean bEncodeQueryParamsAsForm = Boolean.parseBoolean(queryParamsAreFormEncoded);

    if (!StringUtils.isEmpty(queryParams)) {
        try {
            if (bEncodeQueryParamsAsForm) {
                uriBuilder.addParameters(
                        (List<NameValuePair>) Utils.urlEncodeMultipleParams(queryParams, bEncodeQueryParams));
            } else {
                uriBuilder.setCustomQuery(Utils.urlEncodeQueryParams(queryParams, bEncodeQueryParams));
            }
        } catch (IllegalArgumentException ie) {
            throw new IllegalArgumentException(HttpClientInputs.QUERY_PARAMS_ARE_URLENCODED
                    + " is 'false' but queryParams are not properly encoded. " + ie.getMessage(), ie);
        }
    }

    try {
        return uriBuilder.build();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("could not build '" + HttpClientInputs.URL + "' for " + url
                + " and queries " + queryParamsAreURLEncoded, e);
    }

}

From source file:com.amazon.speech.speechlet.servlet.SpeechletServlet.java

public SpeechletServlet() {
    // An invalid value or null will turn signature checking on.
    disableRequestSignatureCheck = Boolean
            .parseBoolean(System.getProperty(Sdk.DISABLE_REQUEST_SIGNATURE_CHECK_SYSTEM_PROPERTY));
    speechletRequestHandler = new ServletSpeechletRequestHandler();
}

From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java

/**
 * Sends a password reset email to the email address provided
 * /* ww w  .java2  s  . c  o m*/
 * @param toEmail
 * @param newPwd
 * @throws Exception
 */
public void sendPwdResetMailFromApp(String toEmail, String newPwd) throws Exception {
    Email email = new SimpleEmail();
    email.setSmtpPort(Integer.parseInt(smtpPort));
    email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd));
    email.setDebug(Boolean.parseBoolean(debugEnabled));
    email.setHostName(smtpSever);
    email.setFrom(fromAddress);
    email.setSubject("Reset Olhie Password");
    email.setMsg("You have requested that your password be reset. Your new Olhie password is " + newPwd);
    email.addTo(toEmail);
    email.setTLS(Boolean.parseBoolean(tlsEnabled));
    email.setSocketTimeout(10000);
    email.setSocketConnectionTimeout(12000);
    email.send();
}

From source file:com.redhat.coolstore.api_gateway.RatingGateway.java

@Override
public void configure() throws Exception {
    try {//  ww  w .  j  a va  2 s. c  om
        getContext().setTracing(Boolean.parseBoolean(env.getProperty("ENABLE_TRACER", "false")));
    } catch (Exception e) {
        LOG.error("Failed to parse the ENABLE_TRACER value: {}", env.getProperty("ENABLE_TRACER", "false"));
    }

    restConfiguration().component("servlet").bindingMode(RestBindingMode.auto).apiContextPath("/api-docs")
            .contextPath("/api").apiProperty("host", "")
            .apiProperty("api.title", "CoolStore Microservice API Gateway").apiProperty("api.version", "1.0.0")
            .apiProperty("api.description",
                    "The API of the gateway which fronts the various backend microservices in the CoolStore")
            .apiProperty("api.contact.name", "Red Hat Developers")
            .apiProperty("api.contact.email", "developers@redhat.com")
            .apiProperty("api.contact.url", "https://developers.redhat.com");

    rest("/rating").description("Product Rating Service").produces(MediaType.APPLICATION_JSON_VALUE)

            .post("/{itemId}/{rating}").description("Add product rating").param().name("itemId")
            .type(RestParamType.path).description("The ID of the item to process").dataType("string").endParam()
            .param().name("rating").type(RestParamType.path).description("The rating from 1-5").dataType("int")
            .endParam().outType(Rating.class).route().id("submitRatingRoute").hystrix()
            .id("Rating Service (Add Rating)").hystrixConfiguration()
            .executionTimeoutInMilliseconds(hystrixExecutionTimeout).groupKey(hystrixGroupKey)
            .circuitBreakerEnabled(hystrixCircuitBreakerEnabled).end().removeHeaders("CamelHttp*")
            .setBody(simple("null")).setHeader(Exchange.HTTP_METHOD, HttpMethods.POST)
            .setHeader(Exchange.HTTP_URI, simple(
                    "http://{{env:RATING_ENDPOINT:rating:8080}}/api/rating/${header.itemId}/${header.rating}"))
            .to("http4://DUMMY").onFallback().setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
            .to("direct:submitRatingFallback").end()
            .setHeader("CamelJacksonUnmarshalType", simple(Rating.class.getName())).unmarshal()
            .json(JsonLibrary.Jackson, Rating.class).endRest();

    // Provide a response
    from("direct:submitRatingFallback").routeId("submitratingfallback")
            .description("Submit Rating Fall back response")
            .process(exchange -> exchange.getIn().setBody(new Rating())).marshal().json(JsonLibrary.Jackson);

}

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

public boolean getAsBooleanValue(String key, Boolean defaultValue) {
    String defaultString = Boolean.toString(defaultValue);
    String value = getValue(key, defaultString);
    return Boolean.parseBoolean(value.trim());
}

From source file:de.blizzy.backup.BackupPlugin.java

boolean isHidden() {
    return Boolean
            .parseBoolean(StringUtils.defaultString(getApplicationArg(ARG_HIDDEN), Boolean.FALSE.toString()));
}

From source file:com.medvision360.medrecord.basex.XmlWrappedArchetypeConverter.java

@Override
public WrappedArchetype parse(InputStream is, String encoding) throws IOException, ParseException {
    Document d = toDocument(is, encoding);

    String asString = xpath(d, "//asString", Filters.element());
    //        System.out.println("--------------------------");
    //        String[] lines = asString.split("\r?\n");
    //        for (int i = 0; i < lines.length; i++)
    //        {/*w w  w.  j  a va  2s.  c om*/
    //            String line = lines[i];
    //            int lineNo = i + 1;
    //            System.out.println(""+lineNo+": "+line);
    //        }
    //        System.out.println("--------------------------");
    boolean locked = Boolean.parseBoolean(xpath(d, "//locked", Filters.element()));

    InputStream asInputStream = IOUtils.toInputStream(asString);
    WrappedArchetype result = m_delegate.parse(asInputStream, encoding);
    return new WrappedArchetype(asString, result.getArchetype(), locked);
}

From source file:com.mirth.connect.model.converters.NCPDPSerializer.java

public NCPDPSerializer(Map<?, ?> properties) {
    if (properties != null) {
        if (properties.get("segmentDelimiter") != null) {
            String segDel = convertNonPrintableCharacters((String) properties.get("segmentDelimiter"));

            if (segDel.equals("0x1E")) {
                this.segmentDelimeter = "\u001E";
            } else {
                this.segmentDelimeter = segDel;
            }//ww  w  .  j av  a2s  .com
        }

        if (properties.get("groupDelimiter") != null) {
            String grpDel = convertNonPrintableCharacters((String) properties.get("groupDelimiter"));

            if (grpDel.equals("0x1D")) {
                this.groupDelimeter = "\u001D";
            } else {
                this.groupDelimeter = grpDel;
            }
        }

        if (properties.get("fieldDelimiter") != null) {
            String fieldDel = convertNonPrintableCharacters((String) properties.get("fieldDelimiter"));

            if (fieldDel.equals("0x1C")) {
                this.fieldDelimeter = "\u001C";
            } else {
                this.fieldDelimeter = fieldDel;
            }
        }

        if (properties.get("useStrictValidation") != null) {
            this.useStrictValidation = Boolean.parseBoolean((String) properties.get("useStrictValidation"));
        }
    }
}

From source file:com.evolveum.midpoint.prism.util.JavaTypeConverter.java

public static <T> T convert(Class<T> expectedType, Object rawValue) {
    if (rawValue == null || expectedType.isInstance(rawValue)) {
        return (T) rawValue;
    }//from   w ww  .j  a  v a2  s.  c o m
    if (rawValue instanceof PrismPropertyValue<?>) {
        rawValue = ((PrismPropertyValue<?>) rawValue).getValue();
    }
    // This really needs to be checked twice
    if (rawValue == null || expectedType.isInstance(rawValue)) {
        return (T) rawValue;
    }

    // Primitive types

    // boolean
    if (expectedType == boolean.class && rawValue instanceof Boolean) {
        return (T) ((Boolean) rawValue);
    }
    if (expectedType == Boolean.class && rawValue instanceof String) {
        return (T) (Boolean) Boolean.parseBoolean(((String) rawValue));
    }
    if (expectedType == Boolean.class && rawValue instanceof PolyString) {
        return (T) (Boolean) Boolean.parseBoolean(((PolyString) rawValue).toString());
    }
    if (expectedType == boolean.class && rawValue instanceof String) {
        return (T) (Boolean) Boolean.parseBoolean(((String) rawValue));
    }
    if (expectedType == boolean.class && rawValue instanceof PolyString) {
        return (T) (Boolean) Boolean.parseBoolean(((PolyString) rawValue).toString());
    }
    if (expectedType == String.class && rawValue instanceof Boolean) {
        return (T) rawValue.toString();
    }

    // int
    if (expectedType == int.class && rawValue instanceof Integer) {
        return (T) ((Integer) rawValue);
    }
    if (expectedType == Integer.class && rawValue instanceof String) {
        return (T) (Integer) Integer.parseInt(((String) rawValue));
    }
    if (expectedType == int.class && rawValue instanceof String) {
        return (T) (Integer) Integer.parseInt(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof Integer) {
        return (T) rawValue.toString();
    }
    if (expectedType == int.class && rawValue instanceof Long) {
        return (T) (Integer) ((Long) rawValue).intValue();
    }

    if (expectedType == long.class && rawValue instanceof Long) {
        return (T) ((Long) rawValue);
    }
    if (expectedType == Long.class && rawValue instanceof String) {
        return (T) (Long) Long.parseLong(((String) rawValue));
    }
    if (expectedType == long.class && rawValue instanceof String) {
        return (T) (Long) Long.parseLong(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof Long) {
        return (T) rawValue.toString();
    }

    if (expectedType == float.class && rawValue instanceof Float) {
        return (T) ((Float) rawValue);
    }
    if (expectedType == Float.class && rawValue instanceof String) {
        return (T) (Float) Float.parseFloat(((String) rawValue));
    }
    if (expectedType == float.class && rawValue instanceof String) {
        return (T) (Float) Float.parseFloat(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof Float) {
        return (T) rawValue.toString();
    }

    if (expectedType == double.class && rawValue instanceof Double) {
        return (T) ((Double) rawValue);
    }
    if (expectedType == Double.class && rawValue instanceof String) {
        return (T) (Double) Double.parseDouble(((String) rawValue));
    }
    if (expectedType == double.class && rawValue instanceof String) {
        return (T) (Double) Double.parseDouble(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof Float) {
        return (T) rawValue.toString();
    }

    if (expectedType == byte.class && rawValue instanceof Byte) {
        return (T) ((Byte) rawValue);
    }
    if (expectedType == Byte.class && rawValue instanceof String) {
        return (T) (Byte) Byte.parseByte(((String) rawValue));
    }
    if (expectedType == byte.class && rawValue instanceof String) {
        return (T) (Byte) Byte.parseByte(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof Byte) {
        return (T) rawValue.toString();
    }

    if (expectedType == BigInteger.class && rawValue instanceof String) {
        return (T) new BigInteger(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof BigInteger) {
        return (T) ((BigInteger) rawValue).toString();
    }

    if (expectedType == BigDecimal.class && rawValue instanceof String) {
        return (T) new BigDecimal(((String) rawValue));
    }
    if (expectedType == String.class && rawValue instanceof BigDecimal) {
        return (T) ((BigDecimal) rawValue).toString();
    }

    if (expectedType == PolyString.class && rawValue instanceof String) {
        return (T) new PolyString((String) rawValue);
    }
    if (expectedType == PolyStringType.class && rawValue instanceof String) {
        PolyStringType polyStringType = new PolyStringType();
        polyStringType.setOrig((String) rawValue);
        return (T) polyStringType;
    }
    if (expectedType == String.class && rawValue instanceof PolyString) {
        return (T) ((PolyString) rawValue).getOrig();
    }
    if (expectedType == String.class && rawValue instanceof PolyStringType) {
        return (T) ((PolyStringType) rawValue).getOrig();
    }
    if (expectedType == PolyString.class && rawValue instanceof PolyStringType) {
        return (T) ((PolyStringType) rawValue).toPolyString();
    }
    if (expectedType == PolyString.class && rawValue instanceof Integer) {
        return (T) new PolyString(((Integer) rawValue).toString());
    }
    if (expectedType == PolyStringType.class && rawValue instanceof PolyString) {
        PolyStringType polyStringType = new PolyStringType((PolyString) rawValue);
        return (T) polyStringType;
    }
    if (expectedType == PolyStringType.class && rawValue instanceof Integer) {
        PolyStringType polyStringType = new PolyStringType(((Integer) rawValue).toString());
        return (T) polyStringType;
    }

    // Date and time
    if (expectedType == XMLGregorianCalendar.class && rawValue instanceof Long) {
        XMLGregorianCalendar xmlCalType = XmlTypeConverter.createXMLGregorianCalendar((Long) rawValue);
        return (T) xmlCalType;
    }
    if (expectedType == XMLGregorianCalendar.class && rawValue instanceof String) {
        XMLGregorianCalendar xmlCalType = magicDateTimeParse((String) rawValue);
        return (T) xmlCalType;
    }
    if (expectedType == String.class && rawValue instanceof XMLGregorianCalendar) {
        return (T) ((XMLGregorianCalendar) rawValue).toXMLFormat();
    }
    if (expectedType == Long.class && rawValue instanceof XMLGregorianCalendar) {
        return (T) (Long) XmlTypeConverter.toMillis((XMLGregorianCalendar) rawValue);
    }

    // XML Enums (JAXB)
    if (expectedType.isEnum() && expectedType.getAnnotation(XmlEnum.class) != null
            && rawValue instanceof String) {
        return XmlTypeConverter.toXmlEnum(expectedType, (String) rawValue);
    }
    if (expectedType == String.class && rawValue.getClass().isEnum()
            && rawValue.getClass().getAnnotation(XmlEnum.class) != null) {
        return (T) XmlTypeConverter.fromXmlEnum(rawValue);
    }

    // Java Enums
    if (expectedType.isEnum() && rawValue instanceof String) {
        return (T) Enum.valueOf((Class<Enum>) expectedType, (String) rawValue);
    }
    if (expectedType == String.class && rawValue.getClass().isEnum()) {
        return (T) rawValue.toString();
    }

    //QName
    if (expectedType == QName.class && rawValue instanceof QName) {
        return (T) rawValue;
    }
    if (expectedType == QName.class && rawValue instanceof String) {
        return (T) QNameUtil.uriToQName((String) rawValue);
    }

    throw new IllegalArgumentException("Expected " + expectedType + " type, but got " + rawValue.getClass());
}