org.das2.util.filesystem
Class FileSystem

java.lang.Object
  extended by org.das2.util.filesystem.FileSystem
Direct Known Subclasses:
LocalFileSystem, SubFileSystem, WebFileSystem

public abstract class FileSystem
extends java.lang.Object

Filesystems provide an abstraction layer so that clients can access any heirarchy of files in a implementation-independent way. For example, remote filesystems accessible via http are accessible through the same interface as a local filesystem.


Nested Class Summary
 class FileSystem.DirectoryEntry
          DirectoryEntry defines a structure for containing directory entry data.
static class FileSystem.FileSystemOfflineException
           
 
Field Summary
protected static java.util.logging.Logger logger
           
static java.lang.String PROP_CASE_INSENSITIVE
          Boolean.TRUE if the filesystem ignores case, such as Windows local filesystem.
protected  java.util.HashMap properties
           
 
Constructor Summary
protected FileSystem(java.net.URL root)
           
 
Method Summary
static FileSystem create(java.net.URL root)
          Creates a FileSystem by parsing the URL and creating the correct FS type.
 FileSystem createFileSystem(java.lang.String directory)
          create a new filesystem that is a part of this filesystem, rooted at directory.
abstract  FileObject getFileObject(java.lang.String filename)
          return the FileObject that corresponds to the name.
abstract  java.io.File getLocalRoot()
          return the folder that is a local copy of the filesystem.
 java.lang.Object getProperty(java.lang.String name)
           
 java.net.URL getRootURL()
           
abstract  boolean isDirectory(java.lang.String filename)
           
abstract  java.lang.String[] listDirectory(java.lang.String directory)
          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.
static void registerFileSystemFactory(java.lang.String proto, FileSystemFactory factory)
           
static FileSystemSettings settings()
           
static java.lang.String[] splitUrl(java.lang.String surl)
          returns a String[5]: [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 ?.
protected static java.lang.String toCanonicalFilename(java.lang.String filename)
          returns the canonical name /a/b/c.dat of a string that contains backslashes and might not have the leading / and trailing slashes.
protected static java.lang.String toCanonicalFolderName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static java.util.logging.Logger logger

PROP_CASE_INSENSITIVE

public static final java.lang.String PROP_CASE_INSENSITIVE
Boolean.TRUE if the filesystem ignores case, such as Windows local filesystem.

See Also:
Constant Field Values

properties

protected java.util.HashMap properties
Constructor Detail

FileSystem

protected FileSystem(java.net.URL root)
Method Detail

create

public static FileSystem create(java.net.URL root)
                         throws FileSystem.FileSystemOfflineException
Creates a FileSystem by parsing the URL and creating the correct FS type. Presently, only "file://" and "http://" are supported.

Throws:
FileSystem.FileSystemOfflineException

settings

public static FileSystemSettings settings()

registerFileSystemFactory

public static void registerFileSystemFactory(java.lang.String proto,
                                             FileSystemFactory factory)

getRootURL

public java.net.URL getRootURL()

toCanonicalFilename

protected static java.lang.String toCanonicalFilename(java.lang.String filename)
returns the canonical name /a/b/c.dat of a string that contains backslashes and might not have the leading / and trailing slashes. Also, double slashes (//) are removed. Note this is the name of the FileObject within the FileSystem.


toCanonicalFolderName

protected static java.lang.String toCanonicalFolderName(java.lang.String name)

getFileObject

public abstract FileObject getFileObject(java.lang.String filename)
return the FileObject that corresponds to the name.


isDirectory

public abstract boolean isDirectory(java.lang.String filename)
                             throws java.io.IOException
Throws:
java.io.IOException

listDirectory

public abstract java.lang.String[] listDirectory(java.lang.String directory)
                                          throws java.io.IOException
returns a list of the names of the files in a directory. Names ending in "/" are themselves directories, and the "/" is not part of the name. This is optional, and a directory may or may not be tagged with the trailing slash.

Throws:
java.io.IOException

listDirectory

public abstract java.lang.String[] listDirectory(java.lang.String directory,
                                                 java.lang.String regex)
                                          throws java.io.IOException
returns a list of the names of the files in a directory that match regex. Trailing slashes on directory names are not part of the name and need not be part of the regex.

Throws:
java.io.IOException

getProperty

public java.lang.Object getProperty(java.lang.String name)

getLocalRoot

public abstract java.io.File getLocalRoot()
return the folder that is a local copy of the filesystem. For LocalFilesystem, this is the same as the filesystem. For remote filesystems, this is a folder within their home directory. Note File.getAbsolutePath() returns the string representation of this root.

Returns:
the folder that is a local copy of the filesystem.

createFileSystem

public FileSystem createFileSystem(java.lang.String directory)
create a new filesystem that is a part of this filesystem, rooted at directory.


splitUrl

public static java.lang.String[] splitUrl(java.lang.String surl)
returns a String[5]: [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 ?.

Parameters:
surl - an url string to parse.