Class ModificationWatcher

  • All Implemented Interfaces:
    IModificationWatcher

    public class ModificationWatcher
    extends java.lang.Object
    implements IModificationWatcher
    Monitors one or more IModifiable objects, calling a IChangeListener when a given object's modification time changes.
    Since:
    1.2.6
    Author:
    Jonathan Locke
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  ModificationWatcher.Entry
      Container class for holding modifiable entries to watch.
    • Constructor Summary

      Constructors 
      Constructor Description
      ModificationWatcher()
      Default constructor for two-phase construction.
      ModificationWatcher​(Duration pollFrequency)
      Constructor that accepts a Duration argument representing the poll frequency.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(IModifiable modifiable, IChangeListener<IModifiable> listener)
      Adds an IModifiable object and an IChangeListener object to call when the modifiable object is modified.
      protected void checkModified()
      Checks which IModifiables were modified and notifies their listeners
      void destroy()
      Stops this ModificationWatcher.
      java.util.Set<IModifiable> getEntries()
      Retrieves a key set of all IModifiable objects currently being monitored.
      IModifiable remove​(IModifiable modifiable)
      Removes all entries associated with an IModifiable object.
      void start​(Duration pollFrequency)
      Starts watching at a given Duration polling rate.
      • Methods inherited from class java.lang.Object

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

      • ModificationWatcher

        public ModificationWatcher()
        Default constructor for two-phase construction.
      • ModificationWatcher

        public ModificationWatcher​(Duration pollFrequency)
        Constructor that accepts a Duration argument representing the poll frequency.
        Parameters:
        pollFrequency - how often to check on IModifiables
    • Method Detail

      • add

        public final boolean add​(IModifiable modifiable,
                                 IChangeListener<IModifiable> listener)
        Description copied from interface: IModificationWatcher
        Adds an IModifiable object and an IChangeListener object to call when the modifiable object is modified.
        Specified by:
        add in interface IModificationWatcher
        Parameters:
        modifiable - an IModifiable object to monitor
        listener - an IChangeListener to call if the IModifiable object is modified
        Returns:
        true if the set did not already contain the specified element
      • remove

        public IModifiable remove​(IModifiable modifiable)
        Description copied from interface: IModificationWatcher
        Removes all entries associated with an IModifiable object.
        Specified by:
        remove in interface IModificationWatcher
        Parameters:
        modifiable - an IModifiable object
        Returns:
        the IModifiable object that was removed, else null
      • start

        public void start​(Duration pollFrequency)
        Description copied from interface: IModificationWatcher
        Starts watching at a given Duration polling rate.
        Specified by:
        start in interface IModificationWatcher
        Parameters:
        pollFrequency - the polling rate Duration
      • checkModified

        protected void checkModified()
        Checks which IModifiables were modified and notifies their listeners
      • getEntries

        public final java.util.Set<IModifiable> getEntries()
        Description copied from interface: IModificationWatcher
        Retrieves a key set of all IModifiable objects currently being monitored.
        Specified by:
        getEntries in interface IModificationWatcher
        Returns:
        a Set of all IModifiable entries currently maintained