Class DirectoryWatcher<T>

  • Type Parameters:
    T - the object representation of the file
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Runnable

    public class DirectoryWatcher<T>
    extends java.lang.Object
    implements java.lang.Runnable, java.io.Closeable
    The Class DirectoryWatcher.
    Author:
    Alejandro Galue
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.util.Set<java.lang.String> getBaseNamesWithExtension​(java.lang.String extension)
      Gets the base names with extension.
      T getContents​(java.lang.String fileName)
      Gets the contents.
      java.util.Set<java.lang.String> getFileNames()
      Gets the file names.
      void join()
      Join.
      void run()  
      void start()
      Start.
      void stop()
      Stop.
      • Methods inherited from class java.lang.Object

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

      • DirectoryWatcher

        public DirectoryWatcher​(java.io.File directory,
                                FileReloadCallback<T> loader)
                         throws java.lang.InterruptedException
        Instantiates a new directory watcher.
        Parameters:
        directory - the directory
        loader - the loader
        Throws:
        java.lang.InterruptedException - the interrupted exception
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • join

        public void join()
                  throws java.lang.InterruptedException
        Join.
        Throws:
        java.lang.InterruptedException - the interrupted exception
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • start

        public void start()
                   throws java.lang.InterruptedException
        Start.
        Throws:
        java.lang.InterruptedException - the interrupted exception
      • stop

        public void stop()
                  throws java.lang.InterruptedException
        Stop.
        Throws:
        java.lang.InterruptedException - the interrupted exception
      • getFileNames

        public java.util.Set<java.lang.String> getFileNames()
        Gets the file names.
        Returns:
        the file names
      • getBaseNamesWithExtension

        public java.util.Set<java.lang.String> getBaseNamesWithExtension​(java.lang.String extension)
        Gets the base names with extension.
        Parameters:
        extension - the extension
        Returns:
        the base names with extension
      • getContents

        public T getContents​(java.lang.String fileName)
                      throws java.io.FileNotFoundException
        Gets the contents.
        Parameters:
        fileName - the file name
        Returns:
        the contents
        Throws:
        java.io.FileNotFoundException - the file not found exception