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
-
ACCESS_ALL
-
-
ACCESS_DEFAULT
- Constants used to determine the access level for
newly opened keys.
-
ACCESS_EXECUTE
-
-
ACCESS_READ
-
-
ACCESS_WRITE
-
-
created
- Used to indicate whether or not the key was created
when method createSubKey() is called, otherwise false.
-
hKey
- This is the actual DWORD key that is returned from the
Registry API.
-
name
- The full pathname of this key.
-
RegistryKey(int, String)
-
-
RegistryKey(int, String, boolean)
-
-
closeKey()
- Closes this subkey.
-
connectRegistry(String)
- Connect to the remote registry on hostName.
-
createSubKey(String, String)
- Create, and open, a Registry subkey of this key with WRITE access.
-
createSubKey(String, String, int)
-
Create a new subkey, or open the existing one.
-
decrDoubleWord(String)
- This method will decrement the value of a REG_DWORD value.
-
deleteSubKey(String)
- Delete a named subkey.
-
deleteValue(String)
- Delete a named value.
-
expandEnvStrings(String)
- This method will expand a string to include the definitions
of System environment variables that are referenced via the
%variable% construct.
-
export(PrintWriter, boolean)
- Export this key's definition to the provided PrintWriter.
-
finalize()
- The finalize() override checks to be sure the key is closed.
-
flushKey()
- Guarentees that this key is written to disk.
-
getDefaultValue()
- Get the data from the default value.
-
getFullName()
- Get the full name of the key, from the top level down.
-
getMaxSubkeyLength()
- Obtains the maximum length of all of the subkey names.
-
getMaxValueDataLength()
- Obtains the maximum length of all of the value data.
-
getMaxValueNameLength()
- Obtains the maximum length of all of the value names.
-
getName()
- Get the name of this key.
-
getNumberSubkeys()
- Obtains the number of subkeys that this key contains.
-
getNumberValues()
- Obtains the number of values that this key contains.
-
getStringValue(String)
- Get the value of a REG_SZ or REG_EXPAND_SZ value.
-
getValue(String)
- Get the data of a named value.
-
hasDefaultValue()
- Determines if this key has a default value.
-
hasOnlyDefaultValue()
- Determines if this key has only a default value.
-
incrDoubleWord(String)
- This method will increment the value of a REG_DWORD value.
-
keyElements()
- Returns a new Enumeration that will enumerate the
names of the subkeys of this key,
-
openSubKey(String)
- Open a Registry subkey of this key with READ access.
-
openSubKey(String, int)
- Open a Registry subkey of this key with the specified access.
-
regEnumKey(int)
- Obtains an enumerator for the subkeys of this key.
-
regEnumValue(int)
- Obtains an enumerator for the values of this key.
-
setCreated(boolean)
- Used to set the created state of this key.
-
setValue(RegistryValue)
- Set the value of this RegistryKey.
-
setValue(String, RegistryValue)
- Set the name value to the given data.
-
valueElements()
- Returns a new Enumeration that will enumerate the
names of the values of this key,
-
wasCreated()
- Determine if this key was opened or created and opened.
ACCESS_DEFAULT
public static final int ACCESS_DEFAULT
- Constants used to determine the access level for
newly opened keys.
ACCESS_READ
public static final int ACCESS_READ
ACCESS_WRITE
public static final int ACCESS_WRITE
ACCESS_EXECUTE
public static final int ACCESS_EXECUTE
ACCESS_ALL
public static final int ACCESS_ALL
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.
name
protected String name
- The full pathname of this key.
created
protected boolean created
- Used to indicate whether or not the key was created
when method createSubKey() is called, otherwise false.
RegistryKey
public RegistryKey(int hKey,
String name)
RegistryKey
public RegistryKey(int hKey,
String name,
boolean created)
finalize
public void finalize()
- The finalize() override checks to be sure the key is closed.
- Overrides:
- finalize in class Object
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.
getFullName
public String getFullName()
- Get the full name of the key, from the top level down.
- Returns:
- The full name of the key.
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.
setCreated
public void setCreated(boolean created)
- Used to set the created state of this key.
- Parameters:
- created - The new created state.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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