本文整理汇总了Java中org.apache.commons.vfs2.FileListener类的典型用法代码示例。如果您正苦于以下问题:Java FileListener类的具体用法?Java FileListener怎么用?Java FileListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileListener类属于org.apache.commons.vfs2包,在下文中一共展示了FileListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Removes a listener from a file in this file system.
* @param file The FileObject to be monitored.
* @param listener The FileListener
*/
public void removeListener(final FileObject file,
final FileListener listener)
{
synchronized (listenerMap)
{
final ArrayList<?> listeners = listenerMap.get(file.getName());
if (listeners != null)
{
listeners.remove(listener);
if (listeners.isEmpty())
{
listenerMap.remove(file.getName());
}
}
}
}
示例2: addListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Adds a listener on a file in this file system.
* @param file The FileObject to be monitored.
* @param listener The FileListener
*/
public void addListener(final FileObject file,
final FileListener listener)
{
synchronized (listenerMap)
{
ArrayList<FileListener> listeners = listenerMap.get(file.getName());
if (listeners == null)
{
listeners = new ArrayList<FileListener>();
listenerMap.put(file.getName(), listeners);
}
listeners.add(listener);
}
}
示例3: fireEvent
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Fires an event.
*/
private void fireEvent(final AbstractFileChangeEvent event)
{
FileListener[] fileListeners = null;
final FileObject file = event.getFile();
synchronized (listenerMap)
{
final ArrayList<?> listeners = listenerMap.get(file.getName());
if (listeners != null)
{
fileListeners = listeners.toArray(new FileListener[listeners.size()]);
}
}
if (fileListeners != null)
{
for (int i = 0; i < fileListeners.length; i++)
{
final FileListener fileListener = fileListeners[i];
try
{
event.notify(fileListener);
}
catch (final Exception e)
{
final String message = Messages.getString("vfs.provider/notify-listener.warn", file);
// getLogger().warn(message, e);
VfsLog.warn(getLogger(), LOG, message, e);
}
}
}
}
示例4: installListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* This will install the <code>listener</code> at the given <code>file</code>.
* @param file The FileObject to listen on.
* @param listener The FileListener
*/
public static void installListener(final FileObject file, final FileListener listener)
{
WeakRefFileListener weakListener = new WeakRefFileListener(file, listener);
file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener));
}
示例5: getListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* returns the wrapped listener. If it is gone, the WeakRefFileListener wrapper will
* remove itself from the list of listeners.
* @return The FileListener.
* @throws Exception if an error occurs.
*/
protected FileListener getListener() throws Exception
{
FileListener listener = this.listener.get();
if (listener == null)
{
FileObject file = fs.resolveFile(name);
file.getFileSystem().removeListener(file, this);
}
return listener;
}
示例6: fileCreated
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Called when a file is created.
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
public void fileCreated(final FileChangeEvent event) throws Exception
{
FileListener listener = getListener();
if (listener == null)
{
return;
}
listener.fileCreated(event);
}
示例7: fileDeleted
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Called when a file is deleted.
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
public void fileDeleted(final FileChangeEvent event) throws Exception
{
FileListener listener = getListener();
if (listener == null)
{
return;
}
listener.fileDeleted(event);
}
示例8: fileChanged
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Called when a file is changed.
* <p/>
* This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}.
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
public void fileChanged(FileChangeEvent event) throws Exception
{
FileListener listener = getListener();
if (listener == null)
{
return;
}
listener.fileChanged(event);
}
示例9: addListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
public void addListener(FileObject path, FileListener listener) throws Exception {
stop();
try {
monitor = new DefaultFileMonitor(listener);
monitor.addFile(path);
} finally {
start();
}
}
示例10: notify
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
listener.fileCreated(this);
}
示例11: notify
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
listener.fileDeleted(this);
}
示例12: notify
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
listener.fileChanged(this);
}
示例13: WeakRefFileListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
protected WeakRefFileListener(final FileObject file, final FileListener listener)
{
this.fs = file.getFileSystem();
this.name = file.getName();
this.listener = new WeakReference<FileListener>(listener);
}
示例14: DefaultFileMonitor
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
public DefaultFileMonitor(final FileListener listener)
{
this.listener = listener;
}
示例15: getFileListener
import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
* Access method to get the current FileListener object notified when there
* are changes with the files added.
* @return The FileListener.
*/
FileListener getFileListener()
{
return this.listener;
}