umich.cac.util
Class DataValidator

java.lang.Object
  extended byumich.cac.util.DataValidator

public class DataValidator
extends java.lang.Object

A Utility class that validates various kinds of data to detaint it. If the data is not valid the methods will returns false, and prints a debugging message via the JDK logging mechansim as to the reason

Version:
$Header: /cvsroot/pbsaccounting/pbsaccounting/darkslide/doc/javadoc/umich/cac/util/DataValidator.html,v 1.3 2003/12/18 17:16:40 rodmach Exp $
Author:
rmach@umich.edu

Constructor Summary
DataValidator()
           
 
Method Summary
static boolean checkFile(java.lang.String fileName)
          Validate the filename can be written to if it exists,
static boolean checkTime(java.lang.String time)
          Validate the time A valid time in HH:MM:SS
static boolean validateDate(java.lang.String date)
          Validate the date.
static boolean validateUsername(java.lang.String userName)
          Validate the username of the user, like "ux02939".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataValidator

public DataValidator()
Method Detail

validateUsername

public static boolean validateUsername(java.lang.String userName)
Validate the username of the user, like "ux02939". A valid username only contains [a-z][A-Z][0-9] charachters

Parameters:
userName - The loginId/userName of the user
Returns:
true if the loginId is valid, false if the loginId is null or invalid

validateDate

public static boolean validateDate(java.lang.String date)
Validate the date. A valid date is in the format mm-dd-yyyy like 02-20-2003

Parameters:
date - The date to check
Returns:
true if the date is in the format mm-dd-yyyy, or false if null or not in the correct format

checkTime

public static boolean checkTime(java.lang.String time)
Validate the time A valid time in HH:MM:SS

Parameters:
time - time to check
Returns:
true if the date is in the format HH:MM:SS or false if null or not in the correct format

checkFile

public static boolean checkFile(java.lang.String fileName)
Validate the filename can be written to if it exists,

Parameters:
fileName - name of the file
Returns:
true if we will be able to write to existing file, otherwise false