當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。