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


Java Preferences.childrenNames方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ConfigurationsManager.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProxyPreferencesImplTest.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:InstancePropertiesManager.java

示例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);
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:23,代码来源:PreferenceUtils.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AdjustConfigurationPanel.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:GroupsManager.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProxyPreferencesImplTest.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProxyPreferencesImplTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ConfigurationsManager.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:FormattingCustomizerPanel.java

示例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]));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:FormattingCustomizerPanel.java


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