Class ConnectionEvent

  • All Implemented Interfaces:
    java.io.Serializable

    public class ConnectionEvent
    extends java.util.EventObject
    An event that is generated when a connection is established or dropped.
    Version:
    $Revision: 1.2 $
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    ConnectionListener, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CONNECT
      it was a connect try
      static int DISCONNECT
      it was a disconnect
    • Constructor Summary

      Constructors 
      Constructor Description
      ConnectionEvent​(java.lang.Object source, int type, DbUtils utils)
      constructs the event
      ConnectionEvent​(java.lang.Object source, int type, DbUtils utils, java.lang.Exception ex)
      constructs the event
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean failed()
      whether an exception happened and is stored
      DbUtils getDbUtils()
      returns the DbUtils instance that is responsible for the connect/disconnect.
      java.lang.Exception getException()
      returns the stored exception, if any (can be NULL)
      int getType()
      returns the type of this event, CONNECT or DISCONNECT
      boolean isConnected()
      returns whether the connection is still open.
      java.lang.String toString()
      returns the event in a string representation
      • Methods inherited from class java.util.EventObject

        getSource
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConnectionEvent

        public ConnectionEvent​(java.lang.Object source,
                               int type,
                               DbUtils utils)
        constructs the event
        Parameters:
        source - the source that generated this event
        type - whether CONNECT or DISCONNECT happened
        utils - the DatabaseUtils isntance responsible for the connection
      • ConnectionEvent

        public ConnectionEvent​(java.lang.Object source,
                               int type,
                               DbUtils utils,
                               java.lang.Exception ex)
        constructs the event
        Parameters:
        source - the source that generated this event
        type - whether CONNECT or DISCONNECT happened
        utils - the DatabaseUtils isntance responsible for the connection
        ex - a possible exception, if not successful
    • Method Detail

      • getType

        public int getType()
        returns the type of this event, CONNECT or DISCONNECT
        Returns:
        the type of this event
        See Also:
        CONNECT, DISCONNECT
      • failed

        public boolean failed()
        whether an exception happened and is stored
        Returns:
        whether an exception happened
      • isConnected

        public boolean isConnected()
        returns whether the connection is still open.
        Returns:
        whether the connection is still open
      • getException

        public java.lang.Exception getException()
        returns the stored exception, if any (can be NULL)
      • getDbUtils

        public DbUtils getDbUtils()
        returns the DbUtils instance that is responsible for the connect/disconnect.
        Returns:
        the responsible DbUtils instance
      • toString

        public java.lang.String toString()
        returns the event in a string representation
        Overrides:
        toString in class java.util.EventObject
        Returns:
        the event in a string representation