Package adams.scripting.connection
Class AbstractConnection
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.connection.AbstractConnection
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Connection
,Serializable
,Comparable<Connection>
- Direct Known Subclasses:
AbstractConnectionEnhancer
,AbstractMultiConnection
,AbstractSSHConnection
,DefaultConnection
,FTPConnection
,Multicast
public abstract class AbstractConnection extends AbstractOptionHandler implements Connection
Ancestor for connections.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractConnection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
checkRequest(RemoteCommand cmd)
Hook method that checks the request command and setup for sending it.protected String
checkResponse(RemoteCommand cmd)
Hook method that checks the response command and setup for sending it.void
cleanUp()
Cleans up data structures, frees up memory.int
compareTo(Connection o)
Compares this connection with the other one using the commandline string.protected abstract String
doSendRequest(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the request command.protected abstract String
doSendResponse(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the response command.boolean
equals(Object o)
Checks whether the object is the same as this one.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.String
sendRequest(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the request command.String
sendResponse(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the response command.String
toString()
Just returns the commandline.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager, toCommandLine
-
-
-
-
Method Detail
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
checkRequest
protected String checkRequest(RemoteCommand cmd)
Hook method that checks the request command and setup for sending it.- Parameters:
cmd
- the command to check- Returns:
- null if successful, otherwise error message
-
doSendRequest
protected abstract String doSendRequest(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the request command.- Parameters:
cmd
- the command to sendprocessor
- the processor for formatting/parsing- Returns:
- null if successful, otherwise error message
-
sendRequest
public String sendRequest(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the request command.- Specified by:
sendRequest
in interfaceConnection
- Parameters:
cmd
- the command to sendprocessor
- the processor for formatting/parsing- Returns:
- null if successful, otherwise error message
-
checkResponse
protected String checkResponse(RemoteCommand cmd)
Hook method that checks the response command and setup for sending it.- Parameters:
cmd
- the command to check- Returns:
- null if successful, otherwise error message
-
doSendResponse
protected abstract String doSendResponse(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the response command.- Parameters:
cmd
- the command to sendprocessor
- the processor for formatting/parsing- Returns:
- null if successful, otherwise error message
-
sendResponse
public String sendResponse(RemoteCommand cmd, RemoteCommandProcessor processor)
Sends the response command.- Specified by:
sendResponse
in interfaceConnection
- Parameters:
cmd
- the command to sendprocessor
- the processor for formatting/parsing- Returns:
- null if successful, otherwise error message
-
compareTo
public int compareTo(Connection o)
Compares this connection with the other one using the commandline string.- Specified by:
compareTo
in interfaceComparable<Connection>
- Parameters:
o
- the other connection- Returns:
- less than zero, equal to zero or greater than zero if the commandline string is less, equal or greater than this one
-
equals
public boolean equals(Object o)
Checks whether the object is the same as this one.- Overrides:
equals
in classObject
- Parameters:
o
- the other object- Returns:
- true if also a connection object and the same commandline
- See Also:
compareTo(Connection)
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
Default implementation does nothing.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
toString
public String toString()
Just returns the commandline.- Overrides:
toString
in classAbstractOptionHandler
- Returns:
- the commandline
-
-