Class WatchEvent<T>

java.lang.Object
name.pachler.nio.file.WatchEvent<T>
Direct Known Subclasses:
PathWatchEvent, VoidWatchEvent

public abstract class WatchEvent<T> extends Object
Instances of this class hold the information of a particular change to an element below the watched file system object (e.g. a file modification or a rename). These objects can be retreived from a WatchKey once it has been returned by the WatchService (using the poll() or take() methods).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Instances of this class act as tags to identify different kinds of events (like file creation or deletion)
    static interface 
    A modifier can be specified to register to change the way changes to a watchable are reported.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
     
    abstract int
    The number of times this event occurred, if it is cumulative.
    abstract WatchEvent.Kind<T>
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WatchEvent

      protected WatchEvent()
  • Method Details

    • context

      public abstract T context()
      Returns:
      the context of this event, which is usually a reference to the object that has changed. In the case of WatchEvents for Path, the context will be a Path to the file that this event refers to, relative to the watched Path
    • count

      public abstract int count()
      The number of times this event occurred, if it is cumulative. It is not specified how events cumulate, so use this value for informational purposes only.
      Returns:
      the number of times this event has occurred, in case events of this kind have been aggregated into one WatchEvent instance.
    • kind

      public abstract WatchEvent.Kind<T> kind()
      Returns:
      the kind of event that occurred. This will indicate what actually happened, for instance, StandardWatchEventKind#ENTRY_CREATE indicates that a file has been created.