当前位置: 首页>>代码示例>>Java>>正文


Java AbstractPreferences类代码示例

本文整理汇总了Java中java.util.prefs.AbstractPreferences的典型用法代码示例。如果您正苦于以下问题:Java AbstractPreferences类的具体用法?Java AbstractPreferences怎么用?Java AbstractPreferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractPreferences类属于java.util.prefs包,在下文中一共展示了AbstractPreferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@Override
        protected AbstractPreferences childSpi(String name) {
            if (prefs == null) {
                prefs = new HashMap<String, AbstractPreferences>(3);
            }
            AbstractPreferences p = prefs.get(name);
            if (p == null) {
//                root.cacheMisses++;
                Preferences r = delegate.node(name);
                p = new CachingPreferences(this, name, r);
//                ((CachingPreferences)p).root = this.root;
                prefs.put(name, p);
//            } else {
//                root.cacheHits++;
            }
            return p;
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CodeStylePreferences.java

示例2: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@Override
protected AbstractPreferences childSpi(String name) {
    String escapedName = escape(name);
    NodeList nl = node.getElementsByTagName("node");
    
    for (int i = 0; i < nl.getLength(); i++) {
        Node n = nl.item(i);

        if (n instanceof Element && escapedName.equals(((Element) n).getAttribute("name"))) {
            return new XMLHintPreferences(driver, this, name, (Element) n, node, true);
        }
    }

    Element nue = node.getOwnerDocument().createElement("node");
    
    nue.setAttribute("name", escapedName);

    return new XMLHintPreferences(driver, this, name, nue, node, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:XMLHintPreferences.java

示例3: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
/**
  * http://stackoverflow.com/a/24249709
  */
 @NotNull
 @Override
 protected AbstractPreferences childSpi(@NotNull String name) {
AbstractPreferences childPreferenceNode = (AbstractPreferences) children.get(name);
   boolean isChildRemoved = false;
   if (childPreferenceNode != null) {
     try {
       isChildRemoved = getIsRemoved(childPreferenceNode);
     } catch (ReflectiveOperationException e) {
       Log.error( e.getMessage() );
     }
   }
   if (childPreferenceNode == null || isChildRemoved) {
     final AbstractPreferences castedPreferences = new MarginallyCleverPreferences(this, name);
     childPreferenceNode = castedPreferences;
     children.put(name, childPreferenceNode);
   }
   return childPreferenceNode;
 }
 
开发者ID:MarginallyClever,项目名称:Robot-Overlord-App,代码行数:23,代码来源:MarginallyCleverPreferences.java

示例4: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
/**
  * http://stackoverflow.com/a/24249709
  *
  * @param name
  * @return
  */
 @NotNull
 @Override
 protected AbstractPreferences childSpi(@NotNull String name) {
AbstractPreferences childPreferenceNode = (AbstractPreferences) children.get(name);
   boolean isChildRemoved = false;
   if (childPreferenceNode != null) {
     try {
       isChildRemoved = getIsRemoved(childPreferenceNode);
     } catch (ReflectiveOperationException e) {
       Log.error( e.getMessage() );
     }
   }
   if (childPreferenceNode == null || isChildRemoved) {
     final AbstractPreferences castedPreferences = new MarginallyCleverPreferences(this, name);
     childPreferenceNode = castedPreferences;
     children.put(name, childPreferenceNode);
   }
   return childPreferenceNode;
 }
 
开发者ID:MarginallyClever,项目名称:Robot-Overlord-App,代码行数:26,代码来源:MarginallyCleverPreferences.java

示例5: testSystemRoot

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "SecurityException checking missed.",
    method = "systemRoot",
    args = {}
)
public void testSystemRoot() {
    Preferences p = Preferences.systemRoot();
    assertTrue(p instanceof AbstractPreferences);
    assertEquals("/", p.absolutePath());
    assertSame(null, p.parent());
    assertFalse(p.isUserNode());
    assertEquals("", p.name());
    assertEquals("System Preference Node: " + p.absolutePath(), p
            .toString());
    // assertEquals(0, p.childrenNames().length);
    // assertEquals(0, p.keys().length);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:PreferencesTest.java

示例6: testUserNodeForPackage

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "SecurityException checking missed.",
    method = "userNodeForPackage",
    args = {java.lang.Class.class}
)
public void testUserNodeForPackage() throws BackingStoreException {
    Preferences p = Preferences.userNodeForPackage(Object.class);
    assertEquals("/java/lang", p.absolutePath());
    assertTrue(p instanceof AbstractPreferences);
    Preferences root = Preferences.userRoot();
    Preferences parent = root.node("java");
    assertSame(parent, p.parent());
    assertTrue(p.isUserNode());
    assertEquals("lang", p.name());
    assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
    assertEquals(0, p.childrenNames().length);
    assertEquals(0, p.keys().length);

    try {
        p = Preferences.userNodeForPackage(null);
        fail();
    } catch (NullPointerException e) {
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:PreferencesTest.java

示例7: testUserRoot

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "SecurityException checking missed.",
    method = "userRoot",
    args = {}
)
public void testUserRoot() {
    Preferences p = Preferences.userRoot();
    assertTrue(p instanceof AbstractPreferences);
    assertEquals("/", p.absolutePath());
    assertSame(null, p.parent());
    assertTrue(p.isUserNode());
    assertEquals("", p.name());
    assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
    // assertEquals(0, p.childrenNames().length);
    // assertEquals(p.keys().length, 0);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:PreferencesTest.java

示例8: testGetKey

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Test is correct, functionality checked in separate Mock class.",
    method = "getKey",
    args = {}
)
public void testGetKey() {
    AbstractPreferences parent = (AbstractPreferences) Preferences
            .userNodeForPackage(Preferences.class);

    AbstractPreferences pref = (AbstractPreferences) parent.node("mock");

    MockPreferenceChangeListener pl = new MockPreferenceChangeListener(
            MockPreferenceChangeListener.TEST_GET_KEY);
    pref.addPreferenceChangeListener(pl);
    try {
        pref.putInt("key_int", Integer.MAX_VALUE);
        assertEquals(1, pl.getChanged());
        assertTrue(pl.getResult());
        pl.reset();
    } finally {
        pref.removePreferenceChangeListener(pl);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:PreferenceChangeEventTest.java

示例9: testGetNode

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Test is correct, functionality checked in separate Mock class.",
    method = "getNode",
    args = {}
)
public void testGetNode() {
    AbstractPreferences parent = (AbstractPreferences) Preferences
            .userNodeForPackage(Preferences.class);

    AbstractPreferences pref = (AbstractPreferences) parent.node("mock");

    MockPreferenceChangeListener pl = new MockPreferenceChangeListener(
            MockPreferenceChangeListener.TEST_GET_NODE);
    pref.addPreferenceChangeListener(pl);
    try {
        pref.putInt("key_int", Integer.MAX_VALUE);
        assertEquals(1, pl.getChanged());
        assertTrue(pl.getResult());
        pl.reset();

    } finally {
        pref.removePreferenceChangeListener(pl);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:PreferenceChangeEventTest.java

示例10: testParent

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "parent",
    args = {}
)
public void testParent() throws BackingStoreException {
    AbstractPreferences node = (AbstractPreferences) pref.node("First node/sub node");

    assertTrue(node.parent().name().compareTo("First node") == 0);

    pref.removeNode();

    try {
        node.parent();
        fail("IllegalStateException expected");
    } catch (IllegalStateException e) {
        //expected
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:AbstractPreferencesTest.java

示例11: testUserNodeForPackage

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
public void testUserNodeForPackage() throws BackingStoreException {
    Preferences p = Preferences.userNodeForPackage(Object.class);
    assertEquals("/java/lang", p.absolutePath());
    assertTrue(p instanceof AbstractPreferences);
    Preferences root = Preferences.userRoot();
    Preferences parent = root.node("java");
    assertSame(parent, p.parent());
    assertTrue(p.isUserNode());
    assertEquals("lang", p.name());
    assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
    assertEquals(0, p.childrenNames().length);
    assertEquals(0, p.keys().length);

    try {
        Preferences.userNodeForPackage(null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:PreferencesTest.java

示例12: testUserNodeForPackage

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
public void testUserNodeForPackage() throws BackingStoreException {
	Preferences p = Preferences.userNodeForPackage(Object.class);
	assertEquals("/java/lang", p.absolutePath());
	assertTrue(p instanceof AbstractPreferences);
	Preferences root = Preferences.userRoot();
	Preferences parent = root.node("java");
	assertSame(parent, p.parent());
	assertTrue(p.isUserNode());
	assertEquals("lang", p.name());
	assertEquals("User Preference Node: " + p.absolutePath(), p.toString());
	assertEquals(0, p.childrenNames().length);
	assertEquals(0, p.keys().length);

	try {
		p = Preferences.userNodeForPackage(null);
		fail();
	} catch (NullPointerException e) {
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:PreferencesTest.java

示例13: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@Override
protected AbstractPreferences childSpi(String name) {
    Preferences storedNode = stored != null ? stored.node(name) : null;
    if (storedNode != null) {
        return new InheritedPreferences(null, storedNode);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:InheritedPreferences.java

示例14: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
protected AbstractPreferences childSpi(String name) {
    ModifiedPreferences result = subNodes.get(name);

    if (result == null) {
        subNodes.put(name, result = new ModifiedPreferences(this, name));
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AdjustConfigurationPanel.java

示例15: childSpi

import java.util.prefs.AbstractPreferences; //导入依赖的package包/类
@Override
protected AbstractPreferences childSpi(String name) {
    synchronized (AuxiliaryConfigBasedPreferencesProvider.this) {
        String nuePath = path + "/" + name;
        if (!getChildrenNames().contains(name)) {
            AuxiliaryConfigBasedPreferencesProvider.this.createdNodes.add(nuePath);
        }

        return new AuxiliaryConfigBasedPreferences(this, name, nuePath);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:AuxiliaryConfigBasedPreferencesProvider.java


注:本文中的java.util.prefs.AbstractPreferences类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。