當前位置: 首頁>>代碼示例>>Java>>正文


Java StandardWatchEventKinds.ENTRY_DELETE屬性代碼示例

本文整理匯總了Java中java.nio.file.StandardWatchEventKinds.ENTRY_DELETE屬性的典型用法代碼示例。如果您正苦於以下問題:Java StandardWatchEventKinds.ENTRY_DELETE屬性的具體用法?Java StandardWatchEventKinds.ENTRY_DELETE怎麽用?Java StandardWatchEventKinds.ENTRY_DELETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.nio.file.StandardWatchEventKinds的用法示例。


在下文中一共展示了StandardWatchEventKinds.ENTRY_DELETE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleEvent

@SuppressWarnings ( "unchecked" )
private void handleEvent ( final WatchEvent<?> event )
{
    final Kind<?> kind = event.kind ();

    if ( kind == StandardWatchEventKinds.OVERFLOW )
    {
        // FIXME: full rescan
        return;
    }

    final Path path = this.path.resolve ( ( (WatchEvent<Path>)event ).context () );

    if ( kind == StandardWatchEventKinds.ENTRY_CREATE )
    {
        this.listener.event ( path, Event.ADDED );
    }
    else if ( kind == StandardWatchEventKinds.ENTRY_DELETE )
    {
        this.listener.event ( path, Event.REMOVED );
    }
    else if ( kind == StandardWatchEventKinds.ENTRY_MODIFY )
    {
        this.listener.event ( path, Event.MODIFIED );
    }
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:26,代碼來源:Watcher.java

示例2: MacOSXWatchKey

public MacOSXWatchKey(final Watchable file, final FSEventWatchService service, final WatchEvent.Kind<?>[] events) {
    super(service);
    this.file = file;

    boolean reportCreateEvents = false;
    boolean reportModifyEvents = false;
    boolean reportDeleteEvents = false;

    for(WatchEvent.Kind<?> event : events) {
        if(event == StandardWatchEventKinds.ENTRY_CREATE) {
            reportCreateEvents = true;
        }
        else if(event == StandardWatchEventKinds.ENTRY_MODIFY) {
            reportModifyEvents = true;
        }
        else if(event == StandardWatchEventKinds.ENTRY_DELETE) {
            reportDeleteEvents = true;
        }
    }
    this.reportCreateEvents = reportCreateEvents;
    this.reportDeleteEvents = reportDeleteEvents;
    this.reportModifyEvents = reportModifyEvents;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:23,代碼來源:FSEventWatchService.java

示例3: translateActionToEvent

private WatchEvent.Kind<?> translateActionToEvent(int action) {
    switch (action) {
        case FILE_ACTION_MODIFIED :
            return StandardWatchEventKinds.ENTRY_MODIFY;

        case FILE_ACTION_ADDED :
        case FILE_ACTION_RENAMED_NEW_NAME :
            return StandardWatchEventKinds.ENTRY_CREATE;

        case FILE_ACTION_REMOVED :
        case FILE_ACTION_RENAMED_OLD_NAME :
            return StandardWatchEventKinds.ENTRY_DELETE;

        default :
            return null;  // action not recognized
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:WindowsWatchService.java

示例4: MacOSXWatchKey

public MacOSXWatchKey(AbstractWatchService macOSXWatchService, Iterable<? extends WatchEvent.Kind<?>> events) {
  super(macOSXWatchService, null, events);
  boolean reportCreateEvents = false;
  boolean reportModifyEvents = false;
  boolean reportDeleteEvents = false;

  for (WatchEvent.Kind<?> event : events) {
    if (event == StandardWatchEventKinds.ENTRY_CREATE) {
      reportCreateEvents = true;
    } else if (event == StandardWatchEventKinds.ENTRY_MODIFY) {
      reportModifyEvents = true;
    } else if (event == StandardWatchEventKinds.ENTRY_DELETE) {
      reportDeleteEvents = true;
    }
  }
  this.reportCreateEvents = reportCreateEvents;
  this.reportDeleteEvents = reportDeleteEvents;
  this.reportModifyEvents = reportModifyEvents;
}
 
開發者ID:takari,項目名稱:directory-watcher,代碼行數:19,代碼來源:MacOSXWatchKey.java

示例5: DirEvent

public DirEvent(final JsonObject json) {
    m_base = Paths.get(json.getString(FIELD_BASE));
    m_file = Paths.get(json.getString(FIELD_FILE));
    m_hash = json.getInteger(FIELD_HASH);
    m_modtm = FileTime.fromMillis(json.getLong(FIELD_MODTM));

    switch (json.getString(FIELD_KIND)) {
        case "ENTRY_CREATE":
            m_kind = StandardWatchEventKinds.ENTRY_CREATE;
            break;
        case "ENTRY_MODIFY":
            m_kind = StandardWatchEventKinds.ENTRY_MODIFY;
            break;
        case "ENTRY_DELETE":
            m_kind = StandardWatchEventKinds.ENTRY_DELETE;
            break;
        default:
            m_kind = null;
            break;
    }
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:21,代碼來源:DirEvent.java

示例6: MacOSXWatchKey

public MacOSXWatchKey(Path path, AbstractWatchService macOSXWatchService, WatchEvent.Kind<?>[] events) {
    super(macOSXWatchService);
    this.path = path;
    boolean reportCreateEvents = false;
    boolean reportModifyEvents = false;
    boolean reportDeleteEvents = false;

    for (WatchEvent.Kind<?> event : events) {
        if (event == StandardWatchEventKinds.ENTRY_CREATE) {
            reportCreateEvents = true;
        } else if (event == StandardWatchEventKinds.ENTRY_MODIFY) {
            reportModifyEvents = true;
        } else if (event == StandardWatchEventKinds.ENTRY_DELETE) {
            reportDeleteEvents = true;
        }
    }
    this.reportCreateEvents = reportCreateEvents;
    this.reportDeleteEvents = reportDeleteEvents;
    this.reportModifyEvents = reportModifyEvents;
}
 
開發者ID:ReactiveX,項目名稱:RxJavaFileUtils,代碼行數:20,代碼來源:MacOSXWatchKey.java

示例7: remove

public void remove(EphemeralFsPath name) {
    if(!isDir()) {
        throw new IllegalStateException();
    }
    assertOnlyFileName(name);
    
    DirectoryEntry entry = children.remove(name.toFileName());
    if(entry == null) {
        throw new IllegalStateException("removing but nothing exists, name:" + name);
    }
    if(!entry.isSymbolicLink() && !entry.getDestination().parents.remove(this)) {
        throw new IllegalStateException("failed to remove parent? this:" + this + " entry:" + entry);
    }
    if(entry.getDestination() != null) {
        entry.getDestination().removeLink();
    }
    EphemeralFsWatchEvent event = new EphemeralFsWatchEvent(name, StandardWatchEventKinds.ENTRY_DELETE);
    fs.getWatchRegistry().hearChange(this, event);
    contents.setDirty(true);
}
 
開發者ID:sbridges,項目名稱:ephemeralfs,代碼行數:20,代碼來源:INode.java

示例8: _registerDir

/**
 * Register the given directory with the WatchService
 *
 * @param aDir
 *        Directory to be watched. May not be <code>null</code>.
 */
private void _registerDir (@Nonnull final Path aDir) throws IOException
{
  if (s_aLogger.isDebugEnabled ())
    s_aLogger.debug ("Register directory " +
                     aDir +
                     (m_bRecursive && !m_bRegisterRecursiveManually ? " (recursively)" : ""));

  final WatchEvent.Kind <?> [] aKinds = new WatchEvent.Kind <?> [] { StandardWatchEventKinds.ENTRY_CREATE,
                                                                     StandardWatchEventKinds.ENTRY_DELETE,
                                                                     StandardWatchEventKinds.ENTRY_MODIFY };

  // throws exception when using with modifiers even if null
  final WatchKey aKey = m_aModifiers != null ? aDir.register (m_aWatcher, aKinds, m_aModifiers)
                                             : aDir.register (m_aWatcher, aKinds);
  m_aKeys.put (aKey, aDir);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:22,代碼來源:WatchDir.java

示例9: main

public static void main(String[] args) {
    DirectoryWatcher dictionaryWatcher = new DirectoryWatcher(new WatcherCallback(){
        private long lastExecute = System.currentTimeMillis();
        @Override
        public void execute(WatchEvent.Kind<?> kind, String path) {
            if(System.currentTimeMillis() - lastExecute > 1000){                  
                lastExecute = System.currentTimeMillis();
                //刷新詞典
                System.out.println("事件:"+kind.name()+" ,路徑:"+path);
            }
        }
    }, StandardWatchEventKinds.ENTRY_CREATE,
                StandardWatchEventKinds.ENTRY_MODIFY,
                StandardWatchEventKinds.ENTRY_DELETE);
    //監控DIC目錄及其所有子目錄的子目錄...遞歸
    dictionaryWatcher.watchDirectoryTree("d:/DIC");
    //隻監控DIC2目錄
    dictionaryWatcher.watchDirectory("d:/DIC2");
}
 
開發者ID:ysc,項目名稱:word,代碼行數:19,代碼來源:DirectoryWatcher.java

示例10: refreshResource

private void refreshResource(Path elementPath, WatchEvent.Kind<?> kind) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IContainer[] containers = root.findContainersForLocationURI(elementPath
			.toUri());
	IFile[] files = root.findFilesForLocationURI(elementPath.toUri());

	if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
		refresh(containers);
		refresh(files);
	} else {
		if (Files.isDirectory(elementPath)) {
			refresh(containers);
		} else {
			refresh(files);
		}
	}
}
 
開發者ID:zendtech,項目名稱:studio-workspace-refresher,代碼行數:17,代碼來源:WorkspaceRefreshMonitor.java

示例11: handleEvent

public void handleEvent ( final Path watchable, final WatchEvent<?> event ) throws IOException
{
    final Path path = (Path)event.context ();
    logger.debug ( "Change {} for base: {} on {}", new Object[] { event.kind (), watchable, path } );

    if ( watchable.endsWith ( "native" ) && path.toString ().equals ( "settings.xml" ) )
    {
        if ( event.kind () != StandardWatchEventKinds.ENTRY_DELETE )
        {
            check ();
        }
        else
        {
            storageRemoved ();
        }
    }
    else
    {
        if ( path.toString ().equals ( "settings.xml" ) )
        {
            if ( event.kind () == StandardWatchEventKinds.ENTRY_CREATE )
            {
                this.nativeKey = new File ( watchable.toFile (), "native" ).toPath ().register ( this.watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE );
            }
        }
        else if ( path.toString ().endsWith ( ".hds" ) )
        {
            if ( this.id != null )
            {
                this.storageManager.fileChanged ( this.path.toFile (), this.id, path.toFile () );
            }
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:34,代碼來源:BaseWatcher.java

示例12: checkBaseEvents

private void checkBaseEvents ( final WatchKey key, final List<WatchEvent<?>> events )
{
    for ( final WatchEvent<?> event : events )
    {
        if ( ! ( event.context () instanceof Path ) )
        {
            continue;
        }

        final Path path = this.base.resolve ( (Path)event.context () );

        logger.debug ( "Event for {}, {} : {} -> {}", new Object[] { event.context (), key.watchable (), event.kind (), path } );

        if ( event.kind () == StandardWatchEventKinds.ENTRY_DELETE )
        {
            // check delete
            checkDeleteStorage ( path );
        }
        else
        {
            try
            {
                checkAddStorage ( path );
            }
            catch ( final IOException e )
            {
                logger.warn ( "Failed to check for storage", e );
            }
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:31,代碼來源:BaseWatcher.java

示例13: isDirectory

private boolean isDirectory(Path path, WatchEvent.Kind<?> eventKind) {
    if (eventKind == StandardWatchEventKinds.ENTRY_DELETE) {
        // we cannot ask the file system whether a deleted path is a file or directory, but we
        // can use our own administration: if the path is watched, it must be a directory
        return watchedPaths.containsValue(path);
    }
    return Files.isDirectory(path);
}
 
開發者ID:openweb-nl,項目名稱:hippo-groovy-updater,代碼行數:8,代碼來源:FileSystemWatcher.java

示例14: processChange

void processChange(final WatchEvent.Kind<?> kind, final Path changedAbsPath, final boolean isDirectory) {
    if (isDirectory) {
        if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
            listener.directoryCreated(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
            listener.directoryModified(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
            listener.directoryDeleted(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.OVERFLOW) {
            if (Files.exists(changedAbsPath)) {
                log.info("Having an event overflow for '{}'. Entire directory '{}' will be recreated",
                        changedAbsPath, changedAbsPath);
                listener.directoryCreated(changedAbsPath);
            } else {
                log.info("Having an event overflow for non existing directory '{}'. Directory will be removed",
                        changedAbsPath, changedAbsPath);
                listener.directoryDeleted(changedAbsPath);
            }
        }
    } else {
        if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
            listener.fileCreated(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
            listener.fileModified(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
            listener.fileDeleted(changedAbsPath);
        } else if (kind == StandardWatchEventKinds.OVERFLOW) {
            throw new IllegalStateException("Only a directory should even possibly overflow in events, for example" +
                    " by saving 1000 new files in one go.");
        }
    }
}
 
開發者ID:openweb-nl,項目名稱:hippo-groovy-updater,代碼行數:32,代碼來源:FileSystemWatcher.java

示例15: testDeleteNonLoadedProperties

/**
 * Test what happens if an event comes in deleting a properties file for an adapter that wasn't
 * loaded <<<<<<< HEAD
 *
 * =======
 *
 * >>>>>>> bfbe35aaaf0e3eee16a4cb4121998f22a0e7cd5f
 *
 * @throws IOException
 */
@Test
public void testDeleteNonLoadedProperties() throws IOException {
    Path newdir = Paths.get(monitorDir);

    AdapterManager adapterManager = mock(AdapterManager.class);
    AdapterLoader adapterLoader = new AdapterLoader(newdir.toAbsolutePath().toString());
    adapterLoader.adapterManager = adapterManager;

    // copy the config into the monitored DIR
    Path source = Paths.get("src/test/resources/adapterConfigs/fakeAdapterPrivate.properties");
    Files.copy(source, newdir.resolve(source.getFileName()));

    WatchEvent<Path> event = new WatchEvent<Path>() {

        @Override
        public java.nio.file.WatchEvent.Kind<Path> kind() {
            return StandardWatchEventKinds.ENTRY_DELETE;
        }

        @Override
        public int count() {
            return 1;
        }

        @Override
        public Path context() {
            return Paths.get("fakeAdapterPrivate.properties");
        }

    };
    adapterLoader.processWatchEvent(event);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:42,代碼來源:AdapterLoaderTest.java


注:本文中的java.nio.file.StandardWatchEventKinds.ENTRY_DELETE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。