public class ModificationWatcher extends Object implements IModificationWatcher
IModifiable
objects, calling a IChangeListener
when a given object's modification time changes.Modifier and Type | Class and Description |
---|---|
protected static class |
ModificationWatcher.Entry
Container class for holding modifiable entries to watch.
|
Constructor and Description |
---|
ModificationWatcher()
Default constructor for two-phase construction.
|
ModificationWatcher(Duration pollFrequency)
Constructor that accepts a
Duration argument representing the poll frequency. |
Modifier and Type | Method and 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 . |
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. |
public ModificationWatcher()
public ModificationWatcher(Duration pollFrequency)
Duration
argument representing the poll frequency.pollFrequency
- how often to check on IModifiable
spublic final boolean add(IModifiable modifiable, IChangeListener<IModifiable> listener)
IModificationWatcher
IModifiable
object and an IChangeListener
object to call
when the modifiable object is modified.add
in interface IModificationWatcher
modifiable
- an IModifiable
object to monitorlistener
- an IChangeListener
to call if the IModifiable
object is
modifiedtrue
if the set did not already contain the specified elementpublic IModifiable remove(IModifiable modifiable)
IModificationWatcher
IModifiable
object.remove
in interface IModificationWatcher
modifiable
- an IModifiable
objectIModifiable
object that was removed, else null
public void start(Duration pollFrequency)
IModificationWatcher
Duration
polling rate.start
in interface IModificationWatcher
pollFrequency
- the polling rate Duration
protected void checkModified()
public void destroy()
IModificationWatcher
ModificationWatcher
.destroy
in interface IModificationWatcher
public final Set<IModifiable> getEntries()
IModificationWatcher
IModifiable
objects currently being monitored.getEntries
in interface IModificationWatcher
Set
of all IModifiable
entries currently maintainedCopyright © 2006–2022 Apache Software Foundation. All rights reserved.