|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
org.gridlab.gat.io.File
public class File
An abstract representation of a physical file. See File
.
An instance of this class presents an abstract, system-independent view of a physical file. User interfaces and operating systems use system-dependent pathname strings to identify physical files. GAT, however, uses an operating system independent pathname string to identify a physical file. A physical file in GAT is identified by a URI.
An instance of this File class allows for various high-level operations to be performed on a physical file. For example, one can, with a single API call, copy a physical file from one location to a second location, move a physical file from one location to a second location, delete a physical file, and perform various other operations on a physical file. The utility of this high-level view of a physical file is multi-fold. The client of an instance of this class does not have to concern themselves with the details of reading every single byte of a physical file when all they wish to do is copy the physical file to a new location. Similarly, a client does not have to deal with all the various error states that can occur when moving a physical file. Have all the various bytes been read correctly? Have all the various bytes been saved correctly? Did the deletion of the original file proceed correctly? The client simply has to call a single API call and the physical file is moved.
Field Summary |
---|
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
---|---|
File(org.gridlab.gat.io.FileInterface f)
Do not use this constructor, it is for internal GAT use. |
Method Summary | ||
---|---|---|
void |
addMetricListener(MetricListener metricListener,
Metric metric)
This method adds the passed instance of a MetricListener to the
list of MetricListener s which are notified of MetricEvents by an
instance of this class. |
|
boolean |
canRead()
|
|
boolean |
canWrite()
|
|
int |
compareTo(File pathname)
|
|
void |
copy(URI loc)
This method copies the physical file represented by this File instance to a physical file identified by the passed URI. |
|
boolean |
createNewFile()
|
|
boolean |
delete()
|
|
void |
deleteOnExit()
|
|
boolean |
equals(Object obj)
|
|
boolean |
exists()
|
|
File |
getAbsoluteFile()
|
|
String |
getAbsolutePath()
|
|
File |
getCanonicalFile()
|
|
String |
getCanonicalPath()
|
|
|
getFileAttributeView(Class<V> type,
boolean followSymbLinks)
Returns a file attribute view of a given type. |
|
org.gridlab.gat.io.FileInterface |
getFileInterface()
Returns the FileInterface object associated with this File . |
|
MetricEvent |
getMeasurement(Metric metric)
Returns a MetricEvent that represents the measured Metric . |
|
MetricDefinition |
getMetricDefinitionByName(String name)
Gets the MetricDefinition using its name . |
|
List<MetricDefinition> |
getMetricDefinitions()
This method returns a List of MetricDefinition
instances. |
|
String |
getName()
|
|
String |
getParent()
|
|
File |
getParentFile()
|
|
String |
getPath()
|
|
int |
hashCode()
|
|
boolean |
isAbsolute()
|
|
boolean |
isDirectory()
|
|
boolean |
isFile()
|
|
boolean |
isHidden()
|
|
long |
lastModified()
|
|
long |
length()
|
|
String[] |
list()
|
|
String[] |
list(FilenameFilter filter)
|
|
File[] |
listFiles()
|
|
File[] |
listFiles(FileFilter filter)
|
|
File[] |
listFiles(FilenameFilter filter)
|
|
String |
marshal()
Create a String representation of this object. |
|
boolean |
mkdir()
|
|
boolean |
mkdirs()
|
|
void |
move(URI location)
This method moves the physical file represented by this File instance to a physical file identified by the passed URI. |
|
void |
recursivelyDeleteDirectory()
This method deletes a directory and everything that is in it. |
|
void |
removeMetricListener(MetricListener metricListener,
Metric metric)
Removes the passed MetricListener from the List
of MetricListener s which are notified of MetricEvents
corresponding to the passed Metric instance. |
|
boolean |
renameTo(File dest)
|
|
boolean |
setLastModified(long time)
|
|
boolean |
setReadOnly()
|
|
URI |
toGATURI()
|
|
String |
toString()
|
|
URI |
toURI()
|
|
URL |
toURL()
|
Methods inherited from class java.io.File |
---|
canExecute, compareTo, createTempFile, createTempFile, getFreeSpace, getTotalSpace, getUsableSpace, listRoots, setExecutable, setExecutable, setReadable, setReadable, setWritable, setWritable |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public File(org.gridlab.gat.io.FileInterface f)
Method Detail |
---|
public void copy(URI loc) throws GATInvocationException
loc
- The new location
GATInvocationException
- Thrown upon problems accessing the remote instancepublic org.gridlab.gat.io.FileInterface getFileInterface()
File
. Use
The FileInterface offers the same functionality as the File object. The
difference between the FileInterface object and the File object is that
the FileInterface is an internal GAT object and it will throw
GATInvocationException
s upon failures, whereas the File object
would have default values.
This might be handy in certain circumstances. Suppose that one checks whether a file exists and if not one creates a file at that location. Using the File object the code will look like this:
if (!file.exists()) {
file.createNewFile();
}
Now suppose that the exists()
call fails because the network is
down for a moment. The File object will return false for this call,
because the network was down, even though the file might exist. To
overcome this one can change the code to code which uses the
FileInterface instead of the File object:
if (!file.getFileInterface().exists()) {
file.getFileInterface().createNewFile();
}
Now an exception will be thrown by the FileInterface if the network is down. It is possible to retry the code until the network is up again.
public void move(URI location) throws GATInvocationException
location
- The URI to which to move the physical file corresponding
to this File instance
GATInvocationException
- Thrown upon problems accessing the remote instancepublic void recursivelyDeleteDirectory() throws GATInvocationException
GATInvocationException
public boolean canRead()
canRead
in class File
File.canRead()
public boolean canWrite()
canWrite
in class File
File.canWrite()
public int compareTo(File pathname)
File.compareTo(java.io.File)
public boolean createNewFile() throws IOException
createNewFile
in class File
IOException
File.createNewFile()
public boolean delete()
delete
in class File
File.delete()
public void deleteOnExit()
deleteOnExit
in class File
File.deleteOnExit()
public boolean equals(Object obj)
equals
in class File
File.equals(java.lang.Object)
public boolean exists()
exists
in class File
File.exists()
public File getAbsoluteFile()
getAbsoluteFile
in class File
File.getAbsoluteFile()
public String getAbsolutePath()
getAbsolutePath
in class File
File.getAbsolutePath()
public File getCanonicalFile() throws IOException
getCanonicalFile
in class File
IOException
File.getCanonicalFile()
public String getCanonicalPath() throws IOException
getCanonicalPath
in class File
IOException
File.getCanonicalPath()
public <V extends FileAttributeView> V getFileAttributeView(Class<V> type, boolean followSymbLinks)
A file attribute view provides a read-only or updatable view of a
set of file attributes. This method is intended to be used where the file
attribute view defines type-safe methods to read or update the file
attributes. The type
parameter is the type of the attribute view
required and the method returns an instance of that type if supported.
The BasicFileAttributeView
type supports access to the basic
attributes of a file. Invoking this method to select a file attribute
view of that type will always return an instance of that class.
The followSymbLinks
option may be used to indicate how symbolic links
are handled by the resulting file attribute view for the case that the
file is a symbolic link. By default, symbolic links are followed. If the
option is set to false
then symbolic links are not followed.
This option is ignored by implementations that do not support symbolic links.
type
- The Class
object corresponding to the file attribute viewfollowSymbLinks
- boolean indicating how symbolic links are handled
null
if
the attribute view type is not availablepublic String getName()
getName
in class File
File.getName()
public String getParent()
getParent
in class File
File.getParent()
public File getParentFile()
getParentFile
in class File
File.getParentFile()
public String getPath()
getPath
in class File
File.getPath()
public int hashCode()
hashCode
in class File
File.hashCode()
public boolean isAbsolute()
isAbsolute
in class File
File.isAbsolute()
public boolean isDirectory()
isDirectory
in class File
File.isDirectory()
public boolean isFile()
isFile
in class File
File.isFile()
public boolean isHidden()
isHidden
in class File
File.isHidden()
public long lastModified()
lastModified
in class File
Please note there's an issue with the gt4 file adaptor (gt4gridftp). It
takes time zones into account where as the
{@link java.io.File#lastModified()} doesn't. For instance a file that's
last modified on 10 July 1984 at 00:00 GMT +2:00 will have a last
modified time of 9 July 1984 at 22:00 using the gt4 file adaptor. The
{@link java.io.File#lastModified()} will return 10 July 1984, 00:00.
public long length()
length
in class File
File.length()
public String[] list()
list
in class File
File.list()
public String[] list(FilenameFilter filter)
list
in class File
File.list(java.io.FilenameFilter)
public File[] listFiles()
listFiles
in class File
File.listFiles()
public File[] listFiles(FileFilter filter)
listFiles
in class File
File.listFiles(java.io.FileFilter)
public File[] listFiles(FilenameFilter filter)
listFiles
in class File
File.listFiles(java.io.FilenameFilter)
public boolean mkdir()
mkdir
in class File
File.mkdir()
public boolean mkdirs()
mkdirs
in class File
File.mkdirs()
public boolean renameTo(File dest)
renameTo
in class File
File.renameTo(java.io.File)
public boolean setLastModified(long time)
setLastModified
in class File
File.setLastModified(long)
public boolean setReadOnly()
setReadOnly
in class File
File.setReadOnly()
public String toString()
toString
in class File
File.toString()
public URI toURI()
toURI
in class File
File.toURI()
public URI toGATURI()
File.toURI()
public URL toURL() throws MalformedURLException
toURL
in class File
MalformedURLException
this method does {@link java.io.File#toURI()}.toURL(), because
{@link java.io.File#toURL()} is deprecated.
public String marshal()
Advertisable
String
representation of this object. This method
should not be used, it is used internally in the GAT.
marshal
in interface Advertisable
String
representation of this objectpublic void addMetricListener(MetricListener metricListener, Metric metric) throws GATInvocationException
Monitorable
MetricListener
to the
list of MetricListener
s which are notified of MetricEvents by an
instance of this class. The passed MetricListener
is only
notified of MetricEvents which correspond to Metric
instance
passed to this method.
addMetricListener
in interface Monitorable
metricListener
- The MetricListener
to notify of MetricEventsmetric
- The Metric
corresponding to the MetricEvents for
which the passed MetricListener
will be notified
GATInvocationException
- The MetricListener
cannot be addedpublic MetricEvent getMeasurement(Metric metric) throws GATInvocationException
Monitorable
MetricEvent
that represents the measured Metric
.
getMeasurement
in interface Monitorable
MetricEvent
that represents the measured Metric
.
GATInvocationException
- the measurement failedpublic MetricDefinition getMetricDefinitionByName(String name) throws GATInvocationException
Monitorable
MetricDefinition
using its name
.
getMetricDefinitionByName
in interface Monitorable
name
- The MetricDefinition name
MetricDefinition
with the given name
GATInvocationException
- An error occurred while getting the list of
Metric
s or no Metric
with this name
existspublic List<MetricDefinition> getMetricDefinitions() throws GATInvocationException
Monitorable
List
of MetricDefinition
instances. Each instance in this List
is a
MetricDefinition
which can be monitored on this instance.
getMetricDefinitions
in interface Monitorable
List
of MetricDefinition
instances.
Each instance in this List
is a Metric
which can be monitored on this instance
GATInvocationException
- An error occurred while getting the list of metricspublic void removeMetricListener(MetricListener metricListener, Metric metric) throws GATInvocationException
Monitorable
MetricListener
from the List
of MetricListener
s which are notified of MetricEvents
corresponding to the passed Metric
instance.
removeMetricListener
in interface Monitorable
metricListener
- The MetricListener
to notify of MetricEventsmetric
- The Metric
corresponding to the MetricEvents for
which the passed MetricListener
has been notified
GATInvocationException
- The MetricListener
cannot be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |