public class DefaultFileValidator extends Object implements FileValidator, Serializable
null
. DefaultDirectoryValidator
.DefaultDirectoryValidator
,
AcceptFileType
,
Serialized FormModifier and Type | Field and Description |
---|---|
static DefaultFileValidator |
ALL
All files and content is accepted.
|
Constructor and Description |
---|
DefaultFileValidator()
Default constructor, where the parameters are:
mustExists =
true
readable = true
writeable = false
acceptFileType = AcceptFileType.FILE
|
DefaultFileValidator(AcceptFileType acceptFileType)
Default constructor, where the parameters are:
mustExists =
true
readable = true
writeable = false
|
DefaultFileValidator(boolean mustExists,
AcceptFileType acceptFileType)
Default constructor, where the parameters are:
writeable =
true
writable = false
|
DefaultFileValidator(boolean mustExists,
boolean readable,
boolean writeable,
AcceptFileType acceptFileType)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
AcceptFileType |
getAcceptFileType()
The accepted file type.
|
org.apache.commons.logging.Log |
getLogger()
Gets the logger
|
List<String> |
getRestrictions()
Gets a detailed description of the FileValidator with any constraints that might influence the validation.
|
String |
getType()
A short string defining the type of "file" the FileValidator is validating.
|
boolean |
isMustExists()
If test on existence should be performed.
|
boolean |
isReadable()
If test on readability should be performed.
|
boolean |
isWriteable()
If test on writeable should be performed.
|
void |
validate(String sourceType,
String sourceName,
String intialValue,
File file)
Method to implement for validation a
File . |
public static final DefaultFileValidator ALL
public DefaultFileValidator()
true
true
false
AcceptFileType.FILE
public DefaultFileValidator(AcceptFileType acceptFileType)
true
true
false
acceptFileType
- the File must be of either FILE,DIRECTORY or BOTH, if not an exception is thrown when validating.public DefaultFileValidator(boolean mustExists, AcceptFileType acceptFileType)
true
false
mustExists
- if true
test that the file/directory must exists otherwise an exception is thrown when validating.acceptFileType
- the File must be of either FILE,DIRECTORY or BOTH, if not an exception is thrown when validating.public DefaultFileValidator(boolean mustExists, boolean readable, boolean writeable, AcceptFileType acceptFileType)
mustExists
- if true
test that the file/directory must exists otherwise an exception is thrown when validating.readable
- if true
test that the file/directory must be readable otherwise an exception is thrown when validating.writeable
- if true
test that the file/directory must be writeable otherwise an exception is thrown when validating.acceptFileType
- the File must be of either FILE,DIRECTORY or BOTH, if not an exception is thrown when validating.public void validate(String sourceType, String sourceName, String intialValue, File file) throws PropertyException
FileValidator
File
.validate
in interface FileValidator
sourceType
- the type from where the FileValidator is called, this is used to make sensible exception messages.sourceName
- the sourceName of from where the FileValidator is called, this is used to make sensible exception messages.intialValue
- the initial value which the File has been initialized.file
- the file instance.PropertyException
- thrown if fails validation. The intention of the message build is sourceType [sourceName with value [intialValue] <the error message
> [file.getAbsolutePath()].public AcceptFileType getAcceptFileType()
public boolean isReadable()
true
test of readability will be performed.public boolean isWriteable()
true
test of writeable will be performed.public boolean isMustExists()
true
test existence will be performed.public List<String> getRestrictions()
FileValidator
getRestrictions
in interface FileValidator
public org.apache.commons.logging.Log getLogger()
FileValidator
getLogger
in interface FileValidator
public String getType()
FileValidator
getType
in interface FileValidator