Example usage for org.apache.commons.lang BooleanUtils toBoolean

List of usage examples for org.apache.commons.lang BooleanUtils toBoolean

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toBoolean.

Prototype

public static boolean toBoolean(String str) 

Source Link

Document

Converts a String to a boolean (optimised for performance).

'true', 'on' or 'yes' (case insensitive) will return true.

Usage

From source file:org.mule.transport.stdio.StdioMessageReceiver.java

public StdioMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint,
        long checkFrequency) throws CreateException {
    super(connector, flowConstruct, endpoint);
    this.setFrequency(checkFrequency);

    this.connector = (StdioConnector) connector;
    String streamName = endpoint.getEndpointURI().getAddress();
    if (StdioConnector.STREAM_SYSTEM_IN.equalsIgnoreCase(streamName)) {
        inputStream = System.in;// www .  jav a2  s . co m
    } else {
        inputStream = this.connector.getInputStream();
    }

    // apply connector-specific properties
    if (connector instanceof PromptStdioConnector) {
        PromptStdioConnector ssc = (PromptStdioConnector) connector;

        String promptMessage = (String) endpoint.getProperties().get("promptMessage");
        if (promptMessage != null) {
            ssc.setPromptMessage(promptMessage);
        }
    }

    this.sendStream = BooleanUtils.toBoolean((String) endpoint.getProperties().get("sendStream"));
}

From source file:org.ngrinder.common.util.PropertiesWrapper.java

/**
 * Get the property as boolean.//  w  ww. j a  v  a  2 s  .  com
 *
 * @param key property key
 * @return property boolean value
 */
public boolean getPropertyBoolean(String key) {
    return BooleanUtils.toBoolean(getProperty(key));
}

From source file:org.ngrinder.NGrinderStarter.java

/**
 * Constructor./*  www . j a v  a 2s .co m*/
 */
public NGrinderStarter() {

    // Check agent start mode
    isWebStart = BooleanUtils.toBoolean(System.getProperty("start.webstart", "false"));

    if (!isValidCurrentDirectory() && !isWebStart) {
        staticPrintHelpAndExit("nGrinder agent should start in the folder which nGrinder agent exists.");
    }
    agentConfig = new AgentConfig();
    agentConfig.init();
    // Configure log.
    Boolean verboseMode = agentConfig.getPropertyBoolean("verbose", false);
    File logDirectory = agentConfig.getHome().getLogDirectory();
    configureLogging(verboseMode, logDirectory);
    addClassPath();
    addLibarayPath();
}

From source file:org.ngrinder.recorder.infra.RecorderConfig.java

/**
 * if there is testmode property in system.properties.. return true
 * /* ww  w  . ja  v a 2 s .  com*/
 * @return true is test mode
 */
public boolean isTestMode() {
    return BooleanUtils.toBoolean(getAgentProperty("testmode", "false"));
}

From source file:org.ngrinder.recorder.util.PropertiesWrapper.java

/**
 * Get property as boolean./*  ww w . j ava 2s  .  c  o  m*/
 * 
 * @param key
 *            property key
 * @param defaultValue
 *            default value when data is not available
 * @return property boolean value
 */
public boolean getPropertyBoolean(String key, boolean defaultValue) {
    String property = getProperty(key, String.valueOf(defaultValue), DEFAULT_ERROR_MESSGAE);
    return BooleanUtils.toBoolean(property);
}

From source file:org.nuxeo.ecm.platform.suggestbox.service.suggesters.DocumentParameterLookupSuggester.java

@Override
public void initWithParameters(SuggesterDescriptor descriptor) {
    this.descriptor = descriptor;
    String providerName = descriptor.getParameters().get("providerName");
    if (providerName != null) {
        this.providerName = providerName;
    }/*  w  ww  .j a  v a 2s  . c om*/
    String appendWildcard = descriptor.getParameters().get("appendWildcard");
    if (appendWildcard != null) {
        this.appendWildcard = BooleanUtils.toBoolean(appendWildcard);
    }
}

From source file:org.objectstyle.cayenne.dataview.DataView.java

private void loadField(ObjEntityView entityView, Element element) {
    String name = element.getAttributeValue("name");
    ObjEntityViewField field = new ObjEntityViewField();
    field.setName(name);//from   w w w .  j ava2 s . com
    String prefIndex = element.getAttributeValue("pref-index");
    field.setPreferredIndex(NumberUtils.stringToInt(prefIndex, -1));
    entityView.insertField(field);

    String calcType = element.getAttributeValue("calc-type");
    Validate.notNull(calcType);
    CalcTypeEnum fieldCalcType = CalcTypeEnum.getEnum(calcType);
    Validate.isTrue(
            CalcTypeEnum.NO_CALC_TYPE.equals(fieldCalcType) || CalcTypeEnum.LOOKUP_TYPE.equals(fieldCalcType),
            "Calc Type not supported yet: ", fieldCalcType);
    field.setCalcType(fieldCalcType);

    ObjEntity objEntity = entityView.getObjEntity();

    if (CalcTypeEnum.NO_CALC_TYPE.equals(fieldCalcType)) {
        String objAttributeName = element.getAttributeValue("obj-attribute-name");
        Validate.notNull(objAttributeName);
        ObjAttribute objAttribute = (ObjAttribute) objEntity.getAttribute(objAttributeName);
        field.setObjAttribute(objAttribute);
    } else if (CalcTypeEnum.LOOKUP_TYPE.equals(fieldCalcType)) {
        String objRelationshipName = element.getAttributeValue("obj-relationship-name");
        Validate.notNull(objRelationshipName);
        ObjRelationship objRelationship = (ObjRelationship) objEntity.getRelationship(objRelationshipName);
        field.setObjRelationship(objRelationship);
        Element lookupElement = element.getChild("lookup");
        Validate.notNull(lookupElement);
        String lookupEntityView = lookupElement.getAttributeValue("obj-entity-view-name");
        Validate.notNull(lookupEntityView);
        String lookupEntityField = lookupElement.getAttributeValue("field-name");
        Validate.notNull(lookupEntityField);
        String[] lookupDescriptor = new String[] { lookupEntityView, lookupEntityField };
        lookupReferenceTable.put(field, lookupDescriptor);
    }

    String dataType = element.getAttributeValue("data-type");
    Validate.notNull(dataType);
    field.setDataType(dataTypeSpec.getDataType(dataType));

    String editable = element.getAttributeValue("editable");
    field.setEditable(BooleanUtils.toBoolean(editable));

    String visible = element.getAttributeValue("visible");
    field.setVisible(BooleanUtils.toBoolean(visible));

    Element captionElement = element.getChild("caption");
    if (captionElement != null)
        field.setCaption(StringUtils.stripToEmpty(captionElement.getText()));

    Element editFormatElement = element.getChild("edit-format");
    if (editFormatElement != null) {
        String formatClassName = editFormatElement.getAttributeValue("class");
        Validate.notNull(formatClassName);
        Class formatClass;
        try {
            formatClass = Class.forName(formatClassName);
            Map parameters = DataView.childrenToMap(editFormatElement);
            Format format = formatFactory.createFormat(formatClass, locale, parameters);
            field.setEditFormat(format);
        } catch (ClassNotFoundException ex) {
        }
    }

    Element displayFormatElement = element.getChild("display-format");
    if (displayFormatElement != null) {
        String formatClassName = displayFormatElement.getAttributeValue("class");
        Validate.notNull(formatClassName);
        Class formatClass;
        try {
            formatClass = Class.forName(formatClassName);
            Map parameters = DataView.childrenToMap(displayFormatElement);
            Format format = formatFactory.createFormat(formatClass, locale, parameters);
            field.setDisplayFormat(format);
        } catch (ClassNotFoundException ex) {
        }
    }

    Element defaultValueElement = element.getChild("default-value");
    if (defaultValueElement != null) {
        String defaultValueStr = StringUtils.stripToEmpty(defaultValueElement.getText());
        Object defaultValue = dataTypeSpec.create(field.getDataType(), defaultValueStr);
        field.setDefaultValue(defaultValue);
    }
}

From source file:org.ojbc.adapters.analyticaldatastore.processor.PretrialEnrollmentReportProcessor.java

private void addPretrialServiceIdToList(Integer pretrialServiceParticipationPkId,
        List<Integer> pretrialServiceIds, String indicator, AssessedNeeds assessedNeeds) {
    if (BooleanUtils.toBoolean(indicator)) {
        pretrialServiceIds.add(/*from ww  w. jav  a 2 s.  c  o  m*/
                descriptionCodeLookupService.retrieveCode(CodeTable.PretrialService, assessedNeeds.toString()));
    }
}

From source file:org.ojbc.adapters.analyticaldatastore.processor.PretrialEnrollmentReportProcessor.java

private void addAssessedNeedsIdToList(Integer pretrialServiceParticipationPkId, List<Integer> assessedNeedsIds,
        String indicator, AssessedNeeds assessedNeeds) {
    if (BooleanUtils.toBoolean(indicator)) {
        assessedNeedsIds.add(//ww  w  .ja v a2s .c om
                descriptionCodeLookupService.retrieveCode(CodeTable.AssessedNeed, assessedNeeds.toString()));
    }
}

From source file:org.ojbc.util.camel.processor.accesscontrol.OriAndRoleAccessControlStrategy.java

private boolean isAuthorized(String employerORI, Message cxfMessage) {
    String firearmsRegistrationRecordsPersonnelIndicator = SAMLTokenUtils.getSamlAttributeFromCxfMessage(
            cxfMessage, SamlAttribute.FirearmsRegistrationRecordsPersonnelIndicator);
    String supervisoryRoleIndicator = SAMLTokenUtils.getSamlAttributeFromCxfMessage(cxfMessage,
            SamlAttribute.SupervisoryRoleIndicator);
    log.debug("FirearmsRegistrationRecordsPersonnelIndicator"
            + StringUtils.trimToEmpty(firearmsRegistrationRecordsPersonnelIndicator));
    log.debug("SupervisoryRoleIndicator" + StringUtils.trimToEmpty(supervisoryRoleIndicator));

    return authorizedORIs.contains(employerORI) && (BooleanUtils.toBoolean(supervisoryRoleIndicator)
            || BooleanUtils.toBoolean(firearmsRegistrationRecordsPersonnelIndicator));
}