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:us.paulevans.basicxslt.BasicXSLTFrame.java

/**
 * Load the output properties on the aOutputProperties object from the 
 * user's preferences.//from   w w  w.  ja  va2 s .c  o  m
 * @param aOutputProperties
 * @param aPropertyNamePrefix
 */
private void loadOutputProperties(TransformOutputProperties aOutputProperties, String aPropertyNamePrefix) {

    aOutputProperties.setCDATA_SECTION_ELEMENTS(StringUtils
            .defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.CDATA_SECTION_ELEMENTS)));
    aOutputProperties.setDOCTYPE_PUBLIC(StringUtils
            .defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.DOCTYPE_PUBLIC)));
    aOutputProperties.setDOCTYPE_SYSTEM(StringUtils
            .defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.DOCTYPE_SYSTEM)));
    aOutputProperties.setENCODING(
            StringUtils.defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.ENCODING)));
    aOutputProperties.setINDENT(
            BooleanUtils.toBoolean(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.INDENT)));
    aOutputProperties.setMEDIA_TYPE(
            StringUtils.defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.MEDIA_TYPE)));
    aOutputProperties.setMETHOD(
            StringUtils.defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.METHOD)));
    aOutputProperties.setOMIT_XML_DECLARATION(BooleanUtils
            .toBoolean(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.OMIT_XML_DECLARATION)));
    aOutputProperties.setSTANDALONE(
            BooleanUtils.toBoolean(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.STANDALONE)));
    aOutputProperties.setVERSION(
            StringUtils.defaultString(userPrefs.getProperty(aPropertyNamePrefix + AppConstants.VERSION)));
}

From source file:us.paulevans.basicxslt.BasicXSLTFrame.java

/**
 * Initialize the gui/*from   w ww .  j a  v  a 2s. c  om*/
 *
 */
private void initializeControls() {

    String val, xCoord, yCoord, propertyNamePrefix;
    boolean areGoodCoordinates;
    int loop;
    XSLRow xslRow;

    loop = 0;
    val = userPrefs.getProperty(AppConstants.CHK_WARNINGS_PROP);
    checkSaxWarning.setSelected(val != null ? Boolean.valueOf(val).booleanValue() : false);
    val = userPrefs.getProperty(AppConstants.CHK_ERRORS_PROP);
    checkSaxError.setSelected(val != null ? Boolean.valueOf(val).booleanValue() : false);
    val = userPrefs.getProperty(AppConstants.CHK_FATAL_ERRORS_PROP);
    checkSaxFatalError.setSelected(val != null ? Boolean.valueOf(val).booleanValue() : false);
    xCoord = userPrefs.getProperty(AppConstants.X_COORD_PROP);
    yCoord = userPrefs.getProperty(AppConstants.Y_COORD_PROP);
    areGoodCoordinates = false;
    if (xCoord != null && yCoord != null) {
        this.setLocation(Integer.parseInt(xCoord), Integer.parseInt(yCoord));
        areGoodCoordinates = true;
    }
    if (!areGoodCoordinates) {
        GUIUtils.center(this, null);
    }
    sourceXmlTf.setText(userPrefs.getProperty(AppConstants.LAST_XML_FILE_PROP));
    val = userPrefs.getProperty(AppConstants.SUPPRESS_OUTPUT_WINDOW_PROP);
    suppressOutputWindowCb.setSelected(BooleanUtils.toBoolean(val));
    val = userPrefs.getProperty(AppConstants.OUTPUT_AS_TEXT_IF_XML_PROP);
    outputAsTextIfXml.setSelected(BooleanUtils.toBoolean(val));
    outputAsTextIfXmlLabel.setEnabled(!suppressOutputWindowCb.isSelected());
    outputAsTextIfXml.setEnabled(!suppressOutputWindowCb.isSelected());
    val = userPrefs.getProperty(AppConstants.AUTOSAVE_RESULT_PROP);
    autosaveCb.setSelected(BooleanUtils.toBoolean(val));
    autosavePathTf.setText(userPrefs.getProperty(AppConstants.AUTOSAVE_FILE_PROP));
    autosavePathTf.setEnabled(autosaveCb.isSelected());
    browseAutosavePathBtn.setEnabled(autosaveCb.isSelected());
    removeCheckedBtn.setEnabled(false);

    xmlIdentityTransformOutputProps = new TransformOutputProperties();
    // load xml output props from user prefs
    val = userPrefs.getProperty("xml_identity_transform_opInd");
    setAreOutputPropertiesSet(BooleanUtils.toBoolean(val));
    loadOutputProperties(xmlIdentityTransformOutputProps, "xml_identity_transform_outputproperties_");

    refreshXmlIndicatorLabel();

    do {
        propertyNamePrefix = "xsl_" + loop + "_outputproperties_";
        val = userPrefs.getProperty("xsl_" + loop + "_file");
        if (val != null) {
            xslRow = xslRows.get(loop);
            loadParameters(xslRow);
            xslRow.getTextField().setText(val);
            val = userPrefs.getProperty("xsl_" + loop + "_onoff");
            xslRow.setOn(BooleanUtils.toBoolean(val));
            val = userPrefs.getProperty("xsl_" + loop + "_opInd");
            xslRow.setAreOutputPropertiesSet(BooleanUtils.toBoolean(val));
            loadOutputProperties(xslRow.getTransformOutputProperties(), propertyNamePrefix);
            loop++;
        }
    } while (val != null);
}

From source file:us.paulevans.basicxslt.TransformOutputPropertiesFrame.java

/**
 * Initializes the GUI//  w  ww. jav a 2s.c om
 * @param aOutputProperties
 */
private void initializeGUI(TransformOutputProperties aOutputProperties) {

    String method;

    CDATASectionElements.setText(StringUtils.defaultString(aOutputProperties.getCDATA_SECTION_ELEMENTS()));
    doctypePublic.setText(StringUtils.defaultString(aOutputProperties.getDOCTYPE_PUBLIC()));
    doctypeSystem.setText(StringUtils.defaultString(aOutputProperties.getDOCTYPE_SYSTEM()));
    encoding.setText(StringUtils.defaultString(aOutputProperties.getENCODING()));
    indent.setSelected(BooleanUtils.toBoolean(aOutputProperties.getINDENT()));
    mediaType.setText(StringUtils.defaultString(aOutputProperties.getMEDIA_TYPE()));
    version.setText(StringUtils.defaultString(aOutputProperties.getVERSION()));
    omitXmlDeclaration.setSelected(BooleanUtils.toBoolean(aOutputProperties.getOMIT_XML_DECLARATION()));
    standalone.setSelected(BooleanUtils.toBoolean(aOutputProperties.getSTANDALONE()));
    method = aOutputProperties.getMETHOD();
    if (StringUtils.isNotBlank(method)) {
        if (method.equals(VALID_METHODS[XML_INDEX])) {
            xml.setSelected(true);
        } else if (method.equals(VALID_METHODS[HTML_INDEX])) {
            html.setSelected(true);
            setEnableXmlCheckboxes(false);
        } else if (method.equals(VALID_METHODS[TEXT_INDEX])) {
            text.setSelected(true);
            setEnableXmlCheckboxes(false);
        } else {
            setEnableXmlCheckboxes(false);
            other.setSelected(true);
            otherMethod.setEnabled(true);
            otherMethod.setBackground(Color.WHITE);
            otherMethod.setText(aOutputProperties.getMETHOD());
        }
    } else {
        xml.setSelected(true);
    }
}

From source file:utils.AccessControl.java

public static void onStart() {
    allowsAnonymousAccess = BooleanUtils
            .toBoolean(play.Configuration.root().getBoolean("application.allowsAnonymousAccess", true));
}