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,IMAP,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 Stringm_LoggingPrefixthe logging prefix.protected Ratm_Ownerthe owner.protected booleanm_ReceptionInterruptedwhether reception was interrupted.protected booleanm_ReceptionRunningwhether reception is currently underway.protected booleanm_Stoppedwhether 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 booleancanReceive()Whether reception is possible.protected Stringcheck()Hook method for performing checks before receiving data.voidcleanUp()Cleans up data structures, frees up memory.protected voidconfigureLogger()Initializes the logger.protected abstract StringdoReceive()Performs the actual reception of data.protected voiddoWait(int msec)A simple waiting method.abstract Classgenerates()Returns the type of data this scheme generates.StringgetAdditionalInformation()Returns the additional information.StringgetFullName()Returns the full name of the receiver.RatgetOwner()Returns the actor the receiver belongs to.protected adams.flow.control.StorageQueueHandlergetQueue(adams.flow.control.StorageName name)Returns the flow's queue.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.booleangetReceptionInterrupted()Returns whether the reception was interrupted.protected StringhandleException(String msg, Throwable t)Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.abstract booleanhasPendingOutput()Checks whether any output can be collected.protected voidinitialize()Initializes the members.StringinitReception()Initializes the reception.voidinterruptReception()Interrupts the reception (eg when pausing).booleanisReceptionRunning()Returns whether the reception is currently running.booleanisStopped()Returns whether the receiver has been stopped.abstract Objectoutput()Returns the received data.Stringreceive()Initiates the reception of data.voidsetOwner(Rat value)Sets the actor the receiver belongs to.StringsetUp()Hook method for performing checks at setup time.AbstractRatInputshallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.AbstractRatInputshallowCopy(boolean expand)Returns a shallow copy of itself, i.e., based on the commandline options.voidstopExecution()Stops the execution.protected voidupdatePrefix()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:
initializein classadams.core.option.AbstractOptionHandler
-
configureLogger
protected void configureLogger()
Initializes the logger.- Overrides:
configureLoggerin classadams.core.logging.LoggingObject
-
getFullName
public String getFullName()
Returns the full name of the receiver.- Specified by:
getFullNamein 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:
getAdditionalInformationin 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:
getQuickInfoin 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:
hasPendingOutputin 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:
initReceptionin 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:
interruptReceptionin interfaceRatInput
-
getReceptionInterrupted
public boolean getReceptionInterrupted()
Returns whether the reception was interrupted.- Specified by:
getReceptionInterruptedin interfaceRatInput- Returns:
- true if interrupted
-
isReceptionRunning
public boolean isReceptionRunning()
Returns whether the reception is currently running.- Specified by:
isReceptionRunningin 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:
shallowCopyin 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:
shallowCopyin 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:
stopExecutionin interfaceRatInput- Specified by:
stopExecutionin 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:
cleanUpin interfaceadams.core.CleanUpHandler
-
-