/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Base implementation class for watch keys.
*/
/**
* Maximum size of event list (in the future this may be tunable)
*/
/**
* Special event to signal overflow
*/
/**
* Possible key states
*/
// reference to watcher
// reference to the original directory
// key state
// pending events
// maps a context to the last event for the context (iff the last queued
// event for the context is an ENTRY_MODIFY event).
}
return watcher;
}
/**
* Return the original watchable (Path)
*/
return dir;
}
/**
* Enqueues this key to the watch service
*/
final void signal() {
synchronized (this) {
watcher.enqueueKey(this);
}
}
}
/**
* Adds the event to this key and signals it.
*/
@SuppressWarnings("unchecked")
synchronized (this) {
if (size > 0) {
// if the previous event is an OVERFLOW event or this is a
// repeated event then we simply increment the counter
{
return;
}
// if this is a modify event and the last entry for the context
// is a modify event then we simply increment the count
if (!lastModifyEvents.isEmpty()) {
if (isModify) {
return;
}
} else {
// not a modify event so remove from the map as the
// last event will no longer be a modify event.
}
}
// if the list has reached the limit then drop pending events
// and queue an OVERFLOW event
if (size >= MAX_EVENT_LIST_SIZE) {
isModify = false;
}
}
// non-repeated event
if (isModify) {
// drop all pending events
}
signal();
}
}
synchronized (this) {
return result;
}
}
public final boolean reset() {
synchronized (this) {
} else {
// pending events so re-queue key
watcher.enqueueKey(this);
}
}
return isValid();
}
}
/**
* WatchEvent implementation
*/
private final T context;
private int count;
this.count = 1;
}
return kind;
}
public T context() {
return context;
}
public int count() {
return count;
}
// for repeated events
void increment() {
count++;
}
}
}