public static class OaIdl.SAFEARRAY extends Structure implements Closeable
VARTYPE for the SAFEARRAY can be:
General comment: All indices in the helper methods use java int.
The native type for the indices is LONG, which is defined as:
A 32-bit signed integer. The range is �2147483648 through 2147483647 decimal.
Modifier and Type | Class and Description |
---|---|
static class |
OaIdl.SAFEARRAY.ByReference |
Structure.ByValue, Structure.StructField
Modifier and Type | Field and Description |
---|---|
WinDef.ULONG |
cbElements |
WinDef.USHORT |
cDims |
WinDef.ULONG |
cLocks |
WinDef.USHORT |
fFeatures |
static List<String> |
FIELDS |
WinDef.PVOID |
pvData |
OaIdl.SAFEARRAYBOUND[] |
rgsabound
The rgsabound.
|
ALIGN_DEFAULT, ALIGN_GNUC, ALIGN_MSVC, ALIGN_NONE, CALCULATE_SIZE
Modifier and Type | Method and Description |
---|---|
Pointer |
accessData()
Lock array and retrieve pointer to data
|
void |
close()
Implemented to satisfy Closeable interface, delegates to destroy.
|
static OaIdl.SAFEARRAY |
createSafeArray(int... size)
Create a SAFEARRAY with supplied VARIANT as element type.
|
static OaIdl.SAFEARRAY |
createSafeArray(WTypes.VARTYPE vartype,
int... size)
Create a SAFEARRAY with supplied element type.
|
void |
destroy()
Destroy the underlying SAFEARRAY and free memory
|
int |
getDimensionCount()
Return number of dimensions of the SAFEARRAY
|
Object |
getElement(int... indices)
Retrieve the value at the referenced index from the SAFEARRAY.
|
long |
getElemsize()
Get size of one element in bytes
|
protected List<String> |
getFieldOrder()
Return this Structure's field names in their proper order.
|
int |
getLBound(int dimension)
Retrieve lower bound for the selected dimension.
|
int |
getUBound(int dimension)
Retrieve upper bound for the selected dimension.
|
WTypes.VARTYPE |
getVarType()
Return VARTYPE of the SAFEARRAY
|
void |
lock()
Increments the lock count of an array, and places a pointer to the
array data in pvData of the array descriptor.
|
Pointer |
ptrOfIndex(int... indices)
Retrieve pointer to data element from array.
|
void |
putElement(Object arg,
int... indices)
Set value at
indices in array to arg. |
void |
read()
Reads the fields of the struct from native memory
|
void |
redim(int cElements,
int lLbound)
Changes the right-most (least significant) bound of the specified
safe array.
|
void |
unaccessData()
Unlock array and invalidate the pointer retrieved via
SafeArrayAccessData
|
void |
unlock()
Decrements the lock count of an array so it can be freed or resized
|
allocateMemory, allocateMemory, autoAllocate, autoRead, autoRead, autoWrite, autoWrite, cacheTypeInfo, calculateSize, clear, createFieldsOrder, createFieldsOrder, createFieldsOrder, createFieldsOrder, dataEquals, dataEquals, ensureAllocated, equals, fieldOffset, getAutoRead, getAutoWrite, getFieldList, getFields, getNativeAlignment, getNativeSize, getNativeSize, getPointer, getStringEncoding, getStructAlignment, hashCode, newInstance, newInstance, readField, readField, setAlignType, setAutoRead, setAutoSynch, setAutoWrite, setFieldOrder, setStringEncoding, size, sortFields, toArray, toArray, toString, toString, useMemory, useMemory, write, writeField, writeField, writeField
public WinDef.USHORT cDims
public WinDef.USHORT fFeatures
public WinDef.ULONG cbElements
public WinDef.ULONG cLocks
public WinDef.PVOID pvData
public OaIdl.SAFEARRAYBOUND[] rgsabound
public SAFEARRAY()
public SAFEARRAY(Pointer pointer)
public void read()
Structure
protected List<String> getFieldOrder()
Structure
protected List getFieldOrder() {
return Arrays.asList(new String[] { ... });
}
IMPORTANT
When deriving from an existing Structure subclass, ensure that
you augment the list provided by the superclass, e.g.
protected List getFieldOrder() {
List fields = new ArrayList(super.getFieldOrder());
fields.addAll(Arrays.asList(new String[] { ... }));
return fields;
}
Field order must be explicitly indicated, since the
field order as returned by Class.getFields()
is not
guaranteed to be predictable.getFieldOrder
in class Structure
public static OaIdl.SAFEARRAY createSafeArray(int... size)
This helper creates a basic SAFEARRAY with a base type of VT_VARIANT. The array will have as many dimensions as parameters are passed in. The lowerbound for each dimension is set to zero, the count to the parameter value.
size
- array of dimension sizeNULL
if creation fails.public static OaIdl.SAFEARRAY createSafeArray(WTypes.VARTYPE vartype, int... size)
The array will have as many dimensions as parameters are passed in. The lowerbound for each dimension is set to zero, the count to the parameter value.
vartype
- type of array contents (see Variant.VT_* constants)size
- array of dimension sizeNULL
if creation fails.public void putElement(Object arg, int... indices)
indices
in array
to arg.
The supplied argument is copied into the array. If the value is no longer needed, it needs to be freed if not handled automatically.
indices
- the index, order follows java/C conventionarg
- the argpublic Object getElement(int... indices)
The function creates a copy of the value. The values are allocated with native functions and need to be freed accordingly.
indices
- the index, order follows java/C conventionpublic Pointer ptrOfIndex(int... indices)
Caller is responsible for (un)locking the array via
OleAuto.SafeArrayLock(com.sun.jna.platform.win32.OaIdl.SAFEARRAY)
and OleAuto.SafeArrayUnlock(com.sun.jna.platform.win32.OaIdl.SAFEARRAY)
or
the helper methods: lock()
and
unlock()
.
indices
- the index, order follows java/C conventionpublic void destroy()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public int getLBound(int dimension)
As in the all the accessor functions, that index is converted to java conventions.
dimension
- zerobased indexpublic int getUBound(int dimension)
As in the all the accessor functions, that index is converted to java conventions.
dimension
- zerobased indexpublic int getDimensionCount()
public Pointer accessData()
public void unaccessData()
public void lock()
public void unlock()
public void redim(int cElements, int lLbound)
cElements
- lLbound
- public WTypes.VARTYPE getVarType()
public long getElemsize()