Class Resource.FileSet
Object
FileSet
- Enclosing interface:
Resource
Paths to the files potentially used by the enclosing resource.
They are typically the files given to the
DataStore
constructor,
sometime with auxiliary files (metadata, index, etc.).
FileSet
allows efficient copies of data set from one location to another.
Note that some FileSet
items of a given resource may be shared by the FileSet
of another resource. Therefore, there is no guarantee that modifying or deleting a file will not
impact other resources.
- Since:
- 1.5
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
FileSet
Creates a new instance with the given path. This is a convenience constructor for the common case where the data store uses exactly one file.- Parameters:
paths
- the single file to be returned bygetPaths()
.
-
FileSet
Creates a new instance with the given paths.- Parameters:
paths
- the files to be returned bygetPaths()
.
-
FileSet
Creates a new instance with the given paths. The content of the given collection is copied.- Parameters:
paths
- the files to be returned bygetPaths()
.
-
-
Method Details
-
getPaths
Returns the paths to the files potentially used by the enclosing resource. The first file in the returned collection should be the main file given to theDataStore
constructor or opened by other kinds of resource. All other files, if any, may be auxiliary files such as metadata or index. The files are not necessarily in the same directory, and the same files may be used by more than one resource.The returned paths should be regular files instead of directories, unless the enclosing resource is designed for using the content of the whole directory. The collection should not contain non-existent files.
- Returns:
- paths to the files potentially used by the enclosing resource.
-
copy
Copies all resource files to the given directory. The copied files are usually the files returned bygetPaths()
, but details may very depending on theDataStore
implementation. It is recommended to invoke this method only when theDataStore
is closed.Limitations:
- This method does not overwrite existing files or sub-directories. If a destination already exists, an exception should be thrown.
- This copy operation is not atomic. If an exception is thrown, some files may be only partially copied or not created at all.
jdk.zipfs
module.Default implementation
The default implementation performs a copy operation for each item returned byinvalid reference
#getPath()
- Parameters:
destDir
- the directory where to copy the resource files.- Returns:
- the copied main file. May be in a sub-directory of
destDir
. - Throws:
FileAlreadyExistsException
- if a destination file or directory already exists.IOException
- if another error occurred while copying the files.- See Also:
-
delete
Deletes the files used by the enclosing resource. TheDataStore
that contains the resource should be closed before to invoke this method. This is not an atomic operation. If an exception is thrown, some files may still remain.Default implementation
The default implementation deletes the files returned bygetPaths()
that are in the same directory or a sub-directory of the main file. Files in parent directory are not deleted, because they are often files shared by many resources (e.g. a globalmetadata.xml
file).- Throws:
IOException
- if another error occurred while deleting a file.- See Also:
-