Class FileSystemFactoryMgr


  • public class FileSystemFactoryMgr
    extends java.lang.Object
    Statically scoped mugger that handles the dirty work of probing for and creating GFileSystem instances.

    Auto-discovers all GFileSystem instances in the classpath that have a FileSystemInfo annotation.

    • Method Detail

      • getAllFilesystemNames

        public java.util.List<java.lang.String> getAllFilesystemNames()
        Returns a list of all registered filesystem implementation descriptions.
        Returns:
        list of strings
      • getFileSystemType

        public java.lang.String getFileSystemType​(java.lang.Class<? extends GFileSystem> fsClass)
        Returns the file system type of the specified GFileSystem class.
        Parameters:
        fsClass - Class to inspect
        Returns:
        String file system type, from the FileSystemInfo.type() annotation.
      • mountFileSystem

        public GFileSystem mountFileSystem​(java.lang.String fsType,
                                           FSRL containerFSRL,
                                           java.io.File containerFile,
                                           FileSystemService fsService,
                                           TaskMonitor monitor)
                                    throws java.io.IOException,
                                           CancelledException
        Creates a new GFileSystem instance when the filesystem type is already known.

        Parameters:
        fsType - filesystem type string, ie. "file", "zip".
        containerFSRL - FSRL of the containing file.
        containerFile - File the containing file.
        fsService - reference to the FileSystemService instance.
        monitor - TaskMonitor to use for canceling and updating progress.
        Returns:
        new GFileSystem instance.
        Throws:
        java.io.IOException - if error when opening the filesystem or unknown fsType.
        CancelledException - if the user canceled the operation.
      • test

        public boolean test​(FSRL containerFSRL,
                            java.io.File containerFile,
                            FileSystemService fsService,
                            TaskMonitor monitor)
                     throws java.io.IOException,
                            CancelledException
        Returns true if the specified file contains a supported GFileSystem.

        Parameters:
        containerFSRL - FSRL of the containing file.
        containerFile - File the containing file.
        fsService - reference to the FileSystemService instance.
        monitor - TaskMonitor to use for canceling and updating progress.
        Returns:
        true if the file seems to contain a filesystem, false if it does not.
        Throws:
        java.io.IOException - if error when accessing the containing file
        CancelledException - if the user canceled the operation