com.ice.jni.registry
Class WindowsRegistry

java.lang.Object
  extended bycom.ice.jni.registry.WindowsRegistry

public class WindowsRegistry
extends java.lang.Object

The Registry class provides is used to load the native library DLL, as well as a placeholder for the top level keys, error codes, and utility methods.
Changelog:
20050315 : If 'ICE_JNIRegistry.DLL' DLL is not installed, then static code try to load it from the 'registry.jar' directory.

Version:
3.1.3

Field Summary
 boolean debugLevel
          If true, debug the fv parameters and computation.
static int ERROR_ACCESS_DENIED
           
static int ERROR_BADDB
           
static int ERROR_BADKEY
           
static int ERROR_CALL_NOT_IMPLEMENTED
           
static int ERROR_CANTOPEN
           
static int ERROR_CANTREAD
           
static int ERROR_CANTWRITE
           
static int ERROR_FILE_NOT_FOUND
           
static int ERROR_INSUFFICIENT_BUFFER
           
static int ERROR_INVALID_HANDLE
           
static int ERROR_INVALID_PARAMETER
           
static int ERROR_KEY_DELETED
           
static int ERROR_LOCK_FAILED
           
static int ERROR_MORE_DATA
           
static int ERROR_NO_MORE_ITEMS
           
static int ERROR_NOT_REGISTRY_FILE
           
static int ERROR_REGISTRY_CORRUPT
           
static int ERROR_REGISTRY_IO_FAILED
           
static int ERROR_REGISTRY_RECOVERED
           
static int ERROR_SUCCESS
          These are the Registry API error codes, which can be returned via the RegistryException.
static int ERROR_TRANSFER_TOO_LONG
           
static com.ice.jni.registry.RegistryKey HKEY_CLASSES_ROOT
          The following statics are the top level keys.
static com.ice.jni.registry.RegistryKey HKEY_CURRENT_CONFIG
           
static com.ice.jni.registry.RegistryKey HKEY_CURRENT_USER
           
static com.ice.jni.registry.RegistryKey HKEY_DYN_DATA
           
private static com.ice.jni.registry.RegistryKey HKEY_ICE_TESTKEY
          This is a key for ICE's testing purposes.
static com.ice.jni.registry.RegistryKey HKEY_LOCAL_MACHINE
           
static com.ice.jni.registry.RegistryKey HKEY_PERFORMANCE_DATA
           
static com.ice.jni.registry.RegistryKey HKEY_USERS
           
private static java.lang.String[] preDefines
          These are predefined keys ($0-$9) used to make the testing program easier to use (less typing).
private static int ROW_BYTES
          These are used by dumpHex().
private static int ROW_HALF
           
private static int ROW_QTR1
           
private static int ROW_QTR2
           
private static java.lang.String saveKey
          This is the last key used by the test program ($$).
private static java.util.Hashtable topLevelKeys
          This is a Hashtable which maps nams to the top level keys.
 
Constructor Summary
WindowsRegistry()
           
 
Method Summary
private static void createCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName)
           
private static void deleteKeyCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String deleteKeyName)
           
private static void deleteValueCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName)
           
static void dumpHexData(java.io.PrintStream out, java.lang.String title, byte[] buf, int numBytes)
           
static void dumpHexData(java.io.PrintWriter out, java.lang.String title, byte[] buf, int offset, int numBytes)
           
private static void expandStringCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName)
           
private static void exportKeyCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String pathName)
           
static void exportRegistryKey(java.lang.String pathName, com.ice.jni.registry.RegistryKey key, boolean descend)
          Export the textual definition for a registry key to a file.
private static void getDataCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName)
           
static java.lang.String getErrorMessage(int errCode)
          Get the description of a Registry error code.
private static void getStringCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName)
           
static com.ice.jni.registry.RegistryKey getTopLevelKey(java.lang.String keyName)
          Get a top level key by name using the top level key Hashtable.
private static void listKeysCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName)
           
private static void listValuesCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName)
           
private static void loadLibraryFromJarDirectory()
          Try to load 'ICE_JNIRegistry.DLL' DLL from the 'registry.jar' directory.
static void main(java.lang.String[] argv)
          The main() method is used to test the Registry package.
static com.ice.jni.registry.RegistryKey openSubkey(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, int access)
          Open a subkey of a given top level key.
private static com.ice.jni.registry.RegistryKey openSubKeyVerbose(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, int access)
           
static java.lang.String[] parseArgumentString(java.lang.String argStr)
           
static java.util.Vector parseArgumentVector(java.lang.String argStr)
           
private static void setBinaryCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName, java.lang.String data)
           
private static void setDWordCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName, java.lang.String data)
           
private static void setMultiStringCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName, java.lang.String data)
           
private static void setStringCommand(com.ice.jni.registry.RegistryKey topKey, java.lang.String keyName, java.lang.String valueName, java.lang.String data)
           
private static void setValue(com.ice.jni.registry.RegistryKey subKey, com.ice.jni.registry.RegistryValue value)
           
static java.lang.String[] splitString(java.lang.String splitStr, java.lang.String delim)
          Split a string into a string array containing the substrings between the delimiters.
static void subMain(java.lang.String[] argv)
          The actual main method, which is called for each command.
static void usage(java.lang.String message)
          Print the usage/help information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HKEY_CLASSES_ROOT

public static com.ice.jni.registry.RegistryKey HKEY_CLASSES_ROOT
The following statics are the top level keys. Without these, there is no way to get "into" the registry, since the RegOpenSubkey() call requires an existing key which contains the subkey.


HKEY_CURRENT_USER

public static com.ice.jni.registry.RegistryKey HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

public static com.ice.jni.registry.RegistryKey HKEY_LOCAL_MACHINE

HKEY_USERS

public static com.ice.jni.registry.RegistryKey HKEY_USERS

HKEY_PERFORMANCE_DATA

public static com.ice.jni.registry.RegistryKey HKEY_PERFORMANCE_DATA

HKEY_CURRENT_CONFIG

public static com.ice.jni.registry.RegistryKey HKEY_CURRENT_CONFIG

HKEY_DYN_DATA

public static com.ice.jni.registry.RegistryKey HKEY_DYN_DATA

HKEY_ICE_TESTKEY

private static com.ice.jni.registry.RegistryKey HKEY_ICE_TESTKEY
This is a key for ICE's testing purposes.


preDefines

private static java.lang.String[] preDefines
These are predefined keys ($0-$9) used to make the testing program easier to use (less typing).


ERROR_SUCCESS

public static final int ERROR_SUCCESS
These are the Registry API error codes, which can be returned via the RegistryException.

See Also:
Constant Field Values

ERROR_FILE_NOT_FOUND

public static final int ERROR_FILE_NOT_FOUND
See Also:
Constant Field Values

ERROR_ACCESS_DENIED

public static final int ERROR_ACCESS_DENIED
See Also:
Constant Field Values

ERROR_INVALID_HANDLE

public static final int ERROR_INVALID_HANDLE
See Also:
Constant Field Values

ERROR_INVALID_PARAMETER

public static final int ERROR_INVALID_PARAMETER
See Also:
Constant Field Values

ERROR_CALL_NOT_IMPLEMENTED

public static final int ERROR_CALL_NOT_IMPLEMENTED
See Also:
Constant Field Values

ERROR_INSUFFICIENT_BUFFER

public static final int ERROR_INSUFFICIENT_BUFFER
See Also:
Constant Field Values

ERROR_LOCK_FAILED

public static final int ERROR_LOCK_FAILED
See Also:
Constant Field Values

ERROR_TRANSFER_TOO_LONG

public static final int ERROR_TRANSFER_TOO_LONG
See Also:
Constant Field Values

ERROR_MORE_DATA

public static final int ERROR_MORE_DATA
See Also:
Constant Field Values

ERROR_NO_MORE_ITEMS

public static final int ERROR_NO_MORE_ITEMS
See Also:
Constant Field Values

ERROR_BADDB

public static final int ERROR_BADDB
See Also:
Constant Field Values

ERROR_BADKEY

public static final int ERROR_BADKEY
See Also:
Constant Field Values

ERROR_CANTOPEN

public static final int ERROR_CANTOPEN
See Also:
Constant Field Values

ERROR_CANTREAD

public static final int ERROR_CANTREAD
See Also:
Constant Field Values

ERROR_CANTWRITE

public static final int ERROR_CANTWRITE
See Also:
Constant Field Values

ERROR_REGISTRY_RECOVERED

public static final int ERROR_REGISTRY_RECOVERED
See Also:
Constant Field Values

ERROR_REGISTRY_CORRUPT

public static final int ERROR_REGISTRY_CORRUPT
See Also:
Constant Field Values

ERROR_REGISTRY_IO_FAILED

public static final int ERROR_REGISTRY_IO_FAILED
See Also:
Constant Field Values

ERROR_NOT_REGISTRY_FILE

public static final int ERROR_NOT_REGISTRY_FILE
See Also:
Constant Field Values

ERROR_KEY_DELETED

public static final int ERROR_KEY_DELETED
See Also:
Constant Field Values

ROW_BYTES

private static final int ROW_BYTES
These are used by dumpHex().

See Also:
Constant Field Values

ROW_QTR1

private static final int ROW_QTR1
See Also:
Constant Field Values

ROW_HALF

private static final int ROW_HALF
See Also:
Constant Field Values

ROW_QTR2

private static final int ROW_QTR2
See Also:
Constant Field Values

saveKey

private static java.lang.String saveKey
This is the last key used by the test program ($$).


topLevelKeys

private static java.util.Hashtable topLevelKeys
This is a Hashtable which maps nams to the top level keys.


debugLevel

public boolean debugLevel
If true, debug the fv parameters and computation.

Constructor Detail

WindowsRegistry

public WindowsRegistry()
Method Detail

loadLibraryFromJarDirectory

private static void loadLibraryFromJarDirectory()
Try to load 'ICE_JNIRegistry.DLL' DLL from the 'registry.jar' directory.


getTopLevelKey

public static com.ice.jni.registry.RegistryKey getTopLevelKey(java.lang.String keyName)
Get a top level key by name using the top level key Hashtable.

Parameters:
keyName - The name of the top level key.
Returns:
The top level RegistryKey, or null if unknown keyName.
See Also:
topLevelKeys

openSubkey

public static com.ice.jni.registry.RegistryKey openSubkey(com.ice.jni.registry.RegistryKey topKey,
                                                          java.lang.String keyName,
                                                          int access)
Open a subkey of a given top level key.

Parameters:
topKey - The top level key containing the subkey.
keyName - The subkey's name.
access - The access flag for the newly opened key.
Returns:
The newly opened RegistryKey.
See Also:
RegistryKey

getErrorMessage

public static java.lang.String getErrorMessage(int errCode)
Get the description of a Registry error code.

Parameters:
errCode - The error code from a RegistryException
Returns:
The description of the error code.

exportRegistryKey

public static void exportRegistryKey(java.lang.String pathName,
                                     com.ice.jni.registry.RegistryKey key,
                                     boolean descend)
                              throws java.io.IOException,
                                     com.ice.jni.registry.NoSuchKeyException,
                                     com.ice.jni.registry.RegistryException
Export the textual definition for a registry key to a file. The resulting file can be re-loaded via RegEdit.

Parameters:
pathName - The pathname of the file into which to export.
key - The registry key definition to export.
descend - If true, descend and export all subkeys.
Throws:
NoSuchKeyException - Thrown by openSubKey().
RegistryException - Any other registry API error.
java.io.IOException

main

public static void main(java.lang.String[] argv)
The main() method is used to test the Registry package.


usage

public static void usage(java.lang.String message)
Print the usage/help information.


subMain

public static void subMain(java.lang.String[] argv)
The actual main method, which is called for each command.


exportKeyCommand

private static void exportKeyCommand(com.ice.jni.registry.RegistryKey topKey,
                                     java.lang.String keyName,
                                     java.lang.String pathName)

getDataCommand

private static void getDataCommand(com.ice.jni.registry.RegistryKey topKey,
                                   java.lang.String keyName,
                                   java.lang.String valueName)

getStringCommand

private static void getStringCommand(com.ice.jni.registry.RegistryKey topKey,
                                     java.lang.String keyName,
                                     java.lang.String valueName)

expandStringCommand

private static void expandStringCommand(com.ice.jni.registry.RegistryKey topKey,
                                        java.lang.String keyName,
                                        java.lang.String valueName)

deleteKeyCommand

private static void deleteKeyCommand(com.ice.jni.registry.RegistryKey topKey,
                                     java.lang.String keyName,
                                     java.lang.String deleteKeyName)

deleteValueCommand

private static void deleteValueCommand(com.ice.jni.registry.RegistryKey topKey,
                                       java.lang.String keyName,
                                       java.lang.String valueName)

listKeysCommand

private static void listKeysCommand(com.ice.jni.registry.RegistryKey topKey,
                                    java.lang.String keyName)

listValuesCommand

private static void listValuesCommand(com.ice.jni.registry.RegistryKey topKey,
                                      java.lang.String keyName)

setDWordCommand

private static void setDWordCommand(com.ice.jni.registry.RegistryKey topKey,
                                    java.lang.String keyName,
                                    java.lang.String valueName,
                                    java.lang.String data)

setMultiStringCommand

private static void setMultiStringCommand(com.ice.jni.registry.RegistryKey topKey,
                                          java.lang.String keyName,
                                          java.lang.String valueName,
                                          java.lang.String data)

setStringCommand

private static void setStringCommand(com.ice.jni.registry.RegistryKey topKey,
                                     java.lang.String keyName,
                                     java.lang.String valueName,
                                     java.lang.String data)

setBinaryCommand

private static void setBinaryCommand(com.ice.jni.registry.RegistryKey topKey,
                                     java.lang.String keyName,
                                     java.lang.String valueName,
                                     java.lang.String data)

createCommand

private static void createCommand(com.ice.jni.registry.RegistryKey topKey,
                                  java.lang.String keyName)

openSubKeyVerbose

private static com.ice.jni.registry.RegistryKey openSubKeyVerbose(com.ice.jni.registry.RegistryKey topKey,
                                                                  java.lang.String keyName,
                                                                  int access)

setValue

private static void setValue(com.ice.jni.registry.RegistryKey subKey,
                             com.ice.jni.registry.RegistryValue value)

dumpHexData

public static void dumpHexData(java.io.PrintStream out,
                               java.lang.String title,
                               byte[] buf,
                               int numBytes)

dumpHexData

public static void dumpHexData(java.io.PrintWriter out,
                               java.lang.String title,
                               byte[] buf,
                               int offset,
                               int numBytes)

splitString

public static java.lang.String[] splitString(java.lang.String splitStr,
                                             java.lang.String delim)
Split a string into a string array containing the substrings between the delimiters. NOTE This method WILL NOT return an empty token at the end of the array that is returned, if the string ends with the delimiter. If you wish to have a property string array that ends with the delimiter return an empty string at the end of the array, use vectorString().


parseArgumentString

public static java.lang.String[] parseArgumentString(java.lang.String argStr)

parseArgumentVector

public static java.util.Vector parseArgumentVector(java.lang.String argStr)


Copyright © 2002