Package org.appng.forms
Interface FormUpload
-
- All Known Implementing Classes:
FormUploadBean
public interface FormUpload
- Author:
- Matthias Müller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<String>
getAcceptedTypes()
byte[]
getBytes()
Returns the bytes of the uploadedFile
.String
getContentType()
Returns the content-type (if any) for thisFormUpload
.File
getFile()
long
getMaxSize()
Returns the maximum size (in bytes) for the uploadedFile
(default: -1, which means there is no limit).long
getMinSize()
Returns the minimum size (in bytes) for the uploaded file (default: 0).String
getOriginalFilename()
Returns the name of the original (without any path prefix) file which was uploaded.boolean
isValid()
Returnstrue
if, and only if, all of those methods returntrue
:isValidFile()
isValidSize()
isValidType()
boolean
isValid(Class<? extends FormUploadValidator> validatorClass)
CallsFormUploadValidator.isValid(FormUpload)
using thisFormUpload
and returns the result.boolean
isValid(String[] types, long minSize, long maxSize)
Checks whether thisFormUpload
has one of the given types and matches the given size restrictions.boolean
isValid(FormUploadValidator validator)
CallsFormUploadValidator.isValid(FormUpload)
using thisFormUpload
and returns the result.boolean
isValidFile()
boolean
isValidSize()
Checks whether theFile
has a valid size.boolean
isValidType()
Checks whether theFile
's extension or content-type are contained in the list of accepted types for thisFormUpload
.long
size()
Returns the size (in bytes) of the uploadedFile
.
-
-
-
Method Detail
-
getOriginalFilename
String getOriginalFilename()
Returns the name of the original (without any path prefix) file which was uploaded.- Returns:
- the name of the original file
-
getFile
File getFile()
Returns theFile
which has been locally saved, but only ifisValid()
returnstrue
. The name of this file may have nothing to do with the file's original name.- Returns:
- the
File
, ornull
if no file was uploaded orisValid()
returnsfalse
- See Also:
getOriginalFilename()
-
getBytes
byte[] getBytes()
Returns the bytes of the uploadedFile
.- Returns:
- the bytes
-
size
long size()
Returns the size (in bytes) of the uploadedFile
.- Returns:
- the size
-
getMinSize
long getMinSize()
Returns the minimum size (in bytes) for the uploaded file (default: 0).- Returns:
- the minimum size
-
getMaxSize
long getMaxSize()
Returns the maximum size (in bytes) for the uploadedFile
(default: -1, which means there is no limit).- Returns:
- the maximum size
-
isValid
boolean isValid()
Returnstrue
if, and only if, all of those methods returntrue
:- Returns:
true
if thisFormUpload
is valid,false
otherwise.
-
isValid
boolean isValid(FormUploadValidator validator)
CallsFormUploadValidator.isValid(FormUpload)
using thisFormUpload
and returns the result.- Parameters:
validator
- aFormUploadValidator
- Returns:
- the result returned by
FormUploadValidator.isValid(FormUpload)
-
isValid
boolean isValid(Class<? extends FormUploadValidator> validatorClass)
CallsFormUploadValidator.isValid(FormUpload)
using thisFormUpload
and returns the result.- Parameters:
validatorClass
- a type extendingFormUploadValidator
- Returns:
- the result returned by
FormUploadValidator.isValid(FormUpload)
-
isValid
boolean isValid(String[] types, long minSize, long maxSize)
Checks whether thisFormUpload
has one of the given types and matches the given size restrictions. Delegates toisValidSize()
andisValidType()
.- Parameters:
types
- an array containing the allowed file-extensions (without.
) and content-typesminSize
- the minimum size of the file (in bytes)maxSize
- the maximum size of the file (in bytes)- Returns:
true
if thisFormUpload
is valid,false
otherwise.- See Also:
isValidSize()
,isValidType()
,getContentType()
,getAcceptedTypes()
-
isValidSize
boolean isValidSize()
Checks whether theFile
has a valid size. Note that by default, there is no minimum size. The default maximum size is provided by the concreteFormUpload
.- Returns:
true
if the file's size is valid,false
otherwise- See Also:
isValid(String[], long, long)
,getMinSize()
,getMaxSize()
-
isValidType
boolean isValidType()
Checks whether theFile
's extension or content-type are contained in the list of accepted types for thisFormUpload
. IfgetAcceptedTypes()
isnull
or empty, all types are allowed.- Returns:
true
if the uploadedFile
has a valid type,false
otherwise.- See Also:
getAcceptedTypes()
,getContentType()
-
getAcceptedTypes
List<String> getAcceptedTypes()
- Returns:
- the list of accepted types
- See Also:
getContentType()
-
isValidFile
boolean isValidFile()
- Returns:
true
if theFile
is valid,false
otherwise
-
getContentType
String getContentType()
Returns the content-type (if any) for thisFormUpload
. Usually the content-type has been retrieved usingServletRequest.getContentType()
- Returns:
- the content type for this
FormUpload
, ornull
-
-