public abstract class FileSystem
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FileSystem.DirectoryEntry
DirectoryEntry defines a structure for containing directory entry data.
|
static class |
FileSystem.FileSystemOfflineException
Exception indicating the file system is off-line.
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
logger |
protected static java.util.logging.Logger |
loggerUrl
this logger is for opening connections to remote sites.
|
static FileSystem.DirectoryEntry |
NULL
result from failed listing, etc.
|
static java.lang.String |
PROP_CASE_INSENSITIVE
Boolean.TRUE if the filesystem ignores case, such as Windows local filesystem.
|
protected java.util.HashMap |
properties |
Modifier | Constructor and Description |
---|---|
protected |
FileSystem(java.net.URI root) |
Modifier and Type | Method and Description |
---|---|
static FileSystem |
create(java.lang.String s)
convenient method that converts string like "http://das2.org/" into a URI.
|
static FileSystem |
create(java.lang.String s,
ProgressMonitor mon)
convenient method that converts string like "http://das2.org/" into a URI.
|
static FileSystem |
create(java.net.URI root)
Creates a FileSystem by parsing the URI and creating the correct FS type.
|
static FileSystem |
create(java.net.URI root,
ProgressMonitor mon)
Creates a FileSystem by parsing the URI and creating the correct FS type.
|
static FileSystem |
create(java.net.URL root)
Deprecated.
use create( URI root ) instead.
|
static FileSystem |
create(java.net.URL root,
ProgressMonitor mon)
Deprecated.
use create( URI root, ProgressMonitor mon ) instead.
|
FileSystem |
createFileSystem(java.lang.String directory)
create a new filesystem that is a part of this filesystem, rooted at
directory.
|
static ExceptionHandler |
getExceptionHandler()
return the exception handler.
|
abstract FileObject |
getFileObject(java.lang.String filename)
return the FileObject that corresponds to the name.
|
static java.lang.String[] |
getListing(FileSystem.DirectoryEntry[] des)
part of the refactoring to cache time stamps as well, this convenience method returns the old string.
|
static java.lang.String[] |
getListing(java.util.Map<java.lang.String,FileSystem.DirectoryEntry> des)
part of the refactoring to cache time stamps as well, this convenience method returns the old string.
|
abstract java.io.File |
getLocalRoot()
return the folder that is a local copy of the filesystem.
|
java.lang.Object |
getProperty(java.lang.String name)
return a filesystem property, such as PROP_CASE_INSENSITIVE.
|
java.net.URI |
getRootURI()
return the URI identifying the root of the filesystem.
|
abstract boolean |
isDirectory(java.lang.String filename)
return true if the name is a directory.
|
abstract java.lang.String[] |
listDirectory(java.lang.String directory)
returns a list of the names of the files in a directory.
|
java.lang.String[] |
listDirectory(java.lang.String directory,
ProgressMonitor monitor)
returns a list of the names of the files in a directory.
|
abstract java.lang.String[] |
listDirectory(java.lang.String directory,
java.lang.String regex)
returns a list of the names of the files in a directory that match regex.
|
java.lang.String[] |
listDirectory(java.lang.String directory,
java.lang.String regex,
ProgressMonitor monitor)
returns a list of the names of the files in a directory that match regex.
|
java.lang.String[] |
listDirectoryDeep(java.lang.String directory,
java.lang.String regex)
do a deep listing of directories, resolving wildcards along the way.
|
static FileSystem |
peek(java.net.URI root)
allow factories to peek, so they can see if there is a parent that is offline.
|
static FileSystem[] |
peekInstances()
return a copy of all cached filesystems
|
static FileSystem |
recreate(java.net.URI root)
creates a FileSystem, removing and recreating it if it was in the cache.
|
static FileSystem |
recreate(java.net.URI root,
ProgressMonitor mon)
creates a FileSystem, removing and recreating it if it was in the cache.
|
static void |
registerFileSystemFactory(java.lang.String proto,
FileSystemFactory factory)
register a code for handling a filesystem type.
|
static void |
reset()
remove all the cached FileSystem instances.
|
static void |
reset(FileSystem fs)
remove all the cached FileSystem instances.
|
static void |
setExceptionHandler(ExceptionHandler eh)
set the exception handler that is called when exceptions occur.
|
static FileSystemSettings |
settings()
access the file system settings.
|
static java.lang.String[] |
splitUrl(java.lang.String surl)
returns a String[5]:
|
static java.lang.String |
toCanonicalFilename(java.lang.String filename)
returns the canonical name /a/b/c.dat of a string that
may contain backslashes and might not have the leading /
and trailing slashes.
|
static java.lang.String |
toCanonicalFolderName(java.lang.String name)
returns the canonical name (/a/b/) of a string that
may contain backslashes and might not have the leading /
and trailing slashes.
|
protected static java.net.URI |
toCanonicalFolderName(java.net.URI name) |
protected static final java.util.logging.Logger logger
protected static final java.util.logging.Logger loggerUrl
public static final java.lang.String PROP_CASE_INSENSITIVE
protected java.util.HashMap properties
public static final FileSystem.DirectoryEntry NULL
public static FileSystem create(java.net.URL root) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- java.net.UnknownHostException
java.io.FileNotFoundException
FileSystem.FileSystemOfflineException
java.lang.IllegalArgumentException
- if the url cannot be converted to a URI.public static FileSystem create(java.lang.String s) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
s
- string representation of URI, like "http://das2.org/" or "file:///tmp/"FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
public static FileSystem create(java.lang.String s, ProgressMonitor mon) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
s
- string representation of URI, like "http://das2.org/" or "file:///tmp/"mon
- monitor progress. For most FS types this is instantaneous, but for zip this can take sub-interactive time.FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
public static FileSystem create(java.net.URL root, ProgressMonitor mon) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- mon
- java.net.UnknownHostException
java.io.FileNotFoundException
FileSystem.FileSystemOfflineException
java.lang.IllegalArgumentException
- if the url cannot be converted to a URI.java.lang.IllegalArgumentException
- if the local root does not exist.public static FileSystem recreate(java.net.URI root) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
- if the remote folder is not found.public static FileSystem create(java.net.URI root) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
- if the URI must be converted to a URL, but cannot.java.lang.IllegalArgumentException
- if the local root does not exist.public static FileSystem recreate(java.net.URI root, ProgressMonitor mon) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- mon
- FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
- if the file is not found on the remote host.public static FileSystem peek(java.net.URI root)
root
- the URIpublic static void reset()
public static void reset(FileSystem fs)
fs
- the filesystempublic static FileSystem create(java.net.URI root, ProgressMonitor mon) throws FileSystem.FileSystemOfflineException, java.net.UnknownHostException, java.io.FileNotFoundException
root
- the URI, like URI("http://das2.org/") or URI("file:///tmp/")mon
- monitor progress. For most FS types this is instantaneous, but for zip this can take sub-interactive time.FileSystem.FileSystemOfflineException
java.net.UnknownHostException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
- if the URI must be converted to a URL, but cannot.java.lang.IllegalArgumentException
- if the local root does not exist.public static FileSystemSettings settings()
public static void registerFileSystemFactory(java.lang.String proto, FileSystemFactory factory)
proto
- protocol identifier, like "ftp" "http" or "sftp"factory
- the factory which will handle the URI.public java.net.URI getRootURI()
public static java.lang.String toCanonicalFilename(java.lang.String filename)
filename
- namepublic static java.lang.String toCanonicalFolderName(java.lang.String name)
name
- folder nameprotected static java.net.URI toCanonicalFolderName(java.net.URI name)
public abstract FileObject getFileObject(java.lang.String filename)
filename
- the file name within the filesystempublic abstract boolean isDirectory(java.lang.String filename) throws java.io.IOException
filename
- the namejava.io.IOException
public abstract java.lang.String[] listDirectory(java.lang.String directory) throws java.io.IOException
directory
- the directory name within the filesystem.java.io.IOException
public java.lang.String[] listDirectory(java.lang.String directory, ProgressMonitor monitor) throws java.io.IOException
directory
- the directory name within the filesystem.monitor
- a progress monitor for the task.java.io.IOException
public abstract java.lang.String[] listDirectory(java.lang.String directory, java.lang.String regex) throws java.io.IOException
directory
- the directoryregex
- regular expressionjava.io.IOException
public java.lang.String[] listDirectory(java.lang.String directory, java.lang.String regex, ProgressMonitor monitor) throws java.io.IOException
directory
- regex
- regular expression that must be matched, or null.monitor
- progress monitor for the task.java.io.IOException
public java.lang.String[] listDirectoryDeep(java.lang.String directory, java.lang.String regex) throws java.io.IOException
directory
- location within the filesystem.regex
- regular expression (.*\.dat) (not a glob like *.dat).java.io.IOException
public java.lang.Object getProperty(java.lang.String name)
name
- property name, e.g. PROP_CASE_INSENSITIVEpublic abstract java.io.File getLocalRoot()
public FileSystem createFileSystem(java.lang.String directory) throws java.net.URISyntaxException
directory
- subdirectory within the filesystem.java.net.URISyntaxException
public static java.lang.String[] splitUrl(java.lang.String surl)
[0] is proto "http://"
[1] will be the host
[2] is proto + path
[3] is proto + path + file
[4] is file ext
[5] is params, not including ?.
The URL must start with one of file:, ftp://, http://, https://, sftp://
and "c:" is interpreted as "file:///c:..."surl
- a URL string to parse.public static ExceptionHandler getExceptionHandler()
public static void setExceptionHandler(ExceptionHandler eh)
eh
- the exception handler.public static java.lang.String[] getListing(FileSystem.DirectoryEntry[] des)
des
- array of directory entries.public static java.lang.String[] getListing(java.util.Map<java.lang.String,FileSystem.DirectoryEntry> des)
des
- Map of directory entries.public static FileSystem[] peekInstances()