public class FileValidator extends Object implements Validator
FileValidator
validates the string argument
values are files. If the value is a file, the string value in
the List
of values is replaced with the
File
instance.
The following attributes can also be specified using the
appropriate settors:
... ArgumentBuilder builder = new ArgumentBuilder(); FileValidator validator = FileValidator.getExistingFileInstance(); validator.setReadable(true); validator.setWritable(true); Argument age = builder.withName("config"); .withValidator(validator);
Constructor and Description |
---|
FileValidator() |
Modifier and Type | Method and Description |
---|---|
static FileValidator |
getExistingDirectoryInstance()
Returns a
FileValidator for existing directories. |
static FileValidator |
getExistingFileInstance()
Returns a
FileValidator for existing files. |
static FileValidator |
getExistingInstance()
Returns a
FileValidator for existing files/directories. |
boolean |
isDirectory()
Returns whether the argument values must represent directories.
|
boolean |
isExisting()
Returns whether the argument values must represent existing
files/directories.
|
boolean |
isFile()
Returns whether the argument values must represent directories.
|
boolean |
isHidden()
Returns whether the argument values must represent hidden
files/directories.
|
boolean |
isReadable()
Returns whether the argument values must represent readable
files/directories.
|
boolean |
isWritable()
Returns whether the argument values must represent writable
files/directories.
|
void |
setDirectory(boolean directory)
Specifies whether the argument values must represent directories.
|
void |
setExisting(boolean existing)
Specifies whether the argument values must represent existing
files/directories.
|
void |
setFile(boolean file)
Specifies whether the argument values must represent files.
|
void |
setHidden(boolean hidden)
Specifies whether the argument values must represent hidden
files/directories.
|
void |
setReadable(boolean readable)
Specifies whether the argument values must represent readable
files/directories.
|
void |
setWritable(boolean writable)
Specifies whether the argument values must represent writable
files/directories.
|
void |
validate(List values)
Validate the list of values against the list of permitted values.
|
public FileValidator()
public static FileValidator getExistingInstance()
FileValidator
for existing files/directories.FileValidator
for existing files/directories.public static FileValidator getExistingFileInstance()
FileValidator
for existing files.FileValidator
for existing files.public static FileValidator getExistingDirectoryInstance()
FileValidator
for existing directories.FileValidator
for existing directories.public void validate(List values) throws InvalidArgumentException
values
List
with the File
instance.validate
in interface Validator
values
- The values to validate.InvalidArgumentException
- If any of the
specified values are not valid.Validator.validate(java.util.List)
public boolean isDirectory()
public void setDirectory(boolean directory)
directory
- specifies whether the argument values must
represent directories.public boolean isExisting()
public void setExisting(boolean existing)
existing
- specifies whether the argument values must
represent existing files/directories.public boolean isFile()
public void setFile(boolean file)
file
- specifies whether the argument values must
represent files.public boolean isHidden()
public void setHidden(boolean hidden)
hidden
- specifies whether the argument values must
represent hidden files/directories.public boolean isReadable()
public void setReadable(boolean readable)
readable
- specifies whether the argument values must
represent readable files/directories.public boolean isWritable()
public void setWritable(boolean writable)
writable
- specifies whether the argument values must
represent writable files/directories.Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.