Class FileSystemEventManager

  • All Implemented Interfaces:
    FileSystemListener

    public class FileSystemEventManager
    extends java.lang.Object
    implements FileSystemListener
    FileSystemListenerList maintains a list of FileSystemListener's. This class, acting as a FileSystemListener, simply relays each callback to all FileSystemListener's within its list. Employs either a synchronous and asynchronous notification mechanism.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileSystemEventManager​(boolean enableAsynchronousDispatching)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(FileSystemListener listener)
      Add a listener to this list.
      void dispose()  
      boolean flushEvents​(long timeout, java.util.concurrent.TimeUnit unit)
      Blocks until all current events have been processed.
      void folderCreated​(java.lang.String parentPath, java.lang.String folderName)
      Notification that a new folder was created.
      void folderDeleted​(java.lang.String parentPath, java.lang.String folderName)
      Notification that a folder was deleted.
      void folderMoved​(java.lang.String parentPath, java.lang.String folderName, java.lang.String newParentPath)
      Notification that a folder was moved.
      void folderRenamed​(java.lang.String parentPath, java.lang.String folderName, java.lang.String newFolderName)
      Notification that a folder was renamed.
      void itemChanged​(java.lang.String parentPath, java.lang.String itemName)
      Notfication that an item's state has changed.
      void itemCreated​(java.lang.String parentPath, java.lang.String itemName)
      Notification that a new folder item was created.
      void itemDeleted​(java.lang.String parentPath, java.lang.String itemName)
      Notification that a folder item was deleted.
      void itemMoved​(java.lang.String parentPath, java.lang.String name, java.lang.String newParentPath, java.lang.String newName)
      Notification that an item was moved.
      void itemRenamed​(java.lang.String parentPath, java.lang.String itemName, java.lang.String newName)
      Notification that an item was renamed.
      void remove​(FileSystemListener listener)
      Remove a listener from this list.
      void syncronize()
      Perform a full refresh / synchronization
      • Methods inherited from class java.lang.Object

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

      • FileSystemEventManager

        public FileSystemEventManager​(boolean enableAsynchronousDispatching)
        Constructor
        Parameters:
        enableAsynchronousDispatching - if true a separate dispatch thread will be used to notify listeners. If false, blocking notification will be performed.
    • Method Detail

      • dispose

        public void dispose()
      • add

        public void add​(FileSystemListener listener)
        Add a listener to this list.
        Parameters:
        listener - the listener
      • remove

        public void remove​(FileSystemListener listener)
        Remove a listener from this list.
        Parameters:
        listener - the listener
      • itemMoved

        public void itemMoved​(java.lang.String parentPath,
                              java.lang.String name,
                              java.lang.String newParentPath,
                              java.lang.String newName)
        Description copied from interface: FileSystemListener
        Notification that an item was moved.
        Specified by:
        itemMoved in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that used to contain the item.
        name - the name of the item that was moved.
        newParentPath - the path of the folder that the item was moved to.
        newName - the new name of the item.
      • itemRenamed

        public void itemRenamed​(java.lang.String parentPath,
                                java.lang.String itemName,
                                java.lang.String newName)
        Description copied from interface: FileSystemListener
        Notification that an item was renamed.
        Specified by:
        itemRenamed in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that contains the renamed item
        itemName - the old name of the item.
        newName - the new name of the item.
      • itemDeleted

        public void itemDeleted​(java.lang.String parentPath,
                                java.lang.String itemName)
        Description copied from interface: FileSystemListener
        Notification that a folder item was deleted.
        Specified by:
        itemDeleted in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that contained the deleted item.
        itemName - the name of the item that was deleted.
      • folderRenamed

        public void folderRenamed​(java.lang.String parentPath,
                                  java.lang.String folderName,
                                  java.lang.String newFolderName)
        Description copied from interface: FileSystemListener
        Notification that a folder was renamed.
        Specified by:
        folderRenamed in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder containing the folder that was renamed.
        folderName - the old name of the folder.
        newFolderName - the new name of the folder.
      • folderMoved

        public void folderMoved​(java.lang.String parentPath,
                                java.lang.String folderName,
                                java.lang.String newParentPath)
        Description copied from interface: FileSystemListener
        Notification that a folder was moved.
        Specified by:
        folderMoved in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that used to contain the moved folder.
        folderName - the name of the folder that was moved.
        newParentPath - the path of the folder that now contains the moved folder.
      • folderDeleted

        public void folderDeleted​(java.lang.String parentPath,
                                  java.lang.String folderName)
        Description copied from interface: FileSystemListener
        Notification that a folder was deleted.
        Specified by:
        folderDeleted in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that contained the deleted folder.
        folderName - the name of the folder that was deleted.
      • itemCreated

        public void itemCreated​(java.lang.String parentPath,
                                java.lang.String itemName)
        Description copied from interface: FileSystemListener
        Notification that a new folder item was created.
        Specified by:
        itemCreated in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that contains the new item.
        itemName - the name of the new item.
      • folderCreated

        public void folderCreated​(java.lang.String parentPath,
                                  java.lang.String folderName)
        Description copied from interface: FileSystemListener
        Notification that a new folder was created.
        Specified by:
        folderCreated in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder that contains the new folder
        folderName - the name of the new folder
      • itemChanged

        public void itemChanged​(java.lang.String parentPath,
                                java.lang.String itemName)
        Description copied from interface: FileSystemListener
        Notfication that an item's state has changed.
        Specified by:
        itemChanged in interface FileSystemListener
        Parameters:
        parentPath - the path of the folder containing the item.
        itemName - the name of the item that has changed.
      • flushEvents

        public boolean flushEvents​(long timeout,
                                   java.util.concurrent.TimeUnit unit)
                            throws java.lang.InterruptedException
        Blocks until all current events have been processed.

        Note: clients should only use this method when isAsynchronous() returns true, since this class cannot track when non-threaded events have finished broadcasting to listeners. In a synchronous use case, any test that needs to know when client events have been processed must use some other mechanism to know when event processing is finished.

        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the time argument
        Returns:
        true if the events were processed in the given timeout
        Throws:
        java.lang.InterruptedException - if this waiting thread is interrupted