Package com.ms.com Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class Variant

Constructors , Methods , Fields

public final class Variant {
  // Fields
  public static final short VariantEmpty        = 0;
  public static final short VariantNull         = 1;
  public static final short VariantShort        = 2;
  public static final short VariantInt          = 3;
  public static final short VariantFloat        = 4;
  public static final short VariantDouble       = 5;
  public static final short VariantCurrency     = 6;
  public static final short VariantDate         = 7;
  public static final short VariantString       = 8;
  public static final short VariantDispatch     = 9;
  public static final short VariantError        = 10;
  public static final short VariantBoolean      = 11;
  public static final short VariantVariant      = 12;
  public static final short VariantObject       = 13;
  public static final short VariantByte         = 17;
  public static final short VariantTypeMask     = 0xfff;
  public static final short VariantArray        = 0x2000;
  public static final short VariantByref        = 0x4000;
    // Constructors
  public          Variant();
  public          Variant(int val);
  public          Variant(double val);
  public          Variant(boolean val);
  public          Variant(String val);
  public          Variant(SafeArray val, boolean fByRef);
  public          Variant(Object value);
  public          Variant(int vartype, int val);
  public          Variant(int vartype, boolean val);
  public          Variant(int vartype, double val);
  public          Variant(int vartype, Object val);
  // Methods
  public          void    getEmpty    ();
  public          void    getNull     ();
  public          short   getShort    ();
  public          int     getInt      ();
  public          float   getFloat    ();
  public          double  getDouble   ();
  public          long    getCurrency ();
  public          double  getDate     ();
  public  native  String  getString   ();
  public  native  Object  getDispatch ();
  public          int     getError    ();
  public  native  boolean getBoolean  ();
  public  native  Object  getObject   ();
  public          byte    getByte     ();
  public          void    putEmpty    (               );
  public          void    putNull     (               );
  public          void    putShort    (short       val);
  public          void    putInt      (int         val);
  public          void    putFloat    (float       val);
  public          void    putDouble   (double      val);
  public          void    putCurrency (long        val);
  public          void    putDate     (double      val);
  public  native  void    putString   (String      val);
  public  native  void    putDispatch (Object      val);
  public          void    putError    (int         val);
  public          void    putBoolean  (boolean     val);
  public  native  void    putObject   (Object      val);
  public          void    putByte     (byte        val);
  public  native  void    putShortRef (short       val);
  public  native  void    putIntRef   (int         val);
  public  native  void    putFloatRef (float       val);
  public  native  void    putDoubleRef(double      val);
  public  native  void    putCurrencyRef(long      val);
  public  native  void    putDateRef  (double      val);
  public  native  void    putStringRef(String      val);
  public  native  void    putDispatchRef(Object    val);
  public  native  void    putErrorRef (int         val);
  public  native  void    putBooleanRef(boolean    val);
  public  native  void    putObjectRef(Object      val);
  public  native  void    putByteRef  (byte        val);
  public  native  short   getShortRef   ();
  public  native  int     getIntRef     ();
  public  native  float   getFloatRef   ();
  public  native  double  getDoubleRef  ();
  public  native  long    getCurrencyRef();
  public  native  double  getDateRef    ();
  public  native  String  getStringRef  ();
  public  native  Object  getDispatchRef();
  public  native  int     getErrorRef   ();
  public  native  boolean getBooleanRef ();
  public  native  Object  getObjectRef  ();
  public  native  byte    getByteRef    ();
  public  native  short   toShort     ()  throws ClassCastException;
  public  native  int     toInt       ()  throws ClassCastException;
  public  native  float   toFloat     ()  throws ClassCastException;
  public  native  double  toDouble    ()  throws ClassCastException;
  public  native  long    toCurrency  ()  throws ClassCastException;
  public  native  double  toDate      ()  throws ClassCastException;
  public  native  String  toString    ();
  public  native  Object  toDispatch  ()  throws ClassCastException;
  public  native  int     toError     ()  throws ClassCastException;
  public  native  boolean toBoolean   ()  throws ClassCastException;
  public  native  Object  toObject    ()  throws ClassCastException;
  public  native  byte    toByte      ()  throws ClassCastException;
  public          SafeArray toSafeArray() throws ClassCastException;
  public          void    noParam     ();
  public  native    void    putVariantArray(Variant v[]);
  public  native    void    putVariantArrayRef(Variant v[]);
  public  native  Variant[] getVariantArray();
  public  native  Variant[] getVariantArrayRef();
  public  native  Variant[] toVariantArray();
  public  native    void    putByteArray(Object ba);
  public  native    void    putCharArray(Object ca);
  public  native    Object  toByteArray();
  public  native    Object  toCharArray();
}

The Variant class is used to bridge Java with ActiveX components that manipulate VARIANT data types.

Most Variant methods fall into one of three categories:

toXXX() methods which attempts to coerce the Variant to type XXX and return the converted value. The results of the coercion are not copied back to the Variant. Coersion is performed using the Win32 VariantChangeType() api. If the Variant cannot be converted to the requested type, a ClassCastException is thrown.

getXXX() methods which succeed only if the Variant is already the correct type. If not, ClassCastException is thrown.

putXXX(y) methods which changes the vartype of a Variant and initializes it to a new value. In general, it is better to construct and initialize the Variant atomically using an overloaded constructor rather using one of these methods.


Constructors


Variant

public          Variant()

Creates a Variant of type VT_EMPTY.


Variant

public          Variant(int val)

Creates a Variant of type VT_I4.

ParameterDescription
val the initial value of the Variant.


Variant

public          Variant(double val)

Creates a Variant of type VT_R8.

ParameterDescription
val the initial value of the Variant.


Variant

public          Variant(boolean val)

Creates a Variant of type VT_BOOL.

ParameterDescription
val the initial value of the Variant.


Variant

public          Variant(String val)

Creates a Variant of type VT_BSTR.

ParameterDescription
val the initial value of the Variant.


Variant

public          Variant(SafeArray val, boolean fByRef)

Creates a Variant of type VT_ARRAY or VT_BYREF|VT_ARRAY.

Typically, fByRef is true when creating a Variant to pass as a parameter, and false when creating a Variant to be used as a return value.

If fByRef is true, any changes made to the SAFEARRAY through the new Variant will be visible to the SafeArray instance used to initialize the Variant.

If fByRef is false, the method revokes the SafeArray instance's ownership and any further operations on that instance will throw an exception. This is because ownership of the SAFEARRAY has been transferred to the new Variant. To retrieve any changes made through the Variant, you must call Variant.toSafeArray() to obtain a new proxy.

ParameterDescription
val the initial SafeArray value
fByRef whether to set VT_BYREF modifier.


Variant

public          Variant(Object value)

Creates a Variant of type VT_DISPATCH or VT_BYREF|VT_ARRAY.

If the argument is of type com.ms.com.SafeArray, this constructor is equivalent to:

Variant(val, true)

Otherwise, this constructor creates a VT_DISPATCH.

ParameterDescription
val the initial value


Variant

public          Variant(int vartype, int val)

Creates a Variant of the indicated vartype. The vartype can be VariantShort, VariantInt, or VariantByte. The VariantByref modifier can be set on any of these.

ParameterDescription
vartype the vartype.
val the initial value


Variant

public          Variant(int vartype, boolean val)

Creates a Variant of the indicated vartype. The vartype can be VariantBoolean, or VariantByref|VariantBoolean.

ParameterDescription
vartype the vartype
val the initial value


Variant

public          Variant(int vartype, double val)

Creates a Variant of the indicated vartype. The vartype can be VariantDouble, VariantFloat, or VariantDate. The VariantByref modifier can be set on any of these.

ParameterDescription
vartype the vartype.
val the initial value


Variant

public          Variant(int vartype, Object val)

Creates a Variant of the indicated vartype. The vartype can be VariantString, VariantObject, or VariantDispatch. The VariantByref modifier can be set on any of these.

ParameterDescription
vartype the vartype.
val the initial value


Methods


getBoolean

public  native  boolean getBoolean  ()

Returns the value of a VT_BOOL variant. If the type is not VT_BOOL, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getBooleanRef

public  native  boolean getBooleanRef ()

Returns the referenced value of a VT_BYREF|VT_BOOL variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getByte

public          byte    getByte     ()

Returns the value of a VT_UI1 variant. If the type is not VT_UI1, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getByteRef

public  native  byte    getByteRef    ()

Returns the referenced value of a VT_BYREF|VT_UI1 variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getCurrency

public          long    getCurrency ()

Returns the value of a VT_CY variant. If the type is not VT_CY, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getCurrencyRef

public  native  long    getCurrencyRef()

Returns the referenced value of a VT_BYREF|VT_CY variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getDate

public          double  getDate     ()

Returns the value of a VT_DATE variant. If the type is not VT_DATE, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getDateRef

public  native  double  getDateRef    ()

Returns the referenced value of a VT_BYREF|VT_DATE variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getDispatch

public  native  Object  getDispatch ()

Returns the value of a VT_DISPATCH variant. If the type is not VT_DISPATCH, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getDispatchRef

public  native  Object  getDispatchRef()

Returns the referenced value of a VT_BYREF|VT_DISPATCH variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getDouble

public          double  getDouble   ()

Returns the value of a VT_R8 variant. If the type is not VT_R8, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getDoubleRef

public  native  double  getDoubleRef  ()

Returns the referenced value of a VT_BYREF|VT_R8 variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getEmpty

public          void    getEmpty    ()

Verifies that the vartype is VT_EMPTY, otherwise throws a ClassCastException. That is all this method does since there is no value associated with an empty variant.


getError

public          int     getError    ()

Returns the value of a VT_ERROR variant. If the type is not VT_ERROR, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getErrorRef

public  native  int     getErrorRef   ()

Returns the referenced value of a VT_BYREF|VT_ERROR variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getFloat

public          float   getFloat    ()

Returns the value of a VT_R4 variant. If the type is not VT_R4, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getFloatRef

public  native  float   getFloatRef   ()

Returns the referenced value of a VT_BYREF|VT_R4 variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getInt

public          int     getInt      ()

Returns the value of a VT_I4 variant. If the type is not VT_I4, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getIntRef

public  native  int     getIntRef     ()

Returns the referenced value of a VT_BYREF|VT_I4 variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getNull

public          void    getNull     ()

Verifies that the vartype is VT_NULL, otherwise throws a ClassCastException. That is all this method does since there is no value associated with a null variant.


getObject

public  native  Object  getObject   ()

Returns the value of a VT_UNKNOWN variant. If the type is not VT_UNKNOWN, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getObjectRef

public  native  Object  getObjectRef  ()

Returns the referenced value of a VT_BYREF|VT_UNKNOWN variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getShort

public          short   getShort    ()

Returns the value of a VT_I2 variant. If the type is not VT_I2, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getShortRef

public  native  short   getShortRef   ()

Returns the referenced value of a VT_BYREF|VT_I2 variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getString

public  native  String  getString   ()

Returns the value of a VT_BSTR variant. If the type is not VT_BSTR, a ClassCastException is thrown.

Return Value:

Returns the Variant's value converted to Java


getStringRef

public  native  String  getStringRef  ()

Returns the referenced value of a VT_BYREF|VT_BSTR variant. If the Variant is of any other vartype, a ClassCastException is thrown.

Return Value:

Returns the Variant's referenced value converted to Java


getVariantArray

public  native  Variant[] getVariantArray()

Returns the value of a VT_ARRAY|VT_VARIANT variant. The embedded array must be one-dimensional. This is an expensive method and has been superceded by the toSafeArray method.

Return Value:

Returns the Variant's value converted to Java


getVariantArrayRef

public  native  Variant[] getVariantArrayRef()

Returns the referenced value of a VT_BYREF|VT_ARRAY|VT_VARIANT variant. The embedded array must be one-dimensional. This is an expensive method and has been superceded by the toSafeArray method.

Return Value:

Returns the Variant's referenced value converted to Java


noParam

public          void    noParam     ()

Sets a Variant to represent a missing optional parameter. This method is equivalent to:

putError(0x80020004) //DISP_E_PARAMNOTFOUND


putBoolean

public          void    putBoolean  (boolean     val)

Sets Variant to be type VT_BOOL and clears the previous contents. The preferred way to create a VT_BOOL Variant is the expression:

new Variant(val)

ParameterDescription
val new value


putBooleanRef

public  native  void    putBooleanRef(boolean    val)

Replaces a value referenced by a VT_BYREF|VT_BOOL Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantBoolean, val)

ParameterDescription
val new value


putByte

public          void    putByte     (byte        val)

Sets Variant to be type VT_UI1 and clears the previous contents. The preferred way to create a VT_UI1 Variant is the expression:

new Variant(Variant.VariantByte, val)

ParameterDescription
val new value


putByteArray

public  native    void    putByteArray(Object ba)

Sets Variant to be type VT_ARRAY|VT_UI1 and clears the previous contents.

ParameterDescription
ba initial values of elements: must be of type byte[]


putByteRef

public  native  void    putByteRef  (byte        val)

Replaces a value referenced by a VT_BYREF|VT_UI1 Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantByte, val)

ParameterDescription
val new value


putCharArray

public  native    void    putCharArray(Object ca)

Sets Variant to be type VT_ARRAY|VT_I2 and clears the previous contents.

ParameterDescription
ba initial values of elements: must be of type char[]


putCurrency

public          void    putCurrency (long        val)

Sets Variant to be type VT_CY and clears the previous contents.

ParameterDescription
val new value


putCurrencyRef

public  native  void    putCurrencyRef(long      val)

Replaces a value referenced by a VT_BYREF|VT_CY Variant.

ParameterDescription
val new value


putDate

public          void    putDate     (double      val)

Sets Variant to be type VT_DATE and clears the previous contents. The preferred way to create a VT_DATE Variant is the expression:

new Variant(Variant.VariantDate, val)

ParameterDescription
val new value


putDateRef

public  native  void    putDateRef  (double      val)

Replaces a value referenced by a VT_BYREF|VT_DATE Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantDate, val)

ParameterDescription
val new value


putDispatch

public  native  void    putDispatch (Object      val)

Sets Variant to be type VT_DISPATCH and clears the previous contents. The preferred way to create a VT_DISPATCH Variant is the expression:

new Variant(val)

ParameterDescription
val new value


putDispatchRef

public  native  void    putDispatchRef(Object    val)

Replaces a value referenced by a VT_BYREF|VT_DISPATCH Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantDispatch, val)

ParameterDescription
val new value


putDouble

public          void    putDouble   (double      val)

Sets Variant to be type VT_R8 and clears the previous contents. The preferred way to create a VT_R8 Variant is the expression:

new Variant(val)

ParameterDescription
val new value


putDoubleRef

public  native  void    putDoubleRef(double      val)

Replaces a value referenced by a VT_BYREF|VT_R8 Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantDouble, val)

ParameterDescription
val new value


putEmpty

public          void    putEmpty    (               )

Sets Variant to be type VT_EMPTY and clears the previous contents. The expression:

new Variant()

creates a new Variant that is already type VT_EMPTY so it is not necessary to invoke putEmpty() on it.


putError

public          void    putError    (int         val)

Sets Variant to be type VT_ERROR and clears the previous contents. This is normally passed as placeholder for a missing optional parameter. The preferred way to generate a missing parameter is:

Variant v = new Variant(val);

v.noParam();

ParameterDescription
val new value


putErrorRef

public  native  void    putErrorRef (int         val)

Replaces a value referenced by a VT_BYREF|VT_ERROR Variant.

ParameterDescription
val new value


putFloat

public          void    putFloat    (float       val)

Sets Variant to be type VT_R4 and clears the previous contents. The preferred way to create a VT_R4 Variant is the expression:

new Variant(Variant.VariantFloat, val)

ParameterDescription
val new value


putFloatRef

public  native  void    putFloatRef (float       val)

Replaces a value referenced by a VT_BYREF|VT_R4 Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantFloat, val)

ParameterDescription
val new value


putInt

public          void    putInt      (int         val)

Sets Variant to be type VT_I4 and clears the previous contents. The preferred way to create a VT_I4 Variant is the expression:

new Variant(val)

ParameterDescription
val new value


putIntRef

public  native  void    putIntRef   (int         val)

Replaces a value referenced by a VT_BYREF|VT_I4 Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantInt, val)

ParameterDescription
val new value


putNull

public          void    putNull     (               )

Sets Variant to be type VT_NULL and clears the previous contents.


putObject

public  native  void    putObject   (Object      val)

Sets Variant to be type VT_UNKNOWN and clears the previous contents. The preferred way to create a VT_UNKNOWN Variant is the expression:

new Variant(Variant.VariantObject, val)

ParameterDescription
val new value


putObjectRef

public  native  void    putObjectRef(Object      val)

Replaces a value referenced by a VT_BYREF|VT_UNKNOWN Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantObject, val)

ParameterDescription
val new value


putShort

public          void    putShort    (short       val)

Sets Variant to be type VT_I2 and clears the previous contents. The preferred way to create a VT_I2 Variant is the expression:

new Variant(Variant.VariantShort, val)

ParameterDescription
val new value


putShortRef

public  native  void    putShortRef (short       val)

Replaces a value referenced by a VT_BYREF|VT_I2 Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantShort, val)

ParameterDescription
val new value


putString

public  native  void    putString   (String      val)

Sets Variant to be type VT_BSTR and clears the previous contents. The preferred way to create a VT_BSTR Variant is the expression:

new Variant(val)

ParameterDescription
val new value


putStringRef

public  native  void    putStringRef(String      val)

Replaces a value referenced by a VT_BYREF|VT_BSTR Variant. This method can also be used to initialize a Variant, but the preferred method is the expression:

new Variant(Variant.VariantByref|Variant.VariantString, val)

ParameterDescription
val new value


putVariantArray

public  native    void    putVariantArray(Variant v[])

Sets Variant to be type VT_ARRAY|VT_VARIANT that holds a zero-based one-dimensional SafeArray.

ParameterDescription
v provides initial values for the SAFEARRAY elements.


putVariantArrayRef

public  native    void    putVariantArrayRef(Variant v[])

Replaces a SAFEARRAY referenced by a VT_BYREF|VT_ARRAY|VT_VARIANT Variant. This method can also be used to initialize a Variant, but the preferred method is to pass a SafeArray object to the Variant() constructor.

ParameterDescription
v provides initial values for the SAFEARRAY elements.


toBoolean

public  native  boolean toBoolean   ()  throws ClassCastException

Coerces the Variant to a VT_BOOL, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toByte

public  native  byte    toByte      ()  throws ClassCastException

Coerces the Variant to a VT_UI1, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toByteArray

public  native    Object  toByteArray()

Returns the value of a VT_ARRAY|VT_UI1 or VT_BYREF|VT_ARRAY|VT_UI1, as a one-dimensional byte[] array. This method has been superceded by the toSafeArray() method.

Return Value:

Returns a byte array


toCharArray

public  native    Object  toCharArray()

Returns the value of a VT_ARRAY|VT_I2 or VT_BYREF|VT_ARRAY|VT_I2, as a one-dimensional char[] array. This method has been superceded by the toSafeArray() method.

Return Value:

Returns a char array


toCurrency

public  native  long    toCurrency  ()  throws ClassCastException

Coerces the Variant to a VT_CY, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toDate

public  native  double  toDate      ()  throws ClassCastException

Coerces the Variant to a VT_DATE, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toDispatch

public  native  Object  toDispatch  ()  throws ClassCastException

Coerces the Variant to a VT_DISPATCH, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toDouble

public  native  double  toDouble    ()  throws ClassCastException

Coerces the Variant to a VT_R8, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toError

public  native  int     toError     ()  throws ClassCastException

Coerces the Variant to a VT_ERROR, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toFloat

public  native  float   toFloat     ()  throws ClassCastException

Coerces the Variant to a VT_R4, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toInt

public  native  int     toInt       ()  throws ClassCastException

Coerces the Variant to a VT_I4, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toObject

public  native  Object  toObject    ()  throws ClassCastException

Coerces the Variant to a VT_UNKNOWN, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toSafeArray

public          SafeArray toSafeArray() throws ClassCastException

Extracts a SafeArray from a Variant that has the VT_ARRAY modifier set. This operation does not create an independent SafeArray; thus, it can be used to modify the elements of the SafeArray referenced by the Variant.

Return Value:

Returns the coerced value converted to Java


toShort

public  native  short   toShort     ()  throws ClassCastException

Coerces the Variant to a VT_I2, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toString

public  native  String  toString    ()

Coerces the Variant to a VT_BSTR, and returns the coerced result. The results of the coersion are not stored back in the Variant. If the Variant's type cannot be coerced, a ClassCastException is thrown.

Return Value:

Returns the coerced value converted to Java


toVariantArray

public  native  Variant[] toVariantArray()

Returns the value of either a VT_ARRAY|VT_VARIANT or VT_BYREF|VT_ARRAY|VT_VARIANT variant. The embedded array must be one-dimensional. This is an expensive method and has been superceded by the toSafeArray method.

Return Value:

Returns the coerced value converted to Java


Fields

VariantArray
Corresponds to the VT_ARRAY modifier.
VariantBoolean
Corresponds to the VT_BOOL vartype.
VariantByref
Corresponds to the VT_BYREF modifier.
VariantByte
Corresponds to the VT_UI1 vartype.
VariantCurrency
Corresponds to the VT_CY vartype.
VariantDate
Corresponds to the VT_DATE vartype.
VariantDispatch
Corresponds to the VT_DISPATCH vartype.
VariantDouble
Corresponds to the VT_R8 vartype.
VariantEmpty
Corresponds to the VT_EMPTY vartype.
VariantError
Corresponds to the VT_ERROR vartype.
VariantFloat
Corresponds to the VT_R4 vartype.
VariantInt
Corresponds to the VT_I4 vartype.
VariantNull
Corresponds to the VT_NULL vartype.
VariantObject
Corresponds to the VT_UNKNOWN vartype.
VariantShort
Corresponds to the VT_I2 vartype.
VariantString
Corresponds to the VT_BSTR vartype.
VariantTypeMask
Masks off vartype modifiers.
VariantVariant
Corresponds to the VT_VARIANT vartype.


© 1997 Microsoft Corporation. All rights reserved. Legal Notices.