Class ConnectionAutomatonImpl<CON>

java.lang.Object
org.refcodes.component.ConnectionAutomatonImpl<CON>
Type Parameters:
CON - The type of the connection to be used.
All Implemented Interfaces:
Closable, Closable.CloseAutomaton, ClosedAccessor, ConnectionComponent<CON>, ConnectionComponent.ConnectionAutomaton<CON>, ConnectionOpenable<CON>, ConnectionOpenable.ConnectionOpenAutomaton<CON>, ConnectionStatusAccessor, OpenedAccessor

public class ConnectionAutomatonImpl<CON> extends Object implements ConnectionComponent.ConnectionAutomaton<CON>
  • Field Details

  • Constructor Details

  • Method Details

    • getConnectionStatus

      public ConnectionStatus getConnectionStatus()
      Retrieves the ConnectionStatus property from the property. Determines in which ConnectionStatus status a component is in.
      Specified by:
      getConnectionStatus in interface ConnectionStatusAccessor
      Returns:
      Returns the ConnectionStatus property stored by the property.
    • isOpenable

      public boolean isOpenable(CON aConnection)
      Determines whether the given connection may get opened, if true then component may open a connection with the given connection via the ConnectionOpenable.open(Object) method. Usually no physical connection is established; usually criteria describing the provided connection are evaluated; for example the connection is tested against a black list, a white list or against well-formedness or whether the specified protocols are supported (in case of a connection being a String URL beginning with "http://", "ftp://" or similar). --------------------------------------------------------------------- CAUTION: Even in case true is returned, the actual opening of a connection may fail (e.g. due to network failure or authentication issues). ---------------------------------------------------------------------
      Specified by:
      isOpenable in interface ConnectionOpenable.ConnectionOpenAutomaton<CON>
      Parameters:
      aConnection - The connection for which to determine whether it can be used to open a connection.
      Returns:
      True if ConnectionOpenable.open(Object) is theoretically possible.
    • open

      public void open(CON aConnection) throws IOException
      Opens the component with the given connection.
      Specified by:
      open in interface ConnectionOpenable<CON>
      Parameters:
      aConnection - The connection used for opening the connection.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • isOpened

      public boolean isOpened()
      Retrieves the is-opened property from the opened property. Determines whether the component's connection is opened. A component's connection is opened after being opened as of Openable.open() or ConnectionOpenable.open(Object).
      Specified by:
      isOpened in interface ConnectionStatusAccessor
      Specified by:
      isOpened in interface OpenedAccessor
      Returns:
      True in case of being opened (returns the is-opened property stored by the opened property).
    • isClosable

      public boolean isClosable()
      Determines whether the component's connection(s) may get closed.
      Specified by:
      isClosable in interface Closable.CloseAutomaton
      Returns:
      True if Closable.close() is possible.
    • isClosed

      public boolean isClosed()
      Retrieves the is-closed status. Determines whether the component's connection is closed. A component's connection is closed after being closed as of Closable.close().
      Specified by:
      isClosed in interface ClosedAccessor
      Returns:
      True in case of being closed.
    • close

      public void close() throws IOException
      Closes the component's connection(s). Throws a IOException as upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).
      Specified by:
      close in interface Closable
      Throws:
      IOException - thrown in case closing failed.