/** * Fire directory/file change events to the registered listeners. * * @param entry The previous file system entry * @param path The current file */ private void doMatch(final FileStatusEntry entry, final Path path) throws IOException { if (entry.refresh(path)) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryChange(path); } else { listener.onFileChange(path); } } } }
@Override public void onDirectoryCreate(Path directory) { try { this.underlying.onDirectoryCreate(directory); } catch (Throwable exc) { log.error("onDirectoryCreate failure: ", exc); } }
/** * Fire directory/file delete events to the registered listeners. * * @param entry The file entry */ private void doDelete(final FileStatusEntry entry) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryDelete(entry.getPath()); } else { listener.onFileDelete(entry.getPath()); } } }
/** * Fire directory/file created events to the registered listeners. * * @param entry The file entry */ private void doCreate(final FileStatusEntry entry) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryCreate(entry.getPath()); } else { listener.onFileCreate(entry.getPath()); } } final FileStatusEntry[] children = entry.getChildren(); for (final FileStatusEntry aChildren : children) { doCreate(aChildren); } }
/** * Check whether the file and its chlidren have been created, modified or deleted. */ public void checkAndNotify() throws IOException { /* fire onStart() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStart(this); } /* fire directory/file events */ final Path rootPath = rootEntry.getPath(); if (fs.exists(rootPath)) { // Current existed. checkAndNotify(rootEntry, rootEntry.getChildren(), listPaths(rootPath)); } else if (rootEntry.isExists()) { // Existed before and not existed now. checkAndNotify(rootEntry, rootEntry.getChildren(), EMPTY_PATH_ARRAY); } else { // Didn't exist and still doesn't } /* fire onStop() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStop(this); } }
@Override public void onFileCreate(Path path) { try { this.underlying.onFileCreate(path); } catch (Throwable exc) { log.error("onFileCreate failure: ", exc); } }
@Override public void onDirectoryDelete(Path directory) { try { this.underlying.onDirectoryDelete(directory); } catch (Throwable exc) { log.error("onDirectoryDelete failure: ", exc); } }
@Override public void onStart(PathAlterationObserver observer) { try { this.underlying.onStart(observer); } catch (Throwable exc) { log.error("onStart failure: ", exc); } }
@Override public void onStop(PathAlterationObserver observer) { try { this.underlying.onStop(observer); } catch (Throwable exc) { log.error("onStop failure: ", exc); } }
@Override public void onFileChange(Path path) { try { this.underlying.onFileChange(path); } catch (Throwable exc) { log.error("onFileChange failure: ", exc); } }
@Override public void onDirectoryChange(Path directory) { try { this.underlying.onDirectoryChange(directory); } catch (Throwable exc) { log.error("onDirectoryChange failure: ", exc); } }
@Override public void onFileDelete(Path path) { try { this.underlying.onFileDelete(path); } catch (Throwable exc) { log.error("onFileDelete failure: ", exc); } } }
/** * Fire directory/file created events to the registered listeners. * * @param entry The file entry */ private void doCreate(final FileStatusEntry entry) { for (final PathAlterationListener listener : listeners.values()) { if (entry.isDirectory()) { listener.onDirectoryCreate(entry.getPath()); } else { listener.onFileCreate(entry.getPath()); } } final FileStatusEntry[] children = entry.getChildren(); for (final FileStatusEntry aChildren : children) { doCreate(aChildren); } }
/** * Check whether the file and its chlidren have been created, modified or deleted. */ public void checkAndNotify() throws IOException { /* fire onStart() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStart(this); } /* fire directory/file events */ final Path rootPath = rootEntry.getPath(); if (fs.exists(rootPath)) { // Current existed. checkAndNotify(rootEntry, rootEntry.getChildren(), listPaths(rootPath)); } else if (rootEntry.isExists()) { // Existed before and not existed now. checkAndNotify(rootEntry, rootEntry.getChildren(), EMPTY_PATH_ARRAY); } else { // Didn't exist and still doesn't } /* fire onStop() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStop(this); } }
@Override public void onFileCreate(Path path) { try { this.underlying.onFileCreate(path); } catch (Throwable exc) { log.error("onFileCreate failure: ", exc); } }
@Override public void onDirectoryDelete(Path directory) { try { this.underlying.onDirectoryDelete(directory); } catch (Throwable exc) { log.error("onDirectoryDelete failure: ", exc); } }
@Override public void onStart(PathAlterationObserver observer) { try { this.underlying.onStart(observer); } catch (Throwable exc) { log.error("onStart failure: ", exc); } }
@Override public void onStop(PathAlterationObserver observer) { try { this.underlying.onStop(observer); } catch (Throwable exc) { log.error("onStop failure: ", exc); } }
@Override public void onFileChange(Path path) { try { this.underlying.onFileChange(path); } catch (Throwable exc) { log.error("onFileChange failure: ", exc); } }
@Override public void onDirectoryChange(Path directory) { try { this.underlying.onDirectoryChange(directory); } catch (Throwable exc) { log.error("onDirectoryChange failure: ", exc); } }