org.das2.util.filesystem
Class WebFileObject

java.lang.Object
  extended by org.das2.util.filesystem.FileObject
      extended by org.das2.util.filesystem.WebFileObject

public class WebFileObject
extends FileObject


Constructor Summary
protected WebFileObject(WebFileSystem wfs, java.lang.String pathname, java.util.Date modifiedDate)
           
 
Method Summary
 boolean canRead()
          returns true if the file can be read by the client.
 boolean exists()
          returns true if the file exists.
 java.nio.channels.ReadableByteChannel getChannel(ProgressMonitor monitor)
          return a Channel for the resource.
 FileObject[] getChildren()
          returns objects within a folder.
 java.io.File getFile(ProgressMonitor monitor)
          gets a File object that can be opened by the client.
 java.io.InputStream getInputStream(ProgressMonitor monitor)
          opens an inputStream, perhaps transferring the file to a cache first.
protected  java.io.File getLocalFile()
          returns the File that corresponds to the remote file.
 java.lang.String getNameExt()
          returns the canonical name of the file within the filesystem.
 FileObject getParent()
          returns the parent FileObject (a folder).
 long getSize()
          returns the size of the file.
 boolean isData()
          returns true if the file is a data file that to be used reading or writing data.
 boolean isFolder()
          indicates the type of FileObject
 boolean isLocal()
          returns true is the file is locally available, meaning clients can call getFile() and the readble File reference will be available in interactive time.
 boolean isReadOnly()
          true is the file is read-only.
 boolean isRoot()
          returns true if this is the root of the filesystem it came from.
 java.util.Date lastModified()
          returns the Date when the file was last modified.
 java.lang.String toString()
           
 
Methods inherited from class org.das2.util.filesystem.FileObject
getChannel, getFile, getInputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebFileObject

protected WebFileObject(WebFileSystem wfs,
                        java.lang.String pathname,
                        java.util.Date modifiedDate)
Method Detail

canRead

public boolean canRead()
Description copied from class: FileObject
returns true if the file can be read by the client.

Specified by:
canRead in class FileObject
Returns:
true if the file can be read (see getInputStream)

getChildren

public FileObject[] getChildren()
                         throws java.io.IOException
Description copied from class: FileObject
returns objects within a folder.

Specified by:
getChildren in class FileObject
Returns:
an array of all FileObjects with the folder.
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream(ProgressMonitor monitor)
                                   throws java.io.FileNotFoundException,
                                          java.io.IOException
Description copied from class: FileObject
opens an inputStream, perhaps transferring the file to a cache first.

Specified by:
getInputStream in class FileObject
Parameters:
monitor - for monitoring the download. The monitor won't be used when the access is immediate, for example with local FileObjects.
Returns:
an InputStream
Throws:
java.io.FileNotFoundException - if the file doesn't exist.
java.io.IOException

getParent

public FileObject getParent()
Description copied from class: FileObject
returns the parent FileObject (a folder).

Specified by:
getParent in class FileObject
Returns:
a WebFileObject referencing the parent directory.

getSize

public long getSize()
Description copied from class: FileObject
returns the size of the file.

Specified by:
getSize in class FileObject
Returns:
the size in bytes of the file, and -1 if the size is unknown.

isData

public boolean isData()
Description copied from class: FileObject
returns true if the file is a data file that to be used reading or writing data. (And not a folder.)

Specified by:
isData in class FileObject
Returns:
true if the file is a data file

isFolder

public boolean isFolder()
Description copied from class: FileObject
indicates the type of FileObject

Specified by:
isFolder in class FileObject
Returns:
true if the object is a folder (directory).

isReadOnly

public boolean isReadOnly()
Description copied from class: FileObject
true is the file is read-only.

Specified by:
isReadOnly in class FileObject
Returns:
true if the file is read-only

isRoot

public boolean isRoot()
Description copied from class: FileObject
returns true if this is the root of the filesystem it came from.

Specified by:
isRoot in class FileObject
Returns:
true if this is the root of the filesystem it came from.

lastModified

public java.util.Date lastModified()
Description copied from class: FileObject
returns the Date when the file was last modified. or new Date(0L) if the date is not available.

Specified by:
lastModified in class FileObject
Returns:
the last modified Date, or new Date(0) if it is not available.

getLocalFile

protected java.io.File getLocalFile()
returns the File that corresponds to the remote file. This may or may not exist, depending on whether it's been downloaded yet.


exists

public boolean exists()
Description copied from class: FileObject
returns true if the file exists. This may have the side effect of downloading the file.

Specified by:
exists in class FileObject
Returns:
true if the file exists

toString

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

getNameExt

public java.lang.String getNameExt()
Description copied from class: FileObject
returns the canonical name of the file within the filesystem. For example, in the local filesystem /mnt/data/steven/, /mnt/data/steven/jan/01.dat would be /jan/01.dat. For example, /a/b/c.dat.

Specified by:
getNameExt in class FileObject
Returns:
the name of the file within the FileSystem.

getChannel

public java.nio.channels.ReadableByteChannel getChannel(ProgressMonitor monitor)
                                                 throws java.io.FileNotFoundException,
                                                        java.io.IOException
return a Channel for the resource. If the resource can be made locally available, a FileChannel is returned.

Specified by:
getChannel in class FileObject
Parameters:
monitor -
Returns:
Throws:
java.io.FileNotFoundException
java.io.IOException

getFile

public java.io.File getFile(ProgressMonitor monitor)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Description copied from class: FileObject
gets a File object that can be opened by the client. This may download a remote file, so a progress monitor can be used to monitor the download.

Specified by:
getFile in class FileObject
Parameters:
monitor - for monitoring the download. The monitor won't be used when the access is immediate, for example with local FileObjects.
Returns:
a reference to a File that can be opened.
Throws:
java.io.FileNotFoundException - if the file doesn't exist.
java.io.IOException - if the file cannot be made local

isLocal

public boolean isLocal()
returns true is the file is locally available, meaning clients can call getFile() and the readble File reference will be available in interactive time. For FileObjects from HttpFileSystem, a HEAD request is made to ensure that the local file is as new as the website one.

Specified by:
isLocal in class FileObject