-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWatchEvent.java
More file actions
118 lines (109 loc) · 2.76 KB
/
WatchEvent.java
File metadata and controls
118 lines (109 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.nio.file;
/**
* An event or a repeated event for an object that is registered with a {@link
* WatchService}.
*
* <p> An event is classified by its {@link #kind() kind} and has a {@link
* #count() count} to indicate the number of times that the event has been
* observed. This allows for efficient representation of repeated events. The
* {@link #context() context} method returns any context associated with
* the event. In the case of a repeated event then the context is the same for
* all events.
*
* <p> Watch events are immutable and safe for use by multiple concurrent
* threads.
*
* @param <T> The type of the context object associated with the event
*
* @since 1.7
*/
public interface WatchEvent<T> {
/**
* An event kind, for the purposes of identification.
*
* @since 1.7
* @see StandardWatchEventKinds
*/
public static interface Kind<T> {
/**
* Returns the name of the event kind.
*
* @return the name of the event kind
*/
String name();
/**
* Returns the type of the {@link WatchEvent#context context} value.
*
*
* @return the type of the context value
*/
Class<T> type();
}
/**
* An event modifier that qualifies how a {@link Watchable} is registered
* with a {@link WatchService}.
*
* <p> This release does not define any <em>standard</em> modifiers.
*
* @since 1.7
* @see Watchable#register
*/
public static interface Modifier {
/**
* Returns the name of the modifier.
*
* @return the name of the modifier
*/
String name();
}
/**
* Returns the event kind.
*
* @return the event kind
*/
Kind<T> kind();
/**
* Returns the event count. If the event count is greater than {@code 1}
* then this is a repeated event.
*
* @return the event count
*/
int count();
/**
* Returns the context for the event.
*
* <p> In the case of {@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE},
* {@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE}, and {@link
* StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} events the context is
* a {@code Path} that is the {@link Path#relativize relative} path between
* the directory registered with the watch service, and the entry that is
* created, deleted, or modified.
*
* @return the event context; may be {@code null}
*/
T context();
}