|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.teamdev.filewatch.FileWatcher
public abstract class FileWatcher
Provides the functionality for monitoring file events in a specified folder.
Field Summary | |
---|---|
static java.lang.String |
FAKE_RENAMES_OPTION
|
static java.lang.String |
MOVE_EVENTS_OPTION
|
protected static java.lang.String |
WATCHING_FOLDER_REMOVED
|
Constructor Summary | |
---|---|
protected |
FileWatcher(java.io.File folder)
Creates a new watcher for the specified folder. |
Method Summary | |
---|---|
protected boolean |
accept(FileEvent event)
Verifies if the specified event should be filtered out or not using the associated FileEventFilter . |
void |
addFileEventsListener(FileEventsListener listener)
Adds file events listener to this watcher. |
void |
addListener(FileEventsListener listener)
Deprecated. use addFileEventsListener(com.teamdev.filewatch.FileEventsListener) instead |
void |
addListener(WatcherEventListener listener)
Deprecated. use addWatcherListener(WatcherEventListener) instead |
void |
addWatcherListener(WatcherEventListener listener)
Add watcher events listener. |
static FileWatcher |
create(java.io.File folder)
Factory method that creates a most efficient file system watcher depending on a current operating system and file system type of the specified folder. |
FileEventFilter |
getFilter()
Returns a file event filter. |
java.io.File |
getFolder()
Returns the currently watching directory. |
java.util.Set<WatchingAttributes> |
getOptions()
Returns set of watching options. |
boolean |
isRunning()
Returns state of the watcher. |
protected abstract java.util.List<FileEvent> |
readEvents()
Reads next portion of file system events. |
protected abstract void |
release()
Releases all native resources which are associated with a watcher instance. |
void |
removeFileEventsListener(FileEventsListener listener)
Removes file events listener from this watcher. |
void |
removeListener(FileEventsListener listener)
Deprecated. use removeFileEventsListener(FileEventsListener) instead |
void |
removeListener(WatcherEventListener listener)
Deprecated. use removeWatcherListener(WatcherEventListener) instead |
void |
removeWatcherListener(WatcherEventListener listener)
Removes file events listener from this watcher. |
void |
resetOptions()
Clears options and initializes with all the attributes from WatchingAttributes . |
void |
setFilter(FileEventFilter filter)
Sets a new file event filter. |
void |
setOptions(java.util.Set<WatchingAttributes> newOptions)
Specifies the set of watcher options. |
void |
setOptions(WatchingAttributes... newOptions)
Specifies the set of new watching options. |
protected void |
setRunning(boolean value)
Sets the state of this watcher. |
protected void |
setRunning(boolean value,
WatcherEvent event)
Sets the state of this watcher. |
void |
start()
Starts watching of the specified folder. |
protected abstract void |
startWatching()
Notifies watcher that the watching is going to be started. |
void |
stop()
Stops file system watcher. |
protected abstract void |
stopWatching()
Notifies watcher that the watching is going to be stopped. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MOVE_EVENTS_OPTION
public static final java.lang.String FAKE_RENAMES_OPTION
protected static final java.lang.String WATCHING_FOLDER_REMOVED
Constructor Detail |
---|
protected FileWatcher(java.io.File folder)
folder
- a root folder to monitor file system events. Must not be null
java.lang.IllegalArgumentException
- if the passed instance is not a directory or does not existMethod Detail |
---|
public final void resetOptions()
WatchingAttributes
.
public void setOptions(java.util.Set<WatchingAttributes> newOptions)
WatchingAttributes.Subtree
) must be specified.
newOptions
- set of watcher optionspublic void setOptions(WatchingAttributes... newOptions)
WatchingAttributes.Subtree
must be specified.
newOptions
- array of watcher optionspublic final void start()
public boolean isRunning()
protected void setRunning(boolean value, WatcherEvent event)
value
- new watcher state; true if watcher is running; false otherwiseevent
- watcher eventprotected void setRunning(boolean value)
value
- new watcher state; true if watcher is running; false otherwisepublic final void stop()
protected abstract void startWatching()
protected abstract java.util.List<FileEvent> readEvents()
protected abstract void stopWatching()
protected abstract void release()
@Deprecated public void addListener(FileEventsListener listener)
addFileEventsListener(com.teamdev.filewatch.FileEventsListener)
instead
listener
- file system listenerpublic void addFileEventsListener(FileEventsListener listener)
listener
- file system listener@Deprecated public void removeListener(FileEventsListener listener)
removeFileEventsListener(FileEventsListener)
instead
listener
- file system listenerpublic void removeFileEventsListener(FileEventsListener listener)
listener
- file system listener@Deprecated public void addListener(WatcherEventListener listener)
addWatcherListener(WatcherEventListener)
instead
listener
- file system listenerpublic void addWatcherListener(WatcherEventListener listener)
listener
- file system listener@Deprecated public void removeListener(WatcherEventListener listener)
removeWatcherListener(WatcherEventListener)
instead
listener
- file system listenerpublic void removeWatcherListener(WatcherEventListener listener)
listener
- file system listenerpublic java.io.File getFolder()
public FileEventFilter getFilter()
public void setFilter(FileEventFilter filter)
filter
- new file events filterprotected boolean accept(FileEvent event)
FileEventFilter
.
If there are no filters associated, returns true
.
event
- file event to verify
true
if there are no filter associated; otherwise calls
FileEventFilter.accept(FileEvent)
of the associated filter.public java.util.Set<WatchingAttributes> getOptions()
WatchingAttributes
optionspublic static FileWatcher create(java.io.File folder)
folder
- watching folder; must be an existing directory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |