Package adams.flow.standalone.rats.input
Class FileLister
- 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.FileLister
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.ArrayProvider
,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 FileLister extends AbstractRatInput implements adams.core.AtomicMoveSupporter, adams.core.ArrayProvider
Polls files in a directory and forwards them.
It can skip files that are currently flagged as 'in use'.
Moving files to the specified target directory will continue, even if errors are occurred with some files (NB: you may end up with a very large error message if all files from a large list of files are failing).
-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 for incoming files. default: ${CWD}
-regexp <adams.core.base.BaseRegExp> (property: regExp) The regular expression that the files must match. default: .*
-max-files <int> (property: maxFiles) The maximum number of files to list; -1 for unlimited. default: -1 minimum: -1
-sorting <NO_SORTING|SORT_BY_NAME|SORT_BY_LAST_MODIFIED> (property: sorting) The type of sorting to perform. default: NO_SORTING
-sort-descending <boolean> (property: sortDescending) If enabled, the sort direction is descending. default: false
-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
-skip-in-use <boolean> (property: skipInUse) If enabled, then files are that currently 'in use' get removed from the list. default: false
-check <adams.core.io.fileuse.AbstractFileUseCheck> (property: check) If scheme to use checking the 'in use' state of a file. default: adams.core.io.fileuse.Default
-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}
-output-array <boolean> (property: outputArray) If enabled, the files get output as array rather than one-by-one. default: false
-report-moving-errors <boolean> (property: reportMovingErrors) If enabled, errors encountered while moving files get reported rather than just logged as warnings. default: false
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_AtomicMove
whether to perform an atomic move.protected adams.core.io.fileuse.AbstractFileUseCheck
m_Check
the 'in use' check scheme.protected List<String>
m_Files
the located files.protected adams.core.io.lister.LocalDirectoryLister
m_Lister
the lister for listing the files.protected boolean
m_MoveFiles
whether to move the files before transmitting them.protected boolean
m_OutputArray
whether to output an array instead of single items.protected boolean
m_ReportMovingErrors
whether to return errors when moving files.protected boolean
m_SkipInUse
whether to skip 'in-use' files.protected adams.core.io.PlaceholderDirectory
m_Target
the directory to move the files to.protected int
m_WaitList
the waiting period in msec after listing the files.-
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 FileLister()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
atomicMoveTipText()
Returns the tip text for this property.String
check()
Hook method for performing checks.String
checkTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected String
doReceive()
Performs the actual reception of data.Class
generates()
Returns the type of data this scheme generates.boolean
getAtomicMove()
Returns whether to attempt atomic move operation.adams.core.io.fileuse.AbstractFileUseCheck
getCheck()
Returns the file 'in use' check scheme.int
getMaxFiles()
Returns the maximum number of files to list.boolean
getMoveFiles()
Returns whether to move the files to the specified target directory before transmitting them.boolean
getOutputArray()
Returns whether to generate the as array or as single objects.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.adams.core.base.BaseRegExp
getRegExp()
Returns the regular expression for the files.boolean
getReportMovingErrors()
Returns whether to report errors encountered while moving files rather than just logging them as warnings.boolean
getSkipInUse()
Returns whether to skip files that are currently in use.boolean
getSortDescending()
Returns whether to sort in descending manner.adams.core.io.lister.Sorting
getSorting()
Returns the sorting type.adams.core.io.PlaceholderDirectory
getSource()
Returns the incoming directory.adams.core.io.PlaceholderDirectory
getTarget()
Returns the move-to directory.int
getWaitList()
Returns the number of milli-seconds to wait after listing the files.String
globalInfo()
Returns a string describing the object.boolean
hasPendingOutput()
Checks whether any output can be collected.protected void
initialize()
Initializes the members.String
maxFilesTipText()
Returns the tip text for this property.String
moveFilesTipText()
Returns the tip text for this property.Object
output()
Returns the received data.String
outputArrayTipText()
Returns the tip text for this property.String
regExpTipText()
Returns the tip text for this property.String
reportMovingErrorsTipText()
Returns the tip text for this property.void
setAtomicMove(boolean value)
Sets whether to attempt atomic move operation.void
setCheck(adams.core.io.fileuse.AbstractFileUseCheck value)
Sets the file 'in use' check scheme.void
setLoggingLevel(adams.core.logging.LoggingLevel value)
Sets the logging level.void
setMaxFiles(int value)
Sets the maximum number of files to list.void
setMoveFiles(boolean value)
Sets whether to move the files to the specified target directory before transmitting them.void
setOutputArray(boolean value)
Sets whether to generate data as array or as single objects.void
setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression for the files.void
setReportMovingErrors(boolean value)
Sets whether to report errors encountered while moving files rather than just logging them as warnings.void
setSkipInUse(boolean value)
Sets whether to skip files that are currently in use.void
setSortDescending(boolean value)
Sets whether to sort in descending manner.void
setSorting(adams.core.io.lister.Sorting value)
Sets the sorting type.void
setSource(adams.core.io.PlaceholderDirectory value)
Sets the incoming directory.void
setTarget(adams.core.io.PlaceholderDirectory value)
Sets the move-to directory.void
setWaitList(int value)
Sets the number of milli-seconds to wait after listing the files.String
skipInUseTipText()
Returns the tip text for this property.String
sortDescendingTipText()
Returns the tip text for this property.String
sortingTipText()
Returns the tip text for this property.String
sourceTipText()
Returns the tip text for this property.String
targetTipText()
Returns the tip text for this property.String
waitListTipText()
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, stopExecution, updatePrefix
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Lister
protected adams.core.io.lister.LocalDirectoryLister m_Lister
the lister for listing the files.
-
m_WaitList
protected int m_WaitList
the waiting period in msec after listing the files.
-
m_MoveFiles
protected boolean m_MoveFiles
whether to move the files before transmitting them.
-
m_SkipInUse
protected boolean m_SkipInUse
whether to skip 'in-use' files.
-
m_Check
protected adams.core.io.fileuse.AbstractFileUseCheck m_Check
the 'in use' check scheme.
-
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_OutputArray
protected boolean m_OutputArray
whether to output an array instead of single items.
-
m_ReportMovingErrors
protected boolean m_ReportMovingErrors
whether to return errors when moving files.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in 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:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractRatInput
-
setLoggingLevel
public void setLoggingLevel(adams.core.logging.LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevel
in interfaceadams.core.logging.LoggingLevelHandler
- Overrides:
setLoggingLevel
in classadams.core.option.AbstractOptionHandler
- Parameters:
value
- the level
-
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.
-
setRegExp
public void setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression for the files.- Parameters:
value
- the regular expression
-
getRegExp
public adams.core.base.BaseRegExp getRegExp()
Returns the regular expression for the files.- Returns:
- the regular 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.
-
setMaxFiles
public void setMaxFiles(int value)
Sets the maximum number of files to list.- Parameters:
value
- the maximum, -1 for unlimited
-
getMaxFiles
public int getMaxFiles()
Returns the maximum number of files to list.- Returns:
- the maximum, -1 for unlimited
-
maxFilesTipText
public String maxFilesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSorting
public void setSorting(adams.core.io.lister.Sorting value)
Sets the sorting type.- Parameters:
value
- the sorting
-
getSorting
public adams.core.io.lister.Sorting getSorting()
Returns the sorting type.- Returns:
- the sorting
-
sortingTipText
public String sortingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSortDescending
public void setSortDescending(boolean value)
Sets whether to sort in descending manner.- Parameters:
value
- true if desending sort manner
-
getSortDescending
public boolean getSortDescending()
Returns whether to sort in descending manner.- Returns:
- true if descending sort manner
-
sortDescendingTipText
public String sortDescendingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWaitList
public void setWaitList(int value)
Sets the number of milli-seconds to wait after listing the files.- Parameters:
value
- the number of milli-seconds
-
getWaitList
public int getWaitList()
Returns the number of milli-seconds to wait after listing the files.- Returns:
- the number of milli-seconds
-
waitListTipText
public String waitListTipText()
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.
-
setSkipInUse
public void setSkipInUse(boolean value)
Sets whether to skip files that are currently in use.- Parameters:
value
- if true then 'in-use' files are skipped
-
getSkipInUse
public boolean getSkipInUse()
Returns whether to skip files that are currently in use.- Returns:
- true if to skip 'in-use' files
-
skipInUseTipText
public String skipInUseTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCheck
public void setCheck(adams.core.io.fileuse.AbstractFileUseCheck value)
Sets the file 'in use' check scheme.- Parameters:
value
- the check scheme
-
getCheck
public adams.core.io.fileuse.AbstractFileUseCheck getCheck()
Returns the file 'in use' check scheme.- Returns:
- the check scheme
-
checkTipText
public String checkTipText()
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:
setAtomicMove
in 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:
getAtomicMove
in interfaceadams.core.AtomicMoveSupporter
- Returns:
- true if to attempt atomic move operation
-
atomicMoveTipText
public String atomicMoveTipText()
Returns the tip text for this property.- Specified by:
atomicMoveTipText
in 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.
-
setOutputArray
public void setOutputArray(boolean value)
Sets whether to generate data as array or as single objects.- Specified by:
setOutputArray
in interfaceadams.core.ArrayProvider
- Parameters:
value
- true if output is an array
-
getOutputArray
public boolean getOutputArray()
Returns whether to generate the as array or as single objects.- Specified by:
getOutputArray
in interfaceadams.core.ArrayProvider
- Returns:
- true if output is an array
-
outputArrayTipText
public String outputArrayTipText()
Returns the tip text for this property.- Specified by:
outputArrayTipText
in interfaceadams.core.ArrayProvider
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setReportMovingErrors
public void setReportMovingErrors(boolean value)
Sets whether to report errors encountered while moving files rather than just logging them as warnings.- Parameters:
value
- true if to report
-
getReportMovingErrors
public boolean getReportMovingErrors()
Returns whether to report errors encountered while moving files rather than just logging them as warnings.- Returns:
- true if to report
-
reportMovingErrorsTipText
public String reportMovingErrorsTipText()
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:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractRatInput
- Returns:
- null if no info available, otherwise short string
-
check
public String check()
Hook method for performing checks. Makes sure that directories exist.- Overrides:
check
in classAbstractRatInput
- Returns:
- null if successful, otherwise error message
-
generates
public Class generates()
Returns the type of data this scheme generates.- Specified by:
generates
in interfaceRatInput
- Specified by:
generates
in classAbstractRatInput
- Returns:
- the type of data
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutput
in interfaceRatInput
- Specified by:
hasPendingOutput
in classAbstractRatInput
- Returns:
- true if output available
-
output
public Object output()
Returns the received data.- Specified by:
output
in interfaceRatInput
- Specified by:
output
in classAbstractRatInput
- Returns:
- the data
-
doReceive
protected String doReceive()
Performs the actual reception of data.- Specified by:
doReceive
in classAbstractRatInput
- Returns:
- null if successful, otherwise error message
-
-