org.das2.util.filesystem
Class WebFileSystem

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

public abstract class WebFileSystem
extends FileSystem

Base class for HTTP and FTP-based filesystems. A local cache is kept of the files.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.das2.util.filesystem.FileSystem
FileSystem.DirectoryEntry, FileSystem.FileSystemOfflineException
 
Field Summary
protected  java.io.File localRoot
           
protected  boolean offline
           
static java.lang.String PROP_OFFLINE
          if true, then the remote filesystem is not accessible, but local cache copies may be accessed.
protected  WebProtocol protocol
          plug-in template for implementation.
 
Fields inherited from class org.das2.util.filesystem.FileSystem
logger, PROP_CASE_INSENSITIVE, properties
 
Constructor Summary
protected WebFileSystem(java.net.URL root, java.io.File localRoot)
          Creates a new instance of WebFileSystem
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
protected  void copyStream(java.io.InputStream is, java.io.OutputStream out, ProgressMonitor monitor)
          copies data from in to out, sending the number of bytesTransferred to the monitor.
protected abstract  void downloadFile(java.lang.String filename, java.io.File f, java.io.File partfile, ProgressMonitor monitor)
          Transfers the file from the remote store to a local copy f.
static java.io.File getDownloadDirectory()
           
 FileObject getFileObject(java.lang.String filename)
          return the FileObject that corresponds to the name.
 java.lang.String getLocalName(java.io.File file)
          return the name of the File within the FileSystem, where File is a local file within the local copy of the filesystem.
 java.lang.String getLocalName(java.net.URL url)
           
 java.io.File getLocalRoot()
          return the folder that is a local copy of the filesystem.
 java.lang.String getLocalRootAbsPath()
          Deprecated. use getLocalRoot().getAbsolutePath()
 java.net.URL getURL(java.lang.String filename)
           
 boolean isAppletMode()
           
abstract  boolean isDirectory(java.lang.String filename)
           
 boolean isOffline()
           
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, java.lang.String regex)
          returns a list of the names of the files in a directory that match regex.
protected static java.io.File localRoot(java.net.URL root)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setAppletMode(boolean applet)
           
 void setOffline(boolean offline)
           
 java.lang.String toString()
           
 
Methods inherited from class org.das2.util.filesystem.FileSystem
create, createFileSystem, getProperty, getRootURL, registerFileSystemFactory, settings, splitUrl, toCanonicalFilename, toCanonicalFolderName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

localRoot

protected final java.io.File localRoot

protocol

protected WebProtocol protocol
plug-in template for implementation. if non-null, use this.


offline

protected boolean offline

PROP_OFFLINE

public static final java.lang.String PROP_OFFLINE
if true, then the remote filesystem is not accessible, but local cache copies may be accessed. See FileSystemSettings.allowOffline

See Also:
Constant Field Values
Constructor Detail

WebFileSystem

protected WebFileSystem(java.net.URL root,
                        java.io.File localRoot)
Creates a new instance of WebFileSystem

Method Detail

getDownloadDirectory

public static java.io.File getDownloadDirectory()

isOffline

public boolean isOffline()

setOffline

public void setOffline(boolean offline)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

localRoot

protected static java.io.File localRoot(java.net.URL root)

downloadFile

protected abstract void downloadFile(java.lang.String filename,
                                     java.io.File f,
                                     java.io.File partfile,
                                     ProgressMonitor monitor)
                              throws java.io.IOException
Transfers the file from the remote store to a local copy f. This should only be used within the class and subclasses, clients should use getFileObject( String ).getFile(). Subclasses implementing this should download data to partfile, then rename partfile to f after the download is complete.

Parameters:
partfile - the temporary file during download.
Throws:
java.io.IOException

getLocalRootAbsPath

public java.lang.String getLocalRootAbsPath()
Deprecated. use getLocalRoot().getAbsolutePath()

Get the root of the local file cache


getLocalRoot

public java.io.File getLocalRoot()
Description copied from class: FileSystem
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.

Specified by:
getLocalRoot in class FileSystem
Returns:
the folder that is a local copy of the filesystem.

isDirectory

public abstract boolean isDirectory(java.lang.String filename)
                             throws java.io.IOException
Specified by:
isDirectory in class FileSystem
Throws:
java.io.IOException

listDirectory

public abstract java.lang.String[] listDirectory(java.lang.String directory)
                                          throws java.io.IOException
Description copied from class: FileSystem
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.

Specified by:
listDirectory in class FileSystem
Throws:
java.io.IOException

listDirectory

public java.lang.String[] listDirectory(java.lang.String directory,
                                        java.lang.String regex)
                                 throws java.io.IOException
Description copied from class: FileSystem
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.

Specified by:
listDirectory in class FileSystem
Throws:
java.io.IOException

getURL

public java.net.URL getURL(java.lang.String filename)

getLocalName

public java.lang.String getLocalName(java.io.File file)
return the name of the File within the FileSystem, where File is a local file within the local copy of the filesystem.


getLocalName

public java.lang.String getLocalName(java.net.URL url)

getFileObject

public FileObject getFileObject(java.lang.String filename)
Description copied from class: FileSystem
return the FileObject that corresponds to the name.

Specified by:
getFileObject in class FileSystem

copyStream

protected void copyStream(java.io.InputStream is,
                          java.io.OutputStream out,
                          ProgressMonitor monitor)
                   throws java.io.IOException
copies data from in to out, sending the number of bytesTransferred to the monitor.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isAppletMode

public boolean isAppletMode()

setAppletMode

public void setAppletMode(boolean applet)