Default implementation of {@code AbstractPreferences} for windows
platform, using windows registry as back end.
Method from java.util.prefs.RegistryPreferencesImpl Detail: |
protected AbstractPreferences childSpi(String name) {
int[] error = new int[1];
RegistryPreferencesImpl result = new RegistryPreferencesImpl(this, name);
// FIXME: is it right thing to set newNode here?
result.newNode = getNode(path, encodeWindowsStr(name).getBytes(),
result.userNode, error);
if (error[ERROR_CODE] == RETURN_ACCESS_DENIED) {
// prefs.E=Access denied
throw new SecurityException(Messages.getString("prefs.E")); //$NON-NLS-1$
}
return result;
}
|
protected String[] childrenNamesSpi() throws BackingStoreException {
int[] error = new int[1];
byte[][] names = getChildNames(path, userNode, error);
if (error[ERROR_CODE] != RETURN_SUCCESS) {
// prefs.B=Enumerate child nodes error
throw new BackingStoreException(Messages.getString("prefs.B")); //$NON-NLS-1$
}
String[] result = new String[names.length];
for (int i = 0; i < result.length; i++) {
result[i] = decodeWindowsStr(new String(names[i]));
}
return result;
}
|
protected void flushSpi() throws BackingStoreException {
int[] error = new int[1];
flushPrefs(path, userNode, error);
if (error[ERROR_CODE] != RETURN_SUCCESS) {
// prefs.C=Flush error
throw new BackingStoreException(Messages.getString("prefs.C")); //$NON-NLS-1$
}
}
|
protected String getSpi(String key) {
int[] error = new int[1];
byte[] result = getValue(path, encodeWindowsStr(key).getBytes(),
userNode, error);
if (error[ERROR_CODE] != RETURN_SUCCESS) {
return null;
}
return decodeWindowsStr(new String(result));
}
|
protected String[] keysSpi() throws BackingStoreException {
int[] errorCode = new int[1];
byte[][] keys = keys(path, userNode, errorCode);
if (errorCode[ERROR_CODE] != RETURN_SUCCESS) {
// prefs.D=Enumerate keys error
throw new BackingStoreException(Messages.getString("prefs.D")); //$NON-NLS-1$
}
String[] result = new String[keys.length];
for (int i = 0; i < result.length; i++) {
result[i] = decodeWindowsStr(new String(keys[i]));
}
return result;
}
|
protected void putSpi(String name,
String value) {
int[] errorCode = new int[1];
putValue(path, encodeWindowsStr(name).getBytes(), encodeWindowsStr(
value).getBytes(), userNode, errorCode);
if (errorCode[ERROR_CODE] == RETURN_ACCESS_DENIED) {
// prefs.E=Access denied
throw new SecurityException(Messages.getString("prefs.E")); //$NON-NLS-1$
}
}
|
protected void removeNodeSpi() throws BackingStoreException {
int[] error = new int[1];
removeNode(((RegistryPreferencesImpl) parent()).path, encodeWindowsStr(
name()).getBytes(), userNode, error);
if (error[ERROR_CODE] != RETURN_SUCCESS) {
// prefs.F=Remove node error
throw new BackingStoreException(Messages.getString("prefs.F")); //$NON-NLS-1$
}
}
|
protected void removeSpi(String key) {
int[] errorCode = new int[1];
removeKey(path, encodeWindowsStr(key).getBytes(), userNode, errorCode);
if (errorCode[ERROR_CODE] == RETURN_ACCESS_DENIED) {
// prefs.E=Access denied
throw new SecurityException(Messages.getString("prefs.E")); //$NON-NLS-1$
}
}
|
protected void syncSpi() throws BackingStoreException {
flushSpi();
}
|