本文整理汇总了Java中java.util.prefs.Preferences.removeNode方法的典型用法代码示例。如果您正苦于以下问题:Java Preferences.removeNode方法的具体用法?Java Preferences.removeNode怎么用?Java Preferences.removeNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.removeNode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testChildrenNames
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testChildrenNames() throws Exception {
Preferences pref = getPreferencesNode();
assertNotNull(pref);
assertEquals(0, pref.childrenNames().length);
assertFalse(pref.nodeExists("sub1"));
Preferences sub1 =pref.node("sub1");
assertNotNull(sub1);
assertTrue(pref.nodeExists("sub1"));
assertEquals(1, pref.childrenNames().length);
assertFalse(pref.nodeExists("sub2"));
Preferences sub2 =pref.node("sub2");
assertNotNull(sub2);
assertTrue(pref.nodeExists("sub2"));
assertEquals(2, pref.childrenNames().length);
sub1.removeNode();
assertEquals(1, pref.childrenNames().length);
sub2.removeNode();
assertEquals(0, pref.childrenNames().length);
}
示例2: migrate
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private static void migrate() {
// migrate pre 7.2 settings
String prevPath = "org/netbeans/modules/localhistory"; // NOI18N
try {
if(!NbPreferences.root().nodeExists(prevPath)) {
return;
}
Preferences prev = NbPreferences.root().node(prevPath);
Preferences cur = NbPreferences.forModule(HistorySettings.class);
String[] keys = prev.keys();
for (String key : keys) {
String value = prev.get(key, null);
if(value != null && cur.get(key, null) == null) {
cur.put(key, value);
}
}
prev.removeNode();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
示例3: testRemoveNode
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testRemoveNode() throws BackingStoreException {
Preferences orig = Preferences.userRoot().node(getName());
Preferences origChild = orig.node("child");
Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
assertTrue("Test child shoculd exist", test.nodeExists("child"));
Preferences testChild = test.node("child");
testChild.removeNode();
assertFalse("Removed test child should not exist", testChild.nodeExists(""));
assertFalse("Removed test child should not exist in parent", test.nodeExists("child"));
test.flush();
assertFalse("Test.flush did not remove orig child", origChild.nodeExists(""));
assertFalse("Test.flush did not remove orig child from parent", orig.nodeExists("child"));
}
示例4: testRemoveNode
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testRemoveNode() throws BackingStoreException {
Preferences orig = Preferences.userRoot().node(getName());
Preferences origChild = orig.node("child");
Preferences test = ProxyPreferences.getProxyPreferences(this, orig);
assertTrue("Test child shoculd exist", test.nodeExists("child"));
Preferences testChild = test.node("child");
testChild.removeNode();
assertFalse("Removed test child should not exist", testChild.nodeExists(""));
assertFalse("Removed test child should not exist in parent", test.nodeExists("child"));
test.flush();
assertFalse("Test.flush did not remove orig child", origChild.nodeExists(""));
assertFalse("Test.flush did not remove orig child from parent", orig.nodeExists("child"));
}
示例5: remove
import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Override
public void remove ( final ConnectionDescriptor connectionInformation ) throws CoreException
{
try
{
if ( removeConnection ( connectionInformation ) )
{
final String uri = URLEncoder.encode ( connectionInformation.getConnectionInformation ().toString (), "UTF-8" ); //$NON-NLS-1$
if ( getNode ().nodeExists ( uri ) )
{
final Preferences node = getNode ().node ( uri );
node.removeNode ();
getNode ().flush ();
fireDiscoveryUpdate ( null, new ConnectionDescriptor[] { connectionInformation } );
}
}
}
catch ( final Exception e )
{
throw new CoreException ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
}
}
示例6: remove
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void remove(Configuration config) {
configs.remove(config);
Preferences prefs = NbPreferences.forModule(this.getClass()).node(config.id());
try {
prefs.removeNode();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
changeSupport.fireChange();
}
示例7: testNodeExists
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testNodeExists() throws Exception {
Preferences pref = getPreferencesNode();
Preferences pref2 = pref.node("a/b/c");
while(pref2 != Preferences.userRoot()) {
assertTrue(pref2.nodeExists(""));
Preferences parent = pref2.parent();
pref2.removeNode();
assertFalse(pref2.nodeExists(""));
pref2 = parent;
}
assertNotNull(getPreferencesNode().node("a/b/c/d"));
assertTrue(getPreferencesNode().node("a/b/c/d").nodeExists(""));
}
示例8: removeGroup
import java.util.prefs.Preferences; //导入方法依赖的package包/类
void removeGroup(DocumentGroupImpl group) {
try {
Preferences prefs = getPreferences();
if( group.getName().equals(prefs.get(SEL_GROUP, "")) ) { //NOI18N
prefs.put(SEL_GROUP, ""); //NOI18N
}
prefs = prefs.node(group.getName());
prefs.removeNode();
//delete all cached files
} catch( Exception e ) {
LOG.log(Level.INFO, "Failed to remove document group '" + group.toString() + "'", e); //NOI18N
}
}
示例9: tearDown
import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
super.tearDown();
Preferences prefs = NbPreferences.forModule(InstancePropertiesManager.class);
prefs.removeNode();
}
示例10: removeFile
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void removeFile ( final File file ) throws Exception
{
for ( final String childName : this.prefs.childrenNames () )
{
final Preferences child = this.prefs.node ( childName );
final String fileName = new File ( child.get ( "file", null ) ).getAbsolutePath ();
if ( file.getAbsolutePath ().equals ( fileName ) )
{
child.removeNode ();
}
}
this.prefs.flush ();
}
示例11: remove
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void remove(Preferences prefs) throws BackingStoreException {
synchronized (this) {
cache.remove(prefs);
prefs.removeNode();
}
}
示例12: expirationCheck
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private static void expirationCheck () {
Preferences p = getPreferences ();
String exp = p.get (EXPIRATION_RECORD, null);
Collection<String> forImport = new HashSet<String> (Arrays.asList (VERSIONS_FOR_IMPORT));
String currentVersion = new File (System.getProperty ("netbeans.user")).getName ();
forImport.add (currentVersion);
if (exp != null && ! forImport.contains (exp)) {
try {
final int period = getPeriod();
boolean shared = Utilities.isGlobalInstallation() == null ? false : Utilities.isGlobalInstallation();
p.removeNode ();
getPreferences ().put (IMPORTED, Boolean.toString (true));
getPreferences ().putInt(PROP_PERIOD, period);
if (shared) {
// Check that we can use 'shared' flag imported from previous installation with a new one.
// Obtained from SettingsTab.cbGlobalInstallActionPerformed
Collection<File> dirs = Utilities.sharedDirs();
if (!dirs.isEmpty()) {
for (File f : dirs) {
if (f.exists() && f.isDirectory() && !Utilities.canWriteInCluster(f)) {
shared = false;
break;
}
}
if (shared) {
Utilities.setGlobalInstallation(shared);
}
}
}
err.log (Level.FINE, "Don't read preferences from userdir " + exp);
} catch (BackingStoreException ex) {
err.log (Level.INFO, ex.getLocalizedMessage (), ex);
}
} else if (exp == null) {
err.log (Level.FINEST, "No preferences imported from previous versoin.");
} else {
err.log (Level.FINEST, "Read preferences from userdir " + exp);
}
err.log (Level.FINEST, "Store current version " + currentVersion + " for future import.");
getPreferences ().put (EXPIRATION_RECORD, currentVersion);
}