|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
j2ee.io.File
public class File
This version of the File class that inherits from the java.io.File class is designed specially to let user's at the J2EEPS at CERN use and write to files stored at their local user area at DFS.
For this to work, the user has to have a file named dfs.properties inside his/hers war-file, where the following keys has to be present
If this information is present and valid, each time the user creates an object of this class, it will be searched for the same file at the DFS location, and the user can call all the methods available in this class and will manipulate the file at DFS.
Field Summary | |
---|---|
private org.apache.commons.httpclient.HttpsURL |
hrl
|
private java.lang.String |
location
|
private java.lang.String |
password
|
private java.lang.String |
path
|
private java.lang.String |
username
|
private org.apache.webdav.lib.WebdavResource |
wdr
|
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
---|---|
File(File parent,
java.lang.String child)
A constructor that creates the file/directory specified with parent and child string in the temporary directory locally at the J2EEPS container in question. |
|
File(java.lang.String pathName)
A constructor that creates the file/directory specified in the temporary directory locally at the J2EEPS container in question. |
|
File(java.lang.String parent,
java.lang.String child)
A constructor that creates the file/directory specified with parent and child string in the temporary directory locally at the J2EEPS container in question. |
Method Summary | |
---|---|
private boolean |
createDirectory(java.lang.String s)
This method creates the directory specified by the input string at DFS, if it already doesn't exist |
boolean |
createNewFile()
Currently not implemented |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix)
Not implemented |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File directory)
Not implemented |
boolean |
delete()
Deletes the file or directory denoted by this abstract pathname. |
private boolean |
deleteFile(java.lang.String path)
This method deletes the file at DFS. |
void |
deleteOnExit()
This method is not possible to implement correctly, as there is no indication to DFS about when the Java virtual machine terminates. |
boolean |
exists()
Tests whether the file or directory denoted by this abstract pathname exists at DFS. |
private boolean |
existsAtDFS(java.lang.String path)
Checks if the specified input path exists at DFS |
java.io.File |
getAbsoluteFile()
Returns the absolute form of this abstract pathname. |
java.lang.String |
getAbsolutePath()
Returns the absolute pathname string of this abstract pathname. |
java.io.File |
getCanonicalFile()
Returns the canonical form of this abstract pathname. |
java.lang.String |
getCanonicalPath()
If a connection to DFS is possible, this will return the same as this.getAbsolutePath(). |
private void |
getDirectory(java.lang.String[] paths)
This method creates the directory with all parents specified in the input array, both locally and at DFS |
private void |
getFile(java.lang.String[] paths)
This method takes the file from the DFS location and copies it to the temporary directory locally at the J2EEPS server, for there to be further accessed/written to from the user's application |
private boolean |
getLocationInfo()
Checks if it can find a dfs.properties file in the user's directory. |
java.lang.String |
getName()
Returns the name of the file or directory denoted by this abstract pathname. |
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. |
java.io.File |
getParentFile()
Returns the file object for abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory. |
java.lang.String |
getPath()
Converts this abstract pathname into a pathname string. |
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. |
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(java.io.FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. |
File[] |
listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. |
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. |
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 File[] |
listRoots()
Not implemented |
boolean |
mkdir()
It the file in question is a directory, this method creates the directory at DFS if DFS location information is available and valid. |
boolean |
mkdirs()
This method creates the directory that is denoted by this abstract pathname both locally and at DFS if valid DFS location information is available. |
private java.lang.String |
parseLocation(java.lang.String s)
Helper method that ensures that the input does not start or end with a "/". |
boolean |
renameTo(java.io.File dest)
Not implemented |
private boolean |
setDFSConnection(java.lang.String location)
This method sets the DFS connection according to the specified input. |
java.net.URI |
toURI()
Not implemented, always returns null |
java.net.URL |
toURL()
Not implmenented, always returns null |
private java.lang.String |
trim(java.lang.String s)
Helper method that removes separators (normally "/"'s) from the end and the beginning of the input string, if they exist |
private java.lang.String |
trimFirst(java.lang.String s)
Helper method that removes the separator (normally "/") if the input string starts with it |
private java.lang.String[] |
vectorize(java.lang.String input)
Helper method that splits the input around the separator defined (usually "/") |
Methods inherited from class java.io.File |
---|
canRead, canWrite, compareTo, equals, hashCode, isHidden, lastModified, length, setLastModified, setReadOnly, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String location
private java.lang.String username
private java.lang.String password
private org.apache.webdav.lib.WebdavResource wdr
private org.apache.commons.httpclient.HttpsURL hrl
private java.lang.String path
Constructor Detail |
---|
public File(java.lang.String pathName)
A constructor that creates the file/directory specified in the temporary directory locally at the J2EEPS container in question.
If it can find information about user credentials for DFS, it tries to retrieve the file and put it in the temporary directory for it to be further accessed
If the input is a directory (e.g. ends with /) it will create the directory at DFS if user credentials is available
The method uses the constructor of the superclass and adds the temporary directory path directly when calling the superclass constructor
pathName
- The path for the file/directorypublic File(java.lang.String parent, java.lang.String child)
A constructor that creates the file/directory specified with parent and child string in the temporary directory locally at the J2EEPS container in question.
If it can find information about user credentials for DFS, it tries to retrieve the file and put it in the temporary directory for it to be further accessed
If the input is a directory (e.g. ends with /) it will create the directory at DFS if user credentials is available
The method uses the constructor of the superclass and adds the temporary directory path directly when calling the superclass constructor
parent
- The path for the parent of the filechild
- The name of the child filepublic File(File parent, java.lang.String child)
A constructor that creates the file/directory specified with parent and child string in the temporary directory locally at the J2EEPS container in question.
If it can find information about user credentials for DFS, it tries to retrieve the file and put it in the temporary directory for it to be further accessed
If the input is a directory (e.g. ends with /) it will create the directory at DFS if user credentials is available
The method uses the constructor of the superclass and adds the temporary directory path directly when calling the superclass constructor
parent
- The parent file objectchild
- The name of the child fileMethod Detail |
---|
private void getDirectory(java.lang.String[] paths)
This method creates the directory with all parents specified in the input array, both locally and at DFS
It uses the method File.createDirectory() to create the directories at DFS. Is only used if a valid connection to DFS can be established
paths
- - The String array with the directory itself and all parents that should be createdpublic java.net.URL toURL()
Not implmenented, always returns null
toURL
in class java.io.File
public java.net.URI toURI()
Not implemented, always returns null
toURI
in class java.io.File
private void getFile(java.lang.String[] paths)
This method takes the file from the DFS location and copies it to the temporary directory locally at the J2EEPS server, for there to be further accessed/written to from the user's application
paths
- - The String array with all the path information for the parents of the file and the file itselfprivate java.lang.String parseLocation(java.lang.String s)
Helper method that ensures that the input does not start or end with a "/". Is used to ensure conformity when treating location strings in the class
s
- - The string to be checked for starting or ending "/"'s
private boolean getLocationInfo()
Checks if it can find a dfs.properties file in the user's directory.
private java.lang.String[] vectorize(java.lang.String input)
Helper method that splits the input around the separator defined (usually "/")
Is used to give an array of parent directories and the directory/file itself
input
- - The string to be split
public boolean delete()
Deletes the file or directory denoted by this abstract pathname. Should be used with care
delete
in class java.io.File
public java.lang.String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.
If a connection to DFS is possible, it will remove the temporary directory of the J2EEPS container from the path, and just show the DFS part from the user's location directory in dfs.properties.
Otherwise it will return the superclass method
getAbsolutePath
in class java.io.File
public void deleteOnExit()
This method is not possible to implement correctly, as there is no indication to DFS about when the Java virtual machine terminates.
It will, if called, call the superclass method and the file will be deleted locally on termination as described for the superclass constructor (but no deletion at DFS)
deleteOnExit
in class java.io.File
private boolean deleteFile(java.lang.String path)
This method deletes the file at DFS. It is used by the File.delete() method
path
- - The path to the file/directory that should be deleted
private boolean setDFSConnection(java.lang.String location)
This method sets the DFS connection according to the specified input. It does not check if this is a valid location, that has to be done after by trying to create the WebdavResource connection
location
- - the DFS location
public java.lang.String getCanonicalPath() throws java.io.IOException
If a connection to DFS is possible, this will return the same as this.getAbsolutePath(). If not, it returns the result of the superclass method
getCanonicalPath
in class java.io.File
java.io.IOException
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.
getParent
in class java.io.File
public java.io.File getParentFile()
Returns the file object for abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
getParentFile
in class java.io.File
private java.lang.String trimFirst(java.lang.String s)
Helper method that removes the separator (normally "/") if the input string starts with it
s
- - The string to be checked
private java.lang.String trim(java.lang.String s)
Helper method that removes separators (normally "/"'s) from the end and the beginning of the input string, if they exist
s
- - The input string to be checked
public java.io.File getCanonicalFile() throws java.io.IOException
Returns the canonical form of this abstract pathname. Equivalent to new File(this.getCanonicalPath()()).
getCanonicalFile
in class java.io.File
java.io.IOException
public boolean createNewFile()
Currently not implemented
createNewFile
in class java.io.File
private boolean existsAtDFS(java.lang.String path)
Checks if the specified input path exists at DFS
path
- - The path to be checked for existance
public boolean exists()
Tests whether the file or directory denoted by this abstract pathname exists at DFS. If no DFS location information is available it calls the suprclass method
exists
in class java.io.File
public java.io.File getAbsoluteFile()
Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath()())
getAbsoluteFile
in class java.io.File
public java.lang.String getPath()
Converts this abstract pathname into a pathname string. The resulting string uses the default name-separator character to separate the names in the name sequence.
getPath
in class java.io.File
public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory. If information about connection to DFS is available it checks whether this pathname is a directory at DFS, otherwise the superclass method is returned
isDirectory
in class java.io.File
public boolean isFile()
Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
isFile
in class java.io.File
public java.lang.String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.
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.
list
in class java.io.File
public java.lang.String[] list(java.io.FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the list() method, except that the strings in the returned array must satisfy the filter. If the given filter is null then all names are accepted. Otherwise, a name satisfies the filter if and only if the value true results when the FilenameFilter.accept(java.io.File, java.lang.String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
list
in class java.io.File
filter
- - A filename filter
public File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.
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.
listFiles
in class java.io.File
public 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. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FileFilter.accept(java.io.File, java.lang.String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
listFiles
in class java.io.File
filter
- - A filename filter
public 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. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FileNameFilter.accept(java.io.File, java.lang.String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
listFiles
in class java.io.File
filter
- - A filename filter
public boolean mkdir()
It the file in question is a directory, this method creates the directory at DFS if DFS location information is available and valid. If parent directories does not exist, this method will return false (use mkdirs() instead to simultaneously create parent directories)
If no valid DFS location information is available, the superclass method is called and the directory can be created locally
mkdir
in class java.io.File
public boolean mkdirs()
This method creates the directory that is denoted by this abstract pathname both locally and at DFS if valid DFS location information is available. If not, it uses the superclass method to create the directory and any non-existent parent directories
mkdirs
in class java.io.File
private boolean createDirectory(java.lang.String s)
This method creates the directory specified by the input string at DFS, if it already doesn't exist
s
- - The path to the directory that should be created
public boolean renameTo(java.io.File dest)
Not implemented
renameTo
in class java.io.File
public java.lang.String getName()
Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.
getName
in class java.io.File
public static File[] listRoots()
Not implemented
public static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File directory)
Not implemented
public static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix)
Not implemented
public boolean isAbsolute()
Tests whether this abstract pathname is absolute. If a connection to DFS is valid, it will never be. Otherwise, the superclass method is used
isAbsolute
in class java.io.File
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |