本文整理汇总了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);
}
}