Class FileSystem

  • Direct Known Subclasses:
    DefaultFileSystem

    public abstract class FileSystem
    extends java.lang.Object
    Abstract layer to allow various types of file systems.
    Since:
    1.7
    • Constructor Summary

      Constructors 
      Constructor Description
      FileSystem()
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.String getBasePath​(java.lang.String path)
      Gets the base path of the given path, for example a directory for a file.
      abstract java.lang.String getFileName​(java.lang.String path)
      Gets the file name of the given path.
      FileOptionsProvider getFileOptionsProvider()
      Gets the FileSystem options provider.
      abstract java.io.InputStream getInputStream​(java.net.URL url)
      Gets an input stream for a URL.
      java.io.InputStream getInputStream​(java.net.URL url, URLConnectionOptions urlConnectionOptions)
      Not abstract for binary compatibility.
      ConfigurationLogger getLogger()
      Gets the logger used by this FileSystem.
      abstract java.io.OutputStream getOutputStream​(java.io.File file)
      Gets an output stream for a File.
      abstract java.io.OutputStream getOutputStream​(java.net.URL url)
      Gets an output stream for a URL.
      abstract java.lang.String getPath​(java.io.File file, java.net.URL url, java.lang.String basePath, java.lang.String fileName)
      Gets a path string for the given input where some values may be null.
      abstract java.net.URL getURL​(java.lang.String basePath, java.lang.String fileName)
      Gets a URL for a base path and file name.
      abstract java.net.URL locateFromURL​(java.lang.String basePath, java.lang.String fileName)
      Locates a URL for a base path and file name.
      void setFileOptionsProvider​(FileOptionsProvider provider)
      Sets the FileOptionsProvider
      void setLogger​(ConfigurationLogger log)
      Sets the logger to be used by this FileSystem.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileSystem

        public FileSystem()
        Constructs a new instance.
    • Method Detail

      • getBasePath

        public abstract java.lang.String getBasePath​(java.lang.String path)
        Gets the base path of the given path, for example a directory for a file.
        Parameters:
        path - the source path.
        Returns:
        the base path.
      • getFileName

        public abstract java.lang.String getFileName​(java.lang.String path)
        Gets the file name of the given path.
        Parameters:
        path - the source path.
        Returns:
        the file name.
      • getFileOptionsProvider

        public FileOptionsProvider getFileOptionsProvider()
        Gets the FileSystem options provider.
        Returns:
        the FileSystem options provider.
      • getInputStream

        public abstract java.io.InputStream getInputStream​(java.net.URL url)
                                                    throws ConfigurationException
        Gets an input stream for a URL.
        Parameters:
        url - the source URL.
        Returns:
        an input stream.
        Throws:
        ConfigurationException - if an problem occurs getting the input stream.
      • getInputStream

        public java.io.InputStream getInputStream​(java.net.URL url,
                                                  URLConnectionOptions urlConnectionOptions)
                                           throws ConfigurationException
        Not abstract for binary compatibility.
        Parameters:
        url - the URL of the file
        urlConnectionOptions - the URLConnection options
        Returns:
        the input stream for the specified URL
        Throws:
        ConfigurationException - if an error occurs while opening the file
        Since:
        2.8.0
      • getLogger

        public ConfigurationLogger getLogger()
        Gets the logger used by this FileSystem.
        Returns:
        the logger
      • getOutputStream

        public abstract java.io.OutputStream getOutputStream​(java.io.File file)
                                                      throws ConfigurationException
        Gets an output stream for a File.
        Parameters:
        file - the source File.
        Returns:
        an output stream.
        Throws:
        ConfigurationException - if an problem occurs getting the output stream.
      • getOutputStream

        public abstract java.io.OutputStream getOutputStream​(java.net.URL url)
                                                      throws ConfigurationException
        Gets an output stream for a URL.
        Parameters:
        url - the source URL.
        Returns:
        an output stream.
        Throws:
        ConfigurationException - if an problem occurs getting the output stream.
      • getPath

        public abstract java.lang.String getPath​(java.io.File file,
                                                 java.net.URL url,
                                                 java.lang.String basePath,
                                                 java.lang.String fileName)
        Gets a path string for the given input where some values may be null.

        The implementation decides on which argument take precedence.

        Parameters:
        file - A file.
        url - A URL.
        basePath - A base path string.
        fileName - A file name.
        Returns:
        A path string.
      • getURL

        public abstract java.net.URL getURL​(java.lang.String basePath,
                                            java.lang.String fileName)
                                     throws java.net.MalformedURLException
        Gets a URL for a base path and file name.
        Parameters:
        basePath - The base path.
        fileName - The file name.
        Returns:
        a URL.
        Throws:
        java.net.MalformedURLException - if a problem occurs creating the URL.
      • locateFromURL

        public abstract java.net.URL locateFromURL​(java.lang.String basePath,
                                                   java.lang.String fileName)
        Locates a URL for a base path and file name.
        Parameters:
        basePath - The base path.
        fileName - The file name.
        Returns:
        a URL.
      • setFileOptionsProvider

        public void setFileOptionsProvider​(FileOptionsProvider provider)
        Sets the FileOptionsProvider
        Parameters:
        provider - The FileOptionsProvider
      • setLogger

        public void setLogger​(ConfigurationLogger log)
        Sets the logger to be used by this FileSystem. This method makes it possible for clients to exactly control logging behavior. Per default a logger is set that will ignore all log messages. Derived classes that want to enable logging should call this method during their initialization with the logger to be used. Passing in a null argument disables logging.
        Parameters:
        log - the new logger