public final class Variant
extends java.lang.Object
It is used within the OleAutomation object for getting a property, setting a property or invoking a method on an OLE Control or OLE Document.
Modifier and Type | Field and Description |
---|---|
private boolean |
booleanData |
private int |
byRefPtr |
private byte |
byteData |
private char |
charData |
private IDispatch |
dispatchData |
private double |
doubleData |
private float |
floatData |
private int |
intData |
private long |
longData |
static Variant |
NULL
A shared Variant instance with type VT_NULL.
|
private short |
shortData |
static int |
sizeof
The size in bytes of a native VARIANT struct.
|
private java.lang.String |
stringData |
private short |
type |
private IUnknown |
unknownData |
Constructor and Description |
---|
Variant()
Create an empty Variant object with type VT_EMPTY.
|
Variant(boolean val)
Create a Variant object which represents a Java boolean as a VT_BOOL.
|
Variant(double val)
Create a Variant object which represents a Java double as a VT_R8.
|
Variant(float val)
Create a Variant object which represents a Java float as a VT_R4.
|
Variant(IDispatch idispatch)
Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
|
Variant(int val)
Create a Variant object which represents a Java int as a VT_I4.
|
Variant(int ptr,
short byRefType)
Create a Variant object which contains a reference to the data being transferred.
|
Variant(IUnknown unknown)
Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN.
|
Variant(long val)
Create a Variant object which represents a Java long as a VT_I8.
|
Variant(OleAutomation automation)
Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
|
Variant(short val)
Create a Variant object which represents a Java short as a VT_I2.
|
Variant(java.lang.String string)
Create a Variant object which represents a Java String as a VT_BSTR.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Calling dispose will release resources associated with this Variant.
|
OleAutomation |
getAutomation()
Returns the OleAutomation object represented by this Variant.
|
boolean |
getBoolean()
Returns the Java boolean represented by this Variant.
|
int |
getByRef()
Returns a pointer to the referenced data represented by this Variant.
|
byte |
getByte()
Returns the Java byte represented by this Variant.
|
char |
getChar()
Returns the Java char represented by this Variant.
|
(package private) void |
getData(int pData) |
IDispatch |
getDispatch()
Returns the IDispatch object represented by this Variant.
|
double |
getDouble()
Returns the Java double represented by this Variant.
|
float |
getFloat()
Returns the Java float represented by this Variant.
|
int |
getInt()
Returns the Java int represented by this Variant.
|
long |
getLong()
Returns the Java long represented by this Variant.
|
short |
getShort()
Returns the Java short represented by this Variant.
|
java.lang.String |
getString()
Returns the Java String represented by this Variant.
|
short |
getType()
Returns the type of the variant type.
|
IUnknown |
getUnknown()
Returns the IUnknown object represented by this Variant.
|
void |
setByRef(boolean val)
Update the by reference value of this variant with a new boolean value.
|
void |
setByRef(float val)
Update the by reference value of this variant with a new float value.
|
void |
setByRef(int val)
Update the by reference value of this variant with a new integer value.
|
void |
setByRef(short val)
Update the by reference value of this variant with a new short value.
|
(package private) void |
setData(int pData) |
java.lang.String |
toString()
Returns a string containing a concise, human-readable
description of the receiver.
|
static void |
win32_copy(int pVarDest,
Variant varSrc)
Invokes platform specific functionality to copy a variant
into operating system memory.
|
static Variant |
win32_new(int pVariant)
Invokes platform specific functionality to wrap a variant
that was allocated in operating system memory.
|
public static final int sizeof
private short type
private boolean booleanData
private byte byteData
private short shortData
private char charData
private int intData
private long longData
private float floatData
private double doubleData
private java.lang.String stringData
private int byRefPtr
private IDispatch dispatchData
private IUnknown unknownData
public static final Variant NULL
public Variant()
public Variant(float val)
val
- the Java float value that this Variant representspublic Variant(double val)
val
- the Java double value that this Variant representspublic Variant(int val)
val
- the Java int value that this Variant representspublic Variant(int ptr, short byRefType)
When creating a VT_BYREF Variant, you must give the full Variant type including VT_BYREF such as
short byRefType = OLE.VT_BSTR | OLE.VT_BYREF
.ptr
- a pointer to the data being transferred.byRefType
- the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREFpublic Variant(OleAutomation automation)
automation
- the OleAutomation object that this Variant representspublic Variant(IDispatch idispatch)
The caller is expected to have appropriately invoked unknown.AddRef() before creating this Variant.
idispatch
- the IDispatch object that this Variant representspublic Variant(IUnknown unknown)
The caller is expected to have appropriately invoked unknown.AddRef() before creating this Variant.
unknown
- the IUnknown object that this Variant representspublic Variant(long val)
val
- the Java long value that this Variant representspublic Variant(java.lang.String string)
string
- the Java String value that this Variant representspublic Variant(short val)
val
- the Java short value that this Variant representspublic Variant(boolean val)
val
- the Java boolean value that this Variant representspublic static void win32_copy(int pVarDest, Variant varSrc)
IMPORTANT: This method is not part of the public
API for Variant
. It is marked public only so that it
can be shared within the packages provided by SWT. It is not
available on all platforms, and should never be called from
application code.
pVarDest
- destination pointer to a variantvarSrc
- source Variant
public static Variant win32_new(int pVariant)
IMPORTANT: This method is not part of the public
API for Variant
. It is marked public only so that it
can be shared within the packages provided by SWT. It is not
available on all platforms, and should never be called from
application code.
pVariant
- pointer to a variantVariant
public void dispose()
public OleAutomation getAutomation()
If this Variant does not contain an OleAutomation object, an attempt is made to coerce the Variant type into an OleAutomation object. If this fails, an error is thrown. Note that OleAutomation objects must be disposed when no longer needed.
SWTException
- public IDispatch getDispatch()
If this Variant does not contain an IDispatch object, an attempt is made to coerce the Variant type into an IDIspatch object. If this fails, an error is thrown.
SWTException
- public boolean getBoolean()
If this Variant does not contain a Java boolean, an attempt is made to coerce the Variant type into a Java boolean. If this fails, an error is thrown.
SWTException
- public int getByRef()
If this Variant does not contain a reference to data, zero is returned.
public byte getByte()
If this Variant does not contain a Java byte, an attempt is made to coerce the Variant type into a Java byte. If this fails, an error is thrown.
SWTException
- public char getChar()
If this Variant does not contain a Java char, an attempt is made to coerce the Variant type into a Java char. If this fails, an error is thrown.
SWTException
- void getData(int pData)
public double getDouble()
If this Variant does not contain a Java double, an attempt is made to coerce the Variant type into a Java double. If this fails, an error is thrown.
SWTException
- public float getFloat()
If this Variant does not contain a Java float, an attempt is made to coerce the Variant type into a Java float. If this fails, an error is thrown.
SWTException
- public int getInt()
If this Variant does not contain a Java int, an attempt is made to coerce the Variant type into a Java int. If this fails, an error is thrown.
SWTException
- public long getLong()
If this Variant does not contain a Java long, an attempt is made to coerce the Variant type into a Java long. If this fails, an error is thrown.
SWTException
- public short getShort()
If this Variant does not contain a Java short, an attempt is made to coerce the Variant type into a Java short. If this fails, an error is thrown.
SWTException
- public java.lang.String getString()
If this Variant does not contain a Java String, an attempt is made to coerce the Variant type into a Java String. If this fails, an error is thrown.
SWTException
- public short getType()
public IUnknown getUnknown()
If this Variant does not contain an IUnknown object, an attempt is made to coerce the Variant type into an IUnknown object. If this fails, an error is thrown.
SWTException
- public void setByRef(boolean val)
val
- the new boolean valueSWTException
- public void setByRef(float val)
val
- the new float valueSWTException
- public void setByRef(int val)
val
- the new integer valueSWTException
- public void setByRef(short val)
val
- the new short valueSWTException
- void setData(int pData)
public java.lang.String toString()
toString
in class java.lang.Object