本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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) {
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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
}
}
示例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
}
}
示例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) {
}
}
示例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;
}
}
示例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;
}
示例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);
}
}