AI-generated Key Takeaways
-
WatchEvent
represents an event (or repeated event) for an object registered with aWatchService
, providing information about changes to the watched object. -
Each event has a
kind
(type of event), acount
(number of occurrences), and acontext
(object-specific information). -
Events can indicate file creation, deletion, or modification within a watched directory, with the context often being the relative path to the affected file.
-
The
WatchEvent
interface provides methods to access these event details, aiding in monitoring and managing changes to registered files and directories. -
These events are immutable, ensuring safe access from multiple threads.
An event or a repeated event for an object that is registered with a WatchService
.
An event is classified by its kind
and has a count
to indicate the number of times that the event has been
observed. This allows for efficient representation of repeated events. The
context
method returns any context associated with
the event. In the case of a repeated event then the context is the same for
all events.
Watch events are immutable and safe for use by multiple concurrent threads.
Nested Class Summary
interface | WatchEvent.Kind<T> | An event kind, for the purposes of identification. | |
interface | WatchEvent.Modifier | An event modifier that qualifies how a Watchable is registered
with a WatchService . |
Public Method Summary
abstract T |
context()
Returns the context for the event.
|
abstract int |
count()
Returns the event count.
|
abstract Kind<T> |
kind()
Returns the event kind.
|
Public Methods
public abstract T context ()
Returns the context for the event.
In the case of ENTRY_CREATE
,
ENTRY_DELETE
, and ENTRY_MODIFY
events the context is
a Path
that is the relative
path between
the directory registered with the watch service, and the entry that is
created, deleted, or modified.
Returns
- the event context; may be
null
public abstract int count ()
Returns the event count. If the event count is greater than 1
then this is a repeated event.
Returns
- the event count