Package de.xima.fc.common.filesystem
Interface ICommonFileSystemManager<FD>
-
- Type Parameters:
FD
- The super type of the file system entries of each file system. Each file system may have a different entry type; this is the common super type of all entry types (which could be Object).
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FormThemeFileSystemManager
public interface ICommonFileSystemManager<FD> extends AutoCloseable
Manager for multiplefile systems
. Each file system represents a volume, such as a local file system, a database, or a remote file system like FTP or WebDAV.The manager is responsible for mounting and unmounting file systems, and for listing all available file systems.
- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
copy(FD from, FD to)
Copies the given file entry to the given target.<FD2 extends FD>
ICommonFileSystem<FD2>fileSystemByEntry(FD2 entry)
Finds the file system responsible for the given file system entry.ICommonFileSystem<? extends FD>
fileSystemByProtocol(String protocol)
Gets the file system handler for the givenprotocol
.ICommonFileSystem<? extends FD>
fileSystemByVolumeId(String volumeId)
Gets the file system handler for the given volume ID.boolean
isOpen()
Checks whether this file system manager is open.Iterable<ICommonFileSystemVolume<? extends FD>>
listVolumes()
Lists all available file systems, sometimes also called volumes.void
refresh()
If the implementation employs any kind of caching: discards all caches so that this instance represents the most up-to-date state.void
rename(FD from, FD to)
Renames the given file entry to the given target.<FileSystemManager>
FileSystemManagerunwrap(Class<? extends FileSystemManager> type)
Unwraps this file system manager to the given type.ICommonFileSystemVolume<? extends FD>
volumeByVolumeId(String volumeId)
Gets the volume info for the given volume ID.VolumeFileSystem<? extends FD>
volumeFileSystemByVolumeId(String volumeId)
Gets the volume and file system handler for the given volume ID.-
Methods inherited from interface java.lang.AutoCloseable
close
-
-
-
-
Method Detail
-
copy
void copy(FD from, FD to) throws IOException
Copies the given file entry to the given target. When the entries are from the same file system or volume, the implementation may simply callICommonFileSystem.copy(Object, Object)
. If the entries are from different file systems, the implementation may need to read the source and write the target manually.Either both source and target are files; or both are directories.
- Parameters:
from
- The file entry to copy.to
- The target file entry.- Throws:
IOException
- If an I/O error occurs.
-
fileSystemByEntry
<FD2 extends FD> ICommonFileSystem<FD2> fileSystemByEntry(FD2 entry)
Finds the file system responsible for the given file system entry.- Type Parameters:
FD2
- The subtype of the file system entry.- Parameters:
entry
- The file system entry for which to find its corresponding file system.- Returns:
- The file system for the given file system entry.
-
fileSystemByProtocol
ICommonFileSystem<? extends FD> fileSystemByProtocol(String protocol)
Gets the file system handler for the givenprotocol
. Returns null if no handler exists.- Parameters:
protocol
- The protocol of the file system to get.- Returns:
- The file system with the given volume name, or null if no such file system is mounted.
-
fileSystemByVolumeId
ICommonFileSystem<? extends FD> fileSystemByVolumeId(String volumeId)
Gets the file system handler for the given volume ID. Returns null if no handler exists. This is a shortcut for callingvolumeByVolumeId(String)
and thenfileSystemByProtocol(String)
.- Parameters:
volumeId
- The ID of the volume to get.- Returns:
- The file system with the given volume ID, or null if no such file system is mounted.
-
isOpen
boolean isOpen()
Checks whether this file system manager is open. If it is not open, all operations will fail.- Returns:
- True if the file system manager is open, false otherwise.
- See Also:
AutoCloseable.close()
-
listVolumes
Iterable<ICommonFileSystemVolume<? extends FD>> listVolumes()
Lists all available file systems, sometimes also called volumes. A volume could e.g. be a local file system, a database, or a remote file system such as FTP.- Returns:
- All available volumes.
-
refresh
void refresh() throws IOException
If the implementation employs any kind of caching: discards all caches so that this instance represents the most up-to-date state.Implementations should usually call
ICommonFileSystem.refresh()
on all mounted file systems. In addition, implementations may also perform additional operations, such as refreshing the list of file systems.- Throws:
IOException
- If an I/O error occurs during the refresh.
-
rename
void rename(FD from, FD to) throws IOException
Renames the given file entry to the given target. When the entries are from the same file system or volume, the implementation may simply callICommonFileSystem.rename(Object, Object)
. If the entries are from different file systems, the implementation may need to read the source, write to the target, and delete the source manually.Either both source and target are files; or both are directories.
- Parameters:
from
- The file entry to copy.to
- The target file entry.- Throws:
IOException
- If an I/O error occurs.
-
unwrap
<FileSystemManager> FileSystemManager unwrap(Class<? extends FileSystemManager> type)
Unwraps this file system manager to the given type. If this file system manager is an instance of the given type, it is returned. Otherwise, potential wrappers are unwrapped until the given type is reached. If the file system manager cannot be unwrapped to the given type, null is returned.If multiple wrappers are present, the first one that can be unwrapped to the given type is returned.
- Type Parameters:
FileSystemManager
- The type of the desired file system manager.- Parameters:
type
- The type to unwrap to.- Returns:
- The unwrapped file system manager, or null if the file system manager cannot be unwrapped to the given type.
-
volumeByVolumeId
ICommonFileSystemVolume<? extends FD> volumeByVolumeId(String volumeId)
Gets the volume info for the given volume ID. Returns null if no such volume exists.- Parameters:
volumeId
- The ID of the volume to get.- Returns:
- The volume with the given volume ID, or null if no such volume is mounted.
-
volumeFileSystemByVolumeId
VolumeFileSystem<? extends FD> volumeFileSystemByVolumeId(String volumeId)
Gets the volume and file system handler for the given volume ID. Returns null if no handler exists. This is a shortcut for callingvolumeByVolumeId(String)
and thenfileSystemByProtocol(String)
.- Parameters:
volumeId
- The ID of the volume to get.- Returns:
- The file system with the given volume ID, or null if no such file system is mounted.
-
-