src/share/classes/java/nio/file/WatchKey.java

Print this page

        

*** 79,113 **** * is processing the events for an object at any time. * * @since 1.7 */ ! public abstract class WatchKey { ! /** ! * Initializes a new instance of this class. ! */ ! protected WatchKey() { } /** * Tells whether or not this watch key is valid. * * <p> A watch key is valid upon creation and remains until it is cancelled, * or its watch service is closed. * * @return {@code true} if, and only if, this watch key is valid */ ! public abstract boolean isValid(); /** * Retrieves and removes all pending events for this watch key, returning * a {@code List} of the events that were retrieved. * * <p> Note that this method does not wait if there are no events pending. * * @return the list of the events retrieved; may be empty */ ! public abstract List<WatchEvent<?>> pollEvents(); /** * Resets this watch key. * * <p> If this watch key has been cancelled or this watch key is already in --- 79,109 ---- * is processing the events for an object at any time. * * @since 1.7 */ ! public interface WatchKey { /** * Tells whether or not this watch key is valid. * * <p> A watch key is valid upon creation and remains until it is cancelled, * or its watch service is closed. * * @return {@code true} if, and only if, this watch key is valid */ ! boolean isValid(); /** * Retrieves and removes all pending events for this watch key, returning * a {@code List} of the events that were retrieved. * * <p> Note that this method does not wait if there are no events pending. * * @return the list of the events retrieved; may be empty */ ! List<WatchEvent<?>> pollEvents(); /** * Resets this watch key. * * <p> If this watch key has been cancelled or this watch key is already in
*** 119,129 **** * * @return {@code true} if the watch key is valid and has been reset, and * {@code false} if the watch key could not be reset because it is * no longer {@link #isValid valid} */ ! public abstract boolean reset(); /** * Cancels the registration with the watch service. Upon return the watch key * will be invalid. If the watch key is enqueued, waiting to be retrieved * from the watch service, then it will remain in the queue until it is --- 115,125 ---- * * @return {@code true} if the watch key is valid and has been reset, and * {@code false} if the watch key could not be reset because it is * no longer {@link #isValid valid} */ ! boolean reset(); /** * Cancels the registration with the watch service. Upon return the watch key * will be invalid. If the watch key is enqueued, waiting to be retrieved * from the watch service, then it will remain in the queue until it is
*** 132,138 **** * cancelled. * * <p> If this watch key has already been cancelled then invoking this * method has no effect. Once cancelled, a watch key remains forever invalid. */ ! public abstract void cancel(); } --- 128,150 ---- * cancelled. * * <p> If this watch key has already been cancelled then invoking this * method has no effect. Once cancelled, a watch key remains forever invalid. */ ! void cancel(); ! ! /** ! * Returns the object for which this watch key was created. This method will ! * continue to return the object even after the key is cancelled. ! * ! * <p> As the {@code WatchService} is intended to map directly on to the ! * native file event notification facility (where available) then many of ! * details on how registered objects are watched is highly implementation ! * specific. When watching a directory for changes for example, and the ! * directory is moved or renamed in the file system, there is no guarantee ! * that the watch key will be cancelled and so the object returned by this ! * method may no longer be a valid path to the directory. ! * ! * @return the object for which this watch key was created ! */ ! //T watchable(); }