public class Registry extends java.lang.Object implements EnvironmentReader
Some terms need to be clarified. Unlike handling the INI file the 4GL sections are stored as registry subkeys, while the keys are stored as registry value names. Current investigation show the 4GL base option has no effect in registry handling, everything is happening under HKEY_CURRENT_USER registry base. Also the documented behavior for getting the subkeys in format 'section1@key1,section2@key2,..,sectionN@keyN' does not work. Another format for getting the list of the keys is implemented: 'section1,section2,..,sectionN'.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
baseKeyName
The name of the registry base to store the keys.
|
static java.lang.String |
HKEY_DEFAULT_BASE
Windows default hive name.
|
private boolean |
isNew
The flag indicating whether we need to create new registry sections replacing existed.
|
static java.lang.String |
KEY_DEFAULT
Windows default key name.
|
static java.lang.String |
NAME_SEPARATOR
Windows registry key-subkey names separator.
|
private java.lang.String |
registryKeyName
The complete key path with subkeys to store the key values without base key name.
|
TYPE_INI, TYPE_REG
Constructor and Description |
---|
Registry(Session session)
Default constructor creating the internals based on the expected registry keys for currently
installed Progress simulation.
|
Registry(java.lang.String env,
boolean flagNew,
java.lang.String baseKey)
Construct an instance of the environment with Windows registry as backend.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getEnvironmentName()
Get the environment's name.
|
java.lang.String |
getEnvironmentType()
Get the environment's type.
|
private static java.lang.String |
getKeyVal(java.lang.String base,
java.lang.String section,
java.lang.String key)
Native entry point to get key value from registry.
|
java.lang.String |
getKeyValue(java.lang.String section,
java.lang.String key)
Getting the key value or key or section lists from the current environment.
|
private static java.lang.String |
getSubKeys(java.lang.String base,
java.lang.String name)
Getting the comma separated list of subkeys for the given environment name.
|
private static java.lang.String |
getValueNames(java.lang.String base,
java.lang.String section)
Getting the comma separated list of keys(value name sin a terms of the windows registry)
for given subkey section.
|
boolean |
load()
Creates application defaults implementing Progress LOAD statement.
|
private static boolean |
removeSubKey(java.lang.String base,
java.lang.String section)
Deletes subkey section and all content.
|
private static boolean |
removeValueName(java.lang.String base,
java.lang.String section,
java.lang.String key)
Deletes name and it's value from subkey 'section'.
|
private static boolean |
setKeyVal(java.lang.String base,
java.lang.String section,
java.lang.String key,
java.lang.String value)
Native entry point to store new key value to registry.
|
void |
setKeyValue(java.lang.String section,
java.lang.String key,
java.lang.String value)
Adds, modifies and deletes keys or sections in current environment.
|
void |
unload()
Unloads specifies environment from the current one.
|
public static final java.lang.String NAME_SEPARATOR
public static final java.lang.String HKEY_DEFAULT_BASE
public static final java.lang.String KEY_DEFAULT
private java.lang.String registryKeyName
private java.lang.String baseKeyName
private boolean isNew
public Registry(Session session)
session
- The server session to get the properties.public Registry(java.lang.String env, boolean flagNew, java.lang.String baseKey)
env
- The environment to create or load. Can be the registry key.flagNew
- If true
- the new file will be created overwriting the possibly
existed one.baseKey
- When the parameter is specified the serching is performed under the particular base
key value.private static java.lang.String getKeyVal(java.lang.String base, java.lang.String section, java.lang.String key)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.section
- The name of the section in the current environment registry entry to look the key.key
- The name of the key(or value name in a terms of the windows registry) whose value
is requested.private static java.lang.String getSubKeys(java.lang.String base, java.lang.String name)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.name
- The name of the current environment registry entry to get the section list.private static java.lang.String getValueNames(java.lang.String base, java.lang.String section)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.section
- The name of the section in the current environment registry entry to get the value
names list.private static boolean setKeyVal(java.lang.String base, java.lang.String section, java.lang.String key, java.lang.String value)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.section
- The name of the section in the current environment registry entry to change the key.key
- The name of the key(or value name in a terms of the windows registry) to modify.value
- The new value to be stored for the key.true
in case of success, false
otherwise.private static boolean removeValueName(java.lang.String base, java.lang.String section, java.lang.String key)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.section
- The name of the section in the current environment registry entry to remove the key.key
- The name of the key(or value name in a terms of the windows registry) to remove.true
in case of success, false
otherwise.private static boolean removeSubKey(java.lang.String base, java.lang.String section)
base
- The name of the root for the environment location. It is currently ignored because
the only root is working is HKEY_CURRENT_USER.section
- The name of the section to remove from the current environment registry entry.true
in case of success, false
otherwise.public boolean load()
load
in interface EnvironmentReader
true
if loaded false otherwisepublic void setKeyValue(java.lang.String section, java.lang.String key, java.lang.String value)
The other possible cases are("" means the parameter is null or empty string if the difference is not important): section == "", key != "", value != "" causes adding directly under current environment value name 'key' with given 'value'. section == "", key != "", value == "" removing value name 'key' directly under current environment with its 'value' section != "", key != "", value == "" deletes name and it's value from subkey 'section'. section != "", key == "", value == "" deletes subkey 'section' with all content. section != "", key == null, value != "" sets new value for DEFAULT value name for subkey 'section'. section != "", key == null, value == "" removes DEFAULT value name setting 'value' as unset for subkey 'section'
setKeyValue
in interface EnvironmentReader
section
- The name of the section containing the key to modify.key
- The name of the key to modify or default key if not specified.value
- The new value of the key under modification.public java.lang.String getKeyValue(java.lang.String section, java.lang.String key)
The other possible cases are("" means the parameter is null or empty string if the difference is not important): section == "", key != "" gets the value for given value name 'key' under current environment. There is no 'section' for this key. section == "", key == "" gets the comma separated list of all subkeys for the current environment. section != "", key == empty gets the comma separated list of value names for subkey 'section'. Empty here means not null string with 0 length. section != "", key == null gets the DEFAULT value for the given subkey 'section'.
getKeyValue
in interface EnvironmentReader
section
- The name of the section containing the key to get.key
- The name of the key to get or default key if not specified.public void unload()
unload
in interface EnvironmentReader
public java.lang.String getEnvironmentName()
getEnvironmentName
in interface EnvironmentReader
public java.lang.String getEnvironmentType()
getEnvironmentType
in interface EnvironmentReader