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


Variable Index

 o EXISTS
Validation constraint - must exist
 o f
The value
 o flags
The validation constraints
 o ISDIR
Validation constraint - must be a directory, not a file
 o ISFILE
Validation constraint - must be a file, not a directory
 o NULLOK
Validation constraint - an empty filename is allowed
 o PATHEXISTS
Validation constraint - the parent directory must exist
 o READABLE
Validation constraint - must be readable (if it exists)
 o WRITEABLE
Validation constraint - must be a writeable (if it exists)

Constructor Index

 o TFileProperty(String, int)
Construct with a value

Method Index

 o arguments()
Return a String representation of the arguments necessary to construct the property.
 o construct(String)
"Construct" the property from a String argument list.
 o fromString(String)
Change the value of the property from a String representation of the new value.
 o get()
Return the value
 o get(TProperties, String)
Return the File value of the specified property in the properties list.
 o set(File)
Set the value
 o toString()
Return a String representation of the value.

Variables

 o f
 protected File f
The value

 o flags
 protected int flags
The validation constraints

 o ISFILE
 public static final int ISFILE
Validation constraint - must be a file, not a directory

 o ISDIR
 public static final int ISDIR
Validation constraint - must be a directory, not a file

 o EXISTS
 public static final int EXISTS
Validation constraint - must exist

 o PATHEXISTS
 public static final int PATHEXISTS
Validation constraint - the parent directory must exist

 o READABLE
 public static final int READABLE
Validation constraint - must be readable (if it exists)

 o WRITEABLE
 public static final int WRITEABLE
Validation constraint - must be a writeable (if it exists)

 o NULLOK
 public static final int NULLOK
Validation constraint - an empty filename is allowed

Constructors

 o 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

Methods

 o get
 public File get()
Return the value

 o 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
 o 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.
 o 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.
 o 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
 o toString
 public String toString()
Return a String representation of the value.

Returns:
the filename
Overrides:
toString in class Object
 o 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