本文整理匯總了Java中java.util.prefs.Preferences.childrenNames方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.childrenNames方法的具體用法?Java Preferences.childrenNames怎麽用?Java Preferences.childrenNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.childrenNames方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void init() {
Preferences prefs = getConfigurationsRoot();
try {
for (String kid:prefs.childrenNames()) {
if (kid.startsWith(RULE_PREFIX)) {
Preferences p = prefs.node(kid);
String displayName = p.get("display.name", "unknown");
create(kid.substring(RULE_PREFIX.length()), displayName);
}
}
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
if (configs.isEmpty()) {
create("default", NbBundle.getMessage(ConfigurationsManager.class, "DN_Default"));
}
prefs.putInt(KEY_CONFIGURATIONS_VERSION, CURRENT_CONFIGURATIONS_VERSION);
}
示例2: checkEquals
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void checkEquals(String msg, Preferences expected, Preferences test) throws BackingStoreException {
assertEquals("Won't compare two Preferences with different absolutePath", expected.absolutePath(), test.absolutePath());
// check the keys and their values
for(String key : expected.keys()) {
String expectedValue = expected.get(key, null);
assertNotNull(msg + "; Expected:" + expected.absolutePath() + " has no '" + key + "'", expectedValue);
String value = test.get(key, null);
assertNotNull(msg + "; Test:" + test.absolutePath() + " has no '" + key + "'", value);
assertEquals(msg + "; Test:" + test.absolutePath() + "/" + key + " has wrong value", expectedValue, value);
}
// check the children
for(String child : expected.childrenNames()) {
assertTrue(msg + "; Expected:" + expected.absolutePath() + " has no '" + child + "' subnode", expected.nodeExists(child));
Preferences expectedChild = expected.node(child);
assertTrue(msg + "; Test:" + test.absolutePath() + " has no '" + child + "' subnode", test.nodeExists(child));
Preferences testChild = test.node(child);
checkEquals(msg, expectedChild, testChild);
}
}
示例3: getProperties
import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
* Returns all existing properties created in the given namespace.
*
* @param namespace string identifying the namespace
* @return list of all existing properties created in the given namespace
*/
public List<InstanceProperties> getProperties(String namespace) {
Preferences prefs = NbPreferences.forModule(InstancePropertiesManager.class);
try {
prefs = prefs.node(namespace);
prefs.flush();
List<InstanceProperties> allProperties = new ArrayList<InstanceProperties>();
synchronized (this) {
for (String id : prefs.childrenNames()) {
Preferences child = prefs.node(id);
InstanceProperties props = cache.get(child);
if (props == null) {
props = new DefaultInstanceProperties(id, this, child);
cache.put(child, props);
}
allProperties.add(props);
}
}
return allProperties;
} catch (BackingStoreException ex) {
LOGGER.log(Level.INFO, null, ex);
throw new IllegalStateException(ex);
}
}
示例4: copyPrefs
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static void copyPrefs(Preferences source, Preferences destination) {
try {
// Copy the key/value pairs first
String[] prefKeys = source.keys();
for (int i = 0; i < prefKeys.length; i++) {
destination.put(prefKeys[i], source.get(prefKeys[i], ""));
}
// Now grab all the names of the children nodes
String[] childrenNames = source.childrenNames();
// Recursively copy the preference nodes
for (int i = 0; i < childrenNames.length; i++) {
copyPrefs(source.node(childrenNames[i]),
destination.node(childrenNames[i]));
}
}
catch (Exception e) {
LoggerFactory.getLogger(PreferenceUtils.class)
.error("Failed to copy preferences.", e);
}
}
示例5: ModifiedPreferences
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public ModifiedPreferences(ModifiedPreferences parent, String name, Preferences node) {
this(parent, name); // NOI18N
try {
for (java.lang.String key : node.keys()) {
put(key, node.get(key, null));
}
for (String child : node.childrenNames()) {
subNodes.put(child, new ModifiedPreferences(this, node.name(), node.node(child)));
}
}
catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
示例6: getGroups
import java.util.prefs.Preferences; //導入方法依賴的package包/類
List<DocumentGroupImpl> getGroups() {
Preferences prefs = getPreferences();
try {
String[] names = prefs.childrenNames();
ArrayList<DocumentGroupImpl> res = new ArrayList<>(names.length);
for( String name : names ) {
res.add(createGroup(name));
}
Collections.sort(res);
return res;
} catch( BackingStoreException e ) {
LOG.log(Level.INFO, null, e);
}
return Collections.emptyList();
}
示例7: dump
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void dump(Preferences prefs, String prefsId) throws BackingStoreException {
for(String key : prefs.keys()) {
System.out.println(prefsId + ", " + prefs.absolutePath() + "/" + key + "=" + prefs.get(key, null));
}
for(String child : prefs.childrenNames()) {
dump(prefs.node(child), prefsId);
}
}
示例8: removeAllKidsAndKeys
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void removeAllKidsAndKeys(Preferences prefs) throws BackingStoreException {
for(String kid : prefs.childrenNames()) {
prefs.node(kid).removeNode();
}
for(String key : prefs.keys()) {
prefs.remove(key);
}
}
示例9: init
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void init() {
Preferences prefs = NbPreferences.forModule(this.getClass());
try {
for (String kid:prefs.childrenNames()) {
if (kid.startsWith(RULE_PREFIX)) {
Preferences p = NbPreferences.forModule(this.getClass()).node(kid);
String displayName = p.get("display.name", "unknown");
create(kid.substring(RULE_PREFIX.length()), displayName);
}
}
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
int configurationsVersion = prefs.getInt(KEY_CONFIGURATIONS_VERSION, 0);
if (configs.isEmpty()) {
create("default", NbBundle.getMessage(ConfigurationsManager.class, "DN_Default"));
Configuration jdk7 = create("jdk7", NbBundle.getMessage(ConfigurationsManager.class, "DN_ConvertToJDK7"));
jdk7.enable("Javac_canUseDiamond");
jdk7.enable("org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch");
jdk7.enable("org.netbeans.modules.java.hints.jdk.ConvertToARM");
jdk7.enable("org.netbeans.modules.java.hints.jdk.JoinCatches");
// #215546 - requires user inspection
// jdk7.enable("org.netbeans.modules.java.hints.jdk.UseSpecificCatch");
//jdk7.enable("java.util.Objects");
}
if (configurationsVersion < 1 && !configurationExists("organizeImports")) {
Configuration organizeImports = create("organizeImports", NbBundle.getMessage(ConfigurationsManager.class, "DN_OrganizeImports"));
organizeImports.enable("org.netbeans.modules.java.hints.OrganizeImports");
}
prefs.putInt(KEY_CONFIGURATIONS_VERSION, CURRENT_CONFIGURATIONS_VERSION);
}
示例10: removeAllKidsAndKeys
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static void removeAllKidsAndKeys(Preferences prefs) throws BackingStoreException {
for(String kid : prefs.childrenNames()) {
// remove just the keys otherwise node listeners won't survive
removeAllKidsAndKeys(prefs.node(kid));
}
for(String key : prefs.keys()) {
prefs.remove(key);
}
}
示例11: deepCopy
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static void deepCopy(Preferences from, Preferences to) throws BackingStoreException {
for(String kid : from.childrenNames()) {
Preferences fromKid = from.node(kid);
Preferences toKid = to.node(kid);
deepCopy(fromKid, toKid);
}
for(String key : from.keys()) {
String value = from.get(key, null);
if (value == null) continue;
Class type = guessType(value);
if (Integer.class == type) {
to.putInt(key, from.getInt(key, -1));
} else if (Long.class == type) {
to.putLong(key, from.getLong(key, -1L));
} else if (Float.class == type) {
to.putFloat(key, from.getFloat(key, -1f));
} else if (Double.class == type) {
to.putDouble(key, from.getDouble(key, -1D));
} else if (Boolean.class == type) {
to.putBoolean(key, from.getBoolean(key, false));
} else if (String.class == type) {
to.put(key, value);
} else /* byte [] */ {
to.putByteArray(key, from.getByteArray(key, new byte [0]));
}
}
}