Class FileSystemWatcherConsumer

  • All Implemented Interfaces:
    ServiceConsumer

    public abstract class FileSystemWatcherConsumer
    extends java.lang.Object
    implements ServiceConsumer
    This class must be implemented if tou want to consume the file system watcher service.
    Author:
    javaito
    • Constructor Summary

      Constructors 
      Constructor Description
      FileSystemWatcherConsumer​(java.nio.file.Path path, java.nio.file.WatchEvent.Kind... eventKinds)
      Constructor
    • Method Summary

      Modifier and Type Method Description
      protected void create​(java.nio.file.WatchEvent<java.nio.file.Path> event)
      This method must be implemented if you want to listen the create event over the base path.
      protected void delete​(java.nio.file.WatchEvent<java.nio.file.Path> event)
      This method must be implemented if you want to listen the delete event over the base path.
      java.nio.file.Path getBasePath()
      Return the base path.
      java.nio.file.WatchEvent.Kind[] getEventKinds()
      Return an array of the event kinds.
      java.lang.String getFileName()
      Return the file name associated to the consumer or null if the consumer is watching a directory
      java.nio.file.Path getPath()
      Return complete path.
      protected void overflow​(java.nio.file.WatchEvent<java.nio.file.Path> event)
      This method must be implemented if you want to listen the overflow event over the base path.
      protected void update​(java.nio.file.WatchEvent<java.nio.file.Path> event)
      This method must be implemented if you want to listen the update event over the base path.
      • Methods inherited from class java.lang.Object

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

      • FileSystemWatcherConsumer

        public FileSystemWatcherConsumer​(java.nio.file.Path path,
                                         java.nio.file.WatchEvent.Kind... eventKinds)
        Constructor
        Parameters:
        path - Base path, all the paths bellow of the base are wached by the consumer
        eventKinds - Kinds of events that this consumer are listening
    • Method Detail

      • getPath

        public java.nio.file.Path getPath()
        Return complete path. If the consumer is watching a directory then path and base path are the same.
        Returns:
        Complete path.
      • getBasePath

        public final java.nio.file.Path getBasePath()
        Return the base path.
        Returns:
        Base path.
      • getFileName

        public final java.lang.String getFileName()
        Return the file name associated to the consumer or null if the consumer is watching a directory
        Returns:
        File name or null.
      • getEventKinds

        public final java.nio.file.WatchEvent.Kind[] getEventKinds()
        Return an array of the event kinds.
        Returns:
        Event kinds.
      • create

        protected void create​(java.nio.file.WatchEvent<java.nio.file.Path> event)
        This method must be implemented if you want to listen the create event over the base path.
        Parameters:
        event - Event information.
      • update

        protected void update​(java.nio.file.WatchEvent<java.nio.file.Path> event)
        This method must be implemented if you want to listen the update event over the base path.
        Parameters:
        event - Event information.
      • delete

        protected void delete​(java.nio.file.WatchEvent<java.nio.file.Path> event)
        This method must be implemented if you want to listen the delete event over the base path.
        Parameters:
        event - Event information.
      • overflow

        protected void overflow​(java.nio.file.WatchEvent<java.nio.file.Path> event)
        This method must be implemented if you want to listen the overflow event over the base path.
        Parameters:
        event - Event information.