當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。