Class GFileSystemBase

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

    public abstract class GFileSystemBase
    extends java.lang.Object
    implements GFileSystem
    This is the original GFileSystem implementation abstract base class, with most of the initially implemented filesystem types extending this class.

    The new GFileSystem interface is being retro-fitted into this equation to support better probing and factory syntax, and new implementations should be based on the interface instead of extending this abstract class.

    NOTE: ALL GFileSystem sub-CLASSES MUST END IN "FileSystem". If not, the ClassSearcher will not find them. Yes, it is an implementation detail.

    GFileSystemBase instances are constructed when probing a container file and are queried with isValid(TaskMonitor) to determine if the container file is handled by the GFileSystemBase subclass.

    The ByteProvider given to the constructor is not considered 'owned' by the GFileSystemBase instance until after it passes the isValid check and is opened.

    • Constructor Detail

      • GFileSystemBase

        protected GFileSystemBase​(java.lang.String fileSystemName,
                                  ByteProvider provider)
    • Method Detail

      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • setFSRL

        public void setFSRL​(FSRLRoot fsrl)
      • setFilesystemService

        public void setFilesystemService​(FileSystemService fsService)
      • isValid

        public abstract boolean isValid​(TaskMonitor monitor)
        Returns true if this file system implementation can handle the bytes provided. This method should perform the minimal amount of checks required to determine validity. Keep it quick and tight!
        monitor - a task monitor
        true if valid for the byte provider
        Throws: - if an I/O error occurs
      • close

        public void close()
        Closes the file system. All resources should be released. (programs, temporary files, etc.)
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface
        Throws: - if an I/O error occurs
      • isClosed

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

        public final java.lang.String getName()
        Returns the name of this file system.
        Specified by:
        getName in interface GFileSystem
        the name of this file system
      • getListing

        public abstract java.util.List<GFile> getListing​(GFile directory)
        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
        directory - NULL means root of filesystem.
        List of GFile instances of file in the requested directory.
        Throws: - if IO problem.
      • getInputStream

        public getInputStream​(GFile file,
                                                  TaskMonitor monitor)
                                           throws 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
        file - GFile to get an InputStream for
        monitor - TaskMonitor to watch and update progress
        new InputStream contains the contents of the file or NULL if the file doesn't have data.
        CancelledException - if user cancels. - if IO problem
      • debug

        protected void debug​(byte[] bytes,
                             java.lang.String fileName)
        Writes the given bytes to a tempfile in the temp directory.
        bytes - the bytes to write
        fileName - the prefix of the temp file name
      • lookup

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

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