com.coi.tools.os.win
Class RegDataContainer

java.lang.Object
  extended bycom.coi.tools.os.win.RegDataContainer
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class RegDataContainer
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Data container for Windows registry values. Windows registry values can contain different data types. It is not possible to map they all to one Java type. Therefore this class contains the different container types.

Author:
Klaus Bartz
See Also:
Serialized Form

Field Summary
private  byte[] binData
           
private  long dwordData
           
private  java.lang.String[] multiStringData
           
static int REG_BINARY
           
static int REG_DWORD
           
static int REG_EXPAND_SZ
           
static int REG_LINK
           
static int REG_MULTI_SZ
           
static int REG_NONE
           
static int REG_SZ
           
private static long serialVersionUID
           
private  java.lang.String stringData
           
private  int type
           
private static int[] VALID_TYPES
           
 
Constructor Summary
RegDataContainer()
          Default constructor.
RegDataContainer(byte[] data)
          Creates a RegDataContainer for type REG_BINARY with the given data
RegDataContainer(int type)
          Creates a RegDataContainer for a special type The data self is not set.
RegDataContainer(long data)
          Creates a RegDataContainer for type REG_DWORD with the given data
RegDataContainer(java.lang.String data)
          Creates a RegDataContainer for type REG_SZ with the given data
RegDataContainer(java.lang.String[] data)
          Creates a RegDataContainer for type REG_MULTI_SZ with the given data
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.Object anObject)
           
 byte[] getBinData()
          Returns the binary data of this container.
 java.lang.Object getDataAsObject()
          Returns the contained data depending to the type.
 long getDwordData()
          Returns the dword data of this container.
 java.lang.String[] getMultiStringData()
          Returns the multi string data as string array of this container.
 java.lang.String getStringData()
          Returns the string data of this container.
 int getType()
          Returns the data type handled by this object.
 boolean isValidType(int type)
          Verifies whether the given int represents a valid type or not.
 void setBinData(byte[] bytes)
          Sets the binary data to the given byte array.
 void setDwordData(long i)
          Sets the dword data to the given value.
 void setMultiStringData(java.lang.String[] strings)
          Sets the multi string data to the given string array.
 void setStringData(java.lang.String string)
          Sets the string data to the given value.
 void setType(int i)
          Sets the type.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

REG_NONE

public static final int REG_NONE
See Also:
Constant Field Values

REG_SZ

public static final int REG_SZ
See Also:
Constant Field Values

REG_EXPAND_SZ

public static final int REG_EXPAND_SZ
See Also:
Constant Field Values

REG_BINARY

public static final int REG_BINARY
See Also:
Constant Field Values

REG_DWORD

public static final int REG_DWORD
See Also:
Constant Field Values

REG_LINK

public static final int REG_LINK
See Also:
Constant Field Values

REG_MULTI_SZ

public static final int REG_MULTI_SZ
See Also:
Constant Field Values

VALID_TYPES

private static final int[] VALID_TYPES

dwordData

private long dwordData

stringData

private java.lang.String stringData

multiStringData

private java.lang.String[] multiStringData

binData

private byte[] binData

type

private int type
Constructor Detail

RegDataContainer

public RegDataContainer()
Default constructor.


RegDataContainer

public RegDataContainer(int type)
                 throws java.lang.IllegalArgumentException
Creates a RegDataContainer for a special type The data self is not set. Valid types are

Parameters:
type -
Throws:
java.lang.IllegalArgumentException - if the type is not valid

RegDataContainer

public RegDataContainer(long data)
Creates a RegDataContainer for type REG_DWORD with the given data

Parameters:
data - data which should be used with this object

RegDataContainer

public RegDataContainer(java.lang.String data)
Creates a RegDataContainer for type REG_SZ with the given data

Parameters:
data - data which should be used with this object

RegDataContainer

public RegDataContainer(java.lang.String[] data)
Creates a RegDataContainer for type REG_MULTI_SZ with the given data

Parameters:
data - data which should be used with this object

RegDataContainer

public RegDataContainer(byte[] data)
Creates a RegDataContainer for type REG_BINARY with the given data

Parameters:
data - data which should be used with this object
Method Detail

getBinData

public byte[] getBinData()
Returns the binary data of this container. It will be contain only data, if the type of this object is REG_BINARY.

Returns:
binary data

getDwordData

public long getDwordData()
Returns the dword data of this container. It will be contain only data, if the type of this object is REG_DWORD.

Returns:
the dword data

getMultiStringData

public java.lang.String[] getMultiStringData()
Returns the multi string data as string array of this container. It will be contain only data, if the type of this object is REG_REG_MULTI_SZ.

Returns:
the multi string data

getStringData

public java.lang.String getStringData()
Returns the string data of this container. It will be contain only data, if the type of this object is REG_REG_SZ.

Returns:
the string data

getType

public int getType()
Returns the data type handled by this object.

Returns:
the data type handled by this object

setBinData

public void setBinData(byte[] bytes)
Sets the binary data to the given byte array.

Parameters:
bytes - data to be set

setDwordData

public void setDwordData(long i)
Sets the dword data to the given value.

Parameters:
i - data to be set

setMultiStringData

public void setMultiStringData(java.lang.String[] strings)
Sets the multi string data to the given string array.

Parameters:
strings - data to be set

setStringData

public void setStringData(java.lang.String string)
Sets the string data to the given value.

Parameters:
string - data to be set

setType

public void setType(int i)
Sets the type.

Parameters:
i - type to be set

isValidType

public boolean isValidType(int type)
Verifies whether the given int represents a valid type or not.

Parameters:
type - value to be verified
Returns:
whether the given int represents a valid type or not

getDataAsObject

public java.lang.Object getDataAsObject()
Returns the contained data depending to the type. Dword data are transformed from long to Long.

Returns:
the contained data

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object anObject)