本文整理汇总了Java中java.nio.file.WatchEvent.Modifier类的典型用法代码示例。如果您正苦于以下问题:Java Modifier类的具体用法?Java Modifier怎么用?Java Modifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Modifier类属于java.nio.file.WatchEvent包,在下文中一共展示了Modifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWatchEventModifiers
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
/**
* This is required to speed up mac based file watcher implementations
*
* @return sensitivity watch event modifier
*/
private static Modifier[] getWatchEventModifiers() {
String className = "com.sun.nio.file.SensitivityWatchEventModifier";
try {
Class<?> c = Class.forName(className);
Field f = c.getField("HIGH");
Modifier modifier = cast(f.get(c));
LOG.debug("Class '{}' is found in classpath setting corresponding watch modifier", className);
return new Modifier[] {modifier};
} catch (Exception e) {
LOG.debug("Class '{}' is not found in classpath, falling to default mode", className, e);
return new Modifier[] {};
}
}
示例2: registerTreeRecursive
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void registerTreeRecursive() throws Exception {
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
.expect(newThread)
.expect(registerTree(true, false))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
unit.captured(FileVisitor.class).get(0).preVisitDirectory(unit.get(Path.class), null);
});
}
示例3: registerTree
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void registerTree() throws Exception {
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例4: registerTreeErr
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void registerTreeErr() throws Exception {
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
.expect(newThread)
.expect(registerTree(false, true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例5: pollIgnoreMissing
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollIgnoreMissing() throws Exception {
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(takeIgnore)
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例6: pollEvents
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEvents() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
.expect(filter(true))
.expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, false))
.expect(recursive(false, false))
.expect(reset(true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例7: pollEventsInvalid
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEventsInvalid() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
.expect(filter(true))
.expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, false))
.expect(recursive(false, false))
.expect(reset(false))
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例8: pollEventsRecursive
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEventsRecursive() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_CREATE, path))
.expect(filter(true))
.expect(handler(StandardWatchEventKinds.ENTRY_CREATE, false))
.expect(recursive(true, false))
.expect(reset(true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.first(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例9: pollEventsRecursiveErr
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEventsRecursiveErr() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_CREATE, path))
.expect(filter(true))
.expect(handler(StandardWatchEventKinds.ENTRY_CREATE, false))
.expect(recursive(true, true))
.expect(reset(true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.first(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例10: pollEventWithHandleErr
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEventWithHandleErr() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
.expect(filter(true))
.expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, true))
.expect(recursive(false, false))
.expect(reset(true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例11: pollEventsNoMatches
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Test
public void pollEventsNoMatches() throws Exception {
Path path = Paths.get("target/foo.txt");
new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
PathMatcher.class, FileEventHandler.class)
.expect(newThread)
.expect(registerTree(false, false))
.expect(take)
.expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
.expect(filter(false))
.expect(recursive(false, false))
.expect(reset(true))
.expect(takeInterrupt)
.run(unit -> {
FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
unit.get(WatchService.class),
ImmutableSet.of(unit.get(FileEventOptions.class)));
unit.captured(ThreadFactory.class).get(0).newThread(monitor);
}, unit -> {
unit.captured(Runnable.class).get(0).run();
});
}
示例12: register
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
if (!CloudWatchService.class.isAssignableFrom(watcher.getClass())) {
throw new IllegalArgumentException("The file system watcher must be of type " +
CloudWatchService.class + " but was " + watcher.getClass());
}
return ((CloudWatchService)watcher).register(this, events, modifiers);
}
示例13: register
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
protected JWatchKey register(JPath path, Kind<?>[] events, Modifier ... modifiers)
{
JWatchKey key = new JWatchKey(this, path, events, modifiers);
synchronized (this) {
_watchList.add(key);
}
return key;
}
示例14: JWatchKey
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
public JWatchKey(JWatchService watchService,
JPath path,
Kind<?>[] events,
Modifier ... modifiers)
{
Objects.requireNonNull(events);
_watchService = watchService;
_path = path;
_events = events;
_modifiers = modifiers;
_watchHandle = path.getBfsFile().watch(pathString -> onWatch(pathString));
}
示例15: register
import java.nio.file.WatchEvent.Modifier; //导入依赖的package包/类
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
Modifier... modifiers) throws IOException
{
if (events.length == 0) {
throw new IllegalArgumentException(L.l("no events specified to watch on: {0}", toUri()));
}
JWatchService jWatcher = (JWatchService) watcher;
WatchKey key = jWatcher.register(this, events, modifiers);
return key;
}