com.mindoo.domino.jna.internal.handles.DHANDLE Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domino-jna Show documentation
Show all versions of domino-jna Show documentation
Java project to access the HCL Domino C API using Java Native Access (JNA)
The newest version!
package com.mindoo.domino.jna.internal.handles;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.mindoo.domino.jna.IAdaptable;
import com.mindoo.domino.jna.errors.NotesError;
import com.mindoo.domino.jna.utils.PlatformUtils;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
public interface DHANDLE extends IAdaptable, IHANDLEBase {
/**
* Returns whether the handle is disposed
*
* @return true if disposed
*/
boolean isDisposed();
/**
* Marks the handle as disposed
*/
void setDisposed();
/**
* Fill handle with a null value
*/
void clear();
/**
* Throws a {@link NotesError} if the handle is marked as disposed
*/
@Override
default void checkDisposed() {
if (isDisposed()) {
throw new NotesError("Handle is already disposed");
}
}
@SuppressWarnings("deprecation")
static DHANDLE newInstance(Pointer peer) {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64(peer);
}
else {
return new DHANDLE32(peer);
}
});
}
@SuppressWarnings("deprecation")
static DHANDLE newInstance() {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64();
}
else {
return new DHANDLE32();
}
});
}
@SuppressWarnings("deprecation")
static DHANDLE.ByReference newInstanceByReference(Pointer peer) {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64.ByReference(peer);
}
else {
return new DHANDLE32.ByReference(peer);
}
});
}
@SuppressWarnings("deprecation")
static DHANDLE.ByReference newInstanceByReference() {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64.ByReference();
}
else {
return new DHANDLE32.ByReference();
}
});
}
@SuppressWarnings("deprecation")
static ByValue newInstanceByValue() {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64.ByValue();
}
else {
return new DHANDLE32.ByValue();
}
});
}
@SuppressWarnings("deprecation")
static ByValue newInstanceByValue(DHANDLE copyHandleValueFrom) {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
DHANDLE64.ByValue newHdl1 = new DHANDLE64.ByValue();
newHdl1.hdl = ((DHANDLE64)copyHandleValueFrom).hdl;
return newHdl1;
}
else {
DHANDLE32.ByValue newHdl2 = new DHANDLE32.ByValue();
newHdl2.hdl = ((DHANDLE32)copyHandleValueFrom).hdl;
return newHdl2;
}
});
}
@SuppressWarnings("deprecation")
static ByValue newInstanceByValue(Pointer peer) {
return AccessController.doPrivileged((PrivilegedAction) () -> {
if (PlatformUtils.is64Bit()) {
return new DHANDLE64.ByValue(peer);
}
else {
return new DHANDLE32.ByValue(peer);
}
});
}
public interface ByReference extends DHANDLE, Structure.ByReference {
public ByValue getByValue();
}
public interface ByValue extends DHANDLE, Structure.ByValue {
}
@Override boolean isNull();
public ByValue getByValue();
}