PAJES 2.3.9

org.pajes.servlet
Class UploadedFile

java.lang.Object
  extended byorg.pajes.servlet.UploadedFile

public class UploadedFile
extends java.lang.Object

A representation of a file which has been uploaded to the server. The uploaded file instance is retrieved using the PajeServlet.getUploadedFile(javax.servlet.http.HttpServletRequest, java.lang.String) method. The names of the available files can be retrieved using PajeServlet.getUploadedFileNames(javax.servlet.http.HttpServletRequest).

Uploaded files are created as temporary files that are set to be deleted on exit if they are not moved or renamed.


Method Summary
 boolean canRead()
          Tests whether the application can read the file.
 boolean canWrite()
          Tests whether the application can modify to the file.
 boolean delete()
          Deletes the file or directory.
 boolean exists()
          Tests whether the file exists.
 java.lang.String getAbsolutePath()
          Returns the absolute pathname string of this abstract pathname.
 java.lang.String getCanonicalPath()
          Returns the canonical pathname string of this abstract pathname.
 java.lang.String getMIMEType()
          Returns the MIME content type of this file.
 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.lang.String getPath()
          Converts this abstract pathname into a pathname string.
 java.lang.String getSourceFileName()
          Returns the source file name from the client browser.
 boolean isAbsolute()
          Tests whether this abstract pathname is absolute.
 boolean isDirectory()
          Tests whether the file is a directory.
 boolean isFile()
          Tests whether the file is a normal file.
 long lastModified()
          Returns the time that the file was last modified.
 long length()
          Returns the length of the file.
 boolean moveTo(java.io.File dest)
          Moves the file to the new file.
 boolean renameTo(java.io.File dest)
          Renames the file.
 boolean wasReplaced()
          Determines whether the file already existed before being uploaded or moved, and was therefore replaced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isAbsolute

public boolean isAbsolute()
Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Win32 systems, a pathname is absolute if its prefix is a drive specifier followed by "\\" , or if its prefix is "\\".

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

getAbsolutePath

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

If this abstract pathname is already absolute, then the pathname string is simply returned as if by the getPath() method. If this abstract pathname is the empty abstract pathname then the pathname string of the current user directory, which is named by the system property user.dir, is returned. Otherwise this pathname is resolved in a system-dependent way. On UNIX systems, a relative pathname is made absolute by resolving it against the current user directory. On Win32 systems, a relative pathname is made absolute by resolving it against the current directory of the drive named by the pathname, if any; if not, it is resolved against the current user directory.

Returns:
The absolute pathname string denoting the same file or directory as this abstract pathname.
See Also:
isAbsolute()

getCanonicalPath

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

Every pathname that denotes an existing file or directory has a unique canonical form. Every pathname that denotes a nonexistent file or directory also has a unique canonical form. The canonical form of the pathname of a nonexistent file or directory may be different from the canonical form of the same pathname after the file or directory is created. Similarly, the canonical form of the pathname of an existing file or directory may be different from the canonical form of the same pathname after the file or directory is deleted.

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.

isDirectory

public boolean isDirectory()
Tests whether the file is a directory.

Returns:
true if and only if the file exists and is a directory; false otherwise.

isFile

public boolean isFile()
Tests whether the file 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.

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

getMIMEType

public java.lang.String getMIMEType()
Returns the MIME content type of this file.

Returns:
the MIME type of this file.

getName

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.

Returns:
The name of the file or directory denoted by this abstract pathname, or the empty string if this pathname's name sequence is empty.

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.

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 pathname string 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()
Converts this abstract pathname into a pathname string.

Returns:
The string form of this abstract pathname.

getSourceFileName

public java.lang.String getSourceFileName()
Returns the source file name from the client browser.

Returns:
the source file name.

canRead

public boolean canRead()
Tests whether the application can read the file.

Returns:
true if and only if the file exists and can be read by the application; false otherwise

canWrite

public boolean canWrite()
Tests whether the application can modify to the file.

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

delete

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

Returns:
true if and only if the file or directory is successfully deleted; false otherwise.

exists

public boolean exists()
Tests whether the file exists.

Returns:
true if and only if the file exists; false otherwise.

lastModified

public long lastModified()
Returns the time that the file was last modified.

Returns:
A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs.

length

public long length()
Returns the length of the file.

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

moveTo

public boolean moveTo(java.io.File dest)
Moves the file to the new file. If the existing file already exists, it will be deleted .

Parameters:
dest - The new abstract pathname for the named file.
Returns:
true if and only if the move succeeded; false otherwise.

renameTo

public boolean renameTo(java.io.File dest)
Renames the file. If the destination file exists, the rename will fail .

Parameters:
dest - The new abstract pathname for the named file.
Returns:
true if and only if the renaming succeeded; false if the rename fails.

wasReplaced

public boolean wasReplaced()
Determines whether the file already existed before being uploaded or moved, and was therefore replaced.

Returns:
true if the file existed, or false if it did not.

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.