Package engineering.swat.watch.impl.jdk
Class JDKFileWatch
- java.lang.Object
-
- engineering.swat.watch.impl.jdk.JDKBaseWatch
-
- engineering.swat.watch.impl.jdk.JDKFileWatch
-
- All Implemented Interfaces:
ActiveWatch
,EventHandlingWatch
,Closeable
,AutoCloseable
public class JDKFileWatch extends JDKBaseWatch
It's not possible to monitor a single file (or directory), so we have to find a directory watcher, and connect to that Note that you should take care to call start only once.
-
-
Field Summary
-
Fields inherited from class engineering.swat.watch.impl.jdk.JDKBaseWatch
eventFilter, eventHandler, exec, path, started
-
-
Constructor Summary
Constructors Constructor Description JDKFileWatch(Path file, Executor exec, BiConsumer<EventHandlingWatch,WatchEvent> eventHandler, Predicate<WatchEvent> eventFilter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
WatchScope
getScope()
Gets the scope of this watch.void
handleEvent(WatchEvent event)
Handles `event`.protected void
start()
Starts this watch.-
Methods inherited from class engineering.swat.watch.impl.jdk.JDKBaseWatch
getPath, open, startIfFirstTime, translate, translate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface engineering.swat.watch.impl.EventHandlingWatch
relativize
-
-
-
-
Constructor Detail
-
JDKFileWatch
public JDKFileWatch(Path file, Executor exec, BiConsumer<EventHandlingWatch,WatchEvent> eventHandler, Predicate<WatchEvent> eventFilter)
-
-
Method Detail
-
getScope
public WatchScope getScope()
Description copied from interface:ActiveWatch
Gets the scope of this watch.
-
handleEvent
public void handleEvent(WatchEvent event)
Description copied from interface:EventHandlingWatch
Handles `event`. The purpose of this method is to trigger the event handler of this watch "from the outside" (in addition to having native file system libraries trigger the event handler "from the inside"). This is useful to report synthetic events (e.g., while handling overflows).- Specified by:
handleEvent
in interfaceEventHandlingWatch
- Overrides:
handleEvent
in classJDKBaseWatch
-
close
public void close() throws IOException
- Throws:
IOException
-
start
protected void start() throws IOException
Description copied from class:JDKBaseWatch
Starts this watch.- Specified by:
start
in classJDKBaseWatch
- Throws:
IOException
- When an I/O exception of some sort has occurred (e.g., a nested watch failed to start)
-
-