public static void removeEmail() { PREFERENCES.remove(EMAIL_FIELD_NAME); }
public static boolean isAdmin(){ Preferences prefs = Preferences.systemRoot(); try{ prefs.put("foo", "bar"); // SecurityException on Windows prefs.remove("foo"); prefs.flush(); // BackingStoreException on Linux return true; }catch(Exception e){ return false; } }
public static boolean isAdmin(){ Preferences prefs = Preferences.systemRoot(); PrintStream systemErr = System.err; synchronized(systemErr){ // better synchroize to avoid problems with other threads that access System.err System.setErr(null); try{ prefs.put("foo", "bar"); // SecurityException on Windows prefs.remove("foo"); prefs.flush(); // BackingStoreException on Linux return true; }catch(Exception e){ return false; }finally{ System.setErr(systemErr); } } }
@Test public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() { factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class) .addPropertyValue("name", "${mypath/myName}") .addPropertyValue("age", "${myAge}") .addPropertyValue("touchy", "${myotherpath/myTouchy}") .getBeanDefinition()); PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer(); Properties props = new Properties(); props.put("myAge", "99"); ppc.setProperties(props); ppc.setSystemTreePath("mySystemPath"); ppc.setUserTreePath("myUserPath"); Preferences.systemRoot().node("mySystemPath").node("mypath").put("myName", "myNameValue"); Preferences.systemRoot().node("mySystemPath/myotherpath").put("myTouchy", "myTouchyValue"); Preferences.userRoot().node("myUserPath/myotherpath").put("myTouchy", "myOtherTouchyValue"); ppc.afterPropertiesSet(); ppc.postProcessBeanFactory(factory); TestBean tb = (TestBean) factory.getBean("tb"); assertEquals("myNameValue", tb.getName()); assertEquals(99, tb.getAge()); assertEquals("myOtherTouchyValue", tb.getTouchy()); Preferences.userRoot().node("myUserPath/myotherpath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath/myotherpath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath/mypath").remove("myName"); }
@Test public void testPreferencesPlaceholderConfigurerWithCustomTreePaths() { factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class) .addPropertyValue("name", "${myName}") .addPropertyValue("age", "${myAge}") .addPropertyValue("touchy", "${myTouchy}") .getBeanDefinition()); PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer(); Properties props = new Properties(); props.put("myAge", "99"); ppc.setProperties(props); ppc.setSystemTreePath("mySystemPath"); ppc.setUserTreePath("myUserPath"); Preferences.systemRoot().node("mySystemPath").put("myName", "myNameValue"); Preferences.systemRoot().node("mySystemPath").put("myTouchy", "myTouchyValue"); Preferences.userRoot().node("myUserPath").put("myTouchy", "myOtherTouchyValue"); ppc.afterPropertiesSet(); ppc.postProcessBeanFactory(factory); TestBean tb = (TestBean) factory.getBean("tb"); assertEquals("myNameValue", tb.getName()); assertEquals(99, tb.getAge()); assertEquals("myOtherTouchyValue", tb.getTouchy()); Preferences.userRoot().node("myUserPath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath").remove("myTouchy"); Preferences.systemRoot().node("mySystemPath").remove("myName"); }
@Test public void testPreferencesPlaceholderConfigurer() { factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class) .addPropertyValue("name", "${myName}") .addPropertyValue("age", "${myAge}") .addPropertyValue("touchy", "${myTouchy}") .getBeanDefinition()); PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer(); Properties props = new Properties(); props.put("myAge", "99"); ppc.setProperties(props); Preferences.systemRoot().put("myName", "myNameValue"); Preferences.systemRoot().put("myTouchy", "myTouchyValue"); Preferences.userRoot().put("myTouchy", "myOtherTouchyValue"); ppc.afterPropertiesSet(); ppc.postProcessBeanFactory(factory); TestBean tb = (TestBean) factory.getBean("tb"); assertEquals("myNameValue", tb.getName()); assertEquals(99, tb.getAge()); assertEquals("myOtherTouchyValue", tb.getTouchy()); Preferences.userRoot().remove("myTouchy"); Preferences.systemRoot().remove("myTouchy"); Preferences.systemRoot().remove("myName"); }
public static boolean removeIgnoredUser(String serverAddress, String username) { Preferences ignoreList = ignoreListNode(serverAddress); boolean exists = ignoreList.getBoolean(username, false); if (exists) { ignoreList.remove(username); } return exists; }
prefs.remove(GRID_LOCATION); } else { prefs.put(GRID_LOCATION, args[0]);
/** * Removes the value set for "ShowTipOnStartup" in the given Preferences to * ensure the dialog shown by a later call to * {@link #showDialog(Component, Preferences)} will be visible to the user. * * @param showOnStartupPref */ public static void forceShowOnStartup(Preferences showOnStartupPref) { showOnStartupPref.remove(PREFERENCE_KEY); }
/** * Remove the preference value. */ public void remove() { this.preferences.remove(this.key); }
public void putString(String key, String val) { if (val == null){ preferences.remove(key); } else{ preferences.put(key, val); } }
private void clearExistingRecentFiles(Preferences preferences) { // Clear all existing recent files (new list may be shorter than the existing one) for (int i = 1; i <= KseFrame.RECENT_FILES_SIZE; i++) { String recentFile = preferences.get(KSE3_RECENTFILE + i, null); if (recentFile == null) { break; } else { preferences.remove(KSE3_RECENTFILE + i); } } }
private void removeRefreshToken() { try { Preferences.userRoot().remove(REFRESH_TOKEN_KEY); } catch (Exception e) { log.error("Error removing oauth refresh token", e); } }
private void saveRecentJobs() { // blow away all the existing values for (int i = 0; i < PREF_RECENT_FILES_MAX; i++) { prefs.remove(PREF_RECENT_FILES + "_" + i); //$NON-NLS-1$ } // update with what we have now for (int i = 0; i < recentJobs.size(); i++) { prefs.put(PREF_RECENT_FILES + "_" + i, recentJobs.get(i).getAbsolutePath()); //$NON-NLS-1$ } updateRecentJobsMenu(); }
protected void putBooleanPref(final String key, final boolean value) { if (value == Boolean.valueOf(properties.getProperty(key, new Boolean(false).toString())).booleanValue()) { prefs.remove(getKey(key)); } else { prefs.putBoolean(getKey(key), value); } } }
protected void putPref(final String key, final String value) { if (value == null || value.equals(properties.getProperty(key, ""))) { prefs.remove(getKey(key)); } else { prefs.put(getKey(key), value); } }
public static void setLastIndexUpdate(String repoId,Date date) { if(repoId.contains("//")) { repoId = repoId.replace("//", "_"); LOG.log(Level.FINE, "Setting last index update: Repo''s id contains consecutive slashes, replacing them with '_': {0}", repoId); } getPreferences().remove(PROP_LAST_INDEX_UPDATE + "." + repoId); storage().node(repoId).putLong(PROP_LAST_INDEX_UPDATE, date.getTime()); }
protected final String putProperty(String key, String value) { String retval = getProperty(key); if (value != null) { getPreferences().put(key, value); } else { getPreferences().remove(key); } return retval; }