org.firebirdsql.gds.ng

## Class AbstractFbAttachment<T extends AbstractConnection<? extends IAttachProperties,? extends FbAttachment>>

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractFbAttachment<T>

- All Implemented Interfaces:
    java.lang.AutoCloseable, FbAttachment, ExceptionListenable
  Direct Known Subclasses:
    AbstractFbDatabase, AbstractFbService

      public abstract class AbstractFbAttachment<T extends AbstractConnection<? extends IAttachProperties,? extends FbAttachment>>
      extends java.lang.Object
      implements FbAttachment

  Common behavior for `AbstractFbService` and `AbstractFbDatabase`.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected T` | `connection`
    `protected ExceptionListenerDispatcher` | `exceptionListenerDispatcher`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractFbAttachment(T connection, DatatypeCoder datatypeCoder)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addExceptionListener(ExceptionListener listener)` Adds an exception listener to this object.
    `protected abstract void` | `checkConnected()` Checks if the attachment is connected, and throws a `SQLException` if it isn't connected.
    `protected DbCryptCallback` | `createDbCryptCallback()` Creates an instance of `DbCryptCallback` for this attachment.
    `DatatypeCoder` | `getDatatypeCoder()`
    `Encoding` | `getEncoding()`
    `IEncodingFactory` | `getEncodingFactory()`
    `GDSServerVersion` | `getServerVersion()`
    `protected org.firebirdsql.gds.ng.ServerVersionInformation` | `getServerVersionInformation()`
    `java.lang.Object` | `getSynchronizationObject()` Get synchronization object.
    `boolean` | `isAttached()` Current attachment status.
    `void` | `removeExceptionListener(ExceptionListener listener)` Removes an exception listener to this object.
    `protected void` | `safelyDetach()` Performs `FbAttachment.close()` suppressing any exception.
    `protected void` | `setAttached()` Called when this attachment is attached.
    `protected void` | `setDetached()` Called when this attachment is detached.
    `protected void` | `setServerVersion(java.lang.String... versionStrings)` Sets the Firebird version from one or more version string elements.

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

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

    - ### Methods inherited from interface org.firebirdsql.gds.ng.FbAttachment

      `attach, close, getHandle`

- - ### Field Detail

    - #### exceptionListenerDispatcher

          protected final ExceptionListenerDispatcher exceptionListenerDispatcher

    - #### connection

          protected final T extends AbstractConnection<? extends IAttachProperties,? extends FbAttachment> connection

  - ### Constructor Detail

    - #### AbstractFbAttachment

          protected AbstractFbAttachment(T connection,
                              DatatypeCoder datatypeCoder)

  - ### Method Detail

    - #### getServerVersion

          public GDSServerVersion getServerVersion()

      Specified by:
        `getServerVersion` in interface `FbAttachment`
      Returns:
        Firebird version string

    - #### setServerVersion

          protected final void setServerVersion(java.lang.String... versionStrings)

      Sets the Firebird version from one or more version string elements.

      This method should only be called by this instance.

      Parameters:
        `versionStrings` - Raw version strings

    - #### getServerVersionInformation

          protected org.firebirdsql.gds.ng.ServerVersionInformation getServerVersionInformation()

    - #### setAttached

          protected final void setAttached()

      Called when this attachment is attached.

      Only this `AbstractFbDatabase` instance should call this method.

    - #### isAttached

          public boolean isAttached()

      Description copied from interface: `FbAttachment`
      Current attachment status.
      Specified by:
        `isAttached` in interface `FbAttachment`
      Returns:
        `true` if connected to the server and attached to a database or service, `false` otherwise.

    - #### setDetached

          protected final void setDetached()

      Called when this attachment is detached.

      Only this `AbstractFbAttachment` instance should call this method.

    - #### getSynchronizationObject

          public final java.lang.Object getSynchronizationObject()

      Description copied from interface: `FbAttachment`
      Get synchronization object.
      Specified by:
        `getSynchronizationObject` in interface `FbAttachment`
      Returns:
        object, cannot be `null`.

    - #### getEncodingFactory

          public final IEncodingFactory getEncodingFactory()

      Specified by:
        `getEncodingFactory` in interface `FbAttachment`
      Returns:
        The `IEncodingFactory` for this connection

    - #### getEncoding

          public final Encoding getEncoding()

      Specified by:
        `getEncoding` in interface `FbAttachment`
      Returns:
        The connection encoding (should be the same as returned from calling `IEncodingFactory.getDefaultEncoding()` on the result of `FbAttachment.getEncodingFactory()`.

    - #### getDatatypeCoder

          public final DatatypeCoder getDatatypeCoder()

      Specified by:
        `getDatatypeCoder` in interface `FbAttachment`
      Returns:
        The `DatatypeCoder` for this database implementation.

    - #### addExceptionListener

          public final void addExceptionListener(ExceptionListener listener)

      Description copied from interface: `ExceptionListenable`
      Adds an exception listener to this object.

      Implementations use `WeakReference`.

      Specified by:
        `addExceptionListener` in interface `ExceptionListenable`
      Parameters:
        `listener` - Listener to register

    - #### removeExceptionListener

          public final void removeExceptionListener(ExceptionListener listener)

      Description copied from interface: `ExceptionListenable`
      Removes an exception listener to this object.
      Specified by:
        `removeExceptionListener` in interface `ExceptionListenable`
      Parameters:
        `listener` - Listener to remove

    - #### checkConnected

          protected abstract void checkConnected()
                                          throws java.sql.SQLException

      Checks if the attachment is connected, and throws a `SQLException` if it isn't connected.
      Throws:
        `java.sql.SQLException`

    - #### safelyDetach

          protected final void safelyDetach()

      Performs `FbAttachment.close()` suppressing any exception.

    - #### createDbCryptCallback

          protected final DbCryptCallback createDbCryptCallback()
                                                         throws java.sql.SQLException

      Creates an instance of `DbCryptCallback` for this attachment.
      Returns:
        Database encryption callback.
      Throws:
        `java.sql.SQLException` - For errors initializing the callback

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.