@Override protected AbstractPreferences childSpi(String name) { FilePreferencesImpl child = new FilePreferencesImpl(this, name); return child; }
@Override protected void syncSpi() throws BackingStoreException { flushSpi(); } }
/** * Construct a prefs using given parent and given name */ private FilePreferencesImpl(AbstractPreferences parent, String name) { super(parent, name); path = ((FilePreferencesImpl) parent).path + File.separator + name; initPrefs(); }
@Override protected String[] childrenNamesSpi() throws BackingStoreException { String[] names = dir.list(new FilenameFilter() { public boolean accept(File parent, String name) { return new File(path + File.separator + name).isDirectory(); } }); if (names == null) {// file is not a directory, exception case throw new BackingStoreException("Cannot get child names for " + toString() + " (path is " + path + ")"); } return names; }
@Override protected void flushSpi() throws BackingStoreException { try { //if removed, return if(isRemoved()){ return; } // reload Properties currentPrefs = XMLParser.readXmlPreferences(prefsFile); // merge Iterator<String> it = removed.iterator(); while (it.hasNext()) { currentPrefs.remove(it.next()); } removed.clear(); it = updated.iterator(); while (it.hasNext()) { Object key = it.next(); currentPrefs.put(key, prefs.get(key)); } updated.clear(); // flush prefs = currentPrefs; XMLParser.writeXmlPreferences(prefsFile, prefs); } catch (Exception e) { throw new BackingStoreException(e); } }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected void flushSpi() throws BackingStoreException { try { //if removed, return if(isRemoved()){ return; } // reload Properties currentPrefs = XMLParser.readXmlPreferences(prefsFile); // merge Iterator<String> it = removed.iterator(); while (it.hasNext()) { currentPrefs.remove(it.next()); } removed.clear(); it = updated.iterator(); while (it.hasNext()) { Object key = it.next(); currentPrefs.put(key, prefs.get(key)); } updated.clear(); // flush prefs = currentPrefs; XMLParser.writeXmlPreferences(prefsFile, prefs); } catch (Exception e) { throw new BackingStoreException(e); } }
/** * Construct root <code>FilePreferencesImpl</code> instance, construct * user root if userNode is true, system root otherwise */ FilePreferencesImpl(boolean userNode) { super(null, ""); this.userNode = userNode; path = userNode ? USER_HOME : SYSTEM_HOME; initPrefs(); }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected AbstractPreferences childSpi(String name) { FilePreferencesImpl child = new FilePreferencesImpl(this, name); return child; }
@Override protected void syncSpi() throws BackingStoreException { flushSpi(); } }
@Override protected void flushSpi() throws BackingStoreException { try { //if removed, return if(isRemoved()){ return; } // reload Properties currentPrefs = XMLParser.readXmlPreferences(prefsFile); // merge Iterator<String> it = removed.iterator(); while (it.hasNext()) { currentPrefs.remove(it.next()); } removed.clear(); it = updated.iterator(); while (it.hasNext()) { Object key = it.next(); currentPrefs.put(key, prefs.get(key)); } updated.clear(); // flush prefs = currentPrefs; XMLParser.writeXmlPreferences(prefsFile, prefs); } catch (Exception e) { throw new BackingStoreException(e); } }
/** * Construct a prefs using given parent and given name */ private FilePreferencesImpl(AbstractPreferences parent, String name) { super(parent, name); path = ((FilePreferencesImpl) parent).path + File.separator + name; initPrefs(); }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected AbstractPreferences childSpi(String name) { FilePreferencesImpl child = new FilePreferencesImpl(this, name); return child; }
@Override protected void syncSpi() throws BackingStoreException { flushSpi(); } }
@Override protected void flushSpi() throws BackingStoreException { try { //if removed, return if(isRemoved()){ return; } // reload Properties currentPrefs = XMLParser.readXmlPreferences(prefsFile); // merge Iterator<String> it = removed.iterator(); while (it.hasNext()) { currentPrefs.remove(it.next()); } removed.clear(); it = updated.iterator(); while (it.hasNext()) { Object key = it.next(); currentPrefs.put(key, prefs.get(key)); } updated.clear(); // flush prefs = currentPrefs; XMLParser.writeXmlPreferences(prefsFile, prefs); } catch (Exception e) { throw new BackingStoreException(e); } }
/** * Construct root <code>FilePreferencesImpl</code> instance, construct * user root if userNode is true, system root otherwise */ FilePreferencesImpl(boolean userNode) { super(null, ""); this.userNode = userNode; path = userNode ? USER_HOME : SYSTEM_HOME; initPrefs(); }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
@Override protected AbstractPreferences childSpi(String name) { FilePreferencesImpl child = new FilePreferencesImpl(this, name); return child; }