public final class JIVariant extends Object implements Serializable
Class representing the VARIANT datatype.
Please use the byRef flag based constructors for by reference
parameters in COM calls. For [optional] parameters use the
OPTIONAL_PARAM()
In case of direct calls to COM server using JICallBuilder, if the byRef flag is set then
that variant should also be added as the [out] parameter in the JICallBuilder.
For developers using the IJIDispatch this is not required and variant would be returned back to them
via JIVariant[] associated with IJIDispatch apis.
An important note for Boolean Arrays (JIArray of Boolean),
please set the JIFlag.FLAG_REPRESENTATION_VARIANT_BOOL using the setFlag(int)
method before making a call on this object. This is required since in DCOM , VARIANT_BOOL are 2 bytes
and standard booleans are 1 byte in length.
| Modifier and Type | Field and Description |
|---|---|
static int |
FADF_AUTO |
static int |
FADF_BSTR |
static int |
FADF_DISPATCH |
static int |
FADF_EMBEDDED |
static int |
FADF_FIXEDSIZE |
static int |
FADF_HAVEIID |
static int |
FADF_HAVEVARTYPE |
static int |
FADF_RECORD |
static int |
FADF_RESERVED |
static int |
FADF_STATIC |
static int |
FADF_UNKNOWN |
static int |
FADF_VARIANT |
static org.jinterop.dcom.core.JIVariant.SCODE |
SCODE
SCODE
VARIANT |
static int |
VT_ARRAY |
static int |
VT_BOOL |
static int |
VT_BSTR |
static int |
VT_BYREF |
static int |
VT_BYREF_VT_ARRAY |
static int |
VT_BYREF_VT_BOOL |
static int |
VT_BYREF_VT_BSTR |
static int |
VT_BYREF_VT_CY |
static int |
VT_BYREF_VT_DATE |
static int |
VT_BYREF_VT_DECIMAL |
static int |
VT_BYREF_VT_DISPATCH |
static int |
VT_BYREF_VT_ERROR |
static int |
VT_BYREF_VT_I1 |
static int |
VT_BYREF_VT_I2 |
static int |
VT_BYREF_VT_I4 |
static int |
VT_BYREF_VT_I8 |
static int |
VT_BYREF_VT_INT |
static int |
VT_BYREF_VT_R4 |
static int |
VT_BYREF_VT_R8 |
static int |
VT_BYREF_VT_UI1 |
static int |
VT_BYREF_VT_UI2 |
static int |
VT_BYREF_VT_UI4 |
static int |
VT_BYREF_VT_UINT |
static int |
VT_BYREF_VT_UNKNOWN |
static int |
VT_BYREF_VT_VARIANT |
static int |
VT_CY |
static int |
VT_DATE |
static int |
VT_DECIMAL |
static int |
VT_DISPATCH |
static int |
VT_EMPTY |
static int |
VT_ERROR |
static int |
VT_I1 |
static int |
VT_I2 |
static int |
VT_I4 |
static int |
VT_I8 |
static int |
VT_INT |
static int |
VT_NULL |
static int |
VT_R4 |
static int |
VT_R8 |
static int |
VT_UI1 |
static int |
VT_UI2 |
static int |
VT_UI4 |
static int |
VT_UINT |
static int |
VT_UNKNOWN |
static int |
VT_VARIANT |
| Constructor and Description |
|---|
JIVariant(boolean value)
Setting up a
VARIANT with a boolean. |
JIVariant(boolean value,
boolean isByRef)
Setting up a
VARIANT with a boolean. |
JIVariant(char value)
Setting up a
VARIANT with a char. |
JIVariant(char value,
boolean isByRef)
Setting up a
VARIANT with a char. |
JIVariant(Date value)
Setting up a
VARIANT with an java.util.Date. |
JIVariant(Date value,
boolean isByRef)
Setting up a
VARIANT with an java.util.Date. |
JIVariant(double value)
Setting up a
VARIANT with a double. |
JIVariant(double value,
boolean isByRef)
Setting up a
VARIANT with a double. |
JIVariant(float value)
Setting up a
VARIANT with a float. |
JIVariant(float value,
boolean isByRef)
Setting up a
VARIANT with a float. |
JIVariant(IJIComObject value)
Setting up a
VARIANT with an IJIComObject. |
JIVariant(IJIComObject value,
boolean isByRef)
Setting up a
VARIANT with an IJIComObject. |
JIVariant(IJIUnsigned number)
Setting up a
VARIANT with a unsigned value. |
JIVariant(IJIUnsigned number,
boolean isByRef)
Setting up a
VARIANT with a unsigned value. |
JIVariant(int value)
Setting up a
VARIANT with an int. |
JIVariant(int value,
boolean isByRef)
Setting up a
VARIANT with an int. |
JIVariant(JIArray array)
Setting up a
VARIANT with a JIArray. |
JIVariant(JIArray array,
boolean isByRef)
Setting up a
VARIANT with a JIArray. |
JIVariant(JIArray array,
boolean isByRef,
int FLAG)
Setting up a
VARIANT with a JIArray. |
JIVariant(JIArray array,
int FLAG)
Setting up a
VARIANT with a JIArray. |
JIVariant(JICurrency value)
Setting up a
VARIANT with a JICurrency. |
JIVariant(JICurrency value,
boolean isByRef)
Setting up a
VARIANT with a JICurrency. |
JIVariant(JIString value)
Setting up a
VARIANT with a JIString. |
JIVariant(JIString value,
boolean isByRef)
Setting up a
VARIANT with a JIString. |
JIVariant(org.jinterop.dcom.core.JIVariant.SCODE value,
int errorCode)
Setting up a
VARIANT with a SCODE value and it's errorCode. |
JIVariant(org.jinterop.dcom.core.JIVariant.SCODE value,
int errorCode,
boolean isByRef)
Setting up a
VARIANT with a SCODE value and it's errorCode. |
JIVariant(JIVariant variant)
Setting up a
VARIANT as reference to another. |
JIVariant(long value,
boolean isByRef)
Setting up a
VARIANT with a long. |
JIVariant(short value)
Setting up a
VARIANT with a short. |
JIVariant(short value,
boolean isByRef)
Setting up a
VARIANT with a short. |
JIVariant(String value)
Setting up a
VARIANT with a String. |
JIVariant(String value,
boolean isByRef)
Setting up a
VARIANT with a String. |
| Modifier and Type | Method and Description |
|---|---|
static JIVariant |
BSTRARRAY()
Helper method for creating an array of
BSTRs , IDL signature [in, out] SAFEARRAY(BSTR) *p. |
static JIVariant |
EMPTY_BYREF()
EMPTY BYREF
VARIANT. |
static JIVariant |
EMPTY()
EMPTY
VARIANT. |
int |
getFlag()
Returns the flag value for this variant.
|
Object |
getObject()
Returns the contained object.
|
JIArray |
getObjectAsArray()
Retrieves the contained object as
JIArray. |
boolean |
getObjectAsBoolean()
Retrieves the contained object as
boolean. |
char |
getObjectAsChar()
Retrieves the contained object as
char. |
IJIComObject |
getObjectAsComObject()
Retrieves the contained object as
IJIComObject. |
Date |
getObjectAsDate()
Retrieves the contained object as
java.util.Date. |
double |
getObjectAsDouble()
Retrieves the contained object as
double. |
float |
getObjectAsFloat()
Retrieves the contained object as
float. |
int |
getObjectAsInt()
Retrieves the contained object as
int. |
long |
getObjectAsLong()
Retrieves the contained object as
long, used when the expected type is VT_I8. |
int |
getObjectAsSCODE()
Retrieves the contained objects errorCode.
|
short |
getObjectAsShort()
Retrieves the contained object as
short. |
JIString |
getObjectAsString()
Retrieves the contained object as
JIString. |
String |
getObjectAsString2()
Retrieves the contained object as
String. |
IJIUnsigned |
getObjectAsUnsigned()
Retrieves the contained object as
unsigned number. |
JIVariant |
getObjectAsVariant()
Retrieves the contained object as
JIVariant. |
int |
getType()
Returns the referent as integer.
|
boolean |
isArray() |
boolean |
isByRefFlagSet() |
boolean |
isNull()
Returns whether this variant is a
NULL variant. |
static JIVariant |
makeVariant(Object o)
Returns a JIVariant (of the right type) based on the
o.getClass() |
static JIVariant |
makeVariant(Object o,
boolean isByRef)
Returns a JIVariant (of the right type) based on the
o.getClass() |
static JIVariant |
NULL()
NULL
VARIANT . |
static JIVariant |
OPTIONAL_PARAM()
OPTIONAL PARAM.
|
static JIVariant |
OUT_IDISPATCH()
VARIANT for ([out] IDispatch*). |
static JIVariant |
OUT_IUNKNOWN()
VARIANT for ([out] IUnknown*). |
static JIVariant |
OUTPARAMforType(Class c,
boolean isArray) |
void |
setFlag(int FLAG)
Sets a
JIFlags value to be used while encoding (marshalling) this Variant. |
String |
toString() |
static JIVariant |
VARIANTARRAY()
Helper method for creating an array of
VARIANTs , IDL signature [in, out] SAFEARRAY(VARIANT) *p
OR [in,out] VARIANT *pArray. |
public static final int VT_NULL
public static final int VT_EMPTY
public static final int VT_I4
public static final int VT_UI1
public static final int VT_I2
public static final int VT_R4
public static final int VT_R8
public static final int VT_VARIANT
public static final int VT_BOOL
public static final int VT_ERROR
public static final int VT_CY
public static final int VT_DATE
public static final int VT_BSTR
public static final int VT_UNKNOWN
public static final int VT_DECIMAL
public static final int VT_DISPATCH
public static final int VT_ARRAY
public static final int VT_BYREF
public static final int VT_BYREF_VT_UI1
public static final int VT_BYREF_VT_I2
public static final int VT_BYREF_VT_I4
public static final int VT_BYREF_VT_R4
public static final int VT_BYREF_VT_R8
public static final int VT_BYREF_VT_BOOL
public static final int VT_BYREF_VT_ERROR
public static final int VT_BYREF_VT_CY
public static final int VT_BYREF_VT_DATE
public static final int VT_BYREF_VT_BSTR
public static final int VT_BYREF_VT_UNKNOWN
public static final int VT_BYREF_VT_DISPATCH
public static final int VT_BYREF_VT_ARRAY
public static final int VT_BYREF_VT_VARIANT
public static final int VT_I1
public static final int VT_UI2
public static final int VT_UI4
public static final int VT_I8
public static final int VT_INT
public static final int VT_UINT
public static final int VT_BYREF_VT_DECIMAL
public static final int VT_BYREF_VT_I1
public static final int VT_BYREF_VT_UI2
public static final int VT_BYREF_VT_UI4
public static final int VT_BYREF_VT_I8
public static final int VT_BYREF_VT_INT
public static final int VT_BYREF_VT_UINT
public static final int FADF_AUTO
public static final int FADF_STATIC
public static final int FADF_EMBEDDED
public static final int FADF_FIXEDSIZE
public static final int FADF_RECORD
public static final int FADF_HAVEIID
public static final int FADF_HAVEVARTYPE
public static final int FADF_BSTR
public static final int FADF_UNKNOWN
public static final int FADF_DISPATCH
public static final int FADF_VARIANT
public static final int FADF_RESERVED
public static final org.jinterop.dcom.core.JIVariant.SCODE SCODE
VARIANTpublic JIVariant(JIVariant variant)
VARIANT as reference to another. Used via serializing the VARIANT.variant - public JIVariant(int value,
boolean isByRef)
VARIANT with an int. Used via serializing the VARIANT.
Used when the variant type is VT_I4.value - isByRef - true if the value is to be represented as a pointer. LONG*public JIVariant(long value,
boolean isByRef)
VARIANT with a long. Used via serializing the VARIANT.
Used when the variant type is VT_I8.value - isByRef - true if the value is to be represented as a pointer.public JIVariant(float value,
boolean isByRef)
VARIANT with a float. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. FLOAT*public JIVariant(boolean value,
boolean isByRef)
VARIANT with a boolean. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. VARIANT_BOOL*public JIVariant(double value,
boolean isByRef)
VARIANT with a double. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. DOUBLE*public JIVariant(short value,
boolean isByRef)
VARIANT with a short. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. SHORT*public JIVariant(char value,
boolean isByRef)
VARIANT with a char. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. CHAR*public JIVariant(JIString value, boolean isByRef)
VARIANT with a JIString. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. BSTR*public JIVariant(String value, boolean isByRef)
VARIANT with a String. Used via serializing the VARIANT. Internally a
JIString is formed with it's default type BSTR.value - isByRef - true if the value is to be represented as a pointer. BSTR*public JIVariant(String value)
VARIANT with a String. Used via serializing the VARIANT. Internally a
JIString is formed with it's default type BSTR.value - public JIVariant(IJIComObject value, boolean isByRef)
VARIANT with an IJIComObject. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. IJIComObject**public JIVariant(org.jinterop.dcom.core.JIVariant.SCODE value,
int errorCode,
boolean isByRef)
VARIANT with a SCODE value and it's errorCode. Used via serializing the VARIANT.value - errorCode - isByRef - true if the value is to be represented as a pointer. SCODE*public JIVariant(int value)
VARIANT with an int. Used via serializing the VARIANT.value - public JIVariant(float value)
VARIANT with a float. Used via serializing the VARIANT.value - public JIVariant(boolean value)
VARIANT with a boolean. Used via serializing the VARIANT.value - public JIVariant(double value)
VARIANT with a double. Used via serializing the VARIANT.value - public JIVariant(short value)
VARIANT with a short. Used via serializing the VARIANT.value - public JIVariant(char value)
VARIANT with a char. Used via serializing the VARIANT.value - public JIVariant(JIString value)
VARIANT with a JIString. Used via serializing the VARIANT.value - public JIVariant(IJIComObject value)
VARIANT with an IJIComObject. Used via serializing the VARIANT.value - public JIVariant(Date value)
VARIANT with an java.util.Date. Used via serializing the VARIANT.value - public JIVariant(Date value, boolean isByRef)
VARIANT with an java.util.Date. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. Date*public JIVariant(JICurrency value)
VARIANT with a JICurrency. Used via serializing the VARIANT.value - public JIVariant(JICurrency value, boolean isByRef)
VARIANT with a JICurrency. Used via serializing the VARIANT.value - isByRef - true if the value is to be represented as a pointer. JICurrency*public JIVariant(org.jinterop.dcom.core.JIVariant.SCODE value,
int errorCode)
VARIANT with a SCODE value and it's errorCode. Used via serializing the VARIANT.value - errorCode - public JIVariant(JIArray array, int FLAG)
VARIANT with a JIArray. Used via serializing the VARIANT.
Only 1 and 2 dimensional array is supported.array - FLAG - JIFlag valuepublic JIVariant(JIArray array, boolean isByRef, int FLAG)
VARIANT with a JIArray. Used via serializing the VARIANT.
Only 1 and 2 dimensional array is supported.array - isByRef - FLAG - JIFlag valuepublic JIVariant(JIArray array, boolean isByRef)
VARIANT with a JIArray. Used via serializing the VARIANT.
Only 1 and 2 dimensional array is supported.array - isByRef - public JIVariant(JIArray array)
VARIANT with a JIArray. Used via serializing the VARIANT. array - public JIVariant(IJIUnsigned number)
VARIANT with a unsigned value. Used via serializing the VARIANT.number - public JIVariant(IJIUnsigned number, boolean isByRef)
VARIANT with a unsigned value. Used via serializing the VARIANT.number - isByRef - true if the value is to be represented as a pointer.public static JIVariant makeVariant(Object o)
o.getClass()o - public static JIVariant makeVariant(Object o, boolean isByRef)
o.getClass()o - isByRef - public static JIVariant EMPTY()
VARIANT. This is not Thread Safe , hence a new instance must be taken each time.public static JIVariant EMPTY_BYREF()
VARIANT. This is not Thread Safe , hence a new instance must be taken each time. Used for a
[out] VARIANT* .public static JIVariant OUT_IUNKNOWN()
VARIANT for ([out] IUnknown*). This is not Thread Safe , hence a new instance must be taken each time.public static JIVariant OUT_IDISPATCH()
VARIANT for ([out] IDispatch*). This is not Thread Safe , hence a new instance must be taken each time.
IDispatch i.e. supports automation (or is a
dispinterface).public static JIVariant NULL()
VARIANT . This is not Thread Safe , hence a new instance must be taken each time.public static JIVariant OPTIONAL_PARAM()
[optional] for a COM call.
This is not Thread Safe , hence a new instance must be taken each time.public static JIVariant BSTRARRAY()
BSTRs , IDL signature [in, out] SAFEARRAY(BSTR) *p.
The return value can directly be used in an IJIDispatchcall.public static JIVariant VARIANTARRAY()
VARIANTs , IDL signature [in, out] SAFEARRAY(VARIANT) *p
OR [in,out] VARIANT *pArray. The return value can directly be used in an IJIDispatch call.public void setFlag(int FLAG)
JIFlags value to be used while encoding (marshalling) this Variant.FLAG - public int getFlag()
public boolean isNull()
NULL variant.true if the variant is a NULLpublic Object getObject() throws JIException
JIExceptionpublic int getObjectAsInt()
throws JIException
int.JIExceptionpublic float getObjectAsFloat()
throws JIException
float.JIExceptionpublic int getObjectAsSCODE()
throws JIException
JIExceptionpublic double getObjectAsDouble()
throws JIException
double.JIExceptionpublic short getObjectAsShort()
throws JIException
short.JIExceptionpublic boolean getObjectAsBoolean()
throws JIException
boolean.JIExceptionpublic JIString getObjectAsString() throws JIException
JIString.JIExceptionpublic String getObjectAsString2() throws JIException
String.JIExceptionpublic Date getObjectAsDate() throws JIException
java.util.Date.JIExceptionpublic char getObjectAsChar()
throws JIException
char.JIExceptionpublic IJIComObject getObjectAsComObject() throws JIException
IJIComObject. Return value must be "narrowed" to get the expected type.
for example :- If expected type is an IJIDispatch,
then the return value must pass through JIObjectFactory.narrowInstance(IJIComObject) to get to the right type.
JIExceptionpublic JIVariant getObjectAsVariant() throws JIException
JIVariant.JIExceptionpublic JIArray getObjectAsArray() throws JIException
JIArray. Only 1 and 2 dim arrays are supported currently.
Please note that this array is not backed by this variant and is a new copy. If the array
is IJIComObjects, please make sure to use JIObjectFactory.narrowObject() to
get the right instance.JIExceptionpublic long getObjectAsLong()
throws JIException
long, used when the expected type is VT_I8.JIExceptionpublic IJIUnsigned getObjectAsUnsigned() throws JIException
unsigned number.JIExceptionpublic boolean isArray()
throws JIException
JIExceptionpublic boolean isByRefFlagSet()
throws JIException
JIExceptionpublic int getType()
throws JIException
JIVariant.VT_XX flags to find out the type of the referent.
For example :-
switch(variant.getType())
{
case JIVariant.VT_VARIANT: value = variant.getObjectAsVariant();
break;
case JIVariant.VT_NULL: ...
break;
}
JIExceptionCopyright © 2017 LSST. All rights reserved.