|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wjhk.jupload2.filedata.DefaultFileData
public class DefaultFileData
This class contains all data and methods for a file to upload. The current
UploadPolicy
contains the necessary parameters
to personalize the way files must be handled.
This class is the default FileData implementation. It gives the default
behaviour, and is used by DefaultUploadPolicy
. It provides standard
control on the files choosen for upload.
FileData
Field Summary | |
---|---|
protected String |
mimeType
Mime type of the file. |
(package private) boolean |
preparedForUpload
Indicates whether the file is prepared for upload or not. |
(package private) UploadPolicy |
uploadPolicy
The current upload policy. |
Constructor Summary | |
---|---|
DefaultFileData(File file,
File root,
UploadPolicy uploadPolicy)
Standard constructor |
Method Summary | |
---|---|
void |
afterUpload()
This function is called after upload, whether it is successful or not. |
void |
appendFileProperties(wjhk.jupload2.upload.helper.ByteArrayEncoder bae,
int index)
Called during the upload, by the FileUploadThread . |
void |
beforeUpload()
Prepare the fileData to upload. |
boolean |
canRead()
Indicate if this file can be read. |
String |
getDirectory()
Get the directory of the file. |
static String |
getExtension(File file)
Returns the extension of the given file. |
File |
getFile()
Standard getter, for the file described by the FileData instance. |
String |
getFileExtension()
|
long |
getFileLength()
|
String |
getFileName()
Get the original filename. |
InputStream |
getInputStream()
This function creates an InputStream from this file. |
Date |
getLastModified()
|
String |
getMimeType()
This function return the FileData content type. |
String |
getRelativeDir()
Retrieves the path of this file relative to it's root dir |
static File |
getRoot(File[] fileArray)
Return the 'biggest' common ancestror of the given file array. |
long |
getUploadLength()
Get size of upload, which may be different from the actual file length. |
boolean |
isPreparedForUpload()
Indicates whether the file can be uploaded or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
UploadPolicy uploadPolicy
boolean preparedForUpload
FileData.isPreparedForUpload()
protected String mimeType
Constructor Detail |
---|
public DefaultFileData(File file, File root, UploadPolicy uploadPolicy)
file
- The file whose data this instance will give.root
- The directory root, to be able to calculate the result of
getRelativeDir()
uploadPolicy
- The current upload policy.Method Detail |
---|
public void appendFileProperties(wjhk.jupload2.upload.helper.ByteArrayEncoder bae, int index) throws JUploadIOException
FileUploadThread
. The FileData
instance should then call the
ByteArrayEncoder.appendTextProperty(String, String, int)
method to add
each file property to the current upload.
appendFileProperties
in interface FileData
bae
- The byte encoder, where the properties must be addedindex
- Index of the file concerned by this value. -1 if this is a
global parameter.
JUploadIOException
- Encapsulation of the IOException, if any would
occurs.ByteArrayEncoder.appendTextProperty(String, String, int)
public void beforeUpload() throws JUploadException
PictureFileData
. This method is called before
the upload of this file.
beforeUpload
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.FileUploadThread
public long getUploadLength() throws JUploadException
FileData.beforeUpload()
and
before the call to FileData.afterUpload()
.
getUploadLength
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.PictureFileData
public void afterUpload()
PictureFileData.afterUpload()
removes the temporary
file, if any was created.
afterUpload
in interface FileData
public InputStream getInputStream() throws JUploadException
FileUploadThread
class then reads bytes from it and transfers
them to the webserver. The caller is responsible for closing this stream.FileData.isPreparedForUpload()
returns true.
getInputStream
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.public String getFileName()
getFileName
in interface FileData
public String getFileExtension()
getFileExtension
in interface FileData
public long getFileLength()
getFileLength
in interface FileData
public Date getLastModified()
getLastModified
in interface FileData
public String getDirectory()
getDirectory
in interface FileData
public String getMimeType()
getMimeType
in interface FileData
public boolean canRead()
canRead
in interface FileData
public File getFile()
getFile
in interface FileData
public String getRelativeDir()
getRelativeDir
in interface FileData
public static String getExtension(File file)
file
- the file whose the extension is wanted!
public static File getRoot(File[] fileArray)
fileArray
-
public boolean isPreparedForUpload()
FileData.beforeUpload()
, and the to false in
the call to FileData.afterUpload()
.
isPreparedForUpload
in interface FileData
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |