public class FormUploadBean extends Object implements FormUpload
FormUpload implementation.| Constructor and Description |
|---|
FormUploadBean(File file,
String originalName,
String contentType,
List<String> acceptedTypes,
long maxSize) |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getAcceptedTypes()
|
byte[] |
getBytes()
Returns the bytes of the uploaded
File. |
String |
getContentType()
Returns the content-type (if any) for this
FormUpload. |
File |
getFile()
|
long |
getMaxSize()
Returns the maximum size (in bytes) for the uploaded
File (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()
Returns
true if, and only if, all of those methods return true:
FormUpload.isValidFile()
FormUpload.isValidSize()
FormUpload.isValidType()
|
boolean |
isValid(Class<? extends FormUploadValidator> validatorClass)
Calls
FormUploadValidator.isValid(FormUpload) using this FormUpload and returns the result. |
boolean |
isValid(FormUploadValidator validator)
Calls
FormUploadValidator.isValid(FormUpload) using this FormUpload and returns the result. |
boolean |
isValid(String[] types,
long minSize,
long maxSize)
Checks whether this
FormUpload has one of the given types and matches the given size restrictions. |
boolean |
isValidFile()
|
boolean |
isValidSize()
Checks whether the
File has a valid size. |
boolean |
isValidType()
Checks whether the
File's extension or content-type are contained in the list of accepted types
for this FormUpload. |
long |
size()
Returns the size (in bytes) of the uploaded
File. |
String |
toString() |
public List<String> getAcceptedTypes()
FormUploadgetAcceptedTypes in interface FormUploadFormUpload.getContentType()public String getOriginalFilename()
FormUploadgetOriginalFilename in interface FormUploadpublic File getFile()
FormUploadFile which has been locally saved, but only if FormUpload.isValid() returns true. The
name of this file may have nothing to do with the file's original name.getFile in interface FormUploadFile, or null if no file was uploaded or FormUpload.isValid() returns falseFormUpload.getOriginalFilename()public long size()
FormUploadFile.size in interface FormUploadpublic long getMaxSize()
FormUploadFile (default: -1, which means there is no limit).getMaxSize in interface FormUploadpublic long getMinSize()
FormUploadgetMinSize in interface FormUploadpublic byte[] getBytes()
FormUploadFile.getBytes in interface FormUploadpublic boolean isValidSize()
FormUploadFile has a valid size. Note that by default, there is no minimum size. The default
maximum size is provided by the concrete FormUpload.isValidSize in interface FormUploadtrue if the file's size is valid, false otherwiseFormUpload.isValid(String[], long, long),
FormUpload.getMinSize(),
FormUpload.getMaxSize()public boolean isValid()
FormUploadtrue if, and only if, all of those methods return true:
isValid in interface FormUploadtrue if this FormUpload is valid, false otherwise.public boolean isValid(String[] types, long minSize, long maxSize)
FormUploadFormUpload has one of the given types and matches the given size restrictions.
Delegates to FormUpload.isValidSize() and FormUpload.isValidType().isValid in interface FormUploadtypes - 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)true if this FormUpload is valid, false otherwise.FormUpload.isValidSize(),
FormUpload.isValidType(),
FormUpload.getContentType(),
FormUpload.getAcceptedTypes()public boolean isValid(FormUploadValidator validator)
FormUploadFormUploadValidator.isValid(FormUpload) using this FormUpload and returns the result.isValid in interface FormUploadvalidator - a FormUploadValidatorFormUploadValidator.isValid(FormUpload)public boolean isValid(Class<? extends FormUploadValidator> validatorClass)
FormUploadFormUploadValidator.isValid(FormUpload) using this FormUpload and returns the result.isValid in interface FormUploadvalidatorClass - a type extending FormUploadValidatorFormUploadValidator.isValid(FormUpload)public boolean isValidFile()
FormUploadisValidFile in interface FormUploadtrue if the File is valid, false otherwisepublic boolean isValidType()
FormUploadFile's extension or content-type are contained in the list of accepted types
for this FormUpload. If FormUpload.getAcceptedTypes() is null or empty, all types are allowed.isValidType in interface FormUploadtrue if the uploaded File has a valid type, false otherwise.FormUpload.getAcceptedTypes(),
FormUpload.getContentType()public String getContentType()
FormUploadFormUpload. Usually the content-type has been retrieved using
ServletRequest.getContentType()getContentType in interface FormUploadFormUpload, or nullCopyright © 2011–2021 aiticon GmbH. All rights reserved.