public class RegistryKeyObject extends Object implements IRegistryKey
Modifier and Type | Field and Description |
---|---|
protected boolean |
dontCacheData |
protected String[] |
emptyValuesList |
protected String |
name |
protected String |
path |
protected RegistryKeyObject |
root |
GET_INDEXES, GET_INDEXES_AS_LONGS, OPTION_READ_32_BIT_VALUES_ONLY, OPTION_READ_64_BIT_VALUES_ONLY, SORT_CASE_SENSITIVE, SORT_DESCENDING, SORT_DONT_SORT
Modifier | Constructor and Description |
---|---|
|
RegistryKeyObject(String name,
int options)
This is used to create a root key only.
|
protected |
RegistryKeyObject(String name,
String fullPath,
RegistryKeyObject root,
int options) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
amRoot() |
IRegistryKey |
changeOptions(int switchOn,
int switchOff)
Get a new IRegistryKey with modified options.
|
protected void |
clearKeyNames()
Used to clear key names if keys have been changed.
|
boolean |
createKey(boolean createFullPath)
If the key does not exist, create it.
|
protected boolean |
createKey(String fullPath)
Override this to create the data that represents a key.
|
boolean |
deleteKey()
Delete the entire key and all its subkeys (if possible).
|
boolean |
deleteValue(String name)
Delete a value with the specified name.
|
protected boolean |
doDelete() |
String |
getFullKeyPath() |
String |
getKeyName()
Get the name to display for the key.
|
protected RegistryKeyObject |
getNew(String name,
String fullPath,
RegistryKeyObject root,
int options)
You must override this method.
|
protected IRegistryKey |
getOrCreate(String fullPath,
int options) |
IRegistryKey |
getParentKey()
This should only return null for the root key.
|
IRegistryKey |
getRootKey()
Return the topmost key.
|
String |
getSubKey(int index) |
IRegistryKey |
getSubKey(String subkeyPath)
This should never return null, even if the subkey does not exist
or is illegal in some way.
|
int |
getSubKeyCount() |
Object |
getSubKeys(int options)
Return an array of Strings or an array of integers or array of longs representing the
subkeys of this key.
|
protected String[] |
getUnsortedKeyNames() |
Object |
getValue(int index,
StringBuffer valueName)
Get a value at the specified index.
|
Object |
getValue(String valueName)
This returns either a String or a byte array, or an Integer (representing a 32-bit value)
or a StringBuffer for an expanding String or null.
|
int |
getValueCount() |
boolean |
keyExists()
Return true if the key already exists.
|
protected void |
keyNamesChanged()
This is called when the key names have been changed.
|
boolean |
setExpandingString(String name,
String value) |
boolean |
setValue(String name,
byte[] value)
Set a binary data value.
|
boolean |
setValue(String name,
int value)
Set a 32-bit data value in the default little-endian format.
|
boolean |
setValue(String name,
String value)
Set a String value.
|
protected String name
protected String path
protected RegistryKeyObject root
protected boolean dontCacheData
protected final String[] emptyValuesList
public RegistryKeyObject(String name, int options)
name
- the display name for the Root key. Its path
will always be an empty String.protected RegistryKeyObject(String name, String fullPath, RegistryKeyObject root, int options)
public IRegistryKey getRootKey()
IRegistryKey
getRootKey
in interface IRegistryKey
protected final IRegistryKey getOrCreate(String fullPath, int options)
public IRegistryKey getSubKey(String subkeyPath)
IRegistryKey
getSubKey
in interface IRegistryKey
subkeyPath
- the subkey path relative to this key.public boolean createKey(boolean createFullPath)
IRegistryKey
createKey
in interface IRegistryKey
createFullPath
- if this is true then create all parent keys too.public String getFullKeyPath()
getFullKeyPath
in interface IRegistryKey
public String getKeyName()
IRegistryKey
getKeyName
in interface IRegistryKey
public IRegistryKey getParentKey()
IRegistryKey
getParentKey
in interface IRegistryKey
public final boolean deleteKey()
IRegistryKey
deleteKey
in interface IRegistryKey
public String getSubKey(int index) throws IndexOutOfBoundsException
getSubKey
in interface IRegistryKey
IndexOutOfBoundsException
public int getSubKeyCount()
getSubKeyCount
in interface IRegistryKey
protected final boolean amRoot()
public Object getSubKeys(int options)
IRegistryKey
getSubKeys
in interface IRegistryKey
options
- By default this will return an array of sorted Strings. If the GET_INDEXES
option is used, then an array of integer indexes (sorted by the sub-key name) will be returned.
If the GET_INDEXES_AS_LONGS option isused, then an array of long indexes (sorted by the sub-key name) will be returned.
& If SORT_DONT_SORT is used then the subkey list returned is not sorted.
protected final void clearKeyNames()
protected void keyNamesChanged()
protected boolean createKey(String fullPath)
fullPath
- the full path of the key.protected String[] getUnsortedKeyNames()
public boolean setExpandingString(String name, String value)
setExpandingString
in interface IRegistryKey
public boolean setValue(String name, String value)
IRegistryKey
setValue
in interface IRegistryKey
public boolean setValue(String name, byte[] value)
IRegistryKey
setValue
in interface IRegistryKey
public boolean setValue(String name, int value)
IRegistryKey
setValue
in interface IRegistryKey
protected RegistryKeyObject getNew(String name, String fullPath, RegistryKeyObject root, int options)
name
- the name to display. If this is null the displayed name
defaults to the last section of the path.fullPath
- the full path but not starting with a leading '\'root
- the root for the key.public Object getValue(String valueName)
IRegistryKey
getValue
in interface IRegistryKey
public Object getValue(int index, StringBuffer valueName) throws IndexOutOfBoundsException
IRegistryKey
getValue
in interface IRegistryKey
index
- the index of the value.valueName
- a StringBuffer to hold the value name.IndexOutOfBoundsException
- if the index is too high.public boolean deleteValue(String name)
IRegistryKey
deleteValue
in interface IRegistryKey
public int getValueCount()
getValueCount
in interface IRegistryKey
public boolean keyExists()
IRegistryKey
keyExists
in interface IRegistryKey
protected boolean doDelete()
public IRegistryKey changeOptions(int switchOn, int switchOff)
IRegistryKey
changeOptions
in interface IRegistryKey
switchOn
- options to switch on. Any of the OPTION_XXX valuesswitchOff
- options to switch off. Any of the OPTION_XXX values