public class Variant extends JacobObject
Just loading this class creates 3 variants that get added to the ROT
PROPVARIANT introduces new types so eventually Variant will need to be upgraded to support PropVariant types. http://blogs.msdn.com/benkaras/archive/2006/09/13/749962.aspx
This object no longer implements Serializable because serialization is broken (and has been since 2000/xp). The underlying marshalling/unmarshalling code is broken in the JNI layer.
Modifier and Type | Field and Description |
---|---|
static Variant |
DEFAULT
Use this constant for optional parameters
|
static short |
VariantArray
variant's type is array VT_ARRAY 0x2000
|
static short |
VariantBoolean
variant's type is boolean VT_BOOL
|
static short |
VariantByref
variant's type is a reference (to IDispatch?) VT_BYREF 0x4000
|
static short |
VariantByte
variant's type is byte VT_UI1 This is an UNSIGNED byte
|
static short |
VariantCurrency
variant's type is currency VT_CY
|
static short |
VariantDate
variant's type is date VT_DATE
|
static short |
VariantDecimal
variant's type is object VT_DECIMAL
|
static short |
VariantDispatch
variant's type is dispatch VT_DISPATCH
|
static short |
VariantDouble
variant's type is double VT_R8
|
static short |
VariantEmpty
variant's type is empty : equivalent to VB Nothing and VT_EMPTY
|
static short |
VariantError
variant's type is error VT_ERROR
|
static short |
VariantFloat
variant's type is float VT_R4
|
static short |
VariantInt
variant's type is int VT_I4, a Long in VC
|
static short |
VariantLongInt
variant's type is 64 bit long integer VT_I8 - not yet implemented in
Jacob because we have to decide what to do with Currency and because its
only supported on XP and later.
|
static short |
VariantNull
variant's type is null : equivalent to VB Null and VT_NULL
|
static short |
VariantObject
variant's type is object VT_UNKNOWN
|
static short |
VariantPointer
This value is for reference only and is not to be used by any callers
|
static short |
VariantShort
variant's type is short VT_I2
|
static short |
VariantString
variant's type is string also known as VT_BSTR
|
static short |
VariantTypeMask
what is this? VT_TYPEMASK && VT_BSTR_BLOB 0xfff
|
static short |
VariantVariant
variant's type is variant it encapsulate another variant VT_VARIANT
|
static Variant |
VT_FALSE
Use for true/false variant parameters
|
static Variant |
VT_MISSING
Same than
DEFAULT |
static Variant |
VT_TRUE
Use for true/false variant parameters
|
Constructor and Description |
---|
Variant()
public constructor, initializes and sets type to VariantEmpty
|
Variant(boolean in)
Constructor that accepts a primitive rather than an object
|
Variant(byte in)
Constructor that accepts a primitive rather than an object
|
Variant(double in)
Constructor that accepts a primitive rather than an object
|
Variant(float in)
Constructor that accepts a primitive rather than an object
|
Variant(int in)
Constructor that accepts a primitive rather than an object
|
Variant(long in)
Constructor that accepts a primitive rather than an object
|
Variant(java.lang.Object in)
Convenience constructor that calls the main one with a byRef value of
false
|
Variant(java.lang.Object pValueObject,
boolean fByRef)
Constructor that accepts the data object and information about whether
this is by reference or not.
|
Variant(short in)
Constructor that accepts a primitive rather than an object
|
Modifier and Type | Method and Description |
---|---|
Variant |
changeType(short in)
Cover for native method so we can cover it.
|
java.lang.Object |
clone()
this returns null
|
Variant |
cloneIndirect()
Deprecated.
No longer used
|
protected void |
finalize() |
boolean |
getBoolean() |
boolean |
getBooleanRef()
public cover for native method
|
byte |
getByte() |
byte |
getByteRef()
public cover for native method
|
Currency |
getCurrency()
MS Currency objects are 64 bit fixed point numbers with 15 digits to the
left and 4 to the right of the decimal place.
|
Currency |
getCurrencyRef()
MS Currency objects are 64 bit fixed point numbers with 15 digits to the
left and 4 to the right of the decimal place.
|
double |
getDate() |
double |
getDateRef() |
java.math.BigDecimal |
getDecimal()
return the BigDecimal value held in this variant (fails on other types)
|
java.math.BigDecimal |
getDecimalRef()
return the BigDecimal value held in this variant (fails on other types)
|
Dispatch |
getDispatch()
cover for
toDispatch() This method now matches other getXXX()
methods. |
Dispatch |
getDispatchRef()
Dispatch and dispatchRef are treated the same This is just a cover for
toDispatch() with a flag check
|
double |
getDouble() |
double |
getDoubleRef() |
void |
getEmpty()
Deprecated.
method never did anything
|
int |
getError() |
int |
getErrorRef() |
float |
getFloat() |
float |
getFloatRef() |
int |
getInt()
return the int value held in this variant if it is an int or a short.
|
int |
getIntRef()
get the content of this variant as an int
|
java.util.Date |
getJavaDate()
returns the windows time contained in this Variant to a Java Date.
|
java.util.Date |
getJavaDateRef()
returns the windows time contained in this Variant to a Java Date should
return null if this is not a date reference Variant SF 959382
|
long |
getLong()
64 bit Longs only available on x64.
|
long |
getLongRef()
64 bit Longs only available on x64.
|
void |
getNull()
Deprecated.
method never did anything
|
short |
getShort()
return the int value held in this variant (fails on other types?)
|
short |
getShortRef()
get the content of this variant as an int
|
java.lang.String |
getString() |
java.lang.String |
getStringRef()
gets the content of the variant as a string ref
|
java.lang.Object |
getVariant()
Used to get the value from a windows type of VT_VARIANT or a jacob
Variant type of VariantVariant.
|
Variant[] |
getVariantArray()
Deprecated.
superseded by SafeArray
|
Variant[] |
getVariantArrayRef()
Deprecated.
superseded by SafeArray
|
short |
getvt()
Reports the type of the underlying Variant object
|
protected void |
init()
initializes the COM Variant and puts its reference in this instance
|
boolean |
isNull() |
void |
noParam()
Deprecated.
replaced by putNoParam()
|
protected boolean |
objectIsAConstant(Variant pVariant)
returns true if the passed in Variant is a constant that should not be
freed
|
void |
putBoolean(boolean in)
puts a boolean into the variant and sets it's type
|
void |
putBooleanRef(boolean in)
pushes a boolean into the variant by ref and sets the type of the variant
to boolean
|
void |
putByte(byte in)
pushes a byte into the varaint and sets the type
|
void |
putByteArray(java.lang.Object in)
Deprecated.
superseded by SafeArray
|
void |
putByteRef(byte in)
pushes a byte into the variant by ref and sets the type
|
void |
putCharArray(java.lang.Object in)
Deprecated.
superseded by SafeArray
|
void |
putCurrency(Currency in)
Puts a value in as a currency and sets the variant type.
|
void |
putCurrencyRef(Currency in)
Pushes a long into the variant as currency and sets the type.
|
void |
putDate(java.util.Date inDate)
converts a java date to a windows time and calls putDate(double) SF
959382
|
void |
putDate(double in)
puts a windows date double into the variant and sets the type
|
void |
putDateRef(java.util.Date inDate)
converts a java date to a windows time and calls putDateRef(double) SF
959382
|
void |
putDateRef(double in)
set the content of this variant to a date (VT_DATE|VT_BYREF)
|
void |
putDecimal(java.math.BigDecimal in)
EXPERIMENTAL 1.14 feature to support rounded decimals.
|
void |
putDecimalRef(java.math.BigDecimal in)
Set the value of this variant and set the type.
|
void |
putDispatch(Dispatch in)
This acts a cover for putVariant Dispatch.
|
void |
putDispatchRef(Dispatch in)
Dispatch and dispatchRef are treated the same This is a cover for
putVariantDispatch().
|
void |
putDouble(double in)
wraps this Variant around the passed in double.
|
void |
putDoubleRef(double in)
set the content of this variant to a double (VT_R8|VT_BYREF)
|
void |
putEmpty()
sets the type to VariantEmpty
|
void |
putError(int in)
puts an error code (I think) into the variant and sets the type
|
void |
putErrorRef(int in)
pushes an error code into the variant by ref and sets the type
|
void |
putFloat(float in)
fills the Variant with a float and sets the type to float
|
void |
putFloatRef(float in)
pushes a float into the variant and sets the type
|
void |
putInt(int in)
set the value of this variant and set the type
|
void |
putIntRef(int in)
set the content of this variant to an int (VT_I4|VT_BYREF)
|
void |
putLong(long in)
Puts a 64 bit Java Long into a 64 bit Variant Long.
|
void |
putLongRef(long in)
Puts a 64 bit Java Long into a 64 bit Variant Long.
|
void |
putNoParam()
sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND
|
void |
putNothing()
Sets the type to VariantDispatch and sets the value to null Equivalent to
VB's nothing
|
void |
putNull()
Set this Variant's type to VT_NULL (the VB equivalent of NULL)
|
void |
putObject(java.lang.Object in)
Deprecated.
should use putDispatch()
|
void |
putObjectRef(java.lang.Object in)
Deprecated.
|
void |
putSafeArray(SafeArray in)
have no idea...
|
void |
putSafeArrayRef(SafeArray in)
have no idea...
|
void |
putShort(short in)
set the content of this variant to a short (VT_I2)
|
void |
putShortRef(short in)
set the content of this variant to a short (VT_I2|VT_BYREF)
|
void |
putString(java.lang.String in)
put a string into the variant and set its type
|
void |
putStringRef(java.lang.String in)
set the content of this variant to a string (VT_BSTR|VT_BYREF)
|
void |
putVariant(java.lang.Object objectToBeWrapped)
Puts a variant into this variant making it type VT_VARIANT.
|
void |
putVariantArray(Variant[] in)
Deprecated.
superseded by SafeArray
|
void |
putVariantArrayRef(Variant[] in)
Deprecated.
superseded by SafeArray
|
void |
safeRelease()
This will release the "C" memory for the Variant unless this Variant is
one of the constants in which case we don't want to release the memory.
|
protected void |
SerializationReadFromBytes(byte[] ba)
this is supposed to cause the underlying variant object struct to be
rebuilt from a previously serialized byte array.
|
protected byte[] |
SerializationWriteToBytes()
this is supposed to create a byte array that represents the underlying
variant object structure
|
boolean |
toBoolean()
Deprecated.
should be replaced by changeType() followed by getBoolean()
|
byte |
toByte()
Deprecated.
should be replaced by changeType() followed by getByte()
|
java.lang.Object |
toByteArray()
Deprecated.
superseded by SafeArray
|
java.lang.Object |
toCharArray()
Deprecated.
superseded by SafeArray
|
Currency |
toCurrency()
Deprecated.
should be replaced by changeType() followed by getCurrency
|
double |
toDate()
Deprecated.
should use changeType() followed by getDate()
|
Dispatch |
toDispatch() |
double |
toDouble()
Deprecated.
should call changeType() then getDouble()
|
EnumVariant |
toEnumVariant() |
int |
toError()
Deprecated.
should use changeType() followed by getError()
|
float |
toFloat()
Deprecated.
should use changeType() and getFloat() instead
|
int |
toInt()
Deprecated.
should use changeType() followed by getInt()
|
java.util.Date |
toJavaDate()
Deprecated.
callers should use getDate()
|
java.lang.Object |
toJavaObject()
Convert a JACOB Variant value to a Java object (type conversions).
|
java.lang.Object |
toObject()
Deprecated.
this is a cover for toDispatch();
|
SafeArray |
toSafeArray()
By default toSafeArray makes a deep copy due to the fact that this
Variant owns the embedded SafeArray and will destroy it when it gc's
calls toSafeArray(true).
|
SafeArray |
toSafeArray(boolean deepCopy)
This lets folk turn into a safe array without a deep copy.
|
java.lang.Object |
toScriptObject()
Deprecated.
|
short |
toShort()
Deprecated.
callers should use changeType() followed by getShort()
|
java.lang.String |
toString()
This method now correctly implements java toString() semantics Attempts
to return the content of this variant as a string
"not initialized" if not initialized
"null" if VariantEmpty,
"null" if VariantError
"null" if VariantNull
"null" if Variant type didn't convert.
|
Variant |
toVariant()
Deprecated.
superseded by "this"
|
Variant[] |
toVariantArray()
Deprecated.
superseded by SafeArray
|
void |
VariantClear()
Clear the content of this variant
|
debug, getBuildDate, getBuildVersion, isDebugEnabled
public static final Variant DEFAULT
public static final Variant VT_TRUE
public static final Variant VT_FALSE
public static final short VariantEmpty
public static final short VariantNull
public static final short VariantShort
public static final short VariantInt
public static final short VariantFloat
public static final short VariantDouble
public static final short VariantCurrency
public static final short VariantDate
public static final short VariantString
public static final short VariantDispatch
public static final short VariantError
public static final short VariantBoolean
public static final short VariantVariant
public static final short VariantObject
public static final short VariantDecimal
public static final short VariantByte
public static final short VariantLongInt
public static final short VariantPointer
public static final short VariantTypeMask
public static final short VariantArray
public static final short VariantByref
public Variant()
public Variant(boolean in)
in
- public Variant(byte in)
in
- public Variant(double in)
in
- public Variant(float in)
in
- public Variant(int in)
in
- public Variant(long in)
in
- public Variant(java.lang.Object in)
in
- object to be made into variantpublic Variant(java.lang.Object pValueObject, boolean fByRef)
pValueObject
- The value object that will pushed down into windows memory. A
null object sets this to "empty"fByRef
- public Variant(short in)
in
- public Variant changeType(short in)
This cannot convert an object to a byRef. It can convert from byref to not byref
in
- type to convert this variant toopublic java.lang.Object clone()
clone
in class java.lang.Object
@Deprecated public Variant cloneIndirect()
protected void finalize()
finalize
in class java.lang.Object
public boolean getBoolean()
java.lang.IllegalStateException
- if variant is not of the requested typepublic boolean getBooleanRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic byte getByte()
java.lang.IllegalStateException
- if variant is not of the requested typepublic byte getByteRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic Currency getCurrency()
java.lang.IllegalStateException
- if variant is not of the requested typepublic Currency getCurrencyRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic double getDate()
java.lang.IllegalStateException
- if variant is not of the requested typepublic double getDateRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.math.BigDecimal getDecimal()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.math.BigDecimal getDecimalRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic Dispatch getDispatch()
toDispatch()
This method now matches other getXXX()
methods. It throws an IllegalStateException if the object is not of type
VariantDispatchjava.lang.IllegalStateException
- if wrong variant typepublic Dispatch getDispatchRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic double getDouble()
java.lang.IllegalStateException
- if variant is not of the requested typepublic double getDoubleRef()
java.lang.IllegalStateException
- if variant is not of the requested type@Deprecated public void getEmpty()
public int getError()
java.lang.IllegalStateException
- if variant is not of the requested typepublic int getErrorRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic float getFloat()
java.lang.IllegalStateException
- if variant is not of the requested typepublic float getFloatRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic int getInt()
java.lang.IllegalStateException
- if variant is not of the requested typepublic int getIntRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.util.Date getJavaDate()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.util.Date getJavaDateRef()
public long getLong()
java.lang.IllegalStateException
- if variant is not of the requested typepublic long getLongRef()
java.lang.IllegalStateException
- if variant is not of the requested type@Deprecated public void getNull()
public short getShort()
java.lang.IllegalStateException
- if variant is not of the requested typepublic short getShortRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.lang.String getString()
java.lang.IllegalStateException
- if this variant is not of type Stringpublic java.lang.String getStringRef()
java.lang.IllegalStateException
- if variant is not of the requested typepublic java.lang.Object getVariant()
@Deprecated public Variant[] getVariantArray()
NotImplementedException
@Deprecated public Variant[] getVariantArrayRef()
NotImplementedException
public short getvt()
java.lang.IllegalStateException
- if there is no underlying windows data structureprotected void init()
public boolean isNull()
java.lang.IllegalStateException
- if there is no underlying windows memory@Deprecated public void noParam()
protected boolean objectIsAConstant(Variant pVariant)
pVariant
- public void putBoolean(boolean in)
in
- the new valuepublic void putBooleanRef(boolean in)
in
- public void putByte(byte in)
in
- @Deprecated public void putByteArray(java.lang.Object in)
in
- doesn't matter because this method does nothingNotImplementedException
public void putByteRef(byte in)
in
- @Deprecated public void putCharArray(java.lang.Object in)
in
- the object that would be wrapped by the Variant if this method
was implementedNotImplementedException
public void putCurrency(Currency in)
in
- the long that will be put into the 64 bit currency object.public void putCurrencyRef(Currency in)
in
- the long that will be put into the 64 bit currency objectpublic void putDate(java.util.Date inDate)
inDate
- a Java date to be convertedjava.lang.IllegalArgumentException
- if inDate = nullpublic void putDate(double in)
in
- public void putDateRef(java.util.Date inDate)
inDate
- a Java date to be convertedjava.lang.IllegalArgumentException
- if inDate = nullpublic void putDateRef(double in)
in
- public void putDecimal(java.math.BigDecimal in)
Set the value of this variant and set the type. This may throw exceptions more often than the caller expects because most callers don't manage the scale of their BigDecimal objects.
This default set method throws exceptions if precision or size is out of bounds
There are 12 bytes available for the integer number.
There is 1 byte for the scale.
in
- the BigDecimal that will be converted to VT_DECIMALjava.lang.IllegalArgumentException
- if the scale is > 28, the maximum for VT_DECIMAL or if there
are more than 12 bytes worth the digitspublic void putDecimalRef(java.math.BigDecimal in)
This default set method throws exceptions if precision or size is out of bounds
There are 12 bytes available for the integer number.
There is 1 byte for the scale.
in
- the BigDecimal that will be converted to VT_DECIMALjava.lang.IllegalArgumentException
- if the scale is > 28, the maximum for VT_DECIMAL or if there
are more than 12 bytes worth the digitspublic void putDispatch(Dispatch in)
in
- the Dispatch we're putting down in the COM variant space.public void putDispatchRef(Dispatch in)
in
- the Dispatch we're putting down in the COM variant space.public void putDouble(double in)
in
- public void putDoubleRef(double in)
in
- public void putEmpty()
public void putError(int in)
in
- public void putErrorRef(int in)
in
- public void putFloat(float in)
in
- public void putFloatRef(float in)
in
- public void putInt(int in)
in
- public void putIntRef(int in)
in
- public void putLong(long in)
in
- the long that will be put into the 64 bit Long object.public void putLongRef(long in)
in
- the long that will be put into the 64 bit Long object.public void putNoParam()
public void putNothing()
public void putNull()
@Deprecated public void putObject(java.lang.Object in)
in
- the object we are putting into the Variant, assumes aputDispatch(Dispatch)
@Deprecated public void putObjectRef(java.lang.Object in)
in
- public void putSafeArray(SafeArray in)
in
- public void putSafeArrayRef(SafeArray in)
in
- public void putShort(short in)
in
- public void putShortRef(short in)
in
- public void putString(java.lang.String in)
in
- public void putStringRef(java.lang.String in)
in
- public void putVariant(java.lang.Object objectToBeWrapped)
objectToBeWrapped
- A object that is to be referenced by this variant. If
objectToBeWrapped is already of type Variant, then it is used.
If objectToBeWrapped is not Variant then
new Variant(objectToBeWrapped)
is called and the
result is passed into the com layerjava.lang.IllegalArgumentException
- if inVariant = null or if inVariant is a Varint@Deprecated public void putVariantArray(Variant[] in)
in
- doesn't matter because this method does nothingNotImplementedException
@Deprecated public void putVariantArrayRef(Variant[] in)
in
- the thing that would be come an array if this method was
implementedNotImplementedException
public void safeRelease()
safeRelease
in class JacobObject
JacobObject.safeRelease()
protected void SerializationReadFromBytes(byte[] ba)
ba
- protected byte[] SerializationWriteToBytes()
@Deprecated public boolean toBoolean()
@Deprecated public byte toByte()
@Deprecated public java.lang.Object toByteArray()
NotImplementedException
@Deprecated public java.lang.Object toCharArray()
NotImplementedException
@Deprecated public Currency toCurrency()
@Deprecated public double toDate()
public Dispatch toDispatch()
@Deprecated public double toDouble()
public EnumVariant toEnumVariant()
@Deprecated public int toError()
@Deprecated public float toFloat()
@Deprecated public int toInt()
@Deprecated public java.util.Date toJavaDate()
This method added 12/2005 for possible use by jacobgen instead of its conversion code
This does not convert the data
public java.lang.Object toJavaObject() throws JacobException
java.lang.IllegalStateException
- if no underlying windows data structureNotImplementedException
- if unsupported conversion is requestedJacobException
- if the calculated result was a JacobObject usually as a
result of error@Deprecated public java.lang.Object toObject()
instead
public SafeArray toSafeArray()
public SafeArray toSafeArray(boolean deepCopy)
deepCopy
- @Deprecated public java.lang.Object toScriptObject()
@Deprecated public short toShort()
public java.lang.String toString()
toString
in class java.lang.Object
java.lang.IllegalStateException
- if there is no underlying windows data structure@Deprecated public Variant toVariant()
@Deprecated public Variant[] toVariantArray()
NotImplementedException
public void VariantClear()
http://jacob-project.sourceforge.net