Microsoft SDK for Java

Variant Class Constructors

The Variant Class contains the following constructors:

Variant()
Variant(int val)
Variant(double val)
Variant(boolean val)
Variant(string val)
Variant(SafeArray val, boolean fByRef)
Variant(object value)
Variant(int vartype, int val)
Variant(int vartype, boolean val)

Variant(int vartype, double val)
Variant(int vartype, Object val)
Variant(Object value, boolean unwrapScriptObjects)

Variant()

Creates a Variant object of type VT_EMPTY.

Syntax

public Variant();

Variant(int val)

Creates a Variant object of type VT_I4.

Syntax

public Variant(int val);

Parameters

val The initial value of the Variant object.

Variant(double val)

Creates a Variant object of type VT_R8.

Syntax

public Variant(double val);

Parameters

val The initial value of the Variant object.

Variant(boolean val)

Creates a Variant object of type VT_BOOL.

Syntax

public Variant(boolean val);

Parameters

val The initial value of the Variant object.

Variant(string val)

Creates a Variant object of type VT_BSTR.

Syntax

public Variant(String val);

Parameters

val The initial value of the Variant object.

Variant(SafeArray val, boolean fByRef)

Creates a Variant object of type VT_ARRAY or VT_BYREF|VT_ARRAY. Typically, fByRef is set to true when you create a Variant object to pass as a parameter, and it is false when you create a Variant object that is used as a return value.

Syntax

public Variant(SafeArray val, boolean fByRef);

Parameters

val The initial SafeArray value.
fByRef Indicates how to set the VT_BYREF modifier.

Remarks

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

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

Variant(object value)

Creates a Variant object of type VT_DISPATCH or VT_BYREF|VT_ARRAY.

Syntax

public Variant(Object value);

If the argument is a Java SafeArray object, this constructor is equivalent to the following code:

Variant(value, true)

Otherwise, this constructor creates a VT_DISPATCH.

Parameters

value The initial value.

Variant(int vartype, int val)

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

Syntax

public Variant(int vartype, int val);

Parameters

vartype The variant type.
val The initial value.

Variant(int vartype, boolean val)

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

Syntax

public Variant(int vartype, boolean val);

Parameters

vartype The variant type.
val The initial value.

Variant(int vartype, double val)

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

Syntax

public Variant(int vartype, double val);

Parameters

vartype The variant type.
val The initial value.

Variant(int vartype, Object val)

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

Syntax

public Variant(int vartype, Object val);

Parameters

vartype The variant type.
val The initial value.

Variant(Object value, boolean unwrapScriptObjects)

If unwrapScriptObjects is set to true, this constructor creates an object of the type indicated by value, which can be types VT_BOOL, VT_BSTR, or VT_R8. Otherwise, this constructor creates a VT_DISPATCH.

Syntax

public Variant(Object value, boolean unwrapScriptObjects);

Parameters

value The initial value.
unwrapScriptObjects Indicates whether script objects are to be unwrapped.

Remarks

This constructor was added as of versions 2437 through 2925 of the Microsoft virtual machine.

© 1999 Microsoft Corporation. All rights reserved. Terms of use.