net.sf.ovanttasks.ovnative.win32
Class Registry

java.lang.Object
  extended by net.sf.ovanttasks.ovnative.win32.Registry
All Implemented Interfaces:
Iterable<Registry>

public class Registry
extends Object
implements Iterable<Registry>

Registry accesses the Windows Registry. Read/write/test/create/delete are supported for both data and subtrees.

Author:
lars.gersmann@roxes.com, arnep@users.sf.net

Nested Class Summary
 class Registry.SubKeyIterator
           
 
Field Summary
static int HKEY_CLASSES_ROOT
           
static int HKEY_CURRENT_CONFIG
           
static int HKEY_CURRENT_USER
           
static int HKEY_DYN_DATA
           
static int HKEY_LOCAL_MACHINE
           
static int HKEY_PERFORMANCE_DATA
           
static int HKEY_PERFORMANCE_NLSTEXT
           
static int HKEY_PERFORMANCE_TEXT
           
static int HKEY_USERS
           
static int KEY_ALL_ACCESS
           
static int KEY_CREATE_LINK
           
static int KEY_CREATE_SUB_KEY
           
static int KEY_ENUMERATE_SUB_KEYS
           
static int KEY_EXECUTE
           
static int KEY_NOTIFY
           
static int KEY_QUERY_VALUE
           
static int KEY_READ
           
static int KEY_SET_VALUE
           
static int KEY_WRITE
           
static int REG_BINARY
          Free form binary
static int REG_DWORD
          32-bit number
static int REG_DWORD_BIG_ENDIAN
          32-bit number
static int REG_DWORD_LITTLE_ENDIAN
          32-bit number (same as REG_DWORD)
static int REG_EXPAND_SZ
          Unicode nul terminated string (with environment variable references)
static int REG_FULL_RESOURCE_DESCRIPTOR
          Resource list in the hardware description TODO implement
static int REG_LINK
          Symbolic Link (unicode)
static int REG_MULTI_SZ
          Multiple Unicode strings
static int REG_NONE
          No value type
static int REG_QWORD
          64-bitnumber TODO implement
static int REG_QWORD_LITTLE_ENDIAN
          64-bit number (same as REG_QWORD) TODO implement
static int REG_RESOURCE_LIST
          Resource list in the resource mapped to struct _CM_RESOURCE_LIST from winddk.h TODO implement
static int REG_RESOURCE_REQUIREMENTS_LIST
          64-bitnumber TODO implement
static int REG_SZ
          Unicode null terminated string
 
Constructor Summary
Registry(int hKey)
           
Registry(int hKey, String subKey)
           
Registry(Registry reg, String subKey)
           
 
Method Summary
 boolean canOpenWith(int flags)
           
 void create()
           
 Registry createSubKey(String subKeyName)
          Create a new subKey as child of this subKey.
 void delete()
           
 void deleteSubKey(String subKeyName)
          Deletes the subKey if it exists
 void deleteValue(String name)
           
 boolean equals(Object other)
           
 boolean exists()
          Deprecated. 
 BigDecimal getBigDecimalValue(String name)
           
 BigInteger getBigIntegerValue(String name)
           
 boolean getBooleanValue(String name)
           
 byte[] getByteArrayValue(String name)
           
 byte getByteValue(String name)
           
 double getDoubleValue(String name)
          internal storage format is Double.toString
 String getExpandableString(String name, boolean doExpand)
           
 float getFloatValue(String name)
          internal storage format Float.toString
 int getHKey()
           
static String getHKeyName(int hKey)
           
 int getIntValue(String name)
           
 long getLongValue(String name)
          internal storage format Long.toString
 String[] getMultiStringValue(String name)
           
 short getShortValue(String name)
           
 String getStringValue(String name)
          if it is an REG_EXPAND_SZ should it be expanded??
 String getSubKey()
           
 int getValueType(String name)
           
static String getValueTypeName(int valueType)
           
 int hashCode()
           
 boolean hasSubKey(String name)
           
 boolean hasSubKeys()
           
 boolean hasValue(String name)
           
 boolean hasValues()
           
 Iterator<Registry> iterator()
           
 Registry openSubKey(String subKeyName)
          Opens a child subKey of this subKey.
static int parseHKeyName(String name)
           
static int parseValueTypeName(String name)
           
 void setExpandableString(String name, String value)
           
 void setValue(String name, BigDecimal value)
           
 void setValue(String name, BigInteger value)
           
 void setValue(String name, boolean value)
           
 void setValue(String name, byte value)
           
 void setValue(String name, byte[] value)
           
 void setValue(String name, double value)
           
 void setValue(String name, float value)
           
 void setValue(String name, int value)
           
 void setValue(String name, long value)
           
 void setValue(String name, short value)
           
 void setValue(String name, String value)
           
 void setValue(String name, String[] value)
           
 void setValue(String name, String value, int valueType)
           
 String[] subKeyNames()
           
 Iterator<Registry> subKeys()
           
 String toString()
           
 String[] valueNames()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_QUERY_VALUE

public static final int KEY_QUERY_VALUE
See Also:
Constant Field Values

KEY_SET_VALUE

public static final int KEY_SET_VALUE
See Also:
Constant Field Values

KEY_CREATE_SUB_KEY

public static final int KEY_CREATE_SUB_KEY
See Also:
Constant Field Values

KEY_ENUMERATE_SUB_KEYS

public static final int KEY_ENUMERATE_SUB_KEYS
See Also:
Constant Field Values

KEY_NOTIFY

public static final int KEY_NOTIFY
See Also:
Constant Field Values

KEY_CREATE_LINK

public static final int KEY_CREATE_LINK
See Also:
Constant Field Values

KEY_WRITE

public static final int KEY_WRITE
See Also:
Constant Field Values

KEY_EXECUTE

public static final int KEY_EXECUTE
See Also:
Constant Field Values

KEY_READ

public static final int KEY_READ
See Also:
Constant Field Values

KEY_ALL_ACCESS

public static final int KEY_ALL_ACCESS
See Also:
Constant Field Values

HKEY_CLASSES_ROOT

public static final int HKEY_CLASSES_ROOT
See Also:
Constant Field Values

HKEY_CURRENT_USER

public static final int HKEY_CURRENT_USER
See Also:
Constant Field Values

HKEY_LOCAL_MACHINE

public static final int HKEY_LOCAL_MACHINE
See Also:
Constant Field Values

HKEY_USERS

public static final int HKEY_USERS
See Also:
Constant Field Values

HKEY_PERFORMANCE_DATA

public static final int HKEY_PERFORMANCE_DATA
See Also:
Constant Field Values

HKEY_PERFORMANCE_TEXT

public static final int HKEY_PERFORMANCE_TEXT
See Also:
Constant Field Values

HKEY_PERFORMANCE_NLSTEXT

public static final int HKEY_PERFORMANCE_NLSTEXT
See Also:
Constant Field Values

HKEY_CURRENT_CONFIG

public static final int HKEY_CURRENT_CONFIG
See Also:
Constant Field Values

HKEY_DYN_DATA

public static final int HKEY_DYN_DATA
See Also:
Constant Field Values

REG_NONE

public static final int REG_NONE
No value type

See Also:
Constant Field Values

REG_SZ

public static final int REG_SZ
Unicode null terminated string

See Also:
Constant Field Values

REG_EXPAND_SZ

public static final int REG_EXPAND_SZ
Unicode nul terminated string (with environment variable references)

See Also:
Constant Field Values

REG_BINARY

public static final int REG_BINARY
Free form binary

See Also:
Constant Field Values

REG_DWORD

public static final int REG_DWORD
32-bit number

See Also:
Constant Field Values

REG_DWORD_LITTLE_ENDIAN

public static final int REG_DWORD_LITTLE_ENDIAN
32-bit number (same as REG_DWORD)

See Also:
Constant Field Values

REG_DWORD_BIG_ENDIAN

public static final int REG_DWORD_BIG_ENDIAN
32-bit number

See Also:
Constant Field Values

REG_LINK

public static final int REG_LINK
Symbolic Link (unicode)

See Also:
Constant Field Values

REG_MULTI_SZ

public static final int REG_MULTI_SZ
Multiple Unicode strings

See Also:
Constant Field Values

REG_RESOURCE_LIST

public static final int REG_RESOURCE_LIST
Resource list in the resource mapped to struct _CM_RESOURCE_LIST from winddk.h TODO implement

See Also:
Constant Field Values

REG_FULL_RESOURCE_DESCRIPTOR

public static final int REG_FULL_RESOURCE_DESCRIPTOR
Resource list in the hardware description TODO implement

See Also:
Constant Field Values

REG_RESOURCE_REQUIREMENTS_LIST

public static final int REG_RESOURCE_REQUIREMENTS_LIST
64-bitnumber TODO implement

See Also:
Constant Field Values

REG_QWORD

public static final int REG_QWORD
64-bitnumber TODO implement

See Also:
Constant Field Values

REG_QWORD_LITTLE_ENDIAN

public static final int REG_QWORD_LITTLE_ENDIAN
64-bit number (same as REG_QWORD) TODO implement

See Also:
Constant Field Values
Constructor Detail

Registry

public Registry(int hKey)

Registry

public Registry(int hKey,
                String subKey)

Registry

public Registry(Registry reg,
                String subKey)
Method Detail

getHKeyName

public static String getHKeyName(int hKey)

getValueTypeName

public static String getValueTypeName(int valueType)

parseHKeyName

public static int parseHKeyName(String name)

parseValueTypeName

public static int parseValueTypeName(String name)

create

public void create()
            throws Win32Exception
Throws:
Win32Exception

createSubKey

public Registry createSubKey(String subKeyName)
                      throws Win32Exception
Create a new subKey as child of this subKey.

Parameters:
subKeyName - the name of the subkey to create
Returns:
the new created registry object
Throws:
Win32Exception

delete

public void delete()
            throws Win32Exception
Throws:
Win32Exception

deleteSubKey

public void deleteSubKey(String subKeyName)
Deletes the subKey if it exists

Parameters:
subKeyName -

deleteValue

public void deleteValue(String name)
                 throws Win32Exception
Throws:
Win32Exception

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

exists

@Deprecated
public boolean exists()
Deprecated. 


canOpenWith

public boolean canOpenWith(int flags)

getBigDecimalValue

public BigDecimal getBigDecimalValue(String name)

getBigIntegerValue

public BigInteger getBigIntegerValue(String name)

getBooleanValue

public boolean getBooleanValue(String name)
                        throws Win32Exception
Throws:
Win32Exception

getByteArrayValue

public byte[] getByteArrayValue(String name)

getByteValue

public byte getByteValue(String name)

getDoubleValue

public double getDoubleValue(String name)
internal storage format is Double.toString

Parameters:
name -
Returns:

getExpandableString

public String getExpandableString(String name,
                                  boolean doExpand)
                           throws Win32Exception
Throws:
Win32Exception

getFloatValue

public float getFloatValue(String name)
                    throws Win32Exception
internal storage format Float.toString

Parameters:
name -
Returns:
Throws:
Win32Exception

getHKey

public int getHKey()

getIntValue

public int getIntValue(String name)

getLongValue

public long getLongValue(String name)
internal storage format Long.toString

Parameters:
name -
Returns:

getShortValue

public short getShortValue(String name)

getStringValue

public String getStringValue(String name)
if it is an REG_EXPAND_SZ should it be expanded??

Parameters:
name -
Returns:

getMultiStringValue

public String[] getMultiStringValue(String name)

getSubKey

public String getSubKey()

getValueType

public int getValueType(String name)

hasSubKey

public boolean hasSubKey(String name)

hasSubKeys

public boolean hasSubKeys()
                   throws Win32Exception
Throws:
Win32Exception

hasValue

public boolean hasValue(String name)
                 throws Win32Exception
Throws:
Win32Exception

hasValues

public boolean hasValues()
                  throws Win32Exception
Throws:
Win32Exception

openSubKey

public Registry openSubKey(String subKeyName)
                    throws Win32Exception
Opens a child subKey of this subKey. You must check, if you can open the key with canOpenWith(String, int, int) and the appropirate flag from the KEY_* constants. the Key might exists, but you have no right to read the key.

Parameters:
subKeyName - the name of the subkey to open
Returns:
the opend registry object
Throws:
Win32Exception

setExpandableString

public void setExpandableString(String name,
                                String value)
                         throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     BigDecimal value)

setValue

public void setValue(String name,
                     BigInteger value)

setValue

public void setValue(String name,
                     boolean value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     byte value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     byte[] value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     double value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     float value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     int value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     long value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     short value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     String value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     String[] value)
              throws Win32Exception
Throws:
Win32Exception

setValue

public void setValue(String name,
                     String value,
                     int valueType)
              throws Win32Exception
Throws:
Win32Exception

subKeyNames

public String[] subKeyNames()

subKeys

public Iterator<Registry> subKeys()

toString

public String toString()
Overrides:
toString in class Object

valueNames

public String[] valueNames()

iterator

public Iterator<Registry> iterator()
Specified by:
iterator in interface Iterable<Registry>


Copyright © 2008 Orangevolt. All Rights Reserved.