Package com.tccc.kos.commons.core.vfs
Class PathRewritingVFSSource
java.lang.Object
com.tccc.kos.commons.core.vfs.AbstractVFSSource
com.tccc.kos.commons.core.vfs.PathRewritingVFSSource
Class that wraps another source. It provides an easy way to transform the incoming
path to adjust it for the proxied source. Override
vfsToLocal()
and
localToVfs()
to perform the necessary transformations.- Since:
- 1.0
- Version:
- 2022-08-30
-
Constructor Summary
ConstructorsConstructorDescriptionPathRewritingVFSSource
(VFSSource source) Proxy the specified source and rewrite the paths for requests. -
Method Summary
Modifier and TypeMethodDescriptiongetBasePath
(VFSSource source) Returns the base path to the specified VFSSource.getFullPath
(String path) Retrieves the full path.getInputStream
(String path) Retrieves the input stream for the given path.localToVfs
(String path) Converts a path from local source to VFS format.vfsToLocal
(String path) Converts a path from VFS to local source format.Methods inherited from class com.tccc.kos.commons.core.vfs.AbstractVFSSource
getParent, isEnabled, setEnabled, setParent
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.vfs.VFSSource
getBasePath, getDetails, onUnmount
-
Constructor Details
-
PathRewritingVFSSource
Proxy the specified source and rewrite the paths for requests.
-
-
Method Details
-
vfsToLocal
Converts a path from VFS to local source format. Used ingetInputStream()
to convert incoming paths. Override as needed.- Parameters:
path
- the path to convert
-
localToVfs
Converts a path from local source to VFS format. Used ingetFullPath()
to convert a local file to full VFS path. Override as needed.- Parameters:
path
- the path to convert
-
getFullPath
Retrieves the full path.- Specified by:
getFullPath
in interfaceVFSSource
- Parameters:
path
- the source relative path- Returns:
- the full path
-
getInputStream
Retrieves the input stream for the given path.- Specified by:
getInputStream
in interfaceVFSSource
- Parameters:
path
- the requested path- Returns:
- the input stream
-
getBasePath
Returns the base path to the specified VFSSource.- Specified by:
getBasePath
in interfaceVFSParent
- Parameters:
source
- the source to return the base path for- Returns:
- the base path to the source
-