Package org.apache.commons.configuration
Class FileSystem
- java.lang.Object
-
- org.apache.commons.configuration.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
- Version:
- $Id: FileSystem.java 1209996 2011-12-03 20:24:21Z oheger $
- Author:
- Commons Configuration team
-
-
Constructor Summary
Constructors Constructor Description FileSystem()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
getBasePath(java.lang.String path)
static FileSystem
getDefaultFileSystem()
Retrieve the FileSystem being used.abstract java.lang.String
getFileName(java.lang.String path)
FileOptionsProvider
getFileOptionsProvider()
abstract java.io.InputStream
getInputStream(java.lang.String basePath, java.lang.String fileName)
abstract java.io.InputStream
getInputStream(java.net.URL url)
org.apache.commons.logging.Log
getLogger()
Returns the logger used by this FileSystem.abstract java.io.OutputStream
getOutputStream(java.io.File file)
abstract java.io.OutputStream
getOutputStream(java.net.URL url)
abstract java.lang.String
getPath(java.io.File file, java.net.URL url, java.lang.String basePath, java.lang.String fileName)
abstract java.net.URL
getURL(java.lang.String basePath, java.lang.String fileName)
abstract java.net.URL
locateFromURL(java.lang.String basePath, java.lang.String fileName)
static void
resetDefaultFileSystem()
Reset the FileSystem to the default.static void
setDefaultFileSystem(FileSystem fs)
Set the FileSystem to use.void
setFileOptionsProvider(FileOptionsProvider provider)
Set the FileOptionsProvidervoid
setLogger(org.apache.commons.logging.Log log)
Allows to set the logger to be used by this FileSystem.
-
-
-
Constructor Detail
-
FileSystem
public FileSystem()
-
-
Method Detail
-
getLogger
public org.apache.commons.logging.Log getLogger()
Returns the logger used by this FileSystem.- Returns:
- the logger
-
setLogger
public void setLogger(org.apache.commons.logging.Log log)
Allows to set 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.- Parameters:
log
- the new logger
-
setDefaultFileSystem
public static void setDefaultFileSystem(FileSystem fs) throws java.lang.NullPointerException
Set the FileSystem to use.- Parameters:
fs
- The FileSystem- Throws:
java.lang.NullPointerException
- if the FileSystem parameter is null.
-
resetDefaultFileSystem
public static void resetDefaultFileSystem()
Reset the FileSystem to the default.
-
getDefaultFileSystem
public static FileSystem getDefaultFileSystem()
Retrieve the FileSystem being used.- Returns:
- The FileSystem.
-
setFileOptionsProvider
public void setFileOptionsProvider(FileOptionsProvider provider)
Set the FileOptionsProvider- Parameters:
provider
- The FileOptionsProvider
-
getFileOptionsProvider
public FileOptionsProvider getFileOptionsProvider()
-
getInputStream
public abstract java.io.InputStream getInputStream(java.lang.String basePath, java.lang.String fileName) throws ConfigurationException
- Throws:
ConfigurationException
-
getInputStream
public abstract java.io.InputStream getInputStream(java.net.URL url) throws ConfigurationException
- Throws:
ConfigurationException
-
getOutputStream
public abstract java.io.OutputStream getOutputStream(java.net.URL url) throws ConfigurationException
- Throws:
ConfigurationException
-
getOutputStream
public abstract java.io.OutputStream getOutputStream(java.io.File file) throws ConfigurationException
- Throws:
ConfigurationException
-
getPath
public abstract java.lang.String getPath(java.io.File file, java.net.URL url, java.lang.String basePath, java.lang.String fileName)
-
getBasePath
public abstract java.lang.String getBasePath(java.lang.String path)
-
getFileName
public abstract java.lang.String getFileName(java.lang.String path)
-
locateFromURL
public abstract java.net.URL locateFromURL(java.lang.String basePath, java.lang.String fileName)
-
getURL
public abstract java.net.URL getURL(java.lang.String basePath, java.lang.String fileName) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
-