Package com.google.common.jimfs
Class AbstractWatchService.Key
- java.lang.Object
-
- com.google.common.jimfs.AbstractWatchService.Key
-
- All Implemented Interfaces:
java.nio.file.WatchKey
- Enclosing class:
- AbstractWatchService
static final class AbstractWatchService.Key extends java.lang.Object implements java.nio.file.WatchKeyImplementation ofWatchKeyfor anAbstractWatchService.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAbstractWatchService.Key.State
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.BlockingQueue<java.nio.file.WatchEvent<?>>events(package private) static intMAX_QUEUE_SIZEprivate java.util.concurrent.atomic.AtomicIntegeroverflowprivate java.util.concurrent.atomic.AtomicReference<AbstractWatchService.Key.State>stateprivate com.google.common.collect.ImmutableSet<java.nio.file.WatchEvent.Kind<?>>subscribedTypesprivate java.util.concurrent.atomic.AtomicBooleanvalidprivate java.nio.file.Watchablewatchableprivate AbstractWatchServicewatcher
-
Constructor Summary
Constructors Constructor Description Key(AbstractWatchService watcher, @Nullable java.nio.file.Watchable watchable, java.lang.Iterable<? extends java.nio.file.WatchEvent.Kind<?>> subscribedTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()booleanisValid()private static java.nio.file.WatchEvent<java.lang.Object>overflowEvent(int count)java.util.List<java.nio.file.WatchEvent<?>>pollEvents()voidpost(java.nio.file.WatchEvent<?> event)Posts the given event to this key.booleanreset()voidsignal()Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in the READY state.(package private) AbstractWatchService.Key.Statestate()Gets the current state of this key, State.READY or SIGNALLED.booleansubscribesTo(java.nio.file.WatchEvent.Kind<?> eventType)Gets whether or not this key is subscribed to the given type of event.java.nio.file.Watchablewatchable()
-
-
-
Field Detail
-
MAX_QUEUE_SIZE
static final int MAX_QUEUE_SIZE
- See Also:
- Constant Field Values
-
watcher
private final AbstractWatchService watcher
-
watchable
private final java.nio.file.Watchable watchable
-
subscribedTypes
private final com.google.common.collect.ImmutableSet<java.nio.file.WatchEvent.Kind<?>> subscribedTypes
-
state
private final java.util.concurrent.atomic.AtomicReference<AbstractWatchService.Key.State> state
-
valid
private final java.util.concurrent.atomic.AtomicBoolean valid
-
overflow
private final java.util.concurrent.atomic.AtomicInteger overflow
-
events
private final java.util.concurrent.BlockingQueue<java.nio.file.WatchEvent<?>> events
-
-
Constructor Detail
-
Key
public Key(AbstractWatchService watcher, @Nullable java.nio.file.Watchable watchable, java.lang.Iterable<? extends java.nio.file.WatchEvent.Kind<?>> subscribedTypes)
-
-
Method Detail
-
overflowEvent
private static java.nio.file.WatchEvent<java.lang.Object> overflowEvent(int count)
-
state
AbstractWatchService.Key.State state()
Gets the current state of this key, State.READY or SIGNALLED.
-
subscribesTo
public boolean subscribesTo(java.nio.file.WatchEvent.Kind<?> eventType)
Gets whether or not this key is subscribed to the given type of event.
-
post
public void post(java.nio.file.WatchEvent<?> event)
Posts the given event to this key. After posting one or more events,signal()must be called to cause the key to be enqueued with the watch service.
-
signal
public void signal()
Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in the READY state.
-
isValid
public boolean isValid()
- Specified by:
isValidin interfacejava.nio.file.WatchKey
-
pollEvents
public java.util.List<java.nio.file.WatchEvent<?>> pollEvents()
- Specified by:
pollEventsin interfacejava.nio.file.WatchKey
-
reset
@CanIgnoreReturnValue public boolean reset()
- Specified by:
resetin interfacejava.nio.file.WatchKey
-
cancel
public void cancel()
- Specified by:
cancelin interfacejava.nio.file.WatchKey
-
watchable
public java.nio.file.Watchable watchable()
- Specified by:
watchablein interfacejava.nio.file.WatchKey
-
-