com.izforge.izpack.util.os
Class Win_RegistryHandler

java.lang.Object
  extended by com.izforge.izpack.util.OSClassHelper
      extended by com.izforge.izpack.util.os.RegistryHandler
          extended by com.izforge.izpack.util.os.Win_RegistryHandler
All Implemented Interfaces:
MSWinConstants

public class Win_RegistryHandler
extends RegistryHandler

This is the Microsoft Windows specific implementation of RegistryHandler.

Author:
bartzkau

Field Summary
(package private)  Registry regWorker
           
 
Fields inherited from class com.izforge.izpack.util.os.RegistryHandler
ROOT_KEY_MAP, UNINSTALL_ROOT, uninstallName
 
Fields inherited from class com.izforge.izpack.util.OSClassHelper
installdata, worker, workerClass
 
Fields inherited from interface com.coi.tools.os.win.MSWinConstants
ACCESS_SYSTEM_SECURITY, DELETE, FILE_ADD_FILE, FILE_ADD_SUBDIRECTORY, FILE_ALL_ACCESS, FILE_APPEND_DATA, FILE_CASE_PRESERVED_NAMES, FILE_CASE_SENSITIVE_SEARCH, FILE_CREATE_PIPE_INSTANCE, FILE_DELETE_CHILD, FILE_EXECUTE, FILE_FILE_COMPRESSION, FILE_GENERIC_EXECUTE, FILE_GENERIC_READ, FILE_GENERIC_WRITE, FILE_LIST_DIRECTORY, FILE_PERSISTENT_ACLS, FILE_READ_ATTRIBUTES, FILE_READ_DATA, FILE_READ_EA, FILE_SUPPORTS_ENCRYPTION, FILE_SUPPORTS_OBJECT_IDS, FILE_SUPPORTS_REMOTE_STORAGE, FILE_SUPPORTS_REPARSE_POINTS, FILE_SUPPORTS_SPARSE_FILES, FILE_TRAVERSE, FILE_UNICODE_ON_DISK, FILE_VOLUME_IS_COMPRESSED, FILE_VOLUME_QUOTAS, FILE_WRITE_ATTRIBUTES, FILE_WRITE_DATA, FILE_WRITE_EA, GENERIC_ALL, GENERIC_EXECUTE, GENERIC_READ, GENERIC_WRITE, HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA, HKEY_LOCAL_MACHINE, HKEY_PERFORMANCE_DATA, HKEY_USERS, MAXIMUM_ALLOWED, READ_CONTROL, REG_BINARY, REG_DWORD, REG_EXPAND_SZ, REG_LINK, REG_MULTI_SZ, REG_NONE, REG_SZ, SPECIFIC_RIGHTS_ALL, STANDARD_RIGHTS_ALL, STANDARD_RIGHTS_EXECUTE, STANDARD_RIGHTS_READ, STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_WRITE, SYNCHRONIZE, WRITE_DAC, WRITE_OWNER
 
Constructor Summary
Win_RegistryHandler()
          Default constructor.
 
Method Summary
 void activateLogging()
          Activates logging of registry changes.
 void addLoggingInfo(java.util.List info)
           
 void createKey(java.lang.String key)
          Creates the given key in the registry.
 void deleteKey(java.lang.String key)
          Deletes the given key if exist, else throws an exception.
 void deleteKeyIfEmpty(java.lang.String key)
          Deletes a key under the current root if it is empty, else do nothing.
 void deleteValue(java.lang.String key, java.lang.String value)
          Deletes a value.
 java.util.List<java.lang.Object> getLoggingInfo()
           
 int getRoot()
          Return the root as integer (HKEY_xxx).
 java.lang.String[] getSubkeys(java.lang.String key)
          Returns all keys which are defined under the given key.
 RegDataContainer getValue(java.lang.String key, java.lang.String value)
          Returns the contents of the key/value pair if value exist, else an exception is raised.
 RegDataContainer getValue(java.lang.String key, java.lang.String value, RegDataContainer defaultVal)
          Returns the contents of the key/value pair if value exist, else the given default value.
 java.lang.String[] getValueNames(java.lang.String key)
          Returns all value names which are defined under the given key.
 boolean keyExist(java.lang.String key)
          Returns whether a key exist or not.
 void resetLogging()
          Resets logging of registry changes.
 void rewind()
           
 void setLoggingInfo(java.util.List info)
           
 void setRoot(int i)
          Sets the root for the next registry access.
 void setValue(java.lang.String key, java.lang.String value, byte[] contents)
          Sets the given contents to the given registry value.
 void setValue(java.lang.String key, java.lang.String value, long contents)
          Sets the given contents to the given registry value.
 void setValue(java.lang.String key, java.lang.String value, java.lang.String contents)
          Sets the given contents to the given registry value.
 void setValue(java.lang.String key, java.lang.String value, java.lang.String[] contents)
          Sets the given contents to the given registry value.
 void suspendLogging()
          Suspends logging of registry changes.
 boolean valueExist(java.lang.String key, java.lang.String value)
          Returns whether a the given value under the given key exist or not.
 
Methods inherited from class com.izforge.izpack.util.os.RegistryHandler
doPerform, getDefaultHandler, getUninstallName, isProductRegistered, registerUninstallKey, setUninstallName, verify
 
Methods inherited from class com.izforge.izpack.util.OSClassHelper
good
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regWorker

Registry regWorker
Constructor Detail

Win_RegistryHandler

public Win_RegistryHandler()
Default constructor.

Method Detail

setValue

public void setValue(java.lang.String key,
                     java.lang.String value,
                     java.lang.String contents)
              throws NativeLibException
Sets the given contents to the given registry value. If a sub key or the registry value does not exist, it will be created. The return value is a String array which contains the names of the keys and values which are created. REG_SZ is used as registry value type.

Overrides:
setValue in class RegistryHandler
Parameters:
key - the registry key which should be used or created
value - the registry value into which the contents should be set
contents - the contents for the value
Throws:
NativeLibException
NativeLibException

setValue

public void setValue(java.lang.String key,
                     java.lang.String value,
                     java.lang.String[] contents)
              throws NativeLibException
Sets the given contents to the given registry value. If a sub key or the registry value does not exist, it will be created. The return value is a String array which contains the names of the keys and values which are created. REG_MULTI_SZ is used as registry value type.

Overrides:
setValue in class RegistryHandler
Parameters:
key - the registry key which should be used or created
value - the registry value into which the contents should be set
contents - the contents for the value
Throws:
NativeLibException

setValue

public void setValue(java.lang.String key,
                     java.lang.String value,
                     byte[] contents)
              throws NativeLibException
Sets the given contents to the given registry value. If a sub key or the registry value does not exist, it will be created. The return value is a String array which contains the names of the keys and values which are created. REG_BINARY is used as registry value type.

Overrides:
setValue in class RegistryHandler
Parameters:
key - the registry key which should be used or created
value - the registry value into which the contents should be set
contents - the contents for the value
Throws:
NativeLibException

setValue

public void setValue(java.lang.String key,
                     java.lang.String value,
                     long contents)
              throws NativeLibException
Sets the given contents to the given registry value. If a sub key or the registry value does not exist, it will be created. The return value is a String array which contains the names of the keys and values which are created. REG_DWORD is used as registry value type.

Overrides:
setValue in class RegistryHandler
Parameters:
key - the registry key which should be used or created
value - the registry value into which the contents should be set
contents - the contents for the value
Throws:
NativeLibException

getValue

public RegDataContainer getValue(java.lang.String key,
                                 java.lang.String value,
                                 RegDataContainer defaultVal)
                          throws NativeLibException
Returns the contents of the key/value pair if value exist, else the given default value.

Overrides:
getValue in class RegistryHandler
Parameters:
key - the registry key which should be used
value - the registry value from which the contents should be requested
defaultVal - value to be used if no value exist in the registry
Returns:
requested value if exist, else the default value
Throws:
NativeLibException

keyExist

public boolean keyExist(java.lang.String key)
                 throws NativeLibException
Returns whether a key exist or not.

Overrides:
keyExist in class RegistryHandler
Parameters:
key - key to be evaluated
Returns:
whether a key exist or not
Throws:
NativeLibException

valueExist

public boolean valueExist(java.lang.String key,
                          java.lang.String value)
                   throws NativeLibException
Returns whether a the given value under the given key exist or not.

Overrides:
valueExist in class RegistryHandler
Parameters:
key - key to be used as path for the value
value - value name to be evaluated
Returns:
whether a the given value under the given key exist or not
Throws:
NativeLibException

getSubkeys

public java.lang.String[] getSubkeys(java.lang.String key)
                              throws NativeLibException
Returns all keys which are defined under the given key.

Overrides:
getSubkeys in class RegistryHandler
Parameters:
key - key to be used as path for the sub keys
Returns:
all keys which are defined under the given key
Throws:
NativeLibException

getValueNames

public java.lang.String[] getValueNames(java.lang.String key)
                                 throws NativeLibException
Returns all value names which are defined under the given key.

Overrides:
getValueNames in class RegistryHandler
Parameters:
key - key to be used as path for the value names
Returns:
all value names which are defined under the given key
Throws:
NativeLibException

getValue

public RegDataContainer getValue(java.lang.String key,
                                 java.lang.String value)
                          throws NativeLibException
Returns the contents of the key/value pair if value exist, else an exception is raised.

Overrides:
getValue in class RegistryHandler
Parameters:
key - the registry key which should be used
value - the registry value from which the contents should be requested
Returns:
requested value if exist, else an exception
Throws:
NativeLibException

createKey

public void createKey(java.lang.String key)
               throws NativeLibException
Creates the given key in the registry.

Overrides:
createKey in class RegistryHandler
Parameters:
key - key to be created
Throws:
NativeLibException

deleteKey

public void deleteKey(java.lang.String key)
               throws NativeLibException
Deletes the given key if exist, else throws an exception.

Overrides:
deleteKey in class RegistryHandler
Parameters:
key - key to be deleted
Throws:
NativeLibException

deleteKeyIfEmpty

public void deleteKeyIfEmpty(java.lang.String key)
                      throws NativeLibException
Deletes a key under the current root if it is empty, else do nothing.

Overrides:
deleteKeyIfEmpty in class RegistryHandler
Parameters:
key - key to be deleted
Throws:
NativeLibException

deleteValue

public void deleteValue(java.lang.String key,
                        java.lang.String value)
                 throws NativeLibException
Deletes a value.

Overrides:
deleteValue in class RegistryHandler
Parameters:
key - key of the value which should be deleted
value - value name to be deleted
Throws:
NativeLibException

setRoot

public void setRoot(int i)
             throws NativeLibException
Sets the root for the next registry access.

Overrides:
setRoot in class RegistryHandler
Parameters:
i - an integer which refers to a HKEY
Throws:
NativeLibException

getRoot

public int getRoot()
            throws NativeLibException
Return the root as integer (HKEY_xxx).

Overrides:
getRoot in class RegistryHandler
Returns:
the root as integer
Throws:
NativeLibException

activateLogging

public void activateLogging()
                     throws NativeLibException
Activates logging of registry changes.

Overrides:
activateLogging in class RegistryHandler
Throws:
NativeLibException

suspendLogging

public void suspendLogging()
                    throws NativeLibException
Suspends logging of registry changes.

Overrides:
suspendLogging in class RegistryHandler
Throws:
NativeLibException

resetLogging

public void resetLogging()
                  throws NativeLibException
Resets logging of registry changes.

Overrides:
resetLogging in class RegistryHandler
Throws:
NativeLibException

getLoggingInfo

public java.util.List<java.lang.Object> getLoggingInfo()
                                                throws NativeLibException
Overrides:
getLoggingInfo in class RegistryHandler
Throws:
NativeLibException

setLoggingInfo

public void setLoggingInfo(java.util.List info)
                    throws NativeLibException
Overrides:
setLoggingInfo in class RegistryHandler
Throws:
NativeLibException

addLoggingInfo

public void addLoggingInfo(java.util.List info)
                    throws NativeLibException
Overrides:
addLoggingInfo in class RegistryHandler
Throws:
NativeLibException

rewind

public void rewind()
            throws NativeLibException
Overrides:
rewind in class RegistryHandler
Throws:
NativeLibException