|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.prefs.Preferences java.util.prefs.AbstractPreferences java.util.prefs.WindowsPreferences
Windows registry based implementation of Preferences. Preferences' systemRoot and userRoot are stored in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs and HKEY_CURRENT_USER\Software\JavaSoft\Prefs correspondingly.
Preferences
,
PreferencesFactory
Nested Class Summary |
Nested classes inherited from class java.util.prefs.AbstractPreferences |
|
Field Summary | |
private static int |
DELETE
|
private static int |
DISPOSITION
|
private static int |
ERROR_ACCESS_DENIED
|
private static int |
ERROR_CODE
|
private static int |
ERROR_FILE_NOT_FOUND
|
private static int |
ERROR_SUCCESS
|
private static int |
HKEY_CURRENT_USER
Windows handles to HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE hives. |
private static int |
HKEY_LOCAL_MACHINE
|
private static int |
INIT_SLEEP_TIME
Initial time between registry access attempts, in ms. |
private boolean |
isBackingStoreAvailable
BackingStore availability flag. |
private static int |
KEY_ALL_ACCESS
|
private static int |
KEY_CREATE_SUB_KEY
|
private static int |
KEY_ENUMERATE_SUB_KEYS
|
private static int |
KEY_QUERY_VALUE
|
private static int |
KEY_READ
|
private static int |
KEY_SET_VALUE
|
private static int |
KEY_WRITE
|
private static Logger |
logger
Logger for error messages |
private static int |
MAX_ATTEMPTS
Maximum number of registry access attempts. |
private static int |
MAX_KEY_LENGTH
|
private static int |
MAX_VALUE_NAME_LENGTH
|
private static int |
MAX_WINDOWS_PATH_LENGTH
Maximum byte-encoded path length for Windows native functions, ending null character not included. |
private static int |
NATIVE_HANDLE
|
private static int |
NULL_NATIVE_HANDLE
|
private static int |
REG_CREATED_NEW_KEY
|
private static int |
REG_OPENED_EXISTING_KEY
|
private static int |
SUBKEYS_NUMBER
|
private static int |
SYSTEM_ROOT_NATIVE_HANDLE
Mount point for Preferences' system root. |
(package private) static Preferences |
systemRoot
System root node. |
private static int |
USER_ROOT_NATIVE_HANDLE
Mount point for Preferences' user root. |
(package private) static Preferences |
userRoot
User root node. |
private static int |
VALUES_NUMBER
|
private static byte[] |
WINDOWS_ROOT_PATH
Windows registry path to Preferences's root nodes. |
Fields inherited from class java.util.prefs.AbstractPreferences |
lock, newNode, parent |
Fields inherited from class java.util.prefs.Preferences |
MAX_NAME_LENGTH, MAX_VALUE_LENGTH |
Constructor Summary | |
private |
WindowsPreferences(int rootNativeHandle,
byte[] rootDirectory)
Constructs a root node creating the underlying Windows registry node and all of its parents, if they have not yet been created. |
private |
WindowsPreferences(WindowsPreferences parent,
String name)
Constructs a WindowsPreferences node, creating underlying Windows registry node and all its Windows parents, if they are not yet created. |
Method Summary | |
private static String |
byteArrayToString(byte[] array)
Converts a null-terminated byte array to java string |
protected String[] |
childrenNamesSpi()
Implements AbstractPreferences childrenNamesSpi() method. |
protected AbstractPreferences |
childSpi(String name)
Implements AbstractPreferences childSpi() method. |
private void |
closeKey(int nativeHandle)
Closes Windows registry key. |
void |
flush()
Implements Preferences flush() method. |
protected void |
flushSpi()
Empty, never used implementation of AbstractPreferences.flushSpi(). |
protected String |
getSpi(String javaName)
Implements AbstractPreferences getSpi() method. |
protected String[] |
keysSpi()
Implements AbstractPreferences keysSpi() method. |
private static Logger |
logger()
|
private int |
openKey(byte[] windowsAbsolutePath,
int mask1,
int mask2)
Opens Windows registry key at a given absolute path using a given security mask. |
private int |
openKey(int securityMask)
Opens current node's underlying Windows registry key using a given security mask. |
private int |
openKey(int nativeHandle,
byte[] windowsRelativePath,
int mask1,
int mask2)
Opens Windows registry key at a given relative path with respect to a given Windows registry key. |
private int |
openKey(int mask1,
int mask2)
Opens current node's underlying Windows registry key using a given security mask. |
protected void |
putSpi(String javaName,
String value)
Implements AbstractPreferences putSpi() method. |
void |
removeNodeSpi()
Implements AbstractPreferences removeNodeSpi() method. |
protected void |
removeSpi(String key)
Implements AbstractPreferences removeSpi() method. |
private int |
rootNativeHandle()
Returns native handle for the top Windows node for this node. |
private static byte[] |
stringToByteArray(String str)
Returns this java string as a null-terminated byte array |
void |
sync()
Implements Preferences sync() method. |
protected void |
syncSpi()
Empty, never used implementation of AbstractPreferences.flushSpi(). |
private static String |
toJavaAlt64Name(String windowsName)
Converts value's or node's name from its Windows representation to java string, using altBase64 encoding. |
private static String |
toJavaName(byte[] windowsNameArray)
Converts value's or node's name from its byte array representation to java string. |
private static String |
toJavaValueString(byte[] windowsNameArray)
Converts value string from its Windows representation to java string. |
private static byte[] |
toWindowsAlt64Name(String javaName)
Converts value's or node's name to its Windows representation as a byte-encoded string, using altBase64 encoding. |
private static byte[] |
toWindowsName(String javaName)
Converts value's or node's name to its Windows representation as a byte-encoded string. |
private static byte[] |
toWindowsValueString(String javaName)
Converts value string to it Windows representation. |
private byte[] |
windowsAbsolutePath()
Returns Windows absolute path of the current node as a byte array. |
private static int |
WindowsRegCloseKey(int hKey)
Java wrapper for Windows registry API RegCloseKey() |
private static int[] |
WindowsRegCreateKeyEx(int hKey,
byte[] subKey)
Java wrapper for Windows registry API RegCreateKeyEx() |
private static int[] |
WindowsRegCreateKeyEx1(int hKey,
byte[] subKey)
Retries RegCreateKeyEx() MAX_ATTEMPTS times before giving up. |
private static int |
WindowsRegDeleteKey(int hKey,
byte[] subKey)
Java wrapper for Windows registry API RegDeleteKey() |
private static int |
WindowsRegDeleteValue(int hKey,
byte[] valueName)
Java wrapper for Windows registry API RegDeleteValue() |
private static byte[] |
WindowsRegEnumKeyEx(int hKey,
int subKeyIndex,
int maxKeyLength)
Java wrapper for Windows registry API RegEnumKeyEx() |
private static byte[] |
WindowsRegEnumKeyEx1(int hKey,
int subKeyIndex,
int maxKeyLength)
Retries RegEnumKeyEx() MAX_ATTEMPTS times before giving up. |
private static byte[] |
WindowsRegEnumValue(int hKey,
int valueIndex,
int maxValueNameLength)
Java wrapper for Windows registry API RegEnumValue() |
private static byte[] |
WindowsRegEnumValue1(int hKey,
int valueIndex,
int maxValueNameLength)
Retries RegEnumValueEx() MAX_ATTEMPTS times before giving up. |
private static int |
WindowsRegFlushKey(int hKey)
Java wrapper for Windows registry API RegFlushKey() |
private static int |
WindowsRegFlushKey1(int hKey)
Retries RegFlushKey() MAX_ATTEMPTS times before giving up. |
private static int[] |
WindowsRegOpenKey(int hKey,
byte[] subKey,
int securityMask)
Java wrapper for Windows registry API RegOpenKey() |
private static int[] |
WindowsRegOpenKey1(int hKey,
byte[] subKey,
int securityMask)
Retries RegOpenKey() MAX_ATTEMPTS times before giving up. |
private static int[] |
WindowsRegQueryInfoKey(int hKey)
Java wrapper for Windows registry API RegQueryInfoKey() |
private static int[] |
WindowsRegQueryInfoKey1(int hKey)
Retries RegQueryInfoKey() MAX_ATTEMPTS times before giving up. |
private static byte[] |
WindowsRegQueryValueEx(int hKey,
byte[] valueName)
Java wrapper for Windows registry API RegQueryValueEx() |
private static int |
WindowsRegSetValueEx(int hKey,
byte[] valueName,
byte[] value)
Java wrapper for Windows registry API RegSetValueEx() |
private static int |
WindowsRegSetValueEx1(int hKey,
byte[] valueName,
byte[] value)
Retries RegSetValueEx() MAX_ATTEMPTS times before giving up. |
Methods inherited from class java.util.prefs.AbstractPreferences |
absolutePath, addNodeChangeListener, addPreferenceChangeListener, cachedChildren, childrenNames, clear, exportNode, exportSubtree, get, getBoolean, getByteArray, getChild, getDouble, getFloat, getInt, getLong, isRemoved, isUserNode, keys, name, node, nodeExists, nodeListeners, parent, prefListeners, put, putBoolean, putByteArray, putDouble, putFloat, putInt, putLong, remove, removeNode, removeNodeChangeListener, removePreferenceChangeListener, toString |
Methods inherited from class java.util.prefs.Preferences |
importPreferences, systemNodeForPackage, systemRoot, userNodeForPackage, userRoot |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static Logger logger
private static final byte[] WINDOWS_ROOT_PATH
private static final int HKEY_CURRENT_USER
private static final int HKEY_LOCAL_MACHINE
private static final int USER_ROOT_NATIVE_HANDLE
private static final int SYSTEM_ROOT_NATIVE_HANDLE
private static final int MAX_WINDOWS_PATH_LENGTH
static final Preferences userRoot
static final Preferences systemRoot
private static final int ERROR_SUCCESS
private static final int ERROR_FILE_NOT_FOUND
private static final int ERROR_ACCESS_DENIED
private static final int NATIVE_HANDLE
private static final int ERROR_CODE
private static final int SUBKEYS_NUMBER
private static final int VALUES_NUMBER
private static final int MAX_KEY_LENGTH
private static final int MAX_VALUE_NAME_LENGTH
private static final int DISPOSITION
private static final int REG_CREATED_NEW_KEY
private static final int REG_OPENED_EXISTING_KEY
private static final int NULL_NATIVE_HANDLE
private static final int DELETE
private static final int KEY_QUERY_VALUE
private static final int KEY_SET_VALUE
private static final int KEY_CREATE_SUB_KEY
private static final int KEY_ENUMERATE_SUB_KEYS
private static final int KEY_READ
private static final int KEY_WRITE
private static final int KEY_ALL_ACCESS
private static int INIT_SLEEP_TIME
private static int MAX_ATTEMPTS
private boolean isBackingStoreAvailable
Constructor Detail |
private WindowsPreferences(WindowsPreferences parent, String name)
private WindowsPreferences(int rootNativeHandle, byte[] rootDirectory)
rootNativeHandle
- Native handle to one of Windows top level keys.rootDirectory
- Path to root directory, as a byte-encoded string.Method Detail |
private static int[] WindowsRegOpenKey(int hKey, byte[] subKey, int securityMask)
private static int[] WindowsRegOpenKey1(int hKey, byte[] subKey, int securityMask)
private static int WindowsRegCloseKey(int hKey)
private static int[] WindowsRegCreateKeyEx(int hKey, byte[] subKey)
private static int[] WindowsRegCreateKeyEx1(int hKey, byte[] subKey)
private static int WindowsRegDeleteKey(int hKey, byte[] subKey)
private static int WindowsRegFlushKey(int hKey)
private static int WindowsRegFlushKey1(int hKey)
private static byte[] WindowsRegQueryValueEx(int hKey, byte[] valueName)
private static int WindowsRegSetValueEx(int hKey, byte[] valueName, byte[] value)
private static int WindowsRegSetValueEx1(int hKey, byte[] valueName, byte[] value)
private static int WindowsRegDeleteValue(int hKey, byte[] valueName)
private static int[] WindowsRegQueryInfoKey(int hKey)
private static int[] WindowsRegQueryInfoKey1(int hKey)
private static byte[] WindowsRegEnumKeyEx(int hKey, int subKeyIndex, int maxKeyLength)
private static byte[] WindowsRegEnumKeyEx1(int hKey, int subKeyIndex, int maxKeyLength)
private static byte[] WindowsRegEnumValue(int hKey, int valueIndex, int maxValueNameLength)
private static byte[] WindowsRegEnumValue1(int hKey, int valueIndex, int maxValueNameLength)
private byte[] windowsAbsolutePath()
Preferences.absolutePath()
private int openKey(int securityMask)
securityMask
- Windows security mask.
#openKey(byte[], int)
,
#openKey(int, byte[], int)
,
closeKey(int)
private int openKey(int mask1, int mask2)
mask1
- Preferred Windows security mask.mask2
- Alternate Windows security mask.
#openKey(byte[], int)
,
#openKey(int, byte[], int)
,
closeKey(int)
private int openKey(byte[] windowsAbsolutePath, int mask1, int mask2)
windowsAbsolutePath
- Windows absolute path of the
key as a byte-encoded string.mask1
- Preferred Windows security mask.mask2
- Alternate Windows security mask.
openKey(int)
,
#openKey(int, byte[],int)
,
closeKey(int)
private int openKey(int nativeHandle, byte[] windowsRelativePath, int mask1, int mask2)
nativeHandle
- handle to the base Windows key.mask1
- Preferred Windows security mask.mask2
- Alternate Windows security mask.
openKey(int)
,
#openKey(byte[],int)
,
closeKey(int)
private void closeKey(int nativeHandle)
openKey(int)
,
#openKey(byte[],int)
,
#openKey(int, byte[],int)
protected void putSpi(String javaName, String value)
putSpi
in class AbstractPreferences
getSpi(String)
protected String getSpi(String javaName)
getSpi
in class AbstractPreferences
putSpi(String, String)
protected void removeSpi(String key)
removeSpi
in class AbstractPreferences
protected String[] keysSpi() throws BackingStoreException
keysSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.protected String[] childrenNamesSpi() throws BackingStoreException
childrenNamesSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.public void flush() throws BackingStoreException
flush
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.AbstractPreferences.flush()
public void sync() throws BackingStoreException
sync
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.flush()
protected AbstractPreferences childSpi(String name)
childSpi
in class AbstractPreferences
name
- The name of the child node to return, relative to
this preference node.
public void removeNodeSpi() throws BackingStoreException
removeNodeSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.private static String toJavaName(byte[] windowsNameArray)
toWindowsName()
for a detailed
description of encoding conventions.
windowsNameArray
- Null-terminated byte array.private static String toJavaAlt64Name(String windowsName)
toWindowsName()
for a detailed
description of encoding conventions.
private static byte[] toWindowsName(String javaName)
Simple encoding is used, if java string does not contain any characters less, than 0x0020, or greater, than 0x007f. Simple encoding adds "/" character to capital letters, i.e. "A" is encoded as "/A". Character '\' is encoded as '//', '/' is encoded as '\'. The constructed string is converted to byte array by truncating the highest byte and adding the terminating null character.
altBase64 encoding is used, if java string does contain at least one character less, than 0x0020, or greater, than 0x007f. This encoding is marked by setting first two bytes of the Windows string to '/!'. The java name is then encoded using byteArrayToAltBase64() method from Base64 class.
private static byte[] toWindowsAlt64Name(String javaName)
toWindowsName()
for a detailed
description of encoding conventions.
private static String toJavaValueString(byte[] windowsNameArray)
toWindowsValueString()
for the
description of the encoding algorithm.
private static byte[] toWindowsValueString(String javaName)
private int rootNativeHandle()
private static byte[] stringToByteArray(String str)
private static String byteArrayToString(byte[] array)
protected void flushSpi() throws BackingStoreException
flushSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.protected void syncSpi() throws BackingStoreException
syncSpi
in class AbstractPreferences
BackingStoreException
- if this operation cannot be completed
due to a failure in the backing store, or inability to
communicate with it.private static Logger logger()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |