org.dhmp.util.xml.validator
Class DateTimeValidator

java.lang.Object
  extended byorg.dhmp.util.xml.validator.Validator
      extended byorg.dhmp.util.xml.validator.DateTimeValidator

public class DateTimeValidator
extends Validator

Validates date, time and dateTime data type. The conversion is locale sensitive and depends on time zone. The date separator and the time zone depend on current SchemaCollection's locale and date time settings.


Nested Class Summary
 
Nested classes inherited from class org.dhmp.util.xml.validator.Validator
Validator.ValidationFailed
 
Field Summary
static int DATE
          Represents date data type.
static int DATE_TIME
          Represents dateTime data type.
static int NOT_DATE
          Represents not a date data type.
static int TIME
          Represents time data type.
 
Fields inherited from class org.dhmp.util.xml.validator.Validator
FAIL
 
Constructor Summary
DateTimeValidator(java.util.Locale locale, java.util.TimeZone timeZone, int type)
          Creates a new instance of DateTimeValidator.
 
Method Summary
 int compareTo(java.lang.Object o1, java.lang.Object o2)
          Abstract method for comparing two valid objects used for boundry check.
 java.lang.Object newValue(java.lang.Object value)
          Creates a java instance of corresponding object depending on data type this Validator is written for.
static java.util.Date parse(java.lang.String stringValue, java.util.TimeZone defaultTimeZone, int type)
           
 java.lang.Object validate(java.lang.String name, java.lang.Object value, HierarchicalMap constraints, Schema schema, HierarchicalMap messages, int replace)
          Returns true if the validation is successfull.
 
Methods inherited from class org.dhmp.util.xml.validator.Validator
appendMessage, checkBoundary, checkEnumeration, checkNillable, checkPattern, convert, hasFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_DATE

public static final int NOT_DATE
Represents not a date data type.

See Also:
Constant Field Values

DATE

public static final int DATE
Represents date data type.

See Also:
Constant Field Values

TIME

public static final int TIME
Represents time data type.

See Also:
Constant Field Values

DATE_TIME

public static final int DATE_TIME
Represents dateTime data type.

See Also:
Constant Field Values
Constructor Detail

DateTimeValidator

public DateTimeValidator(java.util.Locale locale,
                         java.util.TimeZone timeZone,
                         int type)
Creates a new instance of DateTimeValidator.

Parameters:
locale - SchemaCollection's locale.
timeZone - SchemaCollection's timeZone.
type - date, time or dateTime data type which this validator will represent.
Method Detail

validate

public java.lang.Object validate(java.lang.String name,
                                 java.lang.Object value,
                                 HierarchicalMap constraints,
                                 Schema schema,
                                 HierarchicalMap messages,
                                 int replace)
Description copied from class: Validator
Returns true if the validation is successfull. A concreate class can be extended to validate specific data type. It also can replace the value with java object for corresponding XSD data type.

Specified by:
validate in class Validator
Parameters:
name - name of schema component beeing validated.
value - value that is beeing validated.
constraints - HierarchicalMap containing constraints.
schema - reference to Schema which is validating the current value.
messages - StringBuffer where the error messages are appended.
replace - true if value should be replaced by corresponding java Object.
Returns:
true if value contains an valid data type.

parse

public static java.util.Date parse(java.lang.String stringValue,
                                   java.util.TimeZone defaultTimeZone,
                                   int type)

compareTo

public int compareTo(java.lang.Object o1,
                     java.lang.Object o2)
Description copied from class: Validator
Abstract method for comparing two valid objects used for boundry check.

Specified by:
compareTo in class Validator
Parameters:
o1 - first object.
o2 - second object.
Returns:
0 - if two objects are equivalent; < 0 if o1 is less than o2; >0 if o1 is greater than o2.

newValue

public java.lang.Object newValue(java.lang.Object value)
Description copied from class: Validator
Creates a java instance of corresponding object depending on data type this Validator is written for.

Specified by:
newValue in class Validator
Parameters:
value - value to be converted to java object depending on data type.
Returns:
java object of corresponding data type.