public class SafeStmtPtr extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SafeStmtPtr.SafePtrConsumer<E extends Throwable> |
static interface |
SafeStmtPtr.SafePtrDoubleFunction<E extends Throwable> |
static interface |
SafeStmtPtr.SafePtrFunction<T,E extends Throwable> |
static interface |
SafeStmtPtr.SafePtrIntFunction<E extends Throwable> |
static interface |
SafeStmtPtr.SafePtrLongFunction<E extends Throwable> |
Constructor and Description |
---|
SafeStmtPtr(DB db,
long ptr)
Construct a new Safe Pointer Wrapper to ensure a pointer is properly handled
|
Modifier and Type | Method and Description |
---|---|
int |
close()
Close this pointer
|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isClosed()
Check whether this pointer has been closed
|
<T,E extends Throwable> |
safeRun(SafeStmtPtr.SafePtrFunction<T,E> run)
Run a callback with the wrapped pointer safely.
|
<E extends Throwable> |
safeRunConsume(SafeStmtPtr.SafePtrConsumer<E> run)
Run a callback with the wrapped pointer safely.
|
<E extends Throwable> |
safeRunDouble(SafeStmtPtr.SafePtrDoubleFunction<E> run)
Run a callback with the wrapped pointer safely.
|
<E extends Throwable> |
safeRunInt(SafeStmtPtr.SafePtrIntFunction<E> run)
Run a callback with the wrapped pointer safely.
|
<E extends Throwable> |
safeRunLong(SafeStmtPtr.SafePtrLongFunction<E> run)
Run a callback with the wrapped pointer safely.
|
public SafeStmtPtr(DB db, long ptr)
db
- the database that made this pointer. Always locked before any safe run function is
executed to avoid deadlocksptr
- the raw pointerpublic boolean isClosed()
public int close() throws SQLException
SQLException
- if the close callback throws an SQLException, or the pointer is locked
elsewherepublic <E extends Throwable> int safeRunInt(SafeStmtPtr.SafePtrIntFunction<E> run) throws SQLException, E extends Throwable
run
- the function to runSQLException
- if the pointer is utilized elsewhereE extends Throwable
public <E extends Throwable> long safeRunLong(SafeStmtPtr.SafePtrLongFunction<E> run) throws SQLException, E extends Throwable
run
- the function to runSQLException
- if the pointer is utilized elsewhereE extends Throwable
public <E extends Throwable> double safeRunDouble(SafeStmtPtr.SafePtrDoubleFunction<E> run) throws SQLException, E extends Throwable
run
- the function to runSQLException
- if the pointer is utilized elsewhereE extends Throwable
public <T,E extends Throwable> T safeRun(SafeStmtPtr.SafePtrFunction<T,E> run) throws SQLException, E extends Throwable
run
- the function to runSQLException
- if the pointer is utilized elsewhereE extends Throwable
public <E extends Throwable> void safeRunConsume(SafeStmtPtr.SafePtrConsumer<E> run) throws SQLException, E extends Throwable
run
- the function to runSQLException
- if the pointer is utilized elsewhereE extends Throwable
Copyright © 2022. All rights reserved.