|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.builtintypes.Variant
public class Variant
Variant wraps an arbitrary builtin variable, an array of builtin variables or a multi-dimension array of builtin variable. Variant is equals-comparable.
An example: Variant v = new Variant( new UnsignedInteger[4][5][6] );
The value may be builtin primitive or a Structure.
e.g. new Variant( new NotificationData() );
Encoders write a structure as an ExtensionObject.
| Field Summary | |
|---|---|
static Variant |
NULL
Constant NULL |
| Constructor Summary | |
|---|---|
Variant(Object value)
Create variant. |
|
| Method Summary | ||
|---|---|---|
|
asClass(Class<T> clazz,
T defaultValue)
Convert the variant value to any class. |
|
|
asEnum(Class<T> clazz)
Converts the value to the given Enumeration objects. |
|
boolean |
booleanValue()
Returns the value of the specified Variant as a boolean |
|
byte |
byteValue()
Returns the value of the specified Variant as a byte. |
|
int |
compareTo(Variant value2)
Compares the value of a variant with another variant. |
|
protected String |
compositeClassToString()
compositeClassToString. |
|
double |
doubleValue()
Returns the value of the specified Variant as a double. |
|
boolean |
equals(Object obj)
|
|
float |
floatValue()
Returns the value of the specified Variant as a float. |
|
int[] |
getArrayDimensions()
getArrayDimensions. |
|
Class<?> |
getCompositeClass()
The class type of the variant value. |
|
int |
getDimension()
getDimension. |
|
Object |
getValue()
Getter for the field value. |
|
int |
hashCode()
|
|
int |
intValue()
Returns the value of the specified Variant as an int. |
|
boolean |
isArray()
isArray. |
|
boolean |
isComparable()
isComparable. |
|
boolean |
isEmpty()
isEmpty. |
|
boolean |
isNumber()
isNumber. |
|
long |
longValue()
Returns the value of the specified Variant as a long. |
|
short |
shortValue()
Returns the value of the specified Variant as a short. |
|
Number |
toNumber()
Returns the value of the specified Variant as a Number |
|
String |
toString()
|
|
String |
toString(boolean includeCompositeClass)
Convert the value to string, optionally including the compositeClass. |
|
String |
toStringWithType()
Convert the value to string, including the compositeClass. |
|
boolean |
valueEquals(Variant value2)
Compares the value of a variant with another variant. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Variant NULL
NULL
| Constructor Detail |
|---|
public Variant(Object value)
value - scalar, array or multi-dimension array| Method Detail |
|---|
public boolean isEmpty()
isEmpty.
public boolean isArray()
isArray.
public Object getValue()
Getter for the field value.
Object object.public String toString()
toString in class Objectpublic String toStringWithType()
String object.public String toString(boolean includeCompositeClass)
includeCompositeClass - whether to also add the name of the compositeClass
protected String compositeClassToString()
compositeClassToString.
String object.public Class<?> getCompositeClass()
public int[] getArrayDimensions()
getArrayDimensions.
public int getDimension()
getDimension.
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
public <T> T asClass(Class<T> clazz,
T defaultValue)
T - a T object.clazz - The class type to convert to.defaultValue - A default value to return, if the conversion cannot be done
public <T extends Enum<T> & Enumeration> Object asEnum(Class<T> clazz)
clazz - enumeration class
ClassCastException - if internal value is not Integer (or somedimensional array of
them)public boolean booleanValue()
boolean
ClassCastException - if the value cannot be cast to booleanpublic Number toNumber()
Number
ClassCastException - if the value cannot be cast to Numberpublic boolean isNumber()
isNumber.
public boolean isComparable()
isComparable.
public int intValue()
int.
This may involve rounding or truncation.
int.
ClassCastException - if the value cannot be cast to Numberpublic long longValue()
long.
This may involve rounding or truncation.
long.
ClassCastException - if the value cannot be cast to Numberpublic float floatValue()
float.
This may involve rounding.
float.
ClassCastException - if the value cannot be cast to Numberpublic double doubleValue()
double.
This may involve rounding.
double.
ClassCastException - if the value cannot be cast to Numberpublic byte byteValue()
byte.
This may involve rounding or truncation.
byte.
ClassCastException - if the value cannot be cast to Numberpublic short shortValue()
short.
This may involve rounding or truncation.
short.
ClassCastException - if the value cannot be cast to Numberpublic int compareTo(Variant value2)
isNumber(), compares the floatValue() of each.
Otherwise, it will check if isComparable(), in which case it
will compare the values as Comparables. If the values are of
different class, it will try to cast the values to the same type.
value2 - the value to compare to
ClassCastException - if the values cannot be comparedpublic boolean valueEquals(Variant value2)
equals(Object) is called. If both variants
isNumber(), compares the floatValue() of each.
value2 - the value to compare to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||