Preferences getBoolean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Preferences getBoolean method.

This code example shows how to use the following methods:getBoolean, putBoolean
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
 
    private void set(String name, boolean value) {
        boolean old = applicationPreferences.getBoolean(name, false);
        applicationPreferences.putBoolean(name, value);
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
     
} 
 
6
CodeRank
This code example shows how to use the following methods:getBoolean, getInt, getLong, putBoolean, sync
     * flag. 
     * @return Returns <code>true</code> only if an update is available. 
     */ 
    private static boolean isUpdateAvailable( boolean reset ) {
        try { 
            if ( m_prefs.getBoolean( IS_UPDATE_AVAILABLE_KEY, false ) ) {
                if ( reset ) {
                    m_prefs.putBoolean( IS_UPDATE_AVAILABLE_KEY, false );
                    syncPrefs(); 
                } 
                return true; 
            } 
        } 
        catch ( IllegalStateException e ) {
            // ignore? 
        } 
        return false; 
    } 
 
    /** 

6
CodeRank
This code example shows how to use the following methods:getBoolean, getInt, putDouble
      assert false; 
    } 
    PreferencesExt prefs = store.getPreferences();
 
    Preferences node = prefs.node("/myApp");
    int ival  = node.getInt("extraOne", 0);
    assert ival == 1 : "testStandardChain fail 1 " + ival;
 
    ival  = node.getInt("extraTwo", 0);
    assert ival == 2 : "testStandardChain fail 2 " + ival;
 
    ival  = node.getInt("num_rows", 0);
    assert ival == 128 : "testStandardChain fail 3 " + ival;
 
    ival  = node.getInt("missing", 0);
    assert ival == 0 : "testStandardChain fail 4 " + ival;
 
    boolean bval  = node.getBoolean("TestBoolean", false);
    assert bval: "testStandardChain fail 5 " + bval;
 

6
CodeRank
This code example shows how to use the following methods:get, getBoolean
     * 
     * @param prefs map. 
     */ 
    public void restore(Preferences prefs)
    { 
        setEnabled(prefs.getBoolean(PROP_TWITTER_ENABLED, false));
        setScreenName(prefs.get(PROP_TWITTER_SCREEN_NAME, null));
        setAccessToken(prefs.get(PROP_TWITTER_ACCESS_TOKEN, null));
        setTokenSecret(prefs.get(PROP_TWITTER_TOKEN_SECRET, null));
        setProfilePics(prefs.getBoolean(PROP_PROFILE_PICS, true));
        setPasteLink(prefs.getBoolean(PROP_PASTE_LINK, true));
    } 
 
    /** 
     * Resets actions that depend on URLs after the preferences change. 
     */ 
    private static void resetURLDependentActions() 
    { 
        FollowAction.getInstance().setUserURL(null); 
        ReplyAction.getInstance().setUserURL(null); 
6
CodeRank
This code example shows how to use the following methods:getBoolean
  { 
    if (key == null)
    { 
      throw new NullPointerException();
    } 
    return locationPolicy.getBoolean(key, locationPolicy.getBoolean(DEFAULT_KEY, true));
  } 
 
  public void setStoreLocations(final String key, final boolean storeLocations)
  { 
    if (key == null)
    { 
      throw new NullPointerException();
    } 
    this.locationPolicy.putBoolean(key, storeLocations);
  } 
 
  public File getStaticLocation(final String aKey)
  { 
    final String staticLocationValue = staticLocationMappings.get(aKey, null);
6
CodeRank
This code example shows how to use the following methods:getBoolean, putBoolean
This code example shows how to use the following methods:getBoolean, getInt, putDouble
      assert false; 
    } 
    PreferencesExt prefs = store.getPreferences();
 
    Preferences node = prefs.node("/myApp");
    int ival  = node.getInt("extraOne", 0);
    assert ival == 1 : "testStandardChain fail 1 " + ival;
 
    ival  = node.getInt("extraTwo", 0);
    assert ival == 2 : "testStandardChain fail 2 " + ival;
 
    ival  = node.getInt("num_rows", 0);
    assert ival == 128 : "testStandardChain fail 3 " + ival;
 
    ival  = node.getInt("missing", 0);
    assert ival == 0 : "testStandardChain fail 4 " + ival;
 
    boolean bval  = node.getBoolean("TestBoolean", false);
    assert bval: "testStandardChain fail 5 " + bval;
 

6
CodeRank
This code example shows how to use the following methods:get, getBoolean, getInt
     */ 
    public static void restorePreferences(Preferences prefs)
    { 
        SentimentsConfig config = Calculator.getConfig();
 
        config.setEnabled(prefs.getBoolean(PREFIX + PROP_ENABLED, DEFAULT_ENABLED));
        config.setNegativeExpressions(prefs.get(PREFIX + PROP_NEGATIVE_EXPRESSIONS, DEFAULT_NEGATIVE_EXPRESSIONS));
        config.setPositiveExpressions(prefs.get(PREFIX + PROP_POSITIVE_EXPRESSIONS, DEFAULT_POSITIVE_EXPRESSIONS));
        config.setNegativeThreshold(prefs.getInt(PREFIX + PROP_NEGATIVE_THRESHOLD, DEFAULT_NEGATIVE_THRESHOLD));
        config.setPositiveThreshold(prefs.getInt(PREFIX + PROP_POSITIVE_THRESHOLD, DEFAULT_POSITIVE_THRESHOLD));
        config.setPositiveColor(prefToColor(prefs.get(PREFIX + PROP_POSITIVE_COLOR, UifUtilities.colorToHex(DEFAULT_POSITIVE_COLOR))));
        config.setNegativeColor(prefToColor(prefs.get(PREFIX + PROP_NEGATIVE_COLOR, UifUtilities.colorToHex(DEFAULT_NEGATIVE_COLOR))));
 
        // See if we have keywords legacy 
        if (StringUtils.isEmpty(config.positiveExpressions))
        { 
            String keywords = prefs.get(KEY_KEYWORDS, null);
            if (StringUtils.isNotEmpty(keywords))
            { 
                String k = StringUtils.convertKeywordsToNewFormat(keywords);

6
CodeRank
This code example shows how to use the following methods:addPreferenceChangeListener, getBoolean
     * Set the border on the given component to a ToggleTitledBorder that 
     * will update dynamically when the global preference changes. 
     */ 
    public static void setBorder(JComponent comp, String title) {
        ToggleTitleBorder border = new ToggleTitleBorder(comp, title);
        Prefs.addPreferenceChangeListener(border);
        comp.setBorder(border);
    } 
 
    /** 
     * Reset the border on the given component, removing its global 
     * preference change listener and restoring its original border. 
     */ 
    public static void unsetBorder(JComponent comp) {
        Border border = comp.getBorder();
        if (border instanceof ToggleTitleBorder) {
            ToggleTitleBorder ttborder = (ToggleTitleBorder) border;
            Prefs.removePreferenceChangeListener(ttborder);
            comp.setBorder(ttborder.original);
        } 

5
CodeRank
This code example shows how to use the following methods:flush, get, getBoolean, put, putBoolean
        File               tempFile = File.createTempFile("temp", ".temp");
        try 
        { 
            Preferences        preferences = new FileBasedPreferences(tempFile);
 
            Assert.assertNull(preferences.get("test", null));
            Assert.assertFalse(preferences.getBoolean("b", false));
 
            preferences.put("test", "value");
            preferences.putBoolean("b", true);
 
            Assert.assertEquals(preferences.get("test", null), "value");
            Assert.assertTrue(preferences.getBoolean("b", false));
            preferences.flush();
            Assert.assertEquals(preferences.get("test", null), "value");
            Assert.assertTrue(preferences.getBoolean("b", false));
 
            preferences = new FileBasedPreferences(tempFile);
            Assert.assertEquals(preferences.get("test", null), "value");
            Assert.assertTrue(preferences.getBoolean("b", false));
        } 
5
CodeRank

Related Preferences getBoolean Questions & Answers:

getBoolean Method Overview
Returns the boolean value represented by the string associated with the specified key in this preference node.
See Code Examples for other Java 8 Preferences Methods: