Methods Summary |
---|
protected java.util.prefs.AbstractPreferences | childSpi(java.lang.String name)
FilePreferencesImpl child = new FilePreferencesImpl(this, name);
return child;
|
protected java.lang.String[] | childrenNamesSpi()
String[] names = AccessController
.doPrivileged(new PrivilegedAction<String[]>() {
public String[] run() {
return dir.list(new FilenameFilter() {
public boolean accept(File parent, String name) {
return new File(path + File.separator + name).isDirectory();
}
});
}
});
if (null == names) {// file is not a directory, exception case
// prefs.3=Cannot get children names for {0}!
throw new BackingStoreException(
Messages.getString("prefs.3", toString())); //$NON-NLS-1$
}
return names;
|
protected void | flushSpi()
try {
//if removed, return
if(isRemoved()){
return;
}
// reload
Properties currentPrefs = XMLParser.loadFilePrefs(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.flushFilePrefs(prefsFile, prefs);
} catch (Exception e) {
throw new BackingStoreException(e);
}
|
protected java.lang.String | getSpi(java.lang.String key)
try {
if (null == prefs) {
prefs = XMLParser.loadFilePrefs(prefsFile);
}
return prefs.getProperty(key);
} catch (Exception e) {// if Exception happened, return null
return null;
}
|
private void | initPrefs()
dir = new File(path);
newNode = (AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.valueOf(!dir.exists());
}
})).booleanValue();
prefsFile = new File(path + File.separator + PREFS_FILE_NAME);
prefs = XMLParser.loadFilePrefs(prefsFile);
|
protected java.lang.String[] | keysSpi()
return prefs.keySet().toArray(new String[0]);
|
protected void | putSpi(java.lang.String name, java.lang.String value)
prefs.setProperty(name, value);
updated.add(name);
|
protected void | removeNodeSpi()
boolean removeSucceed = (AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
prefsFile.delete();
return Boolean.valueOf(dir.delete());
}
})).booleanValue();
if (!removeSucceed) {
// prefs.4=Cannot remove {0}!
throw new BackingStoreException(Messages.getString("prefs.4", toString())); //$NON-NLS-1$
}
|
protected void | removeSpi(java.lang.String key)
prefs.remove(key);
updated.remove(key);
removed.add(key);
|
protected void | syncSpi()
flushSpi();
|