當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。