| 1 | |
package org.webslinger.commons.vfs; |
| 2 | |
|
| 3 | |
import org.apache.commons.vfs.FileObject; |
| 4 | |
import org.apache.commons.vfs.FileSystemException; |
| 5 | |
import org.apache.commons.vfs.provider.AbstractFileSystem; |
| 6 | |
|
| 7 | |
import org.webslinger.io.AbstractPollingMonitor; |
| 8 | |
|
| 9 | 0 | public class PollingFileObjectMonitor<F extends FileObject> extends AbstractPollingMonitor<F, PollingFileObjectMonitor<F>, PollingFileObjectMonitor.WatchedFileObject<F>, FileObjectMonitor.FileObjectListener<F>> { |
| 10 | |
public PollingFileObjectMonitor(long delay) { |
| 11 | 0 | super(delay); |
| 12 | 0 | } |
| 13 | |
|
| 14 | |
protected WatchedFileObject createWatched(F item) { |
| 15 | 0 | return new WatchedFileObject(this, item); |
| 16 | |
} |
| 17 | |
|
| 18 | |
protected static class WatchedFileObject<F extends FileObject> extends AbstractPollingMonitor.PollingWatched<F, PollingFileObjectMonitor<F>, WatchedFileObject<F>, FileObjectMonitor.FileObjectListener<F>> { |
| 19 | |
public WatchedFileObject(PollingFileObjectMonitor monitor, F item) { |
| 20 | 0 | super(monitor, item); |
| 21 | 0 | } |
| 22 | |
|
| 23 | |
public void refresh() throws FileSystemException { |
| 24 | 0 | item.refresh(); |
| 25 | 0 | } |
| 26 | |
|
| 27 | |
public boolean exists() throws FileSystemException { |
| 28 | 0 | return item.exists(); |
| 29 | |
} |
| 30 | |
|
| 31 | |
public long lastModifiedTime() throws FileSystemException { |
| 32 | 0 | return item.getContent().getLastModifiedTime(); |
| 33 | |
} |
| 34 | |
|
| 35 | |
public long size() throws FileSystemException { |
| 36 | 0 | return item.getContent().getSize(); |
| 37 | |
} |
| 38 | |
} |
| 39 | |
} |