public class DefaultDirectoryValidator extends Object implements FileValidator, Serializable
null
or the type is not a directory. DefaultFileValidator
,
Serialized FormConstructor and Description |
---|
DefaultDirectoryValidator()
Default constructor, where parameters are:
mustExists =
true
autoCreate = false
readable = true
writeable = false
|
DefaultDirectoryValidator(boolean mustExists,
boolean autoCreate)
Constructor, Where parameters are:
readable =
true
writeable = false
|
DefaultDirectoryValidator(boolean mustExists,
boolean autoCreate,
boolean readable,
boolean writeable)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 |
isAutoCreate()
If
true and the directory do NOT exists, it will try to create the directory, before testing the existence. |
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 . |
protected void |
validateAccess(String sourceType,
String sourceName,
String intialValue,
File file) |
public DefaultDirectoryValidator()
true
false
true
false
public DefaultDirectoryValidator(boolean mustExists, boolean autoCreate)
true
false
mustExists
- if true
test that the directory must exists otherwise an exception is thrown when validating.autoCreate
- if true
and if the directory do not exists it will try to create the directory. Before testing for existence when validating.public DefaultDirectoryValidator(boolean mustExists, boolean autoCreate, boolean readable, boolean writeable)
mustExists
- if true
test that the directory must exists otherwise an exception is thrown when validating.autoCreate
- if true
and if the directory do not exists it will try to create the directory. Before testing for existence when validating.readable
- if true
test that the directory must be readable otherwise an exception is thrown when validating.writeable
- if true
test that the directory must be writeable otherwise an exception is thrown when validating.public boolean isMustExists()
true
test existence will be performed.public boolean isAutoCreate()
true
and the directory do NOT exists, it will try to create the directory, before testing the existence.public boolean isReadable()
true
test of readability will be performed.public boolean isWriteable()
true
test of writable will be performed.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()].protected void validateAccess(String sourceType, String sourceName, String intialValue, File file) throws PropertyException
PropertyException
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