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


Java BackingStoreException类代码示例

本文整理汇总了Java中java.util.prefs.BackingStoreException的典型用法代码示例。如果您正苦于以下问题:Java BackingStoreException类的具体用法?Java BackingStoreException怎么用?Java BackingStoreException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BackingStoreException类属于java.util.prefs包,在下文中一共展示了BackingStoreException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStoredProperties

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private Properties getStoredProperties() {
    return AccessController
            .doPrivileged((PrivilegedAction<Properties>) () -> {
                Properties p = new Properties();
                String notePath = "/com/sun/media/sound/softsynthesizer";
                try {
                    Preferences prefroot = Preferences.userRoot();
                    if (prefroot.nodeExists(notePath)) {
                        Preferences prefs = prefroot.node(notePath);
                        String[] prefs_keys = prefs.keys();
                        for (String prefs_key : prefs_keys) {
                            String val = prefs.get(prefs_key, null);
                            if (val != null) {
                                p.setProperty(prefs_key, val);
                            }
                        }
                    }
                } catch (final BackingStoreException ignored) {
                }
                return p;
            });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:SoftSynthesizer.java

示例2: getRepoIds

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private String[] getRepoIds(Preferences preferences, String repoId) {
    String[] keys = null;
    try {
        keys = preferences.keys();
    } catch (BackingStoreException ex) {
        BugtrackingManager.LOG.log(Level.SEVERE, null, ex); 
    }
    if (keys == null || keys.length == 0) {
        return new String[0];
    }
    List<String> ret = new ArrayList<String>();
    for (String key : keys) {
        if (key.startsWith(repoId)) {
            ret.add(key.substring(repoId.length()));
        }
    }
    return ret.toArray(new String[ret.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RepositoryRegistry.java

示例3: getPreferences

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
public Preferences getPreferences(String mimeType) {
    ProxyPreferences pp = mimeTypePreferences.get(mimeType);
    try {
        // clean up the cached ProxyPreferences instance that has been removed in the meantime
        if (pp != null && !pp.nodeExists("")) { //NOI18N
            pp = null;
        }
    } catch (BackingStoreException bse) {
        // ignore
    }

    if (pp == null) {
        Preferences p = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
        pp = ProxyPreferences.getProxyPreferences(this, p);
        pp.addPreferenceChangeListener(weakPrefL);
        pp.addNodeChangeListener(weakNodeL);
        mimeTypePreferences.put(mimeType, pp);
        LOG.fine("getPreferences('" + mimeType + "')"); //NOI18N
    }

    return pp;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CodeCompletionOptionsPanelController.java

示例4: testRemoveKey

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
public void testRemoveKey() throws BackingStoreException {
    Preferences orig = Preferences.userRoot().node(getName());
    orig.put("key-2", "value-2");
    assertNull("Original contains value", orig.get("key-1", null));
    assertEquals("Original doesn't contain value", "value-2", orig.get("key-2", null));

    Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
    test.put("key-1", "xyz");
    assertEquals("Wrong value", "xyz", test.get("key-1", null));
    
    test.remove("key-1");
    assertNull("Test contains removed key-1", test.get("key-1", null));
    
    test.remove("key-2");
    assertNull("Test contains removed key-2", test.get("key-2", null));

    test.flush();
    assertNull("Test flushed removed key-1", orig.get("key-1", null));
    assertNull("Test.flush did not remove removed key-2", orig.get("key-2", null));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProxyPreferencesImplTest.java

示例5: testRemoveKey

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
public void testRemoveKey() throws BackingStoreException {
    Preferences orig = Preferences.userRoot().node(getName());
    orig.put("key-2", "value-2");
    assertNull("Original contains value", orig.get("key-1", null));
    assertEquals("Original doesn't contain value", "value-2", orig.get("key-2", null));

    Preferences test = ProxyPreferences.getProxyPreferences(this, orig);
    test.put("key-1", "xyz");
    assertEquals("Wrong value", "xyz", test.get("key-1", null));
    
    test.remove("key-1");
    assertNull("Test contains removed key-1", test.get("key-1", null));
    
    test.remove("key-2");
    assertNull("Test contains removed key-2", test.get("key-2", null));

    test.flush();
    assertNull("Test flushed removed key-1", orig.get("key-1", null));
    assertNull("Test.flush did not remove removed key-2", orig.get("key-2", null));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProxyPreferencesTest.java

示例6: checkEquals

import java.util.prefs.BackingStoreException; //导入依赖的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

示例7: getProperties

import java.util.prefs.BackingStoreException; //导入依赖的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

示例8: sanitizeNameAndUniquifyForId

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
protected static String sanitizeNameAndUniquifyForId(String name) {
    String sanitizedId = name.replaceAll("[^a-zA-Z0-9_.-]+", "_");
    Set<String> existing;
    try {
        existing = new HashSet<String>(Arrays.asList(NODE.childrenNames()));
    } catch (BackingStoreException x) {
        Exceptions.printStackTrace(x);
        return sanitizedId;
    }
    if (existing.contains(sanitizedId)) {
        for (int i = 2; ; i++) {
            String candidate = sanitizedId + "_" + i;
            if (!existing.contains(candidate)) {
                return candidate;
            }
        }
    } else {
        return sanitizedId;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Group.java

示例9: loadTasks

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private void loadTasks() {
    Preferences pref = NbPreferences.forModule(TaskSchedulingManager.class);
    try {
        for (String key : pref.keys()) {
            if (key.startsWith(PREF_SCHEDULED)) {
                String repositoryId = key.substring(PREF_SCHEDULED.length());
                String tasks = pref.get(key, "");
                for (String taskId : tasks.split(SEP)) {
                    if (!taskId.isEmpty()) {
                        getRepositoryTasks(repositoryId).add(taskId);
                    }
                }
            }
        }
    } catch (BackingStoreException ex) {
        Logger.getLogger(TaskSchedulingManager.class.getName()).log(Level.INFO, null, ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TaskSchedulingManager.java

示例10: findPreferredInputMethodNode

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private String findPreferredInputMethodNode(Locale locale) {
    if (userRoot == null) {
        return null;
    }

    // create locale node relative path
    String nodePath = preferredIMNode + "/" + createLocalePath(locale);

    // look for the descriptor
    while (!nodePath.equals(preferredIMNode)) {
        try {
            if (userRoot.nodeExists(nodePath)) {
                if (readPreferredInputMethod(nodePath) != null) {
                    return nodePath;
                }
            }
        } catch (BackingStoreException bse) {
        }

        // search at parent's node
        nodePath = nodePath.substring(0, nodePath.lastIndexOf('/'));
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:ExecutableInputMethodManager.java

示例11: load

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
void load( Preferences prefs, String prefix ) throws BackingStoreException {
    name = prefs.get( prefix+"_name", "Filter" ); //NOI18N //NOI18N
    if( prefs.getBoolean( prefix+"_types", false ) ) { //NOI18N
        types = new TypesFilter();
        types.load( prefs, prefix+"_types" ); //NOI18N
    } else {
        types = null;
    }
    
    if( prefs.getBoolean( prefix+"_keywords", false ) ) { //NOI18N
        keywords = new KeywordsFilter();
        keywords.load( prefs, prefix+"_keywords" ); //NOI18N
    } else {
        keywords = null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TaskFilter.java

示例12: FactoryImpl

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
public FactoryImpl ()
{
    this.prefs = Preferences.userNodeForPackage ( FactoryImpl.class ).node ( "files" );

    try
    {
        for ( final String child : this.prefs.childrenNames () )
        {
            final Preferences childNode = this.prefs.node ( child );
            final String fileName = childNode.get ( "file", null );
            if ( fileName != null )
            {
                this.files.add ( fileName );
            }
        }
    }
    catch ( final BackingStoreException e )
    {
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:FactoryImpl.java

示例13: checkNotContains

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private void checkNotContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        if (prefs.nodeExists(nodePath)) {
            Preferences node = prefs.node(nodePath);
            String realValue = node.get(key, null);
            if (realValue != null && realValue.equals(value)) {
                fail(prefsId + ", '" + nodePath + "' node contains key '" + key + "' = '" + realValue + "'");
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProxyPreferencesImplTest.java

示例14: checkContains

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
private void checkContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        assertTrue(prefsId + " doesn't contain node '" + nodePath + "'", prefs.nodeExists(nodePath));
        Preferences node = prefs.node(nodePath);

        String realValue = node.get(key, null);
        assertNotNull(prefsId + ", '" + nodePath + "' node doesn't contain key '" + key + "'", realValue);
        assertEquals(prefsId + ", '" + nodePath + "' node, '" + key + "' contains wrong value", value, realValue);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProxyPreferencesImplTest.java

示例15: addGroup

import java.util.prefs.BackingStoreException; //导入依赖的package包/类
void addGroup(String displayName) {
    Preferences prefs = getPreferences();
    int groupIndex = getGroups().size();
    String groupName = DEFAULT_GROUP_NAME + groupIndex;
    try {
        do {
            groupIndex++;
            groupName = DEFAULT_GROUP_NAME + groupIndex;
        } while( prefs.nodeExists(groupName) );
    } catch( BackingStoreException ex ) {
        LOG.log(Level.INFO, null, ex);
    }
    prefs.put(SEL_GROUP, groupName);

    prefs.node(groupName).put(DISPLAY_NAME, displayName);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:GroupsManager.java


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