velosurf.validation
Class FieldConstraint

java.lang.Object
  extended by velosurf.validation.FieldConstraint
Direct Known Subclasses:
DateRange, EmailCheck, 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
private  java.lang.String message
          the error message
 
Constructor Summary
FieldConstraint()
           
 
Method Summary
 java.lang.String getMessage()
          get the error message
 void setMessage(java.lang.String msg)
          error message setter
 boolean validate(java.lang.Object data)
          validate data against this constraint.
 boolean validate(java.lang.Object data, java.util.Locale locale)
          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

private java.lang.String message
the error message

Constructor Detail

FieldConstraint

public FieldConstraint()
Method Detail

validate

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

Parameters:
data - to validate
locale -
Returns:
true if the data respects the constraint
Throws:
java.sql.SQLException

validate

public boolean validate(java.lang.Object data)
                 throws java.sql.SQLException
validate data against this constraint.

Parameters:
data - data to validate
Returns:
true if data respects the constaint
Throws:
java.sql.SQLException

setMessage

public void setMessage(java.lang.String msg)
error message setter

Parameters:
msg - error message

getMessage

public java.lang.String getMessage()
get the error message

Returns:
the error message


~ooOoo~