Class LocalFileSystemSub

  • All Implemented Interfaces:
    GFileSystem, ExtensionPoint, java.io.Closeable, java.lang.AutoCloseable

    public class LocalFileSystemSub
    extends java.lang.Object
    implements GFileSystem
    A GFileSystem interface to a part of the user's local / native file system.

    This class is a sub-view of the LocalFileSystem, and returns hybrid GFile objects that have fully specified FSRL paths that are valid in the Root filesystem, but relative GFile paths.

    This class's name doesn't end with "FileSystem" to ensure it will not be auto-discovered by the FileSystemFactoryMgr.

    • Constructor Detail

      • LocalFileSystemSub

        public LocalFileSystemSub​(java.io.File rootDir,
                                  GFileSystem rootFS)
                           throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getType

        public java.lang.String getType()
        Description copied from interface: GFileSystem
        Returns the type of this file system.

        This default implementation returns the type value in FileSystemInfo annotation.

        Specified by:
        getType in interface GFileSystem
        Returns:
        type string
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: GFileSystem
        Returns a description of this file system.

        This default implementation returns the description value in FileSystemInfo annotation.

        Specified by:
        getDescription in interface GFileSystem
        Returns:
        description string
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • isClosed

        public boolean isClosed()
        Description copied from interface: GFileSystem
        Returns true if the filesystem has been closed
        Specified by:
        isClosed in interface GFileSystem
        Returns:
        boolean true if the filesystem has been closed.
      • isStatic

        public boolean isStatic()
        Description copied from interface: GFileSystem
        Indicates if this filesystem is a static snapshot or changes.
        Specified by:
        isStatic in interface GFileSystem
        Returns:
        boolean true if the filesystem is static or false if dynamic content.
      • getListing

        public java.util.List<GFile> getListing​(GFile directory)
                                         throws java.io.IOException
        Description copied from interface: GFileSystem
        Returns a list of files that reside in the specified directory on this filesystem.

        Specified by:
        getListing in interface GFileSystem
        Parameters:
        directory - NULL means root of filesystem.
        Returns:
        List of GFile instances of file in the requested directory.
        Throws:
        java.io.IOException - if IO problem.
      • getInfo

        public java.lang.String getInfo​(GFile file,
                                        TaskMonitor monitor)
        Description copied from interface: GFileSystem
        Returns a multi-line string with information about the specified file.

        TODO: this method needs to be refactored to return a Map instead of a pre-formatted multi-line string.

        Specified by:
        getInfo in interface GFileSystem
        Parameters:
        file - GFile to get info message for.
        monitor - TaskMonitor to watch and update progress.
        Returns:
        multi-line formatted string with info about the file, or null.
      • getName

        public java.lang.String getName()
        Description copied from interface: GFileSystem
        File system volume name.

        Typically the name of the container file, or a internally stored 'volume' name.

        Specified by:
        getName in interface GFileSystem
        Returns:
        string filesystem volume name.
      • lookup

        public GFile lookup​(java.lang.String path)
                     throws java.io.IOException
        Description copied from interface: GFileSystem
        Retrieves a GFile from this filesystem based on its full path and filename.

        Specified by:
        lookup in interface GFileSystem
        Parameters:
        path - string path and filename of a file located in this filesystem. Use null or "/" to retrieve the root directory
        Returns:
        GFile instance of requested file, null if not found.
        Throws:
        java.io.IOException - if IO error when looking up file.
      • getInputStream

        public java.io.InputStream getInputStream​(GFile file,
                                                  TaskMonitor monitor)
                                           throws java.io.IOException,
                                                  CancelledException
        Description copied from interface: GFileSystem
        Returns an InputStream that contains the contents of the specified GFile.

        The caller is responsible for closing the stream.

        Specified by:
        getInputStream in interface GFileSystem
        Parameters:
        file - GFile to get an InputStream for
        monitor - TaskMonitor to watch and update progress
        Returns:
        new InputStream contains the contents of the file or NULL if the file doesn't have data.
        Throws:
        java.io.IOException - if IO problem
        CancelledException - if user cancels.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object