Class PathRewritingVFSSource

java.lang.Object
com.tccc.kos.commons.core.vfs.AbstractVFSSource
com.tccc.kos.commons.core.vfs.PathRewritingVFSSource
All Implemented Interfaces:
VFSParent, VFSSource

public class PathRewritingVFSSource extends AbstractVFSSource implements VFSParent
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 Details

    • PathRewritingVFSSource

      public PathRewritingVFSSource(VFSSource source)
      Proxy the specified source and rewrite the paths for requests.
  • Method Details

    • vfsToLocal

      public String vfsToLocal(String path)
      Converts a path from VFS to local source format. Used in getInputStream() to convert incoming paths. Override as needed.
      Parameters:
      path - the path to convert
    • localToVfs

      public String localToVfs(String path)
      Converts a path from local source to VFS format. Used in getFullPath() to convert a local file to full VFS path. Override as needed.
      Parameters:
      path - the path to convert
    • getFullPath

      public String getFullPath(String path)
      Retrieves the full path.
      Specified by:
      getFullPath in interface VFSSource
      Parameters:
      path - the source relative path
      Returns:
      the full path
    • getInputStream

      public InputStream getInputStream(String path)
      Retrieves the input stream for the given path.
      Specified by:
      getInputStream in interface VFSSource
      Parameters:
      path - the requested path
      Returns:
      the input stream
    • getBasePath

      public String getBasePath(VFSSource source)
      Returns the base path to the specified VFSSource.
      Specified by:
      getBasePath in interface VFSParent
      Parameters:
      source - the source to return the base path for
      Returns:
      the base path to the source