jodd.servlet.upload
Class FileUpload

java.lang.Object
  extended by jodd.servlet.upload.FileUpload
Direct Known Subclasses:
AdaptiveFileUpload, DiskFileUpload, MemoryFileUpload

public abstract class FileUpload
extends java.lang.Object

Encapsulates base for uploaded file. Its instance may be either valid, when it represent an uploaded file, or invalid when uploaded file doesn't exist or there was a problem with it.

See Also:
MultipartRequest

Field Summary
protected  boolean fileTooBig
           
protected  FileUploadHeader header
           
protected  MultipartRequestInputStream input
           
protected  int maxFileSize
           
protected  int size
           
protected  boolean valid
           
 
Constructor Summary
protected FileUpload(MultipartRequestInputStream input, int maxFileSize)
           
 
Method Summary
abstract  byte[] getFileContent()
          Returns all bytes of uploaded file.
abstract  java.io.InputStream getFileInputStream()
          Returns input stream of uploaded file.
 FileUploadHeader getHeader()
          Returns FileUploadHeader of uploaded file.
 int getMaxFileSize()
          Returns max file size or -1 if there is no max file size.
 int getSize()
          Returns the file upload size or -1 if file was not uploaded.
 boolean isFileTooBig()
          Returns true if file is too big.
abstract  boolean isInMemory()
          Returns true if uploaded file content is stored in memory.
 boolean isUploaded()
          Returns true if file was uploaded.
 boolean isValid()
          Returns true if upload process went correctly.
protected abstract  void processStream()
          Process request input stream.
 java.lang.String toString()
          Returns basic information about the uploaded file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

input

protected final MultipartRequestInputStream input

maxFileSize

protected final int maxFileSize

header

protected final FileUploadHeader header

valid

protected boolean valid

size

protected int size

fileTooBig

protected boolean fileTooBig
Constructor Detail

FileUpload

protected FileUpload(MultipartRequestInputStream input,
                     int maxFileSize)
Method Detail

getHeader

public FileUploadHeader getHeader()
Returns FileUploadHeader of uploaded file.


getFileContent

public abstract byte[] getFileContent()
                               throws java.io.IOException
Returns all bytes of uploaded file.

Throws:
java.io.IOException

getFileInputStream

public abstract java.io.InputStream getFileInputStream()
                                                throws java.io.IOException
Returns input stream of uploaded file.

Throws:
java.io.IOException

getSize

public int getSize()
Returns the file upload size or -1 if file was not uploaded.


isUploaded

public boolean isUploaded()
Returns true if file was uploaded.


isValid

public boolean isValid()
Returns true if upload process went correctly. This still does not mean that file is uploaded, e.g. when file was not specified on the form.


getMaxFileSize

public int getMaxFileSize()
Returns max file size or -1 if there is no max file size.


isFileTooBig

public boolean isFileTooBig()
Returns true if file is too big. File will be marked as invalid.


isInMemory

public abstract boolean isInMemory()
Returns true if uploaded file content is stored in memory.


processStream

protected abstract void processStream()
                               throws java.io.IOException
Process request input stream. Note that file size is unknown at this point. Therefore, the implementation should set the size attribute after successful processing. This method also must set the valid attribute.

Throws:
java.io.IOException
See Also:
MultipartRequestInputStream

toString

public java.lang.String toString()
Returns basic information about the uploaded file.

Overrides:
toString in class java.lang.Object


Copyright © 2003-2012 Jodd Team