public abstract class RegistryValue extends Object implements Cloneable, Comparable<RegistryValue>, Serializable
This class represents a named value that is found in the registry.
Each value has a specific name which refers to the value
as well as a type. The different types can be found in ValueType
.
The data that is associated with the value depends on the type.
For instance if a value was of type REG_SZ, then the data is a String
type.
If the type was REG_MULTI_SZ, then the data is an array of String
s.
This class can only retrieve the data in binary form. In order to obtain the data
in its expected form, this class must be type cast into the appropriate class
representing the value type for the named value.
For example: REG_SZ values must be type cast into RegStringValue
.
Modifier and Type | Field and Description |
---|---|
protected RegistryKey |
key
The key that contains
this value. |
protected String |
name
The name of the value.
|
protected ValueType |
type
The type of the value.
|
protected int |
typei
The integer representing the type of the value.
|
protected Object |
value
An object which holds the data.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates a shallow copy of
this . |
int |
compareTo(RegistryValue o)
Implements the compareTo method in the interface
Comparable . |
boolean |
equals(Object o)
Tests for equality with another
Object . |
byte[] |
getByteData()
Used to retrieve the byte information of the data from
the registry.
|
int |
getByteLength()
Used to retrieve the number of bytes the data takes up
in the registry.
|
RegistryKey |
getKey()
Used to retrieve the registry key that contains
this value. |
String |
getName()
Used to retrieve the name of
this value. |
ValueType |
getValueType()
Used to retrieve the type of
this value. |
int |
getValueTypeInt()
Used to retrieve the type of
this value. |
int |
hashCode()
Calculates the hash code value for
this value. |
abstract int |
refreshData()
This method is used to update the data for
this value
because the data does not update automatically if it was changed. |
int |
setByteData(byte... value)
Used to change the bytes of the data for
this value. |
void |
setValueType(ValueType type)
Used to change the type of
this value. |
void |
setValueTypeInt(int type)
Used to change the type of
this value. |
String |
toString()
Retrieve a
String representation of this value. |
protected String name
protected ValueType type
protected Object value
protected RegistryKey key
this
value.protected int typei
public Object clone()
this
.public int compareTo(RegistryValue o)
Comparable
.
Allows a list of RegistryValue
s to be sorted in ascending order.
Null
values always come before non-null
values.compareTo
in interface Comparable<RegistryValue>
o
- A RegistryValue
to compare against this
.this
should go first
if > 0, o
should go firstpublic boolean equals(Object o)
public RegistryKey getKey()
this
value.this
.public String getName()
this
value.public int hashCode()
this
value.public ValueType getValueType()
this
value.public int getValueTypeInt()
this
value.public void setValueType(ValueType type)
this
value.type
- A ValueType
describing what the new type will be.public void setValueTypeInt(int type)
this
value.type
- An int describing what the new type will be.public abstract int refreshData()
this
value
because the data does not update automatically if it was changed.RegistryKey.formatErrorMessage(int)
.public byte[] getByteData()
this
must be type cast to the corresponding
subclass based on the type of the value.
null
is returned.public int setByteData(byte... value)
this
value.value
- An array of bytes which will be the new data for the value.
NOTE: As of version 1.7.6, this can now be a variable list of bytes.RegistryKey.formatErrorMessage(int)
.public int getByteLength()
Copyright © 2011, Yinon Michaeli. All rights reserved.