public abstract class Directory extends Object
WatchKey of watched directory. Secondly, it
stores the checksums of changed files.| Modifier and Type | Method and Description |
|---|---|
abstract void |
addWatchedDirectory(ch.sourcepond.io.fileobserver.spi.WatchedDirectory pDirectoryKey)
Adds the watched-directory specified to this directory instance.
|
void |
cancelKey()
Cancels the
WatchKey held by this directory object (see WatchKey.cancel()). |
void |
forceInform(EventDispatcher pDispatcher)
Iterates over the files contained by this directory and creates tasks which will be executed
sometime in the future.
|
Path |
getPath()
Returns the path represented by this directory object.
|
ch.sourcepond.io.checksum.api.Resource |
getResource(Path pFile) |
abstract boolean |
hasKeys() |
void |
informCreatedOrInitial(EventDispatcher pDispatcher,
Directory pNewRootOrNull,
Path pFile,
Runnable pDoneCallback) |
void |
informDiscard(EventDispatcher pDispatcher,
Path pFile,
Runnable pDoneCallback)
Iterates over the listeners specified and informs them that the file specified has
been discarded through their
PathChangeListener.discard(DispatchKey) method. |
void |
informIfChanged(EventDispatcher pDispatcher,
Directory pNewRootOrNull,
Path pFile,
Runnable pDoneCallback,
boolean pIsCreated)
Triggers the
PathChangeListener.modified(PathChangeEvent) on all listeners specified if the
file represented by the path specified has been changed i.e. |
void |
informIfChanged(EventDispatcher pDispatcher,
Path pFile,
Runnable pDoneCallback,
boolean pIsCreated)
Triggers the
PathChangeListener.modified(PathChangeEvent) on all listeners specified if the
file represented by the path specified has been changed i.e. |
boolean |
isDirectParentOf(Directory pOther)
Checks whether this directory is the directory parent of the directory specified.
|
abstract boolean |
isRoot() |
abstract Directory |
rebase(Directory pBaseDirectory) |
void |
removeWatchedDirectory(EventDispatcher pDispatcher,
ch.sourcepond.io.fileobserver.spi.WatchedDirectory pWatchedDirectory)
Removes the watched-directory specified from this directory instance and informs
the listeners specified through their
PathChangeListener.discard(DispatchKey). |
abstract Directory |
toRootDirectory() |
public abstract boolean isRoot()
public abstract boolean hasKeys()
public abstract void addWatchedDirectory(ch.sourcepond.io.fileobserver.spi.WatchedDirectory pDirectoryKey)
Adds the watched-directory specified to this directory instance. When a change is detected, a
DispatchKey will be generated for every WatchedDirectory.getKey()/relative-path combination.
This DispatchKey instance will then be delivered (along with the readable file path)
to the PathChangeListener objects which should be informed.
Note: The object returned by WatchedDirectory.getKey() should be immutable,
String or an Enum objects are good condidates for being directory-keys.
pDirectoryKey - Directory key, must not be nullpublic void removeWatchedDirectory(EventDispatcher pDispatcher, ch.sourcepond.io.fileobserver.spi.WatchedDirectory pWatchedDirectory)
PathChangeListener.discard(DispatchKey). If no such
watched-directory is registered nothing happens.pWatchedDirectory - Directory-key to be removed, must be not nullpublic void cancelKey()
WatchKey held by this directory object (see WatchKey.cancel()).
After this, checksum resources are cleared and no more events for this directory can be retrieved.public void forceInform(EventDispatcher pDispatcher)
PathChangeListener.modified(PathChangeEvent) method. Note: only direct children will be
considered, sub-directories and non-regular files will be ignored.public Path getPath()
null.public void informDiscard(EventDispatcher pDispatcher, Path pFile, Runnable pDoneCallback)
PathChangeListener.discard(DispatchKey) method. The listeners
will be called asynchronously sometime in the future.pFile - Discarded file, must be nullpublic boolean isDirectParentOf(Directory pOther)
pOther - Other directory, must not be nulltrue if this object is the direct parent of the directory specified, false otherwisepublic ch.sourcepond.io.checksum.api.Resource getResource(Path pFile)
public void informCreatedOrInitial(EventDispatcher pDispatcher, Directory pNewRootOrNull, Path pFile, Runnable pDoneCallback)
public void informIfChanged(EventDispatcher pDispatcher, Directory pNewRootOrNull, Path pFile, Runnable pDoneCallback, boolean pIsCreated)
PathChangeListener.modified(PathChangeEvent) on all listeners specified if the
file represented by the path specified has been changed i.e. has a new checksum. If no checksum change
has been detected, nothing happens.pFile - File which potentially has changed, must not be nullpublic void informIfChanged(EventDispatcher pDispatcher, Path pFile, Runnable pDoneCallback, boolean pIsCreated)
PathChangeListener.modified(PathChangeEvent) on all listeners specified if the
file represented by the path specified has been changed i.e. has a new checksum. If no checksum change
has been detected, nothing happens.pFile - File which potentially has changed, must not be nullpublic abstract Directory toRootDirectory()
Copyright © 2017 SourcePond. All rights reserved.