public class DirectoryPropertyType extends PropertyType<File> implements MarkerPathPropertyType
java.io.File
. Which must be of type directory. Constructor Example | Comments | ||
---|---|---|---|
Property<File> A_PROPERTY = |
No default value, with DefaultDirectoryValidator(). | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp")" with DefaultDirectoryValidator. | ||
Property<File> A_PROPERTY = |
No default value, with DefaultDirectoryValidator. | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp")" with "new DefaultDirectoryValidator()". | ||
Property<File> A_PROPERTY = |
Default value is "new File("c:/temp")" with "new DefaultDirectoryValidator(true,true,true,false)". | ||
Type of value(s) | Examples | Result | Comments |
Valid | c:/temp | new File("c:/file") | Validate successfully. |
Invalid | cow | 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
,
File.isDirectory()
,
File.exists()
,
FileValidator
,
DefaultDirectoryValidator
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
TYPE
The type name string constant of DirectoryPropertyType.
|
Constructor and Description |
---|
DirectoryPropertyType()
Default constructor, where default value is
null and using no args constructor in DefaultDirectoryValidator. |
DirectoryPropertyType(File defaultValue)
Constructor with default value and using no args constructor in DefaultDirectoryValidator.
|
DirectoryPropertyType(File defaultValue,
FileValidator fileValidator)
Constructor with default value.
|
DirectoryPropertyType(FileValidator fileValidator)
Constructor where default value is
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 DirectoryPropertyType.
|
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 DirectoryPropertyType()
null
and using no args constructor in DefaultDirectoryValidator.
true
false
true
false
DefaultDirectoryValidator
public DirectoryPropertyType(File defaultValue)
defaultValue
- default value returned if property value is undefined.DefaultDirectoryValidator
public DirectoryPropertyType(FileValidator fileValidator)
null
.fileValidator
- instance of FileValidator, this may not be null
. Will use DefaultDirectoryValidator
if it is null
.DefaultDirectoryValidator
public DirectoryPropertyType(File defaultValue, FileValidator fileValidator)
defaultValue
- default value returned if property value is undefined.fileValidator
- instance of FileValidator, this may not be null
. Will use DefaultDirectoryValidator
if it is null
.FileValidator
,
DefaultDirectoryValidator
public FileValidator getFileValidator()
public void setFileValidator(FileValidator fileValidator)
DefaultDirectoryValidator
if this is null
.fileValidator
- the new file validator.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>