当前位置: 首页>>代码示例>>Java>>正文


Java WatchEvent.Modifier方法代码示例

本文整理汇总了Java中java.nio.file.WatchEvent.Modifier方法的典型用法代码示例。如果您正苦于以下问题:Java WatchEvent.Modifier方法的具体用法?Java WatchEvent.Modifier怎么用?Java WatchEvent.Modifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.WatchEvent的用法示例。


在下文中一共展示了WatchEvent.Modifier方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: instantiateWatchModifiers

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
private static WatchEvent.Modifier[] instantiateWatchModifiers() {
    if (JavaVersion.current().isJava9Compatible()) {
        return new WatchEvent.Modifier[]{};
    } else {
        // use reflection to support older JVMs while supporting Java 9
        WatchEvent.Modifier highSensitive = instantiateEnum("com.sun.nio.file.SensitivityWatchEventModifier", "HIGH");
        if (FILE_TREE_WATCHING_SUPPORTED) {
            WatchEvent.Modifier fileTree = instantiateEnum("com.sun.nio.file.ExtendedWatchEventModifier", "FILE_TREE");
            return new WatchEvent.Modifier[]{fileTree, highSensitive};
        } else {
            return new WatchEvent.Modifier[]{highSensitive};
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:15,代码来源:WatchServiceRegistrar.java

示例2: instantiateEnum

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
private static WatchEvent.Modifier instantiateEnum(String className, String enumName) {
    try {
        return (WatchEvent.Modifier) Enum.valueOf((Class<Enum>) Class.forName(className), enumName);
    } catch (ClassNotFoundException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:WatchServiceRegistrar.java

示例3: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(final Watchable folder,
                         final WatchEvent.Kind<?>[] events,
                         final WatchEvent.Modifier... modifiers)
        throws IOException {
    if(log.isInfoEnabled()) {
        log.info(String.format("Register file %s for events %s", folder, Arrays.toString(events)));
    }
    final Pointer[] values = {
            CFStringRef.toCFString(folder.toString()).getPointer()};

    final MacOSXWatchKey key = new MacOSXWatchKey(folder, this, events);

    final double latency = 1.0; // Latency in seconds

    final Map<File, Long> timestamps = createLastModifiedMap(new File(folder.toString()));
    final FSEvents.FSEventStreamCallback callback = new Callback(key, timestamps);
    final FSEventStreamRef stream = library.FSEventStreamCreate(
            Pointer.NULL, callback, Pointer.NULL,
            library.CFArrayCreate(null, values, CFIndex.valueOf(1), null),
            -1, latency,
            kFSEventStreamCreateFlagNoDefer);
    final CountDownLatch lock = new CountDownLatch(1);
    final CFRunLoop loop = new CFRunLoop(lock, stream);
    threadFactory.newThread(loop).start();
    try {
        lock.await();
    }
    catch(InterruptedException e) {
        throw new IOException(String.format("Failure registering for events in %s", folder), e);
    }
    loops.put(key, loop);
    callbacks.put(key, callback);
    return key;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:36,代码来源:FSEventWatchService.java

示例4: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events,
                         final WatchEvent.Modifier... modifiers) throws IOException {
    if(null == monitor) {
        monitor = FileSystems.getDefault().newWatchService();
    }
    final WatchKey key = folder.register(monitor, events, modifiers);
    if(log.isInfoEnabled()) {
        log.info(String.format("Registered for events for %s", key));
    }
    return key;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:13,代码来源:NIOEventWatchService.java

示例5: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
WatchKey register(Path path,
                  WatchEvent.Kind<?>[] events,
                  WatchEvent.Modifier... modifiers)
     throws IOException
{
    // delegate to poller
    return poller.register(path, events, modifiers);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:WindowsWatchService.java

示例6: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register( WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers )
{
    if( watcher == null || events == null || modifiers == null ) {
        throw new NullPointerException();
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:peter-mount,项目名称:filesystem,代码行数:9,代码来源:AbstractPath.java

示例7: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(WatchService watcher,
  WatchEvent.Kind<?>[] events,
  WatchEvent.Modifier... modifiers)
    throws IOException {
  if (watcher == null) {
    throw new NullPointerException();
  }
  if (!(watcher instanceof AbstractWatchService)) {
    throw new ProviderMismatchException();
  }
  return ((AbstractWatchService) watcher).register(this, Arrays.asList(events));
}
 
开发者ID:takari,项目名称:directory-watcher,代码行数:14,代码来源:WatchablePath.java

示例8: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException {
    throw new UnsupportedOperationException("Unexpected call!");
}
 
开发者ID:yandex,项目名称:graphouse,代码行数:5,代码来源:MetricPath.java

示例9: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
WatchKey register(Watchable folder,
WatchEvent.Kind<?>[] events,
WatchEvent.Modifier... modifiers) throws IOException;
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:4,代码来源:RegisterWatchService.java

示例10: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException {
    return null;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:5,代码来源:DisabledWatchService.java

示例11: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
/**
 * Register this internal option as a WatchEvent.Modifier.
 */
public void register(WatchEvent.Modifier option) {
    registerInternal(option, null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:ExtendedOptions.java

示例12: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
/**
 * Register the given file with this watch service
 */
@Override
WatchKey register(final Path path,
                  WatchEvent.Kind<?>[] events,
                  WatchEvent.Modifier... modifiers)
     throws IOException
{
    // check events - CCE will be thrown if there are invalid elements
    final Set<WatchEvent.Kind<?>> eventSet = new HashSet<>(events.length);
    for (WatchEvent.Kind<?> event: events) {
        // standard events
        if (event == StandardWatchEventKinds.ENTRY_CREATE ||
            event == StandardWatchEventKinds.ENTRY_MODIFY ||
            event == StandardWatchEventKinds.ENTRY_DELETE)
        {
            eventSet.add(event);
            continue;
        }

        // OVERFLOW is ignored
        if (event == StandardWatchEventKinds.OVERFLOW) {
            continue;
        }

        // null/unsupported
        if (event == null)
            throw new NullPointerException("An element in event set is 'null'");
        throw new UnsupportedOperationException(event.name());
    }
    if (eventSet.isEmpty())
        throw new IllegalArgumentException("No events to register");

    // Extended modifiers may be used to specify the sensitivity level
    int sensitivity = 10;
    if (modifiers.length > 0) {
        for (WatchEvent.Modifier modifier: modifiers) {
            if (modifier == null)
                throw new NullPointerException();

            if (ExtendedOptions.SENSITIVITY_HIGH.matches(modifier)) {
                sensitivity = ExtendedOptions.SENSITIVITY_HIGH.parameter();
            } else if (ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier)) {
                sensitivity = ExtendedOptions.SENSITIVITY_MEDIUM.parameter();
            } else if (ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) {
                sensitivity = ExtendedOptions.SENSITIVITY_LOW.parameter();
            } else {
                throw new UnsupportedOperationException("Modifier not supported");
            }
        }
    }

    // check if watch service is closed
    if (!isOpen())
        throw new ClosedWatchServiceException();

    // registration is done in privileged block as it requires the
    // attributes of the entries in the directory.
    try {
        int value = sensitivity;
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<PollingWatchKey>() {
                @Override
                public PollingWatchKey run() throws IOException {
                    return doPrivilegedRegister(path, eventSet, value);
                }
            });
    } catch (PrivilegedActionException pae) {
        Throwable cause = pae.getCause();
        if (cause != null && cause instanceof IOException)
            throw (IOException)cause;
        throw new AssertionError(pae);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:76,代码来源:PollingWatchService.java

示例13: register

import java.nio.file.WatchEvent; //导入方法依赖的package包/类
@Override
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events,
    WatchEvent.Modifier... modifiers) throws IOException {
  throw new UnsupportedOperationException();
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:GcsPath.java


注:本文中的java.nio.file.WatchEvent.Modifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。