uk.ac.rdg.resc.jstyx.client
Class FileWrapper

java.lang.Object
  extended by java.io.File
      extended by uk.ac.rdg.resc.jstyx.client.FileWrapper
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>

public class FileWrapper
extends java.io.File

Wraps a CStyxFile as a java.io.File. This allows Styx servers to be browsed by Java-based filesystem viewers

Author:
Jon Blower $Revision: 259 $ $Date: 2005-05-23 17:48:23 +0100 (Mon, 23 May 2005) $ $Log$ Revision 1.3 2005/05/23 16:48:17 jonblower Overhauled CStyxFile (esp. asynchronous methods) and StyxConnection (added cache of CStyxFiles) Revision 1.2 2005/03/11 13:58:25 jonblower Merged MINA-Test_20059309 into main line of development Revision 1.1.2.1 2005/03/11 08:29:52 jonblower Moved to log4j logging system (from apache commons logging) Revision 1.1 2005/03/07 08:27:51 jonblower Initial import
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
FileWrapper(CStyxFile file)
          Creates a new instance of FileWrapper that wraps the given CStyxFile.
 
Method Summary
 java.io.File getAbsoluteFile()
           
 java.lang.String getAbsolutePath()
           
 java.io.File getCanonicalFile()
           
 java.lang.String getCanonicalPath()
           
 CStyxFile getCStyxFile()
           
 java.lang.String getName()
          Gets the name of the file, i.e.
 java.lang.String getParent()
           
 java.io.File getParentFile()
           
 java.lang.String getPath()
          Gets the full path of the file.
 boolean isAbsolute()
           
 boolean isDirectory()
          Tests whether this FileWrapper wraps a directory
 boolean isFile()
          Tests whether this FileWrapper wraps a normal file (i.e.
 long lastModified()
           
 long length()
           
 java.lang.String[] list()
           
 java.lang.String[] list(java.io.FilenameFilter filter)
          Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
 java.io.File[] listFiles()
          Returns an array of FileWrappers denoting the files in this directory.
 java.io.File[] listFiles(java.io.FileFilter filter)
          Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
 java.io.File[] listFiles(java.io.FilenameFilter filter)
          Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
static java.io.File[] listRoots()
          Lists available filesystem roots.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, hashCode, isHidden, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileWrapper

public FileWrapper(CStyxFile file)
Creates a new instance of FileWrapper that wraps the given CStyxFile.

Method Detail

getCStyxFile

public CStyxFile getCStyxFile()
Returns:
the CStyxFile that this FileWrapper wraps

getName

public java.lang.String getName()
Gets the name of the file, i.e. the last part of the path

Overrides:
getName in class java.io.File

getPath

public java.lang.String getPath()
Gets the full path of the file. Makes sure that "/" is used as the separator

Overrides:
getPath in class java.io.File

getParent

public java.lang.String getParent()
Overrides:
getParent in class java.io.File
Returns:
a string representing the parent of this file, or null if this is the root directory

getParentFile

public java.io.File getParentFile()
Overrides:
getParentFile in class java.io.File
Returns:
the parent of this FileWrapper as another FileWrapper, or null if this file does not have a parent

isAbsolute

public boolean isAbsolute()
Overrides:
isAbsolute in class java.io.File
Returns:
true if this path starts with a slash (always return true since CStyxFile always stores the full pathname)

getAbsolutePath

public java.lang.String getAbsolutePath()
Overrides:
getAbsolutePath in class java.io.File
Returns:
the absolute pathname of this file. Simply returns this.getPath() since pathnames are always absolute.

getAbsoluteFile

public java.io.File getAbsoluteFile()
Overrides:
getAbsoluteFile in class java.io.File
Returns:
a FileWrapper representing the absolute pathname. Simply returns this object, since pathnames are always absolute

getCanonicalPath

public java.lang.String getCanonicalPath()
                                  throws java.io.IOException
Overrides:
getCanonicalPath in class java.io.File
Returns:
the canonical filename, i.e. the unique filename after removing . and .. parts of the path. Simply returns the absolute path.
Throws:
java.io.IOException

getCanonicalFile

public java.io.File getCanonicalFile()
                              throws java.io.IOException
Overrides:
getCanonicalFile in class java.io.File
Returns:
a FileWrapper that represents the canonical filename. Simply returns the absolute File (i.e. this object)
Throws:
java.io.IOException

isDirectory

public boolean isDirectory()
Tests whether this FileWrapper wraps a directory

Overrides:
isDirectory in class java.io.File

isFile

public boolean isFile()
Tests whether this FileWrapper wraps a normal file (i.e. not a directory)

Overrides:
isFile in class java.io.File

length

public long length()
Overrides:
length in class java.io.File
Returns:
the length of the file in bytes

lastModified

public long lastModified()
Overrides:
lastModified in class java.io.File
Returns:
The time that the file was last modified, in milliseconds since the epoch

list

public java.lang.String[] list()
Overrides:
list in class java.io.File
Returns:
Array of strings naming the files and directories in the directory that this FileWrapper represents. Returns null if this is not a directory.

list

public java.lang.String[] list(java.io.FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

Overrides:
list in class java.io.File

listFiles

public java.io.File[] listFiles()
Returns an array of FileWrappers denoting the files in this directory.

Overrides:
listFiles in class java.io.File

listFiles

public java.io.File[] listFiles(java.io.FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

Overrides:
listFiles in class java.io.File

listFiles

public java.io.File[] listFiles(java.io.FileFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

Overrides:
listFiles in class java.io.File

listRoots

public static java.io.File[] listRoots()
Lists available filesystem roots. At the moment this just returns a single-membered array of java.io.File with the member "/". So it is not connected to the root of the remote Styx filesystem. Is this going to work? We can't get the root of the real remote filesystem because this is a static method.



Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.