INSTANCE
- The type of instance in the datasetpublic class VFSListDataset<INSTANCE> extends ReadableListDataset<INSTANCE,org.apache.commons.vfs2.FileObject> implements Identifiable
ListDataset
backed by a directory of items (either locally or
remotely), or items stored in a compressed archive.
As an example, this class can be used to easily create a ListDataset
from a directory of images:
ListDataset<FImage> dataset = new VFSListDataset<FImage>("/path/to/directory/of/images", ImageUtilities.FIMAGE_READER);a zip file of images:
ListDataset<FImage> dataset = new VFSListDataset<FImage>( "zip:file:/path/to/images.zip", ImageUtilities.FIMAGE_READER);or even a remote zip of images hosted via http:
ListDataset<FImage> dataset = new VFSListDataset<FImage>( "zip:http://localhost/˜jsh2/thumbnails.zip", ImageUtilities.FIMAGE_READER);
Modifier and Type | Class and Description |
---|---|
static class |
VFSListDataset.FileObjectISReader<INSTANCE>
An adaptor that lets
InputStreamObjectReader s be used as a
ObjectReader with a FileObject source type. |
reader
modCount
Constructor and Description |
---|
VFSListDataset(String path,
InputStreamObjectReader<INSTANCE> reader)
Construct a list dataset from any virtual file system source (local
directory, remote zip file, etc).
|
VFSListDataset(String path,
ObjectReader<INSTANCE,org.apache.commons.vfs2.FileObject> reader)
Construct a list dataset from any virtual file system source (local
directory, remote zip file, etc).
|
Modifier and Type | Method and Description |
---|---|
org.apache.commons.vfs2.FileObject |
getFileObject(int index)
Get the underlying file descriptor for a particular instance in the
dataset.
|
org.apache.commons.vfs2.FileObject[] |
getFileObjects()
Get the underlying file descriptors of the files in the dataset
|
String |
getID() |
String |
getID(int index)
Get an identifier for the instance at the given index.
|
INSTANCE |
getInstance(int index)
Returns the instance at the specified position in this dataset.
|
Iterator<INSTANCE> |
iterator() |
int |
numInstances()
Returns the number of instances in this dataset.
|
String |
toString() |
get, getRandomInstance, indexOfID, size, toIdentifiable
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
equals
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public VFSListDataset(String path, InputStreamObjectReader<INSTANCE> reader) throws org.apache.commons.vfs2.FileSystemException
path
- the file system path or uri. See the Apache Commons VFS2
documentation for all the details.reader
- the InputStreamObjectReader
that reads the data from
the VFSorg.apache.commons.vfs2.FileSystemException
- if an error occurs accessing the VFSpublic VFSListDataset(String path, ObjectReader<INSTANCE,org.apache.commons.vfs2.FileObject> reader) throws org.apache.commons.vfs2.FileSystemException
path
- the file system path or uri. See the Apache Commons VFS2
documentation for all the details.reader
- the ObjectReader
that reads the data from the VFSorg.apache.commons.vfs2.FileSystemException
- if an error occurs accessing the VFSpublic org.apache.commons.vfs2.FileObject[] getFileObjects()
public org.apache.commons.vfs2.FileObject getFileObject(int index)
index
- index of the instancepublic INSTANCE getInstance(int index)
ListDataset
getInstance
in interface ListDataset<INSTANCE>
index
- index of the instance to returnpublic int numInstances()
Dataset
numInstances
in interface Dataset<INSTANCE>
public String getID(int index)
ReadableListDataset
String
, but sub-classes
should override to to something more sensible if possible.getID
in class ReadableListDataset<INSTANCE,org.apache.commons.vfs2.FileObject>
index
- the indexpublic String toString()
toString
in class AbstractCollection<INSTANCE>
public String getID()
getID
in interface Identifiable