All Packages Class Hierarchy This Package Previous Next Index
Class com.trumphurst.utils.TFileProperty
java.lang.Object
|
+----com.trumphurst.utils.TFileProperty
- public class TFileProperty
- extends Object
- implements TProperty
A TProperty which holds a File value, with optional validation constraints
-
EXISTS
- Validation constraint - must exist
-
f
- The value
-
flags
- The validation constraints
-
ISDIR
- Validation constraint - must be a directory, not a file
-
ISFILE
- Validation constraint - must be a file, not a directory
-
NULLOK
- Validation constraint - an empty filename is allowed
-
PATHEXISTS
- Validation constraint - the parent directory must exist
-
READABLE
- Validation constraint - must be readable (if it exists)
-
WRITEABLE
- Validation constraint - must be a writeable (if it exists)
-
TFileProperty(String, int)
- Construct with a value
-
arguments()
- Return a String representation of the arguments necessary to construct the property.
-
construct(String)
- "Construct" the property from a String argument list.
-
fromString(String)
- Change the value of the property from a String representation of the new value.
-
get()
- Return the value
-
get(TProperties, String)
- Return the File value of the specified property in the properties list.
-
set(File)
-
Set the value
-
toString()
- Return a String representation of the value.
f
protected File f
- The value
flags
protected int flags
- The validation constraints
ISFILE
public static final int ISFILE
- Validation constraint - must be a file, not a directory
ISDIR
public static final int ISDIR
- Validation constraint - must be a directory, not a file
EXISTS
public static final int EXISTS
- Validation constraint - must exist
PATHEXISTS
public static final int PATHEXISTS
- Validation constraint - the parent directory must exist
READABLE
public static final int READABLE
- Validation constraint - must be readable (if it exists)
WRITEABLE
public static final int WRITEABLE
- Validation constraint - must be a writeable (if it exists)
NULLOK
public static final int NULLOK
- Validation constraint - an empty filename is allowed
TFileProperty
public TFileProperty(String name,
int flags) throws ValidationException
- Construct with a value
- Parameters:
- name - the file/path name
- flags - any number of validation constraints or'ed together
- Throws: ValidationException
- if the name does not satisfy the constraints
get
public File get()
- Return the value
get
public static File get(TProperties properties,
String key)
- Return the File value of the specified property in the properties list.
Verifies that the key exists, and refers to a TFileProperty (or a
subclass).
- Parameters:
- properties - the properties list
- Returns:
- the File value of the property, or null
set
public void set(File f) throws ValidationException
- Set the value
- Parameters:
- f - the value to set
- Throws: ValidationException
- the File value does not satisfy all the constraints.
construct
public void construct(String arguments) throws ValidationException
- "Construct" the property from a String argument list.
- Parameters:
- arguments - a string of the form "filename,flags"
- Throws: ValidationException
- if the arguments cannot be parsed,
the flags value is not an integer, or the file does not satisfy
the constraints.
fromString
public void fromString(String s) throws ValidationException
- Change the value of the property from a String representation of the new value.
- Parameters:
- arguments - a filename/path string
- Throws: ValidationException
- if the filename does not satisfy the constraints
toString
public String toString()
- Return a String representation of the value.
- Returns:
- the filename
- Overrides:
- toString in class Object
arguments
public String arguments()
- Return a String representation of the arguments necessary to construct the property.
- Returns:
- a string of the form "filename,flags"
All Packages Class Hierarchy This Package Previous Next Index