public class FileWatcher extends Observable implements Serializable
Works in two modes : mode = ALL -> returns all files in the folder.
mode = CHECK_DATE -> returns only new files.
| Modifier and Type | Field and Description |
|---|---|
boolean |
mCheckDate
Check files by their last modification date status or not
|
| Constructor and Description |
|---|
FileWatcher(String fullFolderPath,
boolean checkDate,
long interval,
boolean fileOnly,
boolean isDeamon,
SchedulerService schedulerService)
Constructor
Precise if the Thread to Create is a Deamon or not
|
FileWatcher(String fullFolderPath,
boolean checkDate,
long interval,
boolean fileOnly,
SchedulerService schedulerService)
Constructor
|
FileWatcher(String jobName,
String fullFolderPath,
boolean checkDate,
long interval,
boolean fileOnly)
Constructor
|
FileWatcher(String jobName,
String fullFolderPath,
boolean checkDate,
long interval,
boolean fileOnly,
boolean isDeamon,
SchedulerService schedulerService)
Constructor
Precise if the Thread to Create is a Deamon or not
|
| Modifier and Type | Method and Description |
|---|---|
void |
externalSetChanged()
Small trick to export the setChanged method that has a protected.
|
boolean |
getCheckDate()
Returns The Check File Mode
|
boolean |
getFileOnly() |
File |
getFolder() |
String |
getFolderPath()
Returns The Path of the Folder to watch
|
org.apache.commons.io.filefilter.IOFileFilter |
getIgnoreFilter() |
long |
getInterval()
Returns The Interval Values
|
long |
getLastCheckTime() |
int |
getMaxJobNameLength() |
Collection<File> |
getPreviousFiles() |
boolean |
getRemovedFiles() |
protected void |
initialize()
Verify if the Folder to watch exists.
|
boolean |
isDeamon()
Thread is a Deamon or not
|
boolean |
isRecursive() |
void |
setCheckDate(boolean checkDate)
Set The Check File Mode ( by last modification date or returns all files found
|
protected void |
setDeamon(boolean isDeamon)
Create a Deamon or User Thread
|
void |
setFileOnly(boolean fileOnly)
set file only mode
|
protected void |
setFolderPath(String fullFolderPath)
Set The FolderPath
|
void |
setIgnoreFiles(List<String> ignoreFiles) |
protected void |
setInterval(long interval)
Set The Interval Values
|
void |
setLastCheckTime(long lastCheckTime) |
void |
setMaxJobNameLength(int maxJobNameLength) |
void |
setPreviousFiles(Collection<File> previousFiles) |
void |
setRecursive(boolean recursive) |
void |
setRemovedFiles(boolean removedFiles) |
void |
start()
Creates the Timer Thread and starts it
|
void |
stop() |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedpublic boolean mCheckDate
public FileWatcher(String jobName, String fullFolderPath, boolean checkDate, long interval, boolean fileOnly) throws IOException
jobName - the name of the background job to usefullFolderPath - the real Path to the folder to watchcheckDate - check by last modification date or notinterval - the interval to do the repeat TaskfileOnly - checks only files if true, not directoriesIOExceptionpublic FileWatcher(String fullFolderPath, boolean checkDate, long interval, boolean fileOnly, SchedulerService schedulerService) throws IOException
fullFolderPath - the real Path to the folder to watchcheckDate - check by last modification date or notinterval - the interval to do the repeat TaskfileOnly - checks only files if true, not directoriesIOExceptionpublic FileWatcher(String fullFolderPath, boolean checkDate, long interval, boolean fileOnly, boolean isDeamon, SchedulerService schedulerService) throws IOException
fullFolderPath - the real Path to the folder to watchcheckDate - check new files by date changes ?interval - the interval to do the repeat TaskisDeamon - create a User or Deamon ThreadfileOnly - checks only files if true, not directoriesschedulerService - a dependency injection of the service to use to schedule the file watching job.IOExceptionpublic FileWatcher(String jobName, String fullFolderPath, boolean checkDate, long interval, boolean fileOnly, boolean isDeamon, SchedulerService schedulerService) throws IOException
jobName - the name of the background job to usefullFolderPath - the real Path to the folder to watchcheckDate - check new files by date changes ?interval - the interval to do the repeat TaskisDeamon - create a User or Deamon ThreadfileOnly - checks only files if true, not directoriesschedulerService - a dependency injection of the service to use to schedule the file watching job.IOExceptionpublic void start()
throws IOException
IOExceptionpublic void stop()
public long getInterval()
protected void setInterval(long interval)
interval - the interval used to do repeatitive task in millispublic void externalSetChanged()
public String getFolderPath()
protected void setFolderPath(String fullFolderPath)
fullFolderPath - the path to the folder to watchpublic void setFileOnly(boolean fileOnly)
fileOnly - file only or notpublic boolean getFileOnly()
public boolean isRecursive()
public void setRecursive(boolean recursive)
public boolean getCheckDate()
public void setCheckDate(boolean checkDate)
checkDate - check by last modification date or notpublic boolean isDeamon()
protected void setDeamon(boolean isDeamon)
isDeamon - public File getFolder()
public long getLastCheckTime()
public void setLastCheckTime(long lastCheckTime)
public int getMaxJobNameLength()
public void setMaxJobNameLength(int maxJobNameLength)
public boolean getRemovedFiles()
public void setRemovedFiles(boolean removedFiles)
public Collection<File> getPreviousFiles()
public void setPreviousFiles(Collection<File> previousFiles)
public org.apache.commons.io.filefilter.IOFileFilter getIgnoreFilter()
protected void initialize()
throws IOException
IOExceptionCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.