Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

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

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:blue.soundObject.jmask.Quantizer.java

public static Quantizer loadFromXML(Element data) {
    Quantizer retVal = new Quantizer();

    Elements nodes = data.getElements();

    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        String nodeVal = node.getTextString();

        if (nodeName.equals("gridSize")) {
            retVal.gridSize = Double.parseDouble(nodeVal);
        } else if (nodeName.equals("strength")) {
            retVal.strength = Double.parseDouble(nodeVal);
        } else if (nodeName.equals("offset")) {
            retVal.offset = Double.parseDouble(nodeVal);
        } else if (nodeName.equals("gridSizeTableEnabled")) {
            retVal.gridSizeTableEnabled = Boolean.valueOf(node.getTextString()).booleanValue();
        } else if (nodeName.equals("strengthTableEnabled")) {
            retVal.strengthTableEnabled = Boolean.valueOf(node.getTextString()).booleanValue();
        } else if (nodeName.equals("offsetTableEnabled")) {
            retVal.offsetTableEnabled = Boolean.valueOf(node.getTextString()).booleanValue();
        } else if (nodeName.equals("enabled")) {
            retVal.enabled = Boolean.valueOf(node.getTextString()).booleanValue();
        } else if (nodeName.equals("table")) {
            Table t = Table.loadFromXML(node);
            String tabInstance = node.getAttributeValue("tableId");

            if (tabInstance.equals("gridSizeTable")) {
                retVal.gridSizeTable = t;
            } else if (tabInstance.equals("strengthTable")) {
                retVal.strengthTable = t;
            } else if (tabInstance.equals("offsetTable")) {
                retVal.offsetTable = t;/* w w  w  . ja  va 2  s.co  m*/
            }

        }

    }

    return retVal;
}

From source file:org.hawkular.apm.api.internal.actions.helpers.JSON.java

/**
 * This method evaluates the predicate based on the jsonpath
 * expression on the supplied node./*from   www . jav  a 2 s .  c  o  m*/
 *
 * @param jsonpath The jsonpath expression
 * @param data The json data
 * @return The result, or false if the data was invalid
 */
public static boolean predicate(String jsonpath, Object data) {
    // No jsonpath means return false
    if (jsonpath == null || jsonpath.trim().isEmpty()) {
        return false;
    }

    String json = serialize(data);
    if (json != null) {
        Object result = JsonPath.parse(json).read(jsonpath);
        if (result != null) {
            if (result.getClass() == Boolean.class) {
                return (Boolean) result;
            } else if (result.getClass() == String.class) {
                return Boolean.valueOf((String) result);
            } else if (result.getClass() == JSONArray.class) {
                return !((JSONArray) result).isEmpty();
            }
        }
    }
    return false;
}

From source file:com.baasbox.BBConfiguration.java

public static Boolean getSocialMock() {
    return Boolean.valueOf(configuration.getString(SOCIAL_MOCK));
}

From source file:fr.itldev.koya.webscript.user.GetByAuthKey.java

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    Map<String, Object> jsonMap = KoyaWebscript.getJsonMap(req);

    String authKey = (String) jsonMap.get("authKey");
    Boolean failProof = Boolean.FALSE;

    try {/*from   w w w. j  ava  2s.  com*/
        failProof = Boolean.valueOf(jsonMap.get("failProof").toString());
    } catch (NullPointerException ex) {

    }
    String response = "";

    try {
        response = KoyaWebscript.getObjectAsJson(userService.getUser(authKey));
    } catch (KoyaServiceException ex) {
        if (!failProof) {
            throw new WebScriptException("KoyaError : " + ex.getErrorCode().toString());
        }
    }
    res.setContentType("application/json");
    res.getWriter().write(response);
}

From source file:blankd.acme.pet.licensing.Application.java

@Override
public void run(String... arg0) throws Exception {
    Boolean runLoad = Boolean.valueOf(loadData);
    Account adminOwner = new Account("blankd", "Nothing", "Nothing", "Nothing", "Nothing", AccountTypes.ADMIN);
    Account clerkOwner = new Account("workerblank", "Nothing", "Nothing", "Nothing", "Nothing",
            AccountTypes.CLERK);/*from ww  w .j a v  a  2s .c om*/
    Account petOwner = new Account("superblank", "Nothing", "Nothing", "Nothing", "Nothing", AccountTypes.USER);
    aRepo.save(adminOwner);
    aRepo.save(clerkOwner);
    aRepo.save(petOwner);
    if (runLoad) {
        List<License> inserting = new ArrayList<License>();
        String[] names = petNames.split(",");
        String[] animals = species.split(",");
        Integer assignedLicenses = ZERO;
        for (Integer i = ZERO; i < maxLicense; i++) {
            String license = Integer.toOctalString(i);
            Boolean assignLicense = this.randomBoolean();
            if (assignedLicenses < this.maxAssigned && assignLicense) {
                String assignName = names[this.randomNumber(names.length)];
                String assignSpecies = animals[this.randomNumber(animals.length)];
                log.debug("Assigning Name " + assignName);
                log.debug("Assigning Species " + assignSpecies);
                assignedLicenses++;
                Pet thePet = new Pet(assignName, assignSpecies, Pet.NONE);
                pRepo.save(thePet);
                log.debug("pet id is " + thePet.getId());
                repo.save(new License(license, thePet, this.generateExpirationDate(), petOwner));
            } else {
                log.debug("Generating License " + license);
                repo.save(new License(license, null, null, null));
            }
        }
        log.debug("Assigned " + assignedLicenses + " licenses");

        Account find = aRepo.findByUsername("blankd");
        log.debug(find.getUsername() + " has " + find.getLicences().size() + " pets");
    }
}

From source file:de.hybris.platform.acceleratorservices.payment.cybersource.converters.populators.response.AuthReplyResultPopulator.java

@Override
public void populate(final Map<String, String> source, final CreateSubscriptionResult target)
        throws ConversionException {
    validateParameterNotNull(source, "Parameter [Map<String, String>] source cannot be null");
    validateParameterNotNull(target, "Parameter [CreateSubscriptionResult] target cannot be null");

    final AuthReplyData data = new AuthReplyData();
    data.setCcAuthReplyAmount(getBigDecimalForString(source.get("ccAuthReply_amount")));
    data.setCcAuthReplyAuthorizationCode(source.get("ccAuthReply_authorizationCode"));
    data.setCcAuthReplyAuthorizedDateTime(source.get("ccAuthReply_authorizedDateTime"));
    data.setCcAuthReplyAvsCode(source.get("ccAuthReply_avsCode"));
    data.setCcAuthReplyAvsCodeRaw(source.get("ccAuthReply_avsCodeRaw"));
    data.setCcAuthReplyCvCode(source.get("ccAuthReply_cvCode"));
    data.setCcAuthReplyProcessorResponse(source.get("ccAuthReply_processorResponse"));
    data.setCcAuthReplyReasonCode(getIntegerForString(source.get("ccAuthReply_reasonCode")));
    data.setCvnDecision(Boolean.valueOf(StringUtils.equalsIgnoreCase(source.get("ccAuthReply_cvCode"), "M")));

    target.setAuthReplyData(data);/*  w w w.j  a  va  2  s.co  m*/
}

From source file:net.sf.jasperreports.engine.xml.JRBandFactory.java

@Override
public Object createObject(Attributes atts) {
    JRDesignBand band = new JRDesignBand();

    String height = atts.getValue(JRXmlConstants.ATTRIBUTE_height);
    if (height != null && height.length() > 0) {
        band.setHeight(Integer.parseInt(height));
    }//w w w  .  j  av  a 2  s.c  om

    String isSplitAllowed = atts.getValue(JRXmlConstants.ATTRIBUTE_isSplitAllowed);
    if (isSplitAllowed != null && isSplitAllowed.length() > 0) {
        if (log.isWarnEnabled()) {
            log.warn("The 'isSplitAllowed' attribute is deprecated. Use the 'splitType' attribute instead.");
        }

        if (Boolean.valueOf(isSplitAllowed)) {
            band.setSplitType(SplitTypeEnum.STRETCH);
        } else {
            band.setSplitType(SplitTypeEnum.PREVENT);
        }
    }

    SplitTypeEnum splitType = SplitTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_splitType));
    if (splitType != null) {
        band.setSplitType(splitType);
    }

    return band;
}

From source file:com.oakesville.mythling.prefs.PlaybackPrefs.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActivity().getActionBar().setTitle(R.string.title_playback_settings);
    addPreferencesFromResource(R.xml.playback_prefs);

    // none of these prefs trigger cache refresh

    AppSettings appSettings = new AppSettings(getPreferenceScreen().getContext());

    SwitchPreference swPref = (SwitchPreference) getPreferenceScreen()
            .findPreference(AppSettings.FRONTEND_PLAYBACK);
    swPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            doCategoryEnablement(!Boolean.valueOf(newValue.toString()));
            return true;
        }//from w  w w  .ja v  a  2 s .c om
    });
    doCategoryEnablement(appSettings.isDevicePlayback());

    Preference pref = getPreferenceScreen().findPreference(AppSettings.ALWAYS_PROMPT_FOR_PLAYBACK_OPTIONS);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(false, false) {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean update = super.onPreferenceChange(preference, newValue);
            if (Boolean.parseBoolean(newValue.toString())) {
                AppSettings settings = new AppSettings(getPreferenceScreen().getContext());
                try {
                    settings.getPlaybackOptions().clearAlwaysDoThisSettings();
                } catch (JSONException ex) {
                    Log.e(TAG, ex.getMessage(), ex);
                    if (settings.isErrorReportingEnabled())
                        new Reporter(ex).send();
                    settings.getPlaybackOptions().clearAll();
                }
            }
            return update;
        }
    });

    pref = getPreferenceScreen().findPreference(AppSettings.SKIP_BACK_INTERVAL);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false, getString(R.string.seconds)));
    pref.setSummary("" + appSettings.getSkipBackInterval() + " " + getString(R.string.seconds));

    pref = getPreferenceScreen().findPreference(AppSettings.SKIP_FORWARD_INTERVAL);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false, getString(R.string.seconds)));
    pref.setSummary("" + appSettings.getSkipForwardInterval() + " " + getString(R.string.seconds));

    pref = getPreferenceScreen().findPreference(AppSettings.JUMP_INTERVAL);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false, getString(R.string.seconds)));
    pref.setSummary("" + appSettings.getJumpInterval() + " " + getString(R.string.seconds));

    pref = getPreferenceScreen().findPreference(AppSettings.AUTO_SKIP);
    pref.setOnPreferenceChangeListener(
            new PrefChangeListener(true, false, R.array.auto_skip_values, R.array.auto_skip_entries) {
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    super.onPreferenceChange(preference, newValue);
                    if (!AppSettings.AUTO_SKIP_OFF.equals(newValue.toString())) {
                        AppSettings settings = new AppSettings(getPreferenceScreen().getContext());
                        int scTol = settings.getSeekCorrectionTolerance();
                        if (scTol == 0) {
                            settings.setSeekCorrectionTolerance(3);
                            getPreferenceScreen().findPreference(AppSettings.SEEK_CORRECTION_TOLERANCE)
                                    .setSummary("3");
                            ;
                        }
                    }
                    return true;
                }
            });
    pref.setSummary(Localizer.getStringArrayEntry(R.array.auto_skip_values, R.array.auto_skip_entries,
            appSettings.getAutoSkip()));

    pref = getPreferenceScreen().findPreference(AppSettings.SEEK_CORRECTION_TOLERANCE);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false, getString(R.string.seconds)));
    pref.setSummary("" + appSettings.getSeekCorrectionTolerance() + " " + getString(R.string.seconds));

    pref = getPreferenceScreen().findPreference(AppSettings.LIBVLC_PARAMETERS);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false));
    pref.setSummary(appSettings.getLibVlcParameters());

    swPref = (SwitchPreference) getPreferenceScreen().findPreference(AppSettings.INTERNAL_MUSIC_PLAYER);
    swPref.setOnPreferenceChangeListener(new PrefChangeListener(false, false));

    pref = getPreferenceScreen().findPreference(AppSettings.MYTH_FRONTEND_HOST);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false));
    pref.setSummary(appSettings.getFrontendHost());

    pref = getPreferenceScreen().findPreference(AppSettings.MYTH_FRONTEND_SOCKET_PORT);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false));
    pref.setSummary("" + appSettings.getFrontendSocketPort());

    pref = getPreferenceScreen().findPreference(AppSettings.MYTH_FRONTEND_SERVICE_PORT);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, false));
    pref.setSummary("" + appSettings.getFrontendServicePort());
}

From source file:de.tu_dortmund.ub.data.util.TPUUtil.java

public static Optional<Boolean> getBooleanConfigValue(final String configKey, final Properties config) {

    final String configValue = config.getProperty(configKey);

    final Optional<Boolean> optionalConfigValue;

    if (configValue != null && !configValue.trim().isEmpty()) {

        optionalConfigValue = Optional.of(Boolean.valueOf(configValue));
    } else {/*w  ww  .  ja  va2s  . c  o  m*/

        optionalConfigValue = Optional.empty();
    }

    return optionalConfigValue;
}