public class DirWatcher
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
DirWatcher.WatchTask |
Modifier and Type | Field and Description |
---|---|
protected java.io.File |
dir |
protected int |
filesCount |
protected boolean |
ignoreDotFiles |
protected Consumers<DirWatcherEvent> |
listeners |
protected java.util.HashMap<java.io.File,MutableLong> |
map |
protected java.lang.String[] |
patterns |
protected boolean |
startBlank |
protected java.util.Timer |
timer |
protected java.io.File |
watchFile |
protected long |
watchFileLastAccessTime |
Constructor and Description |
---|
DirWatcher(java.lang.String dir)
Creates new watcher on specified directory.
|
DirWatcher(java.lang.String dirName,
java.lang.String... patterns)
Creates new watched on specified directory with given set of
wildcard patterns for file names.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptFile(java.io.File file)
Accepts if a file is going to be watched.
|
void |
clear()
Removes all event consumers..
|
DirWatcher |
ignoreDotFiles(boolean ignoreDotFiles)
Enables or disables if dot files should be watched.
|
protected void |
init()
Initializes dir watcher by reading all files
from watched folder.
|
DirWatcher |
monitor(java.lang.String... patterns)
Defines patterns to scan.
|
protected void |
onChange(DirWatcherEvent.Type type,
java.io.File file)
Triggers listeners on file change.
|
void |
register(java.util.function.Consumer<DirWatcherEvent> dirWatcherListener)
Registers
consumer . |
void |
remove(java.util.function.Consumer<DirWatcherEvent> dirWatcherListener)
Removes registered
consumer . |
void |
start(long pollingInterval)
Starts the watcher.
|
DirWatcher |
startBlank(boolean startBlank)
Defines if watcher should start blank and consider all present
files as
created . |
void |
stop()
Stops the watcher.
|
DirWatcher |
useWatchFile()
Enables usage of default watch file (".watch.ready").
|
DirWatcher |
useWatchFile(java.lang.String name)
Enables usage of provided watch file.
|
protected final java.io.File dir
protected java.util.HashMap<java.io.File,MutableLong> map
protected int filesCount
protected Consumers<DirWatcherEvent> listeners
protected java.lang.String[] patterns
protected boolean ignoreDotFiles
protected boolean startBlank
protected java.io.File watchFile
protected long watchFileLastAccessTime
protected java.util.Timer timer
public DirWatcher(java.lang.String dir)
later
.public DirWatcher(java.lang.String dirName, java.lang.String... patterns)
protected void init()
public DirWatcher ignoreDotFiles(boolean ignoreDotFiles)
public DirWatcher startBlank(boolean startBlank)
created
.
By default all existing files will consider as existing ones.public DirWatcher monitor(java.lang.String... patterns)
protected boolean acceptFile(java.io.File file)
public DirWatcher useWatchFile()
public DirWatcher useWatchFile(java.lang.String name)
public void start(long pollingInterval)
public void stop()
protected void onChange(DirWatcherEvent.Type type, java.io.File file)
public void register(java.util.function.Consumer<DirWatcherEvent> dirWatcherListener)
consumer
.public void remove(java.util.function.Consumer<DirWatcherEvent> dirWatcherListener)
consumer
.public void clear()
Copyright © 2003-present Jodd Team