Package com.compomics.util.io.file
Class FolderMonitor
java.lang.Object
com.compomics.util.io.file.FolderMonitor
- All Implemented Interfaces:
Runnable
public class FolderMonitor extends Object implements Runnable
This class will monitor a specified folder for activity.
- Author:
- Lennart Martens
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FolderMonitor()
Empty default constructorFolderMonitor(File aFolder, long aDelay, int aOperation, HashMap aParams)
This constructor allows the creation of a FolderMonitor that will take care of performing a specified action, with the specified parameters, whenever a new file is found.FolderMonitor(File aFolder, long aDelay, int aOperation, HashMap aParams, org.apache.log4j.Logger aLogger)
This constructor allows the creation of a FolderMonitor that will take care of performing a specified action, with the specified parameters, whenever a new file is found.FolderMonitor(File aFolder, long aDelay, String aFilter, int aOperation, HashMap aParams)
This constructor allows the creation of a FolderMonitor for the specified filtered files that will take care of performing a specified action, with the specified parameters, whenever a new file is found.FolderMonitor(File aFolder, long aDelay, String aFilter, int aOperation, HashMap aParams, org.apache.log4j.Logger aLogger)
This constructor allows the creation of a FolderMonitor for the specified filtered files that will take care of performing a specified action, with the specified parameters, whenever a new file is found. -
Method Summary
Modifier and Type Method Description boolean
isRunning()
This method can be consulted to find out whether the monitor is running.static void
main(String[] args)
Main method starting the foldermonitor that looks for changes to a monitored folder.void
run()
When an object implementing interfaceRunnable
is used to create a thread, starting the thread causes the object'srun
method to be called in that separately executing thread.void
signalStop()
This method can be used to signal the monitor to halt its monitoring.
-
Field Details
-
HOST
- See Also:
- Constant Field Values
-
USER
- See Also:
- Constant Field Values
-
PASSWORD
- See Also:
- Constant Field Values
-
TEXTMODE
- See Also:
- Constant Field Values
-
PICKUP
- See Also:
- Constant Field Values
-
LIMIT
- See Also:
- Constant Field Values
-
FTP_TO_SPECIFIED_DESTINATION
public static final int FTP_TO_SPECIFIED_DESTINATION- See Also:
- Constant Field Values
-
GATHER_FILES_FOR_PICKUP
public static final int GATHER_FILES_FOR_PICKUP- See Also:
- Constant Field Values
-
-
Constructor Details
-
FolderMonitor
public FolderMonitor()Empty default constructor -
FolderMonitor
This constructor allows the creation of a FolderMonitor that will take care of performing a specified action, with the specified parameters, whenever a new file is found.- Parameters:
aFolder
- File istance with the folder to check.aDelay
- long with the minimal delay in milliseconds between each folder check.aOperation
- int with the code for the operation to perform (use only constants defined on this class).aParams
- HashMap with the necessary parameters for the operation.
-
FolderMonitor
public FolderMonitor(File aFolder, long aDelay, int aOperation, HashMap aParams, org.apache.log4j.Logger aLogger)This constructor allows the creation of a FolderMonitor that will take care of performing a specified action, with the specified parameters, whenever a new file is found. It also specifies a logger, to which messages detailing the activity can be logged.- Parameters:
aFolder
- File istance with the folder to check.aDelay
- long with the minimal delay in milliseconds between each folder check.aOperation
- int with the code for the operation to perform (use only constants defined on this class).aParams
- HashMap with the necessary parameters for the operation.aLogger
- Logger for messages from this class.
-
FolderMonitor
This constructor allows the creation of a FolderMonitor for the specified filtered files that will take care of performing a specified action, with the specified parameters, whenever a new file is found.- Parameters:
aFolder
- File instance with the folder to check.aDelay
- long with the minimal delay in milliseconds between each folder check.aFilter
- String to filter the files in the folder through.aOperation
- int with the code for the operation to perform (use only constants defined on this class).aParams
- HashMap with the necessary parameters for the operation.
-
FolderMonitor
public FolderMonitor(File aFolder, long aDelay, String aFilter, int aOperation, HashMap aParams, org.apache.log4j.Logger aLogger)This constructor allows the creation of a FolderMonitor for the specified filtered files that will take care of performing a specified action, with the specified parameters, whenever a new file is found. It also specifies a logger, to which messages detailing the activity can be logged.- Parameters:
aFolder
- File instance with the folder to check.aDelay
- long with the minimal delay in milliseconds between each folder check.aFilter
- String to filter the files in the folder through.aOperation
- int with the code for the operation to perform (use only constants defined on this class).aParams
- HashMap with the necessary parameters for the operation.aLogger
- Logger for messages from this class.
-
-
Method Details
-
run
public void run()When an object implementing interfaceRunnable
is used to create a thread, starting the thread causes the object'srun
method to be called in that separately executing thread.The general contract of the method
run
is that it may take any action whatsoever.- Specified by:
run
in interfaceRunnable
- See Also:
Thread.run()
-
signalStop
public void signalStop()This method can be used to signal the monitor to halt its monitoring. -
isRunning
public boolean isRunning()This method can be consulted to find out whether the monitor is running.- Returns:
- boolean that indicates whether the monitor is running.
-
main
Main method starting the foldermonitor that looks for changes to a monitored folder.- Parameters:
args
- start-up arguments
-