Microsoft SDK for Java

getVariant

The getVariant method of the SafeArray Class contains the following signatures:

getVariant(int sa_idx)
getVariant(int sa_idx1, int sa_idx2)

getVariant(int sa_idx)

Extracts an element of a one-dimensional SafeArray as a Variant.

Syntax

public Variant getVariant(int sa_idx);

Note   Although the Variant methods can operate on any SafeArray type, it is usually much more efficient to use the specific method for the SafeArray type rather than to extract first as a Variant,and then to coerce the Variant. This is true even if the SafeArray is a SafeArray of Variant.

Return Value

Returns the converted element value.

Parameters

sa_idx The element index, which ranges from the index of the lower bound to the index of the upper bound.

Exceptions

IndexOutOfBoundsException if the array is not one-dimensional or if sa_idx does not lie between the lower bound of the array and the upper bound of the array (inclusive).

ClassCastException if the SafeArray element cannot be converted to the correct type by using the Win32 VariantChangeType function.

getVariant(int sa_idx1, int sa_idx2)

Extracts an element of a two-dimensional SafeArray as a Variant.

Syntax

public Variant getVariant(int sa_idx1, int sa_idx2);

Note   Although the Variant methods can operate on any SafeArray type, it is usually much more efficient to use the specific method for the SafeArray type rather than to extract first as a Variant, and then to coerce the Variant. This is true even if the SafeArray is a SafeArray of Variants.

Return Value

Returns the converted element value.

Parameters

sa_idx1 The first dimension index of the element that is extracted, which ranges from LBound(1) to UBound(1).
sa_idx2 The second dimension index of the element that is extracted, which ranges from LBound(2) to UBound(2).

Exceptions

IndexOutOfBoundsException if the array is not two-dimensional or if either index lies outside the defined range.

ClassCastException if the SafeArray element cannot be converted to the correct type by using the Win32 VariantChangeType function.

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