The SafeArray Class contains the following constructors:
SafeArray(int vt)
SafeArray(int vt, int celems)
SafeArray(int vt, int celems1, int celems2)
SafeArray(int vt, int lbounds[], int celems[])
SafeArray(String s)
getPhysicalSafeArray()
Creates a SafeArray instance that wraps the NULL pointer. The main purpose of this constructor is to pass NULL to Component Object Model (COM) methods that accept SAFEARRAYs.
public SafeArray(int vt);
The variant type of the element must be one of the Variant.VariantXXX constants. Neither the VariantByref nor the VariantArray modifier should be set in the element variant type; setting either of these modifiers will cause a run-time error to occur.
vt | The variant type of the element. |
Creates a one-dimensional SafeArray object. Valid indexes range from zero (inclusive) to celems (exclusive). Note that this convention follows the C language practice of indicating the number of elements rather than the Microsoft® Visual Basic® convention of indicating the upper bound.
The variant type of the element must be one of the Variant.VariantXXX constants. Neither the VariantArray nor the VariantByref modifier can be set.
public SafeArray(int vt, int celems);
vt | The variant type of the element. |
celems | The number of elements. |
Creates a two-dimensional SafeArray object.
public SafeArray(int vt, int celems1, int celems2);
The constructor follows the C language practice of indicating the number of elements rather than the Microsoft® Visual Basic® convention of indicating the upper bound.
The expression:
new SafeArray(Variant.VariantVariant, 21, 11);
is equivalent to the Visual Basic declaration:
Option Base 0 Dim A(20, 10)
The variant type of the element must be one of the Variant.VariantXXX constants. Neither the VariantByref nor the VariantArray modifier should be set in the element variant type; setting either of these modifiers will cause a run-time error to occur.
vt | The variant type of the element. |
celems1 | The number of elements in the first dimension. |
celems2 | The number of elements in the second dimension. |
Creates a SafeArray object of arbitrary shape.
public SafeArray(int vt, int lbounds[], int celems[]);
The lbounds array indicates the lower bound of each dimension. The celems array (which must have the same length as lbounds) gives the number of elements that are in each dimension. If lbounds is null, all the lower bound values default to zero. The variant type of the element must be one of the Variant.VariantXXX constants. Neither the VariantArray nor VariantByref modifier can be set.
The following Java code creates a 3-dimensional SafeArray:
int lbounds[] = {-1,-3, -4}; int celems[] = {10, 20, 30}; SafeArray A = new SafeArray(Variant.VariantVariant, lbounds, celems);
This Visual Basic declaration creates an array with the same shape as the SafeArray created above:
Dim A(-1 To 8, -3 To 16, -4 To 25)
vt | The variant type of the element. |
lbounds | The lower bounds of each dimension. |
celems | The number of elements in each dimension. |
Creates a VT_UI1 SafeArray object from a string.
public SafeArray(String s);
Each character of the string occupies two elements of the array to form a single Unicode character. The array is not null terminated. This constructor corresponds to the standard Automation conversion from VT_BSTR to VT_ARRAY|VT_UI1.
s | The string used to initialize the new SafeArray object. |
Retrieves the linear address of the actual SAFEARRAY data structure, which is packaged as a Java integer. This method is provided only to aid in debugging. Other than displaying information, there are no useful operations that can be performed with this value from Java.
public native int getPhysicalSafeArray();
Returns the linear address of the represented SAFEARRAY.