org.apache.beehive.controls.runtime.bean
Class AnnotationConstraintValidator

Object
  extended by AnnotationConstraintValidator
Direct Known Subclasses:
AnnotationConstraintAptValidator

public class AnnotationConstraintValidator
extends Object

This class offers methods for validating values assigned to a control property. The validation process will ensure 1. The value is appropriate for the property's property type 2. The value satisfies the constraints defined on the property type 3. The value satisfies the constraints defined on the property set that the property is defined in. Refer to AnnotationMemberTypes and AnnotationConstraints for more information on property constraints.


Constructor Summary
AnnotationConstraintValidator()
           
 
Method Summary
static Date parseDate(String format, String value)
          Parse a date value into the specified format.
protected static void validate(Annotation[] annotations, Object value)
           
static void validate(PropertyKey key, Object value)
          This method ensures that any control property value assignment satisfies all property constraints.
static void validateMembership(Annotation propertySet)
          This method ensures the membership constraints defined on a property set is satisfied.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationConstraintValidator

public AnnotationConstraintValidator()
Method Detail

validate

public static void validate(PropertyKey key,
                            Object value)
                     throws IllegalArgumentException
This method ensures that any control property value assignment satisfies all property constraints. This method should be called by control property setters to ensure values assigned to properties at runtime are validated.

Parameters:
key - The property that the specified key is assigned to
value - The value assigned to the specified property key
Throws:
IllegalArgumentException - when the value assigned to the specified property key does not satisfy a property constraint.

validateMembership

public static void validateMembership(Annotation propertySet)
This method ensures the membership constraints defined on a property set is satisfied.

Parameters:
propertySet - the property set to validate

validate

protected static void validate(Annotation[] annotations,
                               Object value)
                        throws IllegalArgumentException
Throws:
IllegalArgumentException

parseDate

public static Date parseDate(String format,
                             String value)
                      throws ParseException
Parse a date value into the specified format. Pay special attention to the case of the value having trailing characters, ex. 12/02/2005xx which will not cause the parse of the date to fail but should be still treated as an error for our purposes.

Parameters:
format - Format string for the date.
value - A String containing the date value to parse.
Returns:
A Date instance if the parse was successful.
Throws:
ParseException - If the value is not a valid date.