Path: blob/master/src/java.base/share/classes/java/nio/file/WatchEvent.java
41159 views
/*1* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file;2627/**28* An event or a repeated event for an object that is registered with a {@link29* WatchService}.30*31* <p> An event is classified by its {@link #kind() kind} and has a {@link32* #count() count} to indicate the number of times that the event has been33* observed. This allows for efficient representation of repeated events. The34* {@link #context() context} method returns any context associated with35* the event. In the case of a repeated event then the context is the same for36* all events.37*38* <p> Watch events are immutable and safe for use by multiple concurrent39* threads.40*41* @param <T> The type of the context object associated with the event42*43* @since 1.744*/4546public interface WatchEvent<T> {4748/**49* An event kind, for the purposes of identification.50*51* @since 1.752* @see StandardWatchEventKinds53*/54public static interface Kind<T> {55/**56* Returns the name of the event kind.57*58* @return the name of the event kind59*/60String name();6162/**63* Returns the type of the {@link WatchEvent#context context} value.64*65*66* @return the type of the context value67*/68Class<T> type();69}7071/**72* An event modifier that qualifies how a {@link Watchable} is registered73* with a {@link WatchService}.74*75* <p> This release does not define any <em>standard</em> modifiers.76*77* @since 1.778* @see Watchable#register79*/80public static interface Modifier {81/**82* Returns the name of the modifier.83*84* @return the name of the modifier85*/86String name();87}8889/**90* Returns the event kind.91*92* @return the event kind93*/94Kind<T> kind();9596/**97* Returns the event count. If the event count is greater than {@code 1}98* then this is a repeated event.99*100* @return the event count101*/102int count();103104/**105* Returns the context for the event.106*107* <p> In the case of {@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE},108* {@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE}, and {@link109* StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} events the context is110* a {@code Path} that is the {@link Path#relativize relative} path between111* the directory registered with the watch service, and the entry that is112* created, deleted, or modified.113*114* @return the event context; may be {@code null}115*/116T context();117}118119120