|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ca.beq.util.win32.registry.RegistryKey
A representation of system registry keys, RegistryKey is the
principle class of the ca.beq.util.win32.registry package.
A RegistryKey is composed of two components (specified at
creation):
The root key component is defined to be any valid RootKey
object. The path component is similar to a file-system pathname; it is a
series of zero or more string names separated by backslahes ("\\").
Unlike file-system pathnames there is no "optional prefix", and each name
defines a registry key. For example, Software\\BEQ Technologies\\Test
is a valid registry key, whereas \\Software\\BEQ Technologies\\Test
is not.
The following code snippet demonstrates creating, reading, and deleting
values in the registry using RegistryKey:
// create a new key, "Test", under HKLM
RegistryKey r = new RegistryKey(RootKey.HKEY_LOCAL_MACHINE, "Test");
if(!r.exists()) {
r.create();
} // if
// create value entries
RegistryValue v = new RegistryValue("aString", ValueType.REG_SZ, "test");
r.setValue(v);
v.setName("aDword");
v.setType(ValueType.REG_DWORD);
v.setData(new Integer(0x1001001));
r.setValue(v);
// read value entries
Iterator i = r.values();
while(i.hasNext()) {
v = (RegistryValue)i.next();
System.out.println(v.toString());
} // while
// delete registry key
r.delete();
| Constructor Summary | |
RegistryKey()
Constructs a new RegistryKey referencing the root path of
the RootKey.HKEY_CURRENT_USER root key. |
|
RegistryKey(RootKey root)
Constructs a new RegistryKey referencing the root path of
the specified RootKey. |
|
RegistryKey(RootKey root,
String path)
Constructs a new RegistryKey referencing the specified path
of the specified RootKey. |
|
RegistryKey(String path)
Constructs a new RegistryKey referencing the specified path
of the RootKey.HKEY_CURRENT_USER root key. |
|
| Method Summary | |
void |
create()
Creates this registry key in the system registry. |
RegistryKey |
createSubkey(String name)
Creates the specified subkey. |
void |
delete()
Deletes this registry key and any subkeys or values from the system registry. |
void |
deleteValue(String name)
Deletes the specified value from this registry key. |
boolean |
exists()
Tests if this registry key, as defined by the RootKey
and path, currently exists in the system registry. |
String |
getName()
Returns this RegistryKey's name. |
String |
getPath()
Returns this RegistryKey's path. |
RootKey |
getRootKey()
Returns this RegistryKey's root key. |
RegistryValue |
getValue(String name)
Returns a RegistryValue representing the specified value. |
boolean |
hasSubkey(String name)
Tests if this registry key possesses the specified subkey. |
boolean |
hasSubkeys()
Tests if this registry key possesses subkeys. |
boolean |
hasValue(String name)
Tests if this registry key possess the specified value. |
boolean |
hasValues()
Tests if this registry key possess any values. |
void |
setValue(RegistryValue value)
Sets the properties of a registry value according to the properties of the specified RegistryValue. |
Iterator |
subkeys()
Returns an iterator for available subkeys. |
String |
toString()
Returns a string representation of this RegistryKey. |
Iterator |
values()
Returns an iterator for available values. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public RegistryKey()
RegistryKey referencing the root path of
the RootKey.HKEY_CURRENT_USER root key.public RegistryKey(RootKey root)
RegistryKey referencing the root path of
the specified RootKey.root - the root key of this RegistryKeypublic RegistryKey(String path)
RegistryKey referencing the specified path
of the RootKey.HKEY_CURRENT_USER root key.path - the path of this RegistryKey
public RegistryKey(RootKey root,
String path)
RegistryKey referencing the specified path
of the specified RootKey.root - the root key of this RegistryKeypath - the path of this RegistryKey| Method Detail |
public RootKey getRootKey()
RegistryKey's root key.public String getPath()
RegistryKey's path.pathpublic String getName()
RegistryKey's name. The name is
last portion of a path. For example, for the
path Software\\BEQ Technologies\\TestKey, the
name would be TestKey.namepublic boolean exists()
RootKey
and path, currently exists in the system registry.true if this key exists in the registrypublic void create()
RegistryException - if this registry key already exists in the
registrypublic RegistryKey createSubkey(String name)
name - name the subkey to be createdRegistryException - if this registry key does not exist in the
registry, or if the specified subkey name already exists.public void delete()
WARNING: This method can potentially cause catastrophic damage to the system registry. USE WITH EXTREME CARE!
RegistryException - if this registry key does not already exist
in the registrypublic boolean hasSubkeys()
subkeys
to retrieve an iterator for available subkeys.true if this registry key possesses subkeysRegistryException - if this registry key does not already exist
in the registrypublic boolean hasSubkey(String name)
name - the subkey to test fortrue if this registry key possesses subkeysRegistryException - if this registry key does not already exist
in the registrypublic Iterator subkeys()
RegistryKey'sRegistryException - if this registry key does not already exist
in the registrypublic Iterator values()
RegistryValue'sRegistryException - if this registry key does not already exist
in the registrypublic boolean hasValue(String name)
name - the name of the value to be testedtrue if this registry keys possess the specified
valueRegistryException - if this registry key does not already exist
in the registrypublic boolean hasValues()
true if this registry keys possess any valuesRegistryException - if this registry key does not already exist
in the registrypublic RegistryValue getValue(String name)
RegistryValue representing the specified value.name - the name of the value to be retreivedRegistryException - if this registry key does not already exist
in the registry, or if this registry key does not possess the
specified valuepublic void setValue(RegistryValue value)
RegistryValue. If the specified value exists,
it will be modified; if not, it will be created.value - the RegistryValueRegistryException - if this registry key does not already exist
in the registrypublic void deleteValue(String name)
name - the name of the value to be deletedRegistryException - if this registry key does not already exist
in the registry, or if the specified value is not possess by
this registry keypublic String toString()
RegistryKey.toString in class ObjectRegistryKey
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||