|
||||||||||
| 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 MetricListeners 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 MetricListeners 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
GATInvocationExceptions 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 instance
public void recursivelyDeleteDirectory()
throws GATInvocationException
GATInvocationExceptionpublic boolean canRead()
canRead in class FileFile.canRead()public boolean canWrite()
canWrite in class FileFile.canWrite()public int compareTo(File pathname)
File.compareTo(java.io.File)
public boolean createNewFile()
throws IOException
createNewFile in class FileIOExceptionFile.createNewFile()public boolean delete()
delete in class FileFile.delete()public void deleteOnExit()
deleteOnExit in class FileFile.deleteOnExit()public boolean equals(Object obj)
equals in class FileFile.equals(java.lang.Object)public boolean exists()
exists in class FileFile.exists()public File getAbsoluteFile()
getAbsoluteFile in class FileFile.getAbsoluteFile()public String getAbsolutePath()
getAbsolutePath in class FileFile.getAbsolutePath()
public File getCanonicalFile()
throws IOException
getCanonicalFile in class FileIOExceptionFile.getCanonicalFile()
public String getCanonicalPath()
throws IOException
getCanonicalPath in class FileIOExceptionFile.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 FileFile.getName()public String getParent()
getParent in class FileFile.getParent()public File getParentFile()
getParentFile in class FileFile.getParentFile()public String getPath()
getPath in class FileFile.getPath()public int hashCode()
hashCode in class FileFile.hashCode()public boolean isAbsolute()
isAbsolute in class FileFile.isAbsolute()public boolean isDirectory()
isDirectory in class FileFile.isDirectory()public boolean isFile()
isFile in class FileFile.isFile()public boolean isHidden()
isHidden in class FileFile.isHidden()public long lastModified()
lastModified in class FilePlease 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 FileFile.length()public String[] list()
list in class FileFile.list()public String[] list(FilenameFilter filter)
list in class FileFile.list(java.io.FilenameFilter)public File[] listFiles()
listFiles in class FileFile.listFiles()public File[] listFiles(FileFilter filter)
listFiles in class FileFile.listFiles(java.io.FileFilter)public File[] listFiles(FilenameFilter filter)
listFiles in class FileFile.listFiles(java.io.FilenameFilter)public boolean mkdir()
mkdir in class FileFile.mkdir()public boolean mkdirs()
mkdirs in class FileFile.mkdirs()public boolean renameTo(File dest)
renameTo in class FileFile.renameTo(java.io.File)public boolean setLastModified(long time)
setLastModified in class FileFile.setLastModified(long)public boolean setReadOnly()
setReadOnly in class FileFile.setReadOnly()public String toString()
toString in class FileFile.toString()public URI toURI()
toURI in class FileFile.toURI()public URI toGATURI()
File.toURI()
public URL toURL()
throws MalformedURLException
toURL in class FileMalformedURLExceptionthis method does {@link java.io.File#toURI()}.toURL(), because
{@link java.io.File#toURL()} is deprecated.public String marshal()
AdvertisableString representation of this object. This method
should not be used, it is used internally in the GAT.
marshal in interface AdvertisableString representation of this object
public void addMetricListener(MetricListener metricListener,
Metric metric)
throws GATInvocationException
MonitorableMetricListener to the
list of MetricListeners 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 MonitorablemetricListener - 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 added
public MetricEvent getMeasurement(Metric metric)
throws GATInvocationException
MonitorableMetricEvent that represents the measured Metric.
getMeasurement in interface MonitorableMetricEvent that represents the measured Metric.
GATInvocationException - the measurement failed
public MetricDefinition getMetricDefinitionByName(String name)
throws GATInvocationException
MonitorableMetricDefinition using its name.
getMetricDefinitionByName in interface Monitorablename - The MetricDefinition name
MetricDefinition with the given name
GATInvocationException - An error occurred while getting the list of
Metrics or no Metric with this name
exists
public List<MetricDefinition> getMetricDefinitions()
throws GATInvocationException
MonitorableList of MetricDefinition
instances. Each instance in this List is a
MetricDefinition which can be monitored on this instance.
getMetricDefinitions in interface MonitorableList 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 metrics
public void removeMetricListener(MetricListener metricListener,
Metric metric)
throws GATInvocationException
MonitorableMetricListener from the List
of MetricListeners which are notified of MetricEvents
corresponding to the passed Metric instance.
removeMetricListener in interface MonitorablemetricListener - 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 | |||||||||