All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ice.jni.registry.RegistryKey

java.lang.Object
   |
   +----com.ice.jni.registry.RegistryKey

public class RegistryKey
extends Object
The RegistryKey class represents a key in the registry. The class also provides all of the native interface calls. You should refer to the Windows Registry API documentation for the details of any of the native methods. The native implementation performs almost no processing before or after a given call, so their behavior should match the API's documented behavior precisely. Note that you can not open a subkey without an existing open RegistryKey. Thus, you need to start with one of the top level keys defined in the Registry class and open relative to that.

See Also:
Registry, RegistryValue

Variable Index

 o ACCESS_ALL
 o ACCESS_DEFAULT
Constants used to determine the access level for newly opened keys.
 o ACCESS_EXECUTE
 o ACCESS_READ
 o ACCESS_WRITE
 o created
Used to indicate whether or not the key was created when method createSubKey() is called, otherwise false.
 o hKey
This is the actual DWORD key that is returned from the Registry API.
 o name
The full pathname of this key.

Constructor Index

 o RegistryKey(int, String)
 o RegistryKey(int, String, boolean)

Method Index

 o closeKey()
Closes this subkey.
 o connectRegistry(String)
Connect to the remote registry on hostName.
 o createSubKey(String, String)
Create, and open, a Registry subkey of this key with WRITE access.
 o createSubKey(String, String, int)
Create a new subkey, or open the existing one.
 o decrDoubleWord(String)
This method will decrement the value of a REG_DWORD value.
 o deleteSubKey(String)
Delete a named subkey.
 o deleteValue(String)
Delete a named value.
 o expandEnvStrings(String)
This method will expand a string to include the definitions of System environment variables that are referenced via the %variable% construct.
 o export(PrintWriter, boolean)
Export this key's definition to the provided PrintWriter.
 o finalize()
The finalize() override checks to be sure the key is closed.
 o flushKey()
Guarentees that this key is written to disk.
 o getDefaultValue()
Get the data from the default value.
 o getFullName()
Get the full name of the key, from the top level down.
 o getMaxSubkeyLength()
Obtains the maximum length of all of the subkey names.
 o getMaxValueDataLength()
Obtains the maximum length of all of the value data.
 o getMaxValueNameLength()
Obtains the maximum length of all of the value names.
 o getName()
Get the name of this key.
 o getNumberSubkeys()
Obtains the number of subkeys that this key contains.
 o getNumberValues()
Obtains the number of values that this key contains.
 o getStringValue(String)
Get the value of a REG_SZ or REG_EXPAND_SZ value.
 o getValue(String)
Get the data of a named value.
 o hasDefaultValue()
Determines if this key has a default value.
 o hasOnlyDefaultValue()
Determines if this key has only a default value.
 o incrDoubleWord(String)
This method will increment the value of a REG_DWORD value.
 o keyElements()
Returns a new Enumeration that will enumerate the names of the subkeys of this key,
 o openSubKey(String)
Open a Registry subkey of this key with READ access.
 o openSubKey(String, int)
Open a Registry subkey of this key with the specified access.
 o regEnumKey(int)
Obtains an enumerator for the subkeys of this key.
 o regEnumValue(int)
Obtains an enumerator for the values of this key.
 o setCreated(boolean)
Used to set the created state of this key.
 o setValue(RegistryValue)
Set the value of this RegistryKey.
 o setValue(String, RegistryValue)
Set the name value to the given data.
 o valueElements()
Returns a new Enumeration that will enumerate the names of the values of this key,
 o wasCreated()
Determine if this key was opened or created and opened.

Variables

 o ACCESS_DEFAULT
 public static final int ACCESS_DEFAULT
Constants used to determine the access level for newly opened keys.

 o ACCESS_READ
 public static final int ACCESS_READ
 o ACCESS_WRITE
 public static final int ACCESS_WRITE
 o ACCESS_EXECUTE
 public static final int ACCESS_EXECUTE
 o ACCESS_ALL
 public static final int ACCESS_ALL
 o hKey
 protected int hKey
This is the actual DWORD key that is returned from the Registry API. This value is totally opaque and should never be referenced.

 o name
 protected String name
The full pathname of this key.

 o created
 protected boolean created
Used to indicate whether or not the key was created when method createSubKey() is called, otherwise false.

Constructors

 o RegistryKey
 public RegistryKey(int hKey,
                    String name)
 o RegistryKey
 public RegistryKey(int hKey,
                    String name,
                    boolean created)

Methods

 o finalize
 public void finalize()
The finalize() override checks to be sure the key is closed.

Overrides:
finalize in class Object
 o getName
 public String getName()
Get the name of this key. This is not fully qualified, which means that the name will not contain any backslashes.

Returns:
The relative name of this key.
 o getFullName
 public String getFullName()
Get the full name of the key, from the top level down.

Returns:
The full name of the key.
 o wasCreated
 public boolean wasCreated()
Determine if this key was opened or created and opened. The result can only be true if createSubKey() was called and the key did not exist, and the creation of the new subkey succeeded.

Returns:
True if the key was created new, else false.
 o setCreated
 public void setCreated(boolean created)
Used to set the created state of this key.

Parameters:
created - The new created state.
 o openSubKey
 public RegistryKey openSubKey(String subkey) throws NoSuchKeyException, RegistryException
Open a Registry subkey of this key with READ access.

Parameters:
subkey - The name of the subkey to open.
Returns:
The newly opened RegistryKey.
Throws: NoSuchKeyException
If the subkey does not exist.
Throws: RegistryException
Any other registry API error.
 o createSubKey
 public RegistryKey createSubKey(String subkey,
                                 String className) throws RegistryException
Create, and open, a Registry subkey of this key with WRITE access. If the key already exists, it is opened, otherwise it is first created and then opened.

Parameters:
subkey - The name of the subkey to create.
className - The className of the created subkey.
Returns:
The newly created and opened RegistryKey.
Throws: RegistryException
Any valid registry API error.
 o setValue
 public void setValue(RegistryValue value) throws RegistryException
Set the value of this RegistryKey.

Parameters:
value - The value to set, including the value name.
Throws: RegistryException
Any valid registry API error.
 o openSubKey
 public native RegistryKey openSubKey(String subKey,
                                      int access) throws NoSuchKeyException, RegistryException
Open a Registry subkey of this key with the specified access.

Parameters:
subkey - The name of the subkey to open.
access - The access level for the open.
Returns:
The newly opened RegistryKey.
Throws: NoSuchKeyException
If the subkey does not exist.
Throws: RegistryException
Any other registry API error.
 o connectRegistry
 public native RegistryKey connectRegistry(String hostName) throws NoSuchKeyException, RegistryException
Connect to the remote registry on hostName. This method will only work when invoked on a toplevel key. The returned value will be the same toplevel key opened from the remote host's registry.

Parameters:
hostName - The remote computer's hostname.
Returns:
The remote top level key identical to this top level key.
Throws: NoSuchKeyException
If the subkey does not exist.
Throws: RegistryException
Any other registry API error.
 o createSubKey
 public native RegistryKey createSubKey(String subKey,
                                        String className,
                                        int access) throws RegistryException
Create a new subkey, or open the existing one. You can determine if the subkey was created, or whether an existing subkey was opened, via the wasCreated() method.

Parameters:
subKey - The name of the subkey to create/open.
className - The key's class name, or null.
access - The access level of the opened subkey.
Returns:
The newly created or opened subkey.
Throws: RegistryException
Any valid registry API error.
 o closeKey
 public native void closeKey() throws RegistryException
Closes this subkey. You may chose to let the finalize() method do the close.

Throws: RegistryException
Any valid registry API error.
 o deleteSubKey
 public native void deleteSubKey(String subKey) throws NoSuchKeyException, RegistryException
Delete a named subkey.

Parameters:
subKey - The name of the subkey to delete.
Throws: NoSuchKeyException
If the subkey does not exist.
Throws: RegistryException
Any other registry API error.
 o deleteValue
 public native void deleteValue(String valueName) throws NoSuchValueException, RegistryException
Delete a named value.

Parameters:
valueName - The name of the value to delete.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o flushKey
 public native void flushKey() throws RegistryException
Guarentees that this key is written to disk. This method should be called only when needed, as it has a huge performance cost.

Throws: RegistryException
Any valid registry API error.
 o setValue
 public native void setValue(String valueName,
                             RegistryValue value) throws RegistryException
Set the name value to the given data.

Parameters:
valueName - The name of the value to set.
value - The data to set the named value.
Throws: RegistryException
Any valid registry API error.
 o getValue
 public native RegistryValue getValue(String valueName) throws NoSuchValueException, RegistryException
Get the data of a named value.

Parameters:
valueName - The name of the value to get.
Returns:
The data of the named value.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o getStringValue
 public native String getStringValue(String valueName) throws NoSuchValueException, RegistryException
Get the value of a REG_SZ or REG_EXPAND_SZ value.

Parameters:
valueName - The name of the value to get.
Returns:
The string data of the named value.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o getDefaultValue
 public native String getDefaultValue() throws NoSuchValueException, RegistryException
Get the data from the default value.

Returns:
The string data of the default value.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o hasDefaultValue
 public native boolean hasDefaultValue() throws RegistryException
Determines if this key has a default value.

Returns:
True if there is a default value, else false.
Throws: RegistryException
Any valid registry API error.
 o hasOnlyDefaultValue
 public native boolean hasOnlyDefaultValue() throws RegistryException
Determines if this key has only a default value.

Returns:
True if there is only a default value, else false.
Throws: RegistryException
Any valid registry API error.
 o getNumberSubkeys
 public native int getNumberSubkeys() throws RegistryException
Obtains the number of subkeys that this key contains.

Returns:
The number of subkeys that this key contains.
Throws: RegistryException
Any valid registry API error.
 o getMaxSubkeyLength
 public native int getMaxSubkeyLength() throws RegistryException
Obtains the maximum length of all of the subkey names.

Returns:
The maximum length of all of the subkey names.
Throws: RegistryException
Any valid registry API error.
 o regEnumKey
 public native String regEnumKey(int index) throws RegistryException
Obtains an enumerator for the subkeys of this key.

Returns:
The key enumerator.
Throws: RegistryException
Any valid registry API error.
 o getNumberValues
 public native int getNumberValues() throws RegistryException
Obtains the number of values that this key contains.

Returns:
The number of values that this key contains.
Throws: RegistryException
Any valid registry API error.
 o getMaxValueDataLength
 public native int getMaxValueDataLength() throws RegistryException
Obtains the maximum length of all of the value data.

Returns:
The maximum length of all of the value data.
Throws: RegistryException
Any valid registry API error.
 o getMaxValueNameLength
 public native int getMaxValueNameLength() throws RegistryException
Obtains the maximum length of all of the value names.

Returns:
The maximum length of all of the value names.
Throws: RegistryException
Any valid registry API error.
 o regEnumValue
 public native String regEnumValue(int index) throws RegistryException
Obtains an enumerator for the values of this key.

Returns:
The value enumerator.
Throws: RegistryException
Any valid registry API error.
 o incrDoubleWord
 public native int incrDoubleWord(String valueName) throws NoSuchValueException, RegistryException
This method will increment the value of a REG_DWORD value.

Parameters:
valueName - The name of the value to increment.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o decrDoubleWord
 public native int decrDoubleWord(String valueName) throws NoSuchValueException, RegistryException
This method will decrement the value of a REG_DWORD value.

Parameters:
valueName - The name of the value to increment.
Throws: NoSuchValueException
If the value does not exist.
Throws: RegistryException
Any other registry API error.
 o expandEnvStrings
 public static native String expandEnvStrings(String exString)
This method will expand a string to include the definitions of System environment variables that are referenced via the %variable% construct. This method invokes EnvExpandStrings().

Parameters:
valueName - The name of the value to increment.
 o keyElements
 public Enumeration keyElements() throws RegistryException
Returns a new Enumeration that will enumerate the names of the subkeys of this key,

Returns:
A new Enumeration to enumerate subkey names.
Throws: RegistryException
Any valid registry API error.
 o valueElements
 public Enumeration valueElements() throws RegistryException
Returns a new Enumeration that will enumerate the names of the values of this key,

Returns:
A new Enumeration to enumerate value names.
Throws: RegistryException
Any valid registry API error.
 o export
 public void export(PrintWriter out,
                    boolean descend) throws NoSuchKeyException, RegistryException
Export this key's definition to the provided PrintWriter. The resulting file can be imported via RegEdit.

Throws: NoSuchKeyException
Thrown by openSubKey().
Throws: NoSuchValueException
Thrown by getValue().
Throws: RegistryException
Any other registry API error.

All Packages  Class Hierarchy  This Package  Previous  Next  Index