org.sqlite.core

## Class SafeStmtPtr

- java.lang.Object
- - org.sqlite.core.SafeStmtPtr

    public class SafeStmtPtr
    extends Object

A class for safely wrapping calls to a native pointer to a statement, ensuring no other thread has access to the pointer while it is run

### Nested Class Summary

Nested Classes
`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 Summary

Constructors
Constructor and Description
`SafeStmtPtr(DB db, long ptr)` Construct a new Safe Pointer Wrapper to ensure a pointer is properly handled

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `close()` Close this pointer
`boolean` `equals(Object o)`
`int` `hashCode()`
`boolean` `isClosed()` Check whether this pointer has been closed
`<T,E extends Throwable> T` `safeRun(SafeStmtPtr.SafePtrFunction<T,E> run)` Run a callback with the wrapped pointer safely.
`<E extends Throwable> void` `safeRunConsume(SafeStmtPtr.SafePtrConsumer<E> run)` Run a callback with the wrapped pointer safely.
`<E extends Throwable> double` `safeRunDouble(SafeStmtPtr.SafePtrDoubleFunction<E> run)` Run a callback with the wrapped pointer safely.
`<E extends Throwable> int` `safeRunInt(SafeStmtPtr.SafePtrIntFunction<E> run)` Run a callback with the wrapped pointer safely.
`<E extends Throwable> long` `safeRunLong(SafeStmtPtr.SafePtrLongFunction<E> run)` Run a callback with the wrapped pointer safely.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SafeStmtPtr

    public SafeStmtPtr(DB db,
                       long ptr)

Construct a new Safe Pointer Wrapper to ensure a pointer is properly handled

Parameters:
  `db` - the database that made this pointer. Always locked before any safe run function is executed to avoid deadlocks
  `ptr` - the raw pointer

### Method Detail

#### isClosed

    public boolean isClosed()

Check whether this pointer has been closed

Returns:
  whether this pointer has been closed

#### close

    public int close()
              throws SQLException

Close this pointer

Returns:
  the return code of the close callback function
Throws:
  `SQLException` - if the close callback throws an SQLException, or the pointer is locked elsewhere

#### safeRunInt

    public <E extends Throwable> int safeRunInt(SafeStmtPtr.SafePtrIntFunction<E> run)
                                         throws SQLException,
                                                E extends Throwable

Run a callback with the wrapped pointer safely.

Parameters:
  `run` - the function to run
Returns:
  the return of the passed in function
Throws:
  `SQLException` - if the pointer is utilized elsewhere
  `E extends Throwable`

#### safeRunLong

    public <E extends Throwable> long safeRunLong(SafeStmtPtr.SafePtrLongFunction<E> run)
                                           throws SQLException,
                                                  E extends Throwable

Run a callback with the wrapped pointer safely.

Parameters:
  `run` - the function to run
Returns:
  the return of the passed in function
Throws:
  `SQLException` - if the pointer is utilized elsewhere
  `E extends Throwable`

#### safeRunDouble

    public <E extends Throwable> double safeRunDouble(SafeStmtPtr.SafePtrDoubleFunction<E> run)
                                               throws SQLException,
                                                      E extends Throwable

Run a callback with the wrapped pointer safely.

Parameters:
  `run` - the function to run
Returns:
  the return of the passed in function
Throws:
  `SQLException` - if the pointer is utilized elsewhere
  `E extends Throwable`

#### safeRun

    public <T,E extends Throwable> T safeRun(SafeStmtPtr.SafePtrFunction<T,E> run)
                                      throws SQLException,
                                             E extends Throwable

Run a callback with the wrapped pointer safely.

Parameters:
  `run` - the function to run
Returns:
  the return code of the function
Throws:
  `SQLException` - if the pointer is utilized elsewhere
  `E extends Throwable`

#### safeRunConsume

    public <E extends Throwable> void safeRunConsume(SafeStmtPtr.SafePtrConsumer<E> run)
                                              throws SQLException,
                                                     E extends Throwable

Run a callback with the wrapped pointer safely.

Parameters:
  `run` - the function to run
Throws:
  `SQLException` - if the pointer is utilized elsewhere
  `E extends Throwable`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`