org.das2.util.filesystem
Class LocalFileObject

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

public class LocalFileObject
extends FileObject


Constructor Summary
protected LocalFileObject(LocalFileSystem lfs, java.io.File localRoot, java.lang.String filename)
           
 
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)
          opens a Channel, perhaps transferring the file to a local cache first.
 FileObject[] getChildren()
          returns objects within a folder.
 java.io.File getFile()
          gets a File object that can be opened by the client.
 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.
 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 if 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, getInputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalFileObject

protected LocalFileObject(LocalFileSystem lfs,
                          java.io.File localRoot,
                          java.lang.String filename)
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()
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.

getInputStream

public java.io.InputStream getInputStream(ProgressMonitor monitor)
                                   throws java.io.FileNotFoundException
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.

getParent

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

Specified by:
getParent in class FileObject
Returns:
the parent folder of this object.

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.

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

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.

toString

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

getChannel

public java.nio.channels.ReadableByteChannel getChannel(ProgressMonitor monitor)
                                                 throws java.io.FileNotFoundException
Description copied from class: FileObject
opens a Channel, perhaps transferring the file to a local cache first. monitor is used to monitor the download.

Specified by:
getChannel 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 java.nio.channels.Channel for fast IO reads.
Throws:
java.io.FileNotFoundException - if the file doesn't exist.

getFile

public java.io.File getFile()
                     throws java.io.FileNotFoundException
Description copied from class: FileObject
gets a File object that can be opened by the client. Note this may block at sub-interactive time if the remote file needs to be downloaded before access.

Overrides:
getFile in class FileObject
Returns:
a reference to a File that can be opened.
Throws:
java.io.FileNotFoundException - if the file doesn't exist.

getFile

public java.io.File getFile(ProgressMonitor monitor)
                     throws java.io.FileNotFoundException
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.

isLocal

public boolean isLocal()
Description copied from class: FileObject
returns true if the file is locally available, meaning clients can call getFile() and the readble File reference will be available in interactive time. Note that isLocal does not imply exists(). Also, This may result in side effects such as a website hit.

Specified by:
isLocal in class FileObject