Package adams.flow.standalone.rats.input
Class AbstractRatInput
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.input.AbstractRatInput
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.QuickInfoSupporter
,adams.core.ShallowCopySupporter<AbstractRatInput>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,RatInput
,Serializable
- Direct Known Subclasses:
AbstractBufferedRatInput
,AbstractMetaRatInput
,AbstractPollingRatInput
,DeQueue
,DirWatch
,DummyCronInput
,DummyInput
,Exec
,FileLister
,RedisAction
,Storage
,StringToken
,Variable
public abstract class AbstractRatInput extends adams.core.option.AbstractOptionHandler implements RatInput, adams.core.ShallowCopySupporter<AbstractRatInput>, adams.core.QuickInfoSupporter, adams.core.CleanUpHandler
Ancestor for input receivers.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_LoggingPrefix
the logging prefix.protected Rat
m_Owner
the owner.protected boolean
m_ReceptionInterrupted
whether reception was interrupted.protected boolean
m_ReceptionRunning
whether reception is currently underway.protected boolean
m_Stopped
whether the reception was stopped.
-
Constructor Summary
Constructors Constructor Description AbstractRatInput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
canReceive()
Whether reception is possible.protected String
check()
Hook method for performing checks before receiving data.void
cleanUp()
Cleans up data structures, frees up memory.protected void
configureLogger()
Initializes the logger.protected abstract String
doReceive()
Performs the actual reception of data.protected void
doWait(int msec)
A simple waiting method.abstract Class
generates()
Returns the type of data this scheme generates.String
getAdditionalInformation()
Returns the additional information.String
getFullName()
Returns the full name of the receiver.Rat
getOwner()
Returns the actor the receiver belongs to.protected adams.flow.control.StorageQueueHandler
getQueue(adams.flow.control.StorageName name)
Returns the flow's queue.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
getReceptionInterrupted()
Returns whether the reception was interrupted.protected String
handleException(String msg, Throwable t)
Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.abstract boolean
hasPendingOutput()
Checks whether any output can be collected.protected void
initialize()
Initializes the members.String
initReception()
Initializes the reception.void
interruptReception()
Interrupts the reception (eg when pausing).boolean
isReceptionRunning()
Returns whether the reception is currently running.boolean
isStopped()
Returns whether the receiver has been stopped.abstract Object
output()
Returns the received data.String
receive()
Initiates the reception of data.void
setOwner(Rat value)
Sets the actor the receiver belongs to.String
setUp()
Hook method for performing checks at setup time.AbstractRatInput
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractRatInput
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.void
stopExecution()
Stops the execution.protected void
updatePrefix()
Updates the prefix of the logger.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Owner
protected Rat m_Owner
the owner.
-
m_Stopped
protected boolean m_Stopped
whether the reception was stopped.
-
m_LoggingPrefix
protected String m_LoggingPrefix
the logging prefix.
-
m_ReceptionRunning
protected boolean m_ReceptionRunning
whether reception is currently underway.
-
m_ReceptionInterrupted
protected boolean m_ReceptionInterrupted
whether reception was interrupted.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.core.option.AbstractOptionHandler
-
configureLogger
protected void configureLogger()
Initializes the logger.- Overrides:
configureLogger
in classadams.core.logging.LoggingObject
-
getFullName
public String getFullName()
Returns the full name of the receiver.- Specified by:
getFullName
in interfaceRatInput
- Returns:
- the name
-
updatePrefix
protected void updatePrefix()
Updates the prefix of the logger.
-
setOwner
public void setOwner(Rat value)
Sets the actor the receiver belongs to.
-
getOwner
public Rat getOwner()
Returns the actor the receiver belongs to.
-
handleException
protected String handleException(String msg, Throwable t)
Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.- Parameters:
msg
- the message for the exceptiont
- the exception- Returns:
- the full error message (message + stacktrace)
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformation
in interfaceadams.core.AdditionalInformationHandler
- Returns:
- the additional information, null or 0-length string for no information
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
generates
public abstract Class generates()
Returns the type of data this scheme generates.
-
hasPendingOutput
public abstract boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutput
in interfaceRatInput
- Returns:
- true if output available
-
output
public abstract Object output()
Returns the received data.
-
setUp
public String setUp()
Hook method for performing checks at setup time.
-
check
protected String check()
Hook method for performing checks before receiving data.
Default implementation returns null.- Returns:
- null if successful, otherwise error message
-
doWait
protected void doWait(int msec)
A simple waiting method.- Parameters:
msec
- the maximum number of milli-seconds to wait, no waiting if 0
-
getQueue
protected adams.flow.control.StorageQueueHandler getQueue(adams.flow.control.StorageName name)
Returns the flow's queue.- Parameters:
name
- the name of the queue- Returns:
- the queue, null if not initialized
- See Also:
QueueInit
-
initReception
public String initReception()
Initializes the reception.- Specified by:
initReception
in interfaceRatInput
- Returns:
- null if successfully initialized, otherwise error message
-
doReceive
protected abstract String doReceive()
Performs the actual reception of data.- Returns:
- null if successful, otherwise error message
-
interruptReception
public void interruptReception()
Interrupts the reception (eg when pausing).- Specified by:
interruptReception
in interfaceRatInput
-
getReceptionInterrupted
public boolean getReceptionInterrupted()
Returns whether the reception was interrupted.- Specified by:
getReceptionInterrupted
in interfaceRatInput
- Returns:
- true if interrupted
-
isReceptionRunning
public boolean isReceptionRunning()
Returns whether the reception is currently running.- Specified by:
isReceptionRunning
in interfaceRatInput
- Returns:
- true if running
-
canReceive
protected boolean canReceive()
Whether reception is possible.- Returns:
- true if possible
- See Also:
m_Stopped
,m_ReceptionInterrupted
-
receive
public String receive()
Initiates the reception of data.
-
shallowCopy
public AbstractRatInput shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractRatInput>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractRatInput shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractRatInput>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceRatInput
- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Returns whether the receiver has been stopped.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
-
-