public class FilePropertyType extends PropertyType<File> implements MarkerPathPropertyType
java.io.File
. Which must be of type file. Constructor Example | Comments | ||
---|---|---|---|
Property<File> A_PROPERTY = |
No default value, with DefaultFileValidator(). | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp/test.htm")", with DefaultFileValidator. | ||
Property<File> A_PROPERTY = |
No default value, with DefaultXmlFileValidator. | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp/test.htm")", "new DefaultDirectoryValidator()". | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp/test.htm")", with "new DefaultFileValidator(true,true,false,AcceptFileType.BOTH)". | ||
Type of value(s) | Examples | Result | Comments |
Valid | c:/temp/cow.txt | new File("c:/file/cow.txt") | Validate successfully. |
Invalid | idontexists.txt | null |
Validate will throw an exception. The resulting value is null . |
Invalid | «empty string» | null |
|
Invalid | «empty string after trim» | null |
|
Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null . |
File
,
DefaultFileValidator
,
DefaultXmlFileValidator
,
File.isFile()
,
File.exists()
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
TYPE
The type name string constant of FilePropertyType.
|
Constructor and Description |
---|
FilePropertyType()
Constructor, sets the default value to
null and no args instance of DefaultFileValidator. |
FilePropertyType(File defaultValue)
Constructor, sets the default value and no args instance of DefaultFileValidator.
|
FilePropertyType(File defaultValue,
FileValidator fileValidator)
Constructor.
|
FilePropertyType(FileValidator fileValidator)
Constructor, sets the default value to
null . |
Modifier and Type | Method and Description |
---|---|
FileValidator |
getFileValidator()
The file validator instance
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
void |
setFileValidator(FileValidator fileValidator)
Sets the file validator for the FilePropertyType.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
File |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
equals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toString, toType, validate, validateNullType
public static final String TYPE
public FilePropertyType()
null
and no args instance of DefaultFileValidator.
true
true
false
AcceptFileType.FILE
public FilePropertyType(File defaultValue)
true
true
false
AcceptFileType.FILE
defaultValue
- default value returned if property value is undefined.public FilePropertyType(FileValidator fileValidator)
null
.fileValidator
- instance of FileValidator, this may not be null
. Will use DefaultFileValidator
if it is null
.DefaultFileValidator
public FilePropertyType(File defaultValue, FileValidator fileValidator)
defaultValue
- default value returned if property value is undefined.fileValidator
- instance of FileValidator, this may not be null
. Will use DefaultFileValidator
if it is null
.DefaultFileValidator
public FileValidator getFileValidator()
public void setFileValidator(FileValidator fileValidator)
DefaultFileValidator
if this is null
.fileValidator
- the new file validator.DefaultFileValidator
public File validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<File>
propertyName
- the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value
- the string representation of the propertyPropertyException
- if the conversion failed.public void validateConstraints(String propertyName) throws PropertyException
PropertyType
validateConstraints
in class PropertyType<File>
propertyName
- the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException
- if the constraints have invalid/conflicting values.Property.validate()
public List<String> getRestrictions()
PropertyType
getRestrictions
in class PropertyType<File>