velosurf.validation
Class FieldConstraint

java.lang.Object
  extended by velosurf.validation.FieldConstraint
Direct Known Subclasses:
DateRange, Email, Length, NotEmpty, NotNull, OneOf, Range, Reference, Regex

public abstract class FieldConstraint
extends java.lang.Object

This class encapsulates a constraint on a column of an entity, used to validate data before an update or an insert.

Author:
Claude Brisson

Field Summary
protected  java.lang.String _message
           
 
Constructor Summary
FieldConstraint()
           
 
Method Summary
 java.lang.String getMessage()
          used to get the error message if an error occured
 void setMessage(java.lang.String msg)
           
 boolean validate(java.lang.Object data)
           
 boolean validate(java.lang.Object data, java.util.Locale locale)
          used to validate data against this constraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_message

protected java.lang.String _message
Constructor Detail

FieldConstraint

public FieldConstraint()
Method Detail

validate

public boolean validate(java.lang.Object data,
                        java.util.Locale locale)
                 throws java.sql.SQLException
used to validate data against this constraint

Parameters:
data - to be validated
locale -
Returns:
true if the data respects the constraint, false if not
Throws:
java.sql.SQLException

validate

public boolean validate(java.lang.Object data)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

setMessage

public void setMessage(java.lang.String msg)

getMessage

public java.lang.String getMessage()
used to get the error message if an error occured

Returns:
the error message


~ooOoo~