com.izforge.izpack.util.os
Class RegistryHandler

java.lang.Object
  extended bycom.izforge.izpack.util.OSClassHelper
      extended bycom.izforge.izpack.util.os.RegistryHandler
Direct Known Subclasses:
Win_RegistryHandler

public class RegistryHandler
extends OSClassHelper

This class represents a registry handler in a operating system independent way. OS specific subclasses are used to implement the necessary mapping from this generic API to the classes that reflect the system dependent AIP.

Author:
Klaus Bartz

Field Summary
private static RegistryHandler defaultHandler
           
static java.util.Map ROOT_KEY_MAP
           
static java.lang.String UNINSTALL_ROOT
           
private static java.lang.String UNINSTALLER_ICON
           
protected  java.lang.String uninstallName
           
 
Fields inherited from class com.izforge.izpack.util.OSClassHelper
installdata, worker, workerClass
 
Constructor Summary
RegistryHandler()
          Default constructor.
RegistryHandler(java.lang.String className)
          Creates an registry handler which uses an oblect of the given class as worker.
 
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.
 boolean doPerform()
          Returns whether an action with this handler should be performed or not.
 RegistryHandler getDefaultHandler()
          Returns the default handler which is the first created registry handler.
 java.util.List 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.
 java.lang.String getUninstallName()
           
 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 isProductRegistered()
           
 boolean keyExist(java.lang.String key)
          Returns whether a key exist or not.
 void registerUninstallKey()
           
 void resetLogging()
          Resets logging of registry changes.
 void rewind()
           
private  void setDefault()
          Set this object as default handler if it is not done earlier.
 void setLoggingInfo(java.util.List info)
           
 void setRoot(int i)
          Sets the root for the next registry access.
 void setUninstallName(java.lang.String name)
           
 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)
           
 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.
 boolean verify(AutomatedInstallData idata)
           
 
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

UNINSTALL_ROOT

public static final java.lang.String UNINSTALL_ROOT
See Also:
Constant Field Values

ROOT_KEY_MAP

public static final java.util.Map ROOT_KEY_MAP

uninstallName

protected java.lang.String uninstallName

UNINSTALLER_ICON

private static final java.lang.String UNINSTALLER_ICON
See Also:
Constant Field Values

defaultHandler

private static RegistryHandler defaultHandler
Constructor Detail

RegistryHandler

public RegistryHandler()
Default constructor.


RegistryHandler

public RegistryHandler(java.lang.String className)
Creates an registry handler which uses an oblect of the given class as worker.

Parameters:
className - full qualified class name of the class which should be used as worker
Method Detail

setDefault

private void setDefault()
Set this object as default handler if it is not done earlier.


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.

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,
                     java.lang.String[] contents)
              throws NativeLibException
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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Parameters:
i - an integer which refers to a HKEY
Throws:
NativeLibException

getRoot

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

Returns:
the root as integer
Throws:
NativeLibException

activateLogging

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

Throws:
NativeLibException

suspendLogging

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

Throws:
NativeLibException

resetLogging

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

Throws:
NativeLibException

getLoggingInfo

public java.util.List getLoggingInfo()
                              throws NativeLibException
Throws:
NativeLibException

setLoggingInfo

public void setLoggingInfo(java.util.List info)
                    throws NativeLibException
Throws:
NativeLibException

addLoggingInfo

public void addLoggingInfo(java.util.List info)
                    throws NativeLibException
Throws:
NativeLibException

rewind

public void rewind()
            throws NativeLibException
Throws:
NativeLibException

getUninstallName

public java.lang.String getUninstallName()

isProductRegistered

public boolean isProductRegistered()
                            throws NativeLibException
Throws:
NativeLibException

setUninstallName

public void setUninstallName(java.lang.String name)

registerUninstallKey

public void registerUninstallKey()
                          throws NativeLibException
Throws:
NativeLibException

verify

public boolean verify(AutomatedInstallData idata)
               throws java.lang.Exception
Overrides:
verify in class OSClassHelper
Parameters:
idata -
Throws:
java.lang.Exception

doPerform

public boolean doPerform()
Returns whether an action with this handler should be performed or not.

Returns:
always true

getDefaultHandler

public RegistryHandler getDefaultHandler()
Returns the default handler which is the first created registry handler.

Returns:
Returns the default handler.