|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.sdsc.grid.io.GeneralFile
edu.sdsc.grid.io.RemoteFile
edu.sdsc.grid.io.irods.IRODSFile
public class IRODSFile
An abstract representation of file and directory pathnames on a iRODS server.
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:
Instances of the IRODSFile class are immutable; that is, once created, the abstract pathname represented by a IRODSFile object will never change.
File,
GeneralFile| Field Summary | |
|---|---|
static java.lang.String |
PATH_SEPARATOR
Standard iRODS path separator character represented as a string for convenience. |
static char |
PATH_SEPARATOR_CHAR
The iRODS path separator character, '/'. |
| Fields inherited from class edu.sdsc.grid.io.GeneralFile |
|---|
BUFFER_MAX_SIZE, directory, fileName, fileSystem, pathSeparator, pathSeparatorChar, separator, separatorChar |
| Constructor Summary | |
|---|---|
IRODSFile(IRODSFile parent,
java.lang.String child)
Creates a new IRODSFile instance from a parent abstract pathname and a child pathname string. |
|
IRODSFile(IRODSFileSystem fileSystem,
java.lang.String filePath)
Creates a new IRODSFile instance by converting the given pathname string into an abstract pathname. |
|
IRODSFile(IRODSFileSystem fileSystem,
java.lang.String parent,
java.lang.String child)
Creates a new iRODSFile instance from a parent pathname string and a child pathname string. |
|
IRODSFile(java.net.URI uri)
Creates a new IRODSFile 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. |
void |
changePermissions(java.lang.String permission,
java.lang.String newUserName,
boolean recursive)
Change the permissions for this IRODSFile. |
void |
copyFrom(GeneralFile file,
boolean forceOverwrite)
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,
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 |
getCanonicalPath()
Returns the canonical pathname string of this abstract pathname. |
java.lang.String |
getDataType()
|
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. |
java.lang.String |
getResource()
|
int |
hashCode()
Computes a hash code for this abstract pathname. |
boolean |
isAbsolute()
Tests whether this abstract pathname is absolute. |
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 |
isFile(boolean update)
Tests whether the file denoted by this abstract pathname is a 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. |
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)
|
boolean |
mkdir()
Creates the directory named by this abstract pathname. |
boolean |
renameTo(GeneralFile dest)
Renames the file denoted by this abstract pathname. |
void |
replicate(java.lang.String newResource)
Replicates this RemoteFile to a new resource. |
protected void |
setDirectory(java.lang.String dir)
Set the directory. |
protected void |
setFileName(java.lang.String filePath)
Set the file name. |
protected void |
setFileSystem(GeneralFileSystem fileSystem)
Sets the file system used of this GeneralFile object. |
void |
setResource(java.lang.String resourceName)
Sets the physical resource this IRODSFile object will be stored on. |
java.lang.String |
toString()
Returns a string representation of this file object. |
| Methods inherited from class edu.sdsc.grid.io.GeneralFile |
|---|
checksum, compareTo, compareTo, copyFrom, copyTo, createTempFile, firstQueryResult, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getFileSystem, getName, getParent, getParentFile, length, listFiles, listRoots, listRoots, mkdirs, modifyMetaData, query, query, query, setLastModified, setReadOnly, toURI, toURL |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PATH_SEPARATOR
PATH_SEPARATOR_CHAR.
public static final char PATH_SEPARATOR_CHAR
| Constructor Detail |
|---|
public IRODSFile(IRODSFileSystem fileSystem,
java.lang.String filePath)
fileSystem - The connection to the iRODS serverfilePath - A pathname string
public IRODSFile(IRODSFileSystem fileSystem,
java.lang.String parent,
java.lang.String child)
If parent is null then the new IRODSFile instance is created as if by invoking the single-argument IRODSFile 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 system-dependent way. If parent is the empty string then the new RemoteFile instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.
fileSystem - The connection to the iRODS serverparent - The parent pathname stringchild - The child pathname string
public IRODSFile(IRODSFile parent,
java.lang.String child)
If parent is null then the new IRODSFile instance is created as if by invoking the single-argument IRODSFile constructor on the given child pathname string.
Otherwise the parent abstract pathname 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 system-dependent way. If parent is the empty abstract pathname then the new RemoteFile instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.
parent - The parent abstract pathnamechild - The child pathname string
public IRODSFile(java.net.URI uri)
throws java.io.IOException,
java.net.URISyntaxException
iRODS URI protocol:
irods:// [ userName [ : password ] @ ] host [ : port ][ / path ]
example:
irods://irods@irods.sdsc.edu:21/pub/testfile.txt
uri - An absolute, hierarchical URI using a supported scheme.
java.lang.NullPointerException - if uri is null.
java.lang.IllegalArgumentException - If the preconditions on the parameter
do not hold.
java.io.IOException
java.net.URISyntaxException| Method Detail |
|---|
protected void finalize()
throws java.lang.Throwable
finalize in class GeneralFilejava.lang.Throwable
protected void setFileSystem(GeneralFileSystem fileSystem)
throws java.lang.IllegalArgumentException,
java.lang.ClassCastException
setFileSystem in class GeneralFilefileSystem - The file system to be used.
java.lang.IllegalArgumentException - - if the argument is null.
java.lang.ClassCastException - -
if the argument is not an object of the approriate subclass.protected void setFileName(java.lang.String filePath)
setFileName in class GeneralFilefleName - The file name or fileName plus some or all of the
directory path.protected void setDirectory(java.lang.String dir)
setDirectory in class GeneralFiledir - The directory path, need not be absolute.public java.lang.String getPathSeparator()
getPathSeparator in class GeneralFilepublic char getPathSeparatorChar()
getPathSeparatorChar in class GeneralFile
public void copyTo(GeneralFile file,
boolean forceOverwrite)
throws java.io.IOException
copyTo in class GeneralFilefile - The file to receive the data.
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.
public void copyFrom(GeneralFile file,
boolean forceOverwrite)
throws java.io.IOException
copyFrom in class GeneralFilefile - The file to receive the data.
java.lang.NullPointerException - If file is null.
java.io.IOException - If an IOException occurs.
public void setResource(java.lang.String resourceName)
throws java.io.IOException,
java.lang.NullPointerException,
java.lang.IllegalArgumentException
resource - The name of resource to be used.
java.lang.NullPointerException - If resourceName is null.
java.lang.IllegalArgumentException - If resourceName is not a valid resource.
java.io.IOException - If an IOException occurs during the system change.
public java.lang.String getResource()
throws java.io.IOException
getResource in class RemoteFilejava.io.IOException - If an IOException occurs during the system query.
public java.lang.String getDataType()
throws java.io.IOException
java.io.IOException - If an IOException occurs during the system query.
public void replicate(java.lang.String newResource)
throws java.io.IOException
RemoteFileIn some remote systems, one can make copies of a data set and store the copies in different locations. But, all these copies are considered to be identifiable by the same identifier. That is, each copy is considered to be equivalent to each other.
When a user reads a replicated data set, the remote system cycles through all the copies of the datset and reads the one that is accessible at that time.
replicate in class RemoteFilenewResource - The storage resource name of the new copy.
java.io.IOException - If an IOException occurs.
public void changePermissions(java.lang.String permission,
java.lang.String newUserName,
boolean recursive)
throws java.io.IOException
permission - "w" - write;"r" - read;"own" or "all" - owner;"n" - null;newUserName - The permissions are changed for this user,userMdasDomain - at this Mdas domain.recursive - Changes this and all subdirectories
java.io.IOException - If an IOException occurs.public boolean canRead()
canRead in class GeneralFiletrue if and only if the file specified by this
abstract pathname exists and can be read; otherwise
false.public boolean canWrite()
canWrite in class GeneralFiletrue 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.
public boolean createNewFile()
throws java.io.IOException
Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably.
createNewFile in class GeneralFiletrue if the named file does not exist and was
successfully created; false if the named file
already exists
java.io.IOException - If an I/O error occurred
public static GeneralFile createTempFile(java.lang.String prefix,
java.lang.String suffix,
GeneralFile directory)
throws java.io.IOException,
java.lang.IllegalArgumentException
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:
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
default temporary-file directory will be used. Since the SRB does not
have a standard temporary directory, files will be placed in a temp/
directory in the user's SRB home directory.
There are certain difficulties creating a static connection to the SRB.
For this static method to connect to the SRB, .Mdas files must be
available in the local home directory/.srb. That is the information that
will be used when storing the temporary file. This comprimise is
necessary to maintain the designs unity with the java.io.File class.
prefix - The prefix string to be used in generating the file's
name; must be at least three characters longsuffix - The suffix string to be used in generating the file's
name; may be null, in which case the
suffix ".tmp" will be useddirectory - The directory in which the file is to be created, or
null if the default temporary-file
directory is to be used
java.lang.IllegalArgumentException - If the prefix argument contains fewer than three
characters
java.io.IOException - If a file could not be createdpublic boolean delete()
delete in class GeneralFiletrue if and only if the file or directory is
successfully deleted; false otherwisepublic void deleteOnExit()
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.
deleteOnExit in class GeneralFilepublic java.lang.String getPath()
getPath in class GeneralFilepublic boolean equals(java.lang.Object obj)
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.
equals in class GeneralFileobj - The object to be compared with this abstract pathname
true if and only if the objects are the same;
false otherwisepublic boolean exists()
exists in class GeneralFiletrue if and only if the file denoted by this
abstract pathname exists; false otherwise
public java.lang.String getCanonicalPath()
throws java.io.IOException
getCanonicalPath in class GeneralFilejava.io.IOException - If an I/O error occurs, which is possible because the
construction of the canonical pathname may require
filesystem queriespublic int hashCode()
1234321.
hashCode in class java.lang.Objectpublic boolean isAbsolute()
"/".
isAbsolute in class GeneralFiletrue if this abstract pathname is absolute,
false otherwisepublic boolean isDirectory()
A SRB collection is a logical name given to a set of data sets. All data sets stored in SRB/MCAT are stored in some collection. A collection can have sub-collections, and hence provides a hierarchical structure. A collection in SRB/MCAT can be equated to a directory in a Unix file system. But unlike a file system, a collection is not limited to a single device (or partition). A collection is logical but the datsets grouped under a collection can be stored in heterogeneous storage devices. There is one obvious restriction, the name given to a data set in a collection or sub-collection should be unique in that collection.
isDirectory in class GeneralFiletrue if and only if the file denoted by this
abstract pathname exists and is a directory;
false otherwisepublic boolean isFile()
In the terminology of SRB, files are known as data sets. A data set is a "stream-of-bytes" entity that can be uniquely identified. For example, a file in HPSS or Unix is a data set, or a LOB stored in a SRB Vault database is a data set. Importantly, note that a data set is not a set of data objects/files. Each data set in SRB is given a unique internal identifier by SRB. A dataset is associated with a collection.
isFile in class GeneralFiletrue if and only if the file denoted by this
abstract pathname exists and is a normal file;
false otherwisepublic boolean isFile(boolean update)
update - If true, send a new query to the SRB to determine if
this abstract pathname refers to a file. If false, this
method will return a previously stored value. Also queries the SRB
if the value is not already stored with this object.
true if and only if the file denoted by this
abstract pathname exists and is a directory;
false otherwisepublic boolean isHidden()
isHidden in class GeneralFiletrue if and only if the file denoted by this
abstract pathname is hidden.public long lastModified()
lastModified in class GeneralFilelong value representing the time the file was
last modified, measured in system-dependent way.public java.lang.String[] list()
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 IRODSFile object denotes a file, the directory containing that file will be listed instead.
This method will return all the files in the directory. Listing directories with a large number of files may take a very long time. The more generic IRODSFile.query() method could be used to iterate through the file list piecewise.
list in class GeneralFilepublic java.lang.String[] list(MetaDataCondition[] conditions)
list in class GeneralFilepublic boolean mkdir()
mkdir in class GeneralFile
public boolean renameTo(GeneralFile dest)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
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.
renameTo in class GeneralFiledest - The new abstract pathname for the named file
java.lang.IllegalArgumentException - If parameter dest is not a GeneralFile.
java.lang.NullPointerException - - If dest is nullpublic java.lang.String toString()
toString in class GeneralFile
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||