edu.sdsc.grid.io
Class GeneralFile

java.lang.Object
  extended by edu.sdsc.grid.io.GeneralFile
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
LocalFile, RemoteFile

public class GeneralFile
extends java.lang.Object
implements java.lang.Comparable

An abstract representation of file and directory pathnames. This abstract class can be subclassed to create a generic file object which may refer to either a remote or local file.

Shares many similarities with the java.io.File class: User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames. An abstract pathname has two components:

An optional system-dependent prefix string, such as a disk-drive specifier, "/" for the UNIX root directory, or "\\" for a Microsoft Windows UNC pathname, and
A sequence of zero or more string names. Each name in an abstract pathname except for the last denotes a directory; the last name may denote either a directory or a file. The empty abstract pathname has no prefix and an empty name sequence. The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an abstract pathname is converted into a pathname string, each name is separated from the next by a single copy of the default separator character. The default name-separator character is defined by the system property file.separator, and is made available in the public static fields separator and separatorChar of this class. When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system.

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in this package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

The prefix concept is used to handle root directories on UNIX platforms, and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, as follows:

For UNIX platforms, the prefix of an absolute pathname is always "/". Relative pathnames have no prefix. The abstract pathname denoting the root directory has the prefix "/" and an empty name sequence.

For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by ":" and possibly followed by "\" if the pathname is absolute. The prefix of a UNC pathname is "\\"; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix.

Instances of the GeneralFile class are immutable; that is, once created, the abstract pathname represented by a GeneralFile object will never change.

See Also:
File

Field Summary
static int BUFFER_MAX_SIZE
          Default buffer size used for copyTo and copyFrom methods.
protected  java.util.Vector directory
          Standardized, absolute directory string
protected  java.lang.String fileName
          Standardized filename
protected  GeneralFileSystem fileSystem
          Holds the server information used by this file.
static java.lang.String PATH_SEPARATOR
          Standard path separator character represented as a string for convenience.
static char PATH_SEPARATOR_CHAR
          The path separator character.
static java.lang.String pathSeparator
          The system-dependent path-separator character, represented as a string for convenience.
static char pathSeparatorChar
          The system-dependent path-separator character.
static java.lang.String separator
          The system-dependent default name-separator character, represented as a string for convenience.
static char separatorChar
          The system-dependent default name-separator character.
 
Constructor Summary
protected GeneralFile(GeneralFileSystem fileSystem, java.lang.String dir, java.lang.String fileName)
          Creates a new GeneralFile from a parent pathname string and a child pathname string.
protected GeneralFile(java.net.URI uri)
          Creates a new GeneralFile instance by converting the given file: URI into an abstract pathname.
 
Method Summary
 boolean canRead()
          Tests whether the application can read the file denoted by this abstract pathname.
 boolean canWrite()
          Tests whether the application can modify to the file denoted by this abstract pathname.
 java.lang.String checksum()
          If this abstract pathname refers to a file (and not a directory,) return the checksum of the file.
 int compareTo(GeneralFile pathName)
          Compares two abstract pathnames lexicographically.
 int compareTo(java.lang.Object o)
          Compares this abstract pathname to another object.
 void copyFrom(GeneralFile file)
          Copies this file to another file.
 void copyFrom(GeneralFile file, boolean forceOverwrite)
          Copies this file to another file.
 void copyTo(GeneralFile file)
          Copies this file to another file.
 void copyTo(GeneralFile file, boolean forceOverwrite)
          Copies this file to another file.
 boolean createNewFile()
          Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
static GeneralFile createTempFile(java.lang.String prefix, java.lang.String suffix)
          Deprecated. Doesn't always work without existing GeneralFile. Instead use GeneralFile.createTempFile(String, String, GeneralFile)
static GeneralFile createTempFile(java.lang.String prefix, java.lang.String suffix, GeneralFile directory)
           Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
 boolean delete()
          Deletes the file or directory denoted by this abstract pathname.
 void deleteOnExit()
          Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
 boolean equals(java.lang.Object obj)
          Tests this abstract pathname for equality with the given object.
 boolean exists()
          Tests whether the file denoted by this abstract pathname exists.
protected  void finalize()
          Finalizes the object by explicitly letting go of each of its internally held values.
 java.lang.String firstQueryResult(java.lang.String fieldName)
          Queries metadata specific to this file object, selecting one metadata value, fieldName, and returns the first result of that query.
 GeneralFile getAbsoluteFile()
          Returns the absolute form of this abstract pathname.
 java.lang.String getAbsolutePath()
          Returns the absolute pathname string of this abstract pathname.
 GeneralFile getCanonicalFile()
          Returns the canonical form of this abstract pathname.
 java.lang.String getCanonicalPath()
          Returns the canonical pathname string of this abstract pathname.
 GeneralFileSystem getFileSystem()
           
 java.lang.String getName()
           
 java.lang.String getParent()
           
 GeneralFile getParentFile()
          Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
 java.lang.String getPath()
           
 java.lang.String getPathSeparator()
          This abstract method gets the path separator as defined by the subclass.
 char getPathSeparatorChar()
          This abstract method gets the path separator char as defined by the subclass.
 boolean isAbsolute()
          Tests whether this abstract pathname is absolute in a system-dependant way.
 boolean isDirectory()
          Tests whether the file denoted by this abstract pathname is a directory.
 boolean isFile()
          Tests whether the file denoted by this abstract pathname is a normal file.
 boolean isHidden()
          Tests whether the file named by this abstract pathname is a hidden file.
 long lastModified()
          Returns the time that the file denoted by this abstract pathname was last modified.
 long length()
          Returns the length of the file denoted by this abstract pathname.
 java.lang.String[] list()
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
 java.lang.String[] list(MetaDataCondition[] conditions)
           
 GeneralFile[] listFiles()
          Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
static GeneralFile[] listRoots()
          Deprecated. Doesn't work reliably without pre-existing fileSystem. use listRoots( GeneralFileSystem )
static GeneralFile[] listRoots(GeneralFileSystem fileSystem)
          List the available filesystem roots.
 boolean mkdir()
          Creates the directory named by this abstract pathname.
 boolean mkdirs()
          Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
 void modifyMetaData(MetaDataRecordList metaDataRecordList)
          Used to modify the metadata associated with this file object.
 MetaDataRecordList[] query(MetaDataCondition[] conditions, MetaDataSelect[] selects)
          Queries the file server to find all files that match a set of conditions.
 MetaDataRecordList[] query(MetaDataSelect[] selectArray)
           
 MetaDataRecordList[] query(java.lang.String[] metaDataFieldNames)
           
 boolean renameTo(GeneralFile dest)
          Renames the file denoted by this abstract pathname.
protected  void setDirectory(java.lang.String dir)
          Abstract method to set the directory.
protected  void setFileName(java.lang.String fileName)
          Abstract method to set the file name.
protected  void setFileSystem(GeneralFileSystem fileSystem)
          Sets the file system used of this GeneralFile object.
 boolean setLastModified(long time)
          Sets the last-modified time of the file or directory named by this abstract pathname.
 boolean setReadOnly()
          Marks the file or directory named by this abstract pathname so that only read operations are allowed.
 java.lang.String toString()
          Returns the pathname string of this abstract pathname.
 java.net.URI toURI()
          Constructs a file: URI that represents this abstract pathname.
 java.net.URL toURL()
          Converts this abstract pathname into a file: URL.
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_MAX_SIZE

public static final int BUFFER_MAX_SIZE
Default buffer size used for copyTo and copyFrom methods.

See Also:
Constant Field Values

separatorChar

public static char separatorChar
The system-dependent default name-separator character. This field is initialized to contain the first character of the value of the system property file.separator. On UNIX systems the value of this field is '/'; on Microsoft Windows systems it is '\\'.

See Also:
System.getProperty(java.lang.String)

separator

public static java.lang.String separator
The system-dependent default name-separator character, represented as a string for convenience. This string contains a single character, namely separatorChar.


pathSeparatorChar

public static char pathSeparatorChar
The system-dependent path-separator character. This field is initialized to contain the first character of the value of the system property path.separator. This character is used to separate filenames in a sequence of files given as a path list. On UNIX systems, this character is ':'; on Microsoft Windows systems it is ';'.

See Also:
System.getProperty(java.lang.String)

pathSeparator

public static java.lang.String pathSeparator
The system-dependent path-separator character, represented as a string for convenience. This string contains a single character, namely pathSeparatorChar.


PATH_SEPARATOR

public static java.lang.String PATH_SEPARATOR
Standard path separator character represented as a string for convenience. This string contains a single character, namely PATH_SEPARATOR_CHAR.


PATH_SEPARATOR_CHAR

public static char PATH_SEPARATOR_CHAR
The path separator character.


fileSystem

protected GeneralFileSystem fileSystem
Holds the server information used by this file.


directory

protected java.util.Vector directory
Standardized, absolute directory string


fileName

protected java.lang.String fileName
Standardized filename

Constructor Detail

GeneralFile

protected GeneralFile(GeneralFileSystem fileSystem,
                      java.lang.String dir,
                      java.lang.String fileName)
               throws java.lang.NullPointerException
Creates a new GeneralFile from a parent pathname string and a child pathname string.

If parent is null then the new GeneralFile instance is created as if by invoking the single-argument GeneralFile constructor on the given child pathname string.

Otherwise the parent pathname string is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a way defined by the subclass. If parent is the empty string then the new GeneralFile is created by converting child into an abstract pathname and resolving the result against the default directory of the subclass. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

Parameters:
fileSystem - The fileSystem used by this object
parent - The parent pathname string
child - The child pathname string
Throws:
java.lang.NullPointerException

GeneralFile

protected GeneralFile(java.net.URI uri)
               throws java.lang.NullPointerException,
                      java.lang.IllegalArgumentException
Creates a new GeneralFile instance by converting the given file: URI into an abstract pathname.

The exact form of a file: URI is system-dependent, hence the transformation performed by this constructor is also system-dependent.

For a given abstract pathname f it is guaranteed that

    new GeneralFile( f.toURI()).equals( f)

so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.

Parameters:
uri - An absolute, hierarchical URI using a supported scheme, eg. "file" or "srb".
Throws:
java.lang.NullPointerException - if uri is null.
java.lang.IllegalArgumentException - If the preconditions on the parameter do not hold.
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalizes the object by explicitly letting go of each of its internally held values.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

setFileSystem

protected void setFileSystem(GeneralFileSystem fileSystem)
                      throws java.lang.IllegalArgumentException,
                             java.lang.ClassCastException
Sets the file system used of this GeneralFile object. The file system object must be a subclass of the GeneralFileSystem matching this file object. eg. XYZFile requires XYZFileSystem.

Parameters:
fileSystem - The file system to be used.
Throws:
java.lang.IllegalArgumentException - - if the argument is null.
java.lang.ClassCastException - - if the argument is not an object of the approriate subclass.

setDirectory

protected void setDirectory(java.lang.String dir)
Abstract method to set the directory.

Parameters:
dir - The directory path, need not be absolute.

setFileName

protected void setFileName(java.lang.String fileName)
Abstract method to set the file name.

Parameters:
fileName - The file name or fileName plus some or all of the directory path.

getPathSeparator

public java.lang.String getPathSeparator()
This abstract method gets the path separator as defined by the subclass.


getPathSeparatorChar

public char getPathSeparatorChar()
This abstract method gets the path separator char as defined by the subclass.


getFileSystem

public GeneralFileSystem getFileSystem()
                                throws java.lang.NullPointerException
Returns:
fileSystem the SRBFileSystem object of this SRBFile.
Throws:
java.lang.NullPointerException - if fileSystem is null.

firstQueryResult

public java.lang.String firstQueryResult(java.lang.String fieldName)
                                  throws java.io.IOException
Queries metadata specific to this file object, selecting one metadata value, fieldName, and returns the first result of that query. Returns null if the query had no results.

Parameters:
fieldName - The string name used to form the select object.
Returns:
The metadata values for this file refered to by fieldName
Throws:
java.io.IOException

query

public MetaDataRecordList[] query(MetaDataCondition[] conditions,
                                  MetaDataSelect[] selects)
                           throws java.io.IOException
Queries the file server to find all files that match a set of conditions. For all those that match, the fields indicated in the select array are returned in the result object.

While condition and select array objects have all been checked for self-consistency during their construction, there are additional problems that must be detected at query time:

For instance, it is possible to build a condition object appropriate for the SRB, then pass that object in a local file system query. That will find that the condition is incompatible and generate a mismatch exception.

Query is implemented by the file-server-specific classes, like that for the SRB, FTP, etc. Those classes must re-map condition and select field names and operator codes to those required by a particular file server and protocol version. Once re-mapped, they issue the query and get results. The results are then mapped back to the standard public field names of the MetaDataGroups. So, if a MetaDataGroup uses a name like "file path", but the SRB calls it "data name", then query maps first from "file path" to "data name" before issuing the query, and then from "data name" back to "file path" within the results. The programmer using this API should never see the internal field names.

Throws:
java.io.IOException

query

public MetaDataRecordList[] query(MetaDataSelect[] selectArray)
                           throws java.io.IOException
Throws:
java.io.IOException

query

public MetaDataRecordList[] query(java.lang.String[] metaDataFieldNames)
                           throws java.io.IOException
Throws:
java.io.IOException

modifyMetaData

public void modifyMetaData(MetaDataRecordList metaDataRecordList)
                    throws java.io.IOException
Used to modify the metadata associated with this file object.

Throws:
java.io.IOException

copyTo

public void copyTo(GeneralFile file)
            throws java.io.IOException
Copies this file to another file. This object is the source file. The destination file is given as the argument. If the destination file, does not exist a new one will be created. Otherwise the source file will be appended to the destination file. Directories will be copied recursively.

Parameters:
file - The file to receive the data.
Throws:
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.

copyTo

public void copyTo(GeneralFile file,
                   boolean forceOverwrite)
            throws java.io.IOException
Copies this file to another file. This object is the source file. The destination file is given as the argument. If the destination file, does not exist a new one will be created. Otherwise the source file will be appended to the destination file. Directories will be copied recursively.

Parameters:
file - The file to receive the data.
Throws:
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.

copyFrom

public void copyFrom(GeneralFile file)
              throws java.io.IOException
Copies this file to another file. This object is the source file. The destination file is given as the argument. If the destination file, does not exist a new one will be created. Otherwise the source file will be appended to the destination file. Directories will be copied recursively.

Parameters:
file - The file to receive the data.
Throws:
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.

copyFrom

public void copyFrom(GeneralFile file,
                     boolean forceOverwrite)
              throws java.io.IOException
Copies this file to another file. This object is the source file. The destination file is given as the argument. If the destination file, does not exist a new one will be created. Otherwise the source file will be appended to the destination file. Directories will be copied recursively.

Parameters:
file - The file to receive the data.
Throws:
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.

checksum

public java.lang.String checksum()
                          throws java.io.IOException
If this abstract pathname refers to a file (and not a directory,) return the checksum of the file. [Currently] uses SysV, UNIX System V to create the checksum value.

Returns:
the checksum value. Returns null if this object is a directory.
Throws:
java.io.IOException

canRead

public boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.

Returns:
true if and only if the file specified by this abstract pathname exists and can be read; otherwise false.

canWrite

public boolean canWrite()
Tests whether the application can modify to the file denoted by this abstract pathname.

Returns:
true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file; otherwise false.

compareTo

public int compareTo(GeneralFile pathName)
Compares two abstract pathnames lexicographically.

Parameters:
pathname - The abstract pathname to be compared to this abstract pathname
Returns:
Zero if the argument is equal to this abstract pathname, a value less than zero if this abstract pathname is lexicographically less than the argument, or a value greater than zero if this abstract pathname is lexicographically greater than the argument

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this abstract pathname to another object. If the other object is an abstract pathname, then this function behaves like compareTo(GeneralFile). Otherwise, it throws a ClassCastException, since abstract pathnames can only be compared to abstract pathnames.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The Object to be compared to this abstract pathname
Returns:
If the argument is an abstract pathname, returns zero if the argument is equal to this abstract pathname, a value less than zero if this abstract pathname is lexicographically less than the argument, or a value greater than zero if this abstract pathname is lexicographically greater than the argument

Throws:
java.lang.ClassCastException - - if the argument is not an abstract pathname

createNewFile

public boolean createNewFile()
                      throws java.io.IOException
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.

Throws:
java.io.IOException

createTempFile

public static GeneralFile createTempFile(java.lang.String prefix,
                                         java.lang.String suffix)
                                  throws java.io.IOException,
                                         java.lang.IllegalArgumentException
Deprecated. Doesn't always work without existing GeneralFile. Instead use GeneralFile.createTempFile(String, String, GeneralFile)

Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. Invoking this method is equivalent to invoking createTempFile(prefix, suffix, null).

Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
Returns:
An abstract pathname denoting a newly-created empty file
Throws:
java.lang.IllegalArgumentException - If the prefix argument contains fewer than three characters
java.io.IOException - If a file could not be created

createTempFile

public static GeneralFile createTempFile(java.lang.String prefix,
                                         java.lang.String suffix,
                                         GeneralFile directory)
                                  throws java.io.IOException

Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. If this method returns successfully then it is guaranteed that:

  1. The file denoted by the returned abstract pathname did not exist before this method was invoked, and
  2. Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
This method provides only part of a temporary-file facility. To arrange for a file created by this method to be deleted automatically, use the deleteOnExit() method.

The prefix argument must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "hjb" or "mail". The suffix argument may be null, in which case the suffix ".tmp" will be used.

To create the new file, the prefix and the suffix may first be adjusted to fit the limitations of the underlying platform. If the prefix is too long then it will be truncated, but its first three characters will always be preserved. If the suffix is too long then it too will be truncated, but if it begins with a period character ('.') then the period and the first three characters following it will always be preserved. Once these adjustments have been made the name of the new file will be generated by concatenating the prefix, five or more internally-generated characters, and the suffix.

If the directory argument is null then the system-dependent default temporary-file directory will be used. The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "c:\\temp". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the the temporary directory used by this method.

Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
directory - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
Returns:
An abstract pathname denoting a newly-created empty file
Throws:
java.lang.IllegalArgumentException - If the prefix argument contains fewer than three characters
java.io.IOException - If a file could not be created

delete

public boolean delete()
Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.


deleteOnExit

public void deleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification.

Once deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. T


equals

public boolean equals(java.lang.Object obj)
Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is an abstract pathname that denotes the same file or directory as this abstract pathname.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to be compared with this abstract pathname
Returns:
true if and only if the objects are the same; false otherwise

exists

public boolean exists()
Tests whether the file denoted by this abstract pathname exists.

Returns:
true if and only if the file denoted by this abstract pathname exists; false otherwise

getAbsoluteFile

public GeneralFile getAbsoluteFile()
Returns the absolute form of this abstract pathname. Equivalent to new GeneralFile(this.getAbsolutePath()()).

Returns:
The absolute abstract pathname denoting the same file or directory as this abstract pathname

getAbsolutePath

public java.lang.String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.

Returns:
The absolute pathname denoting the same file or directory as this abstract pathname

getCanonicalFile

public GeneralFile getCanonicalFile()
                             throws java.io.IOException
Returns the canonical form of this abstract pathname. Equivalent to new GeneralFile(this.getCanonicalPath()()).

Returns:
The canonical abstract pathname denoting the same file or directory as this abstract pathname
Throws:
java.io.IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

getCanonicalPath

public java.lang.String getCanonicalPath()
                                  throws java.io.IOException
Returns the canonical pathname string of this abstract pathname.

Returns:
The canonical pathname string denoting the same file or directory as this abstract pathname
Throws:
java.io.IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

getName

public java.lang.String getName()
Returns:
The name of the file or directory denoted by this abstract pathname.

getParent

public java.lang.String getParent()
Returns:
The pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.

getParentFile

public GeneralFile getParentFile()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.

The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

Returns:
The abstract pathname of the parent directory named by this abstract pathname, or null if this pathname does not name a parent

getPath

public java.lang.String getPath()
Returns:
This abstract pathname as a pathname string.

isAbsolute

public boolean isAbsolute()
Tests whether this abstract pathname is absolute in a system-dependant way.

Returns:
true if this abstract pathname is absolute, false otherwise

isDirectory

public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.

Returns:
true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise

isFile

public boolean isFile()
Tests whether the file denoted by this abstract pathname is a normal file.

Returns:
true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise

isHidden

public boolean isHidden()
Tests whether the file named by this abstract pathname is a hidden file.

Returns:
true if and only if the file denoted by this abstract pathname is hidden.

lastModified

public long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.

Returns:
A long value representing the time the file was last modified, measured in system-dependent way.

length

public long length()
Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.

Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist

list

public java.lang.String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

If this GeneralFile object denotes a file, the results are unspecified.

Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname.

list

public java.lang.String[] list(MetaDataCondition[] conditions)

listFiles

public GeneralFile[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

An array of GeneralFile objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself is included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the GeneralFile(GeneralFile, String) constructor.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty.

listRoots

public static GeneralFile[] listRoots()
Deprecated. Doesn't work reliably without pre-existing fileSystem. use listRoots( GeneralFileSystem )

List the available filesystem roots.

It is guaranteed that the canonical pathname of any file physically present in the system will begin with one of the roots returned by this method.

Returns:
An array of GeneralFile objects denoting the available filesystem root.

listRoots

public static GeneralFile[] listRoots(GeneralFileSystem fileSystem)
List the available filesystem roots. The SRB has a single root directory, namely "/".

It is guaranteed that the canonical pathname of any file physically present in the SRB will begin with one of the roots returned by this method.

Returns:
An array of GeneralFile objects denoting the SRB filesystem root, namely "/".

mkdir

public boolean mkdir()
Creates the directory named by this abstract pathname.


mkdirs

public boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.


renameTo

public boolean renameTo(GeneralFile dest)
                 throws java.lang.IllegalArgumentException,
                        java.lang.NullPointerException
Renames the file denoted by this abstract pathname.

Whether or not this method can move a file from one filesystem to another is platform-dependent. The return value should always be checked to make sure that the rename operation was successful.

Parameters:
dest - The new abstract pathname for the named file
Throws:
java.lang.IllegalArgumentException - If parameter dest is not a GeneralFile.
java.lang.NullPointerException - - If dest is null

setLastModified

public boolean setLastModified(long time)
                        throws java.lang.IllegalArgumentException
Sets the last-modified time of the file or directory named by this abstract pathname.

Parameters:
time - The new last-modified time, measured in a system-dependent way.
Throws:
java.lang.IllegalArgumentException - - If the argument is negative

setReadOnly

public boolean setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory is guaranteed not to change until it is either deleted or marked to allow write access. Whether or not a read-only file or directory may be deleted depends upon the underlying system.


toString

public java.lang.String toString()
Returns the pathname string of this abstract pathname.

Overrides:
toString in class java.lang.Object

toURI

public java.net.URI toURI()
Constructs a file: URI that represents this abstract pathname.

The exact form of the URI is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash.

For a given abstract pathname f, it is guaranteed that

new GeneralFile ( f.toURI()).equals( f)
so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. However, this relationship typically does not hold when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.

Returns:
An absolute, hierarchical URI with a scheme equal to "file", a path representing this abstract pathname, and undefined authority, query, and fragment components
See Also:
GeneralFile(java.net.URI), URI, URI.toURL()

toURL

public java.net.URL toURL()
                   throws java.net.MalformedURLException
Converts this abstract pathname into a file: URL. The exact form of the URL is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URL will end with a slash.

Usage note: This method does not automatically escape characters that are illegal in URLs. It is recommended that new code convert an abstract pathname into a URL by first converting it into a URI, via the toURI method, and then converting the URI into a URL via the URI.toURL method.

Returns:
A URL object representing the equivalent file URL
Throws:
java.net.MalformedURLException - If the path cannot be parsed as a URL
See Also:
toURI(), URI, URI.toURL(), URL