Package adams.flow.standalone.rats.input
Class DirWatch
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.input.AbstractRatInput
-
- adams.flow.standalone.rats.input.DirWatch
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler,adams.core.AtomicMoveSupporter,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
public class DirWatch extends AbstractRatInput implements adams.core.AtomicMoveSupporter
Watches for file changes in a directory and forwards the affected files.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-source <adams.core.io.PlaceholderDirectory> (property: source) The directory to watch. default: ${CWD}-event <CREATE|MODIFY|DELETE> [-event ...] (property: events) The kind of events to report. default: CREATE
-wait-poll <int> (property: waitPoll) The number of milli-seconds to wait before polling again whether files have arrived. default: 50 minimum: 0
-wait-list <int> (property: waitList) The number of milli-seconds to wait after listing the files. default: 0 minimum: 0
-move-files <boolean> (property: moveFiles) If enabled, the files get moved to the specified directory first before being transmitted (with their new filename). default: false
-atomic-move <boolean> (property: atomicMove) If true, then an atomic move operation will be attempted (NB: not supported by all operating systems). default: false
-target <adams.core.io.PlaceholderDirectory> (property: target) The directory to move the files to before transmitting their names. default: ${CWD}- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_AtomicMovewhether to perform an atomic move.protected adams.core.io.WatchEventKind[]m_Eventsthe events to look for.protected List<String>m_Filesthe files that were picked up by the watch service.protected booleanm_MoveFileswhether to move the files before transmitting them.protected adams.core.base.BaseRegExpm_RegExpthe regular expression to match the file names against.protected adams.core.io.PlaceholderDirectorym_Sourcethe directory to watch.protected adams.core.io.PlaceholderDirectorym_Targetthe directory to move the files to.protected intm_WaitPollthe waiting period in msec before polling again.protected WatchServicem_Watchthe watch service.-
Fields inherited from class adams.flow.standalone.rats.input.AbstractRatInput
m_LoggingPrefix, m_Owner, m_ReceptionInterrupted, m_ReceptionRunning, m_Stopped
-
-
Constructor Summary
Constructors Constructor Description DirWatch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringatomicMoveTipText()Returns the tip text for this property.Stringcheck()Hook method for performing checks.voiddefineOptions()Adds options to the internal list of options.protected StringdoReceive()Performs the actual reception of data.StringeventsTipText()Returns the tip text for this property.Classgenerates()Returns the type of data this scheme generates.booleangetAtomicMove()Returns whether to attempt atomic move operation.adams.core.io.WatchEventKind[]getEvents()Returns the events to report.booleangetMoveFiles()Returns whether to move the files to the specified target directory before transmitting them.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.adams.core.base.BaseRegExpgetRegExp()Returns the regular expression to match the filenames against (name only, not path).adams.core.io.PlaceholderDirectorygetSource()Returns the incoming directory.adams.core.io.PlaceholderDirectorygetTarget()Returns the move-to directory.intgetWaitPoll()Returns the number of milli-seconds to wait before polling again whether files have arrived.StringglobalInfo()Returns a string describing the object.booleanhasPendingOutput()Checks whether any output can be collected.protected voidinitialize()Initializes the members.StringmoveFilesTipText()Returns the tip text for this property.Objectoutput()Returns the received data.StringregExpTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetAtomicMove(boolean value)Sets whether to attempt atomic move operation.voidsetEvents(adams.core.io.WatchEventKind[] value)Sets the events to report.voidsetMoveFiles(boolean value)Sets whether to move the files to the specified target directory before transmitting them.voidsetRegExp(adams.core.base.BaseRegExp value)Sets the regular expression to match the filenames against (name only, not path).voidsetSource(adams.core.io.PlaceholderDirectory value)Sets the incoming directory.voidsetTarget(adams.core.io.PlaceholderDirectory value)Sets the move-to directory.voidsetWaitPoll(int value)Sets the number of milli-seconds to wait before polling whether files have arrived.StringsourceTipText()Returns the tip text for this property.voidstopExecution()Stops the execution.protected voidstopWatchService()Stops the watch service, if active.StringtargetTipText()Returns the tip text for this property.StringwaitPollTipText()Returns the tip text for this property.-
Methods inherited from class adams.flow.standalone.rats.input.AbstractRatInput
canReceive, cleanUp, configureLogger, doWait, getAdditionalInformation, getFullName, getOwner, getQueue, getReceptionInterrupted, handleException, initReception, interruptReception, isReceptionRunning, isStopped, receive, setOwner, setUp, shallowCopy, shallowCopy, updatePrefix
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Source
protected adams.core.io.PlaceholderDirectory m_Source
the directory to watch.
-
m_Events
protected adams.core.io.WatchEventKind[] m_Events
the events to look for.
-
m_WaitPoll
protected int m_WaitPoll
the waiting period in msec before polling again.
-
m_RegExp
protected adams.core.base.BaseRegExp m_RegExp
the regular expression to match the file names against.
-
m_MoveFiles
protected boolean m_MoveFiles
whether to move the files before transmitting them.
-
m_AtomicMove
protected boolean m_AtomicMove
whether to perform an atomic move.
-
m_Target
protected adams.core.io.PlaceholderDirectory m_Target
the directory to move the files to.
-
m_Watch
protected transient WatchService m_Watch
the watch service.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractRatInput
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classadams.core.option.AbstractOptionHandler
-
setSource
public void setSource(adams.core.io.PlaceholderDirectory value)
Sets the incoming directory.- Parameters:
value- the incoming directory
-
getSource
public adams.core.io.PlaceholderDirectory getSource()
Returns the incoming directory.- Returns:
- the incoming directory.
-
sourceTipText
public String sourceTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setEvents
public void setEvents(adams.core.io.WatchEventKind[] value)
Sets the events to report.- Parameters:
value- the events
-
getEvents
public adams.core.io.WatchEventKind[] getEvents()
Returns the events to report.- Returns:
- the events
-
eventsTipText
public String eventsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWaitPoll
public void setWaitPoll(int value)
Sets the number of milli-seconds to wait before polling whether files have arrived.- Parameters:
value- the number of milli-seconds
-
getWaitPoll
public int getWaitPoll()
Returns the number of milli-seconds to wait before polling again whether files have arrived.- Returns:
- the number of milli-seconds
-
waitPollTipText
public String waitPollTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRegExp
public void setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression to match the filenames against (name only, not path).- Parameters:
value- the expression
-
getRegExp
public adams.core.base.BaseRegExp getRegExp()
Returns the regular expression to match the filenames against (name only, not path).- Returns:
- the expression
-
regExpTipText
public String regExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMoveFiles
public void setMoveFiles(boolean value)
Sets whether to move the files to the specified target directory before transmitting them.- Parameters:
value- true if to move files
-
getMoveFiles
public boolean getMoveFiles()
Returns whether to move the files to the specified target directory before transmitting them.- Returns:
- true if to move files
-
moveFilesTipText
public String moveFilesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAtomicMove
public void setAtomicMove(boolean value)
Sets whether to attempt atomic move operation.- Specified by:
setAtomicMovein interfaceadams.core.AtomicMoveSupporter- Parameters:
value- if true then attempt atomic move operation
-
getAtomicMove
public boolean getAtomicMove()
Returns whether to attempt atomic move operation.- Specified by:
getAtomicMovein interfaceadams.core.AtomicMoveSupporter- Returns:
- true if to attempt atomic move operation
-
atomicMoveTipText
public String atomicMoveTipText()
Returns the tip text for this property.- Specified by:
atomicMoveTipTextin interfaceadams.core.AtomicMoveSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTarget
public void setTarget(adams.core.io.PlaceholderDirectory value)
Sets the move-to directory.- Parameters:
value- the move-to directory
-
getTarget
public adams.core.io.PlaceholderDirectory getTarget()
Returns the move-to directory.- Returns:
- the move-to directory.
-
targetTipText
public String targetTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Overrides:
getQuickInfoin classAbstractRatInput- Returns:
- null if no info available, otherwise short string
-
generates
public Class generates()
Returns the type of data this scheme generates.- Specified by:
generatesin interfaceRatInput- Specified by:
generatesin classAbstractRatInput- Returns:
- the type of data
-
check
public String check()
Hook method for performing checks. Makes sure that directories exist.- Overrides:
checkin classAbstractRatInput- Returns:
- null if successful, otherwise error message
-
doReceive
protected String doReceive()
Performs the actual reception of data.- Specified by:
doReceivein classAbstractRatInput- Returns:
- null if successful, otherwise error message
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutputin interfaceRatInput- Specified by:
hasPendingOutputin classAbstractRatInput- Returns:
- true if output available
-
output
public Object output()
Returns the received data.- Specified by:
outputin interfaceRatInput- Specified by:
outputin classAbstractRatInput- Returns:
- the data
-
stopWatchService
protected void stopWatchService()
Stops the watch service, if active.
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceRatInput- Specified by:
stopExecutionin interfaceadams.core.Stoppable- Overrides:
stopExecutionin classAbstractRatInput
-
-