Class WatchEvent<T>

  • Direct Known Subclasses:
    PathWatchEvent, VoidWatchEvent

    public abstract class WatchEvent<T>
    extends java.lang.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  WatchEvent.Kind<T>
      Instances of this class act as tags to identify different kinds of events (like file creation or deletion)
      static interface  WatchEvent.Modifier<T>
      A modifier can be specified to register to change the way changes to a watchable are reported.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected WatchEvent()  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract T context()  
      abstract int count()
      The number of times this event occurred, if it is cumulative.
      abstract WatchEvent.Kind<T> kind()  
      • Methods inherited from class java.lang.Object

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

      • WatchEvent

        protected WatchEvent()
    • Method Detail

      • 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.