public final class Variant extends Number
This class allows you to deal with the raw VARIANT type in case you need it,
but in general you should bind VARIANT* to Object
or
Holder
<Object> for more natural Java binding.
Number
changes the variant
type (i.e., similar to a cast in Java) accordingly and returns its value.
Method names that end with '0' are native methods.
Modifier and Type | Class and Description |
---|---|
static class |
Variant.Type
VARIANT type.
|
Modifier and Type | Field and Description |
---|---|
static Variant |
MISSING
Deprecated.
This constant instance is mutable (both by Java methods and COM code where
this gets passed into as a reference), so it's fundamentally unsafe.
use
getMissing() instead. |
Constructor and Description |
---|
Variant()
Creates an empty
Variant . |
Variant(Variant.Type type)
Creates an empty
Variant with the given type. |
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue()
Changes the type of the Variant to
Variant.Type.VT_BOOL and returns the boolean represented by this Variant |
byte |
byteValue()
Changes the type of the Variant to
Variant.Type.VT_I1 and returns the byte represented by this Variant |
void |
clear()
Empties the current contents.
|
<T> T |
convertTo(Class<T> type)
Converts the variant to the given object type.
|
double |
doubleValue()
Changes the type of the Variant to
Variant.Type.VT_R8 and returns the double represented by this Variant |
void |
finalize()
Makes sure the variant is cleared before GC-ed.
|
float |
floatValue()
Changes the type of the Variant to
Variant.Type.VT_R4 and returns the float represented by this Variant |
Object |
get()
Retrieves the current contents of the
Variant and returns an object. |
int |
getError()
Returns the HRESULT error code of this Variant
|
String |
getJavaCode()
Returns a Java literal as a String of this Variant
|
static Variant |
getMissing()
Generates a new Variant object, representing the VARIANT MISSING
|
String |
getParseableString()
Generates an String representation of this Variant that can be parsed.
|
Variant.Type |
getType()
Gets the type of the variant.
|
int |
intValue()
Changes the type of the Variant to
Variant.Type.VT_I4 and returns the int value represented
by this Variant |
boolean |
isMissing()
Tests if this Variant represents the VARIANT MISSING
|
long |
longValue()
Changes the type of the Variant to
Variant.Type.VT_I8 and returns the long value
represented by this Variant |
<T extends Com4jObject> |
object(Class<T> type)
Reads this VARIANT as a COM interface pointer.
|
void |
set(boolean b)
Changes the type of the Variant to
Variant.Type.VT_BOOL and sets its value to the given parameter. |
void |
set(byte i)
Changes the type of the Variant to
Variant.Type.VT_I1 and sets its value to the given parameter. |
void |
set(double d)
Changes the type of the Variant to
Variant.Type.VT_R8 and sets its value to the given parameter. |
void |
set(float f)
Changes the type of the Variant to
Variant.Type.VT_R4 and sets its value to the given parameter. |
void |
set(int i)
Changes the type of the Variant to
Variant.Type.VT_I4 and sets its value to the given parameter. |
void |
set(long i)
Changes the type of the Variant to
Variant.Type.VT_I8 and sets its value to the given parameter. |
void |
set(short i)
Changes the type of the Variant to
Variant.Type.VT_I2 and sets its value to the given parameter. |
void |
set(String value)
|
void |
setType(Variant.Type t)
Sets the type of the variant.
|
short |
shortValue()
Changes the type of the Variant to
Variant.Type.VT_I2 and returns the short represented by this Variant |
String |
stringValue()
Converts this Variant to a String and returns its value
|
String |
toString()
Returns a String representation of this Variant
|
public static final Variant MISSING
getMissing()
instead.public Variant()
Variant
.public Variant(Variant.Type type)
Variant
with the given type.type
- The type of the new Variant.public void clear()
public void finalize()
public void setType(Variant.Type t)
t
- The new type of the Variantpublic Variant.Type getType()
public byte byteValue()
Variant.Type.VT_I1
and returns the byte represented by this Variantpublic void set(byte i)
Variant.Type.VT_I1
and sets its value to the given parameter.i
- The new value.public short shortValue()
Variant.Type.VT_I2
and returns the short represented by this VariantshortValue
in class Number
public void set(short i)
Variant.Type.VT_I2
and sets its value to the given parameter.i
- The new value.public int intValue()
Variant.Type.VT_I4
and returns the int value represented
by this Variantpublic void set(int i)
Variant.Type.VT_I4
and sets its value to the given parameter.i
- The new value.public long longValue()
Variant.Type.VT_I8
and returns the long value
represented by this Variantpublic void set(long i)
Variant.Type.VT_I8
and sets its value to the given parameter.i
- The new value.public int getError()
public float floatValue()
Variant.Type.VT_R4
and returns the float represented by this VariantfloatValue
in class Number
public void set(float f)
Variant.Type.VT_R4
and sets its value to the given parameter.f
- The new value.public double doubleValue()
Variant.Type.VT_R8
and returns the double represented by this VariantdoubleValue
in class Number
public void set(double d)
Variant.Type.VT_R8
and sets its value to the given parameter.d
- The new value.public void set(boolean b)
Variant.Type.VT_BOOL
and sets its value to the given parameter.b
- The new value.public boolean booleanValue()
Variant.Type.VT_BOOL
and returns the boolean represented by this Variantpublic String stringValue()
public void set(String value)
value
- The new String value.public Object get()
Variant
and returns an object. The type of the object depends on the type of the
Variant
.set0(Object, ByteBuffer)
public String getParseableString()
public String getJavaCode()
For example, if the Variant is of the type VT_R4 and its value is 4.6, then the Java literal is "4.6f".
public <T extends Com4jObject> T object(Class<T> type)
T
- The type of the return valuetype
- The class object of the typeCom4jObject
of the IUnknown interface pointer that this Variant represents.public <T> T convertTo(Class<T> type)
T
- The type of the return value.type
- The class object of the destination typepublic static Variant getMissing()
public boolean isMissing()
public String toString()
A Variant consists of 16 bytes in memory. The String representation of a Variant is a sequence of 16 bytes in hex
toString
in class Object
ByteBuffer
of this VariantCopyright © 2014. All rights reserved.