velosurf.validation
Class Reference

java.lang.Object
  extended by velosurf.validation.FieldConstraint
      extended by velosurf.validation.Reference

public class Reference
extends FieldConstraint

A foreign key constraint. Syntax is:

    <column references="table.foreign-key">
 
or:
   <column>
     <references foreign-key="table.foreign-key" [message="error-message"]/>
   </column>
 

Note: his constraint is not meant to replace an internal SQL "references" clause in the database, since it cannot be made sure that complex updates will respect this constraint.

Author:
Claude Brisson

Field Summary
protected  java.lang.String _column
           
protected  Database _db
           
protected  java.lang.String _table
           
 
Fields inherited from class velosurf.validation.FieldConstraint
_message
 
Constructor Summary
Reference(Database db, java.lang.String table, java.lang.String column)
          Constructor.
 
Method Summary
 java.lang.String toString()
           
 boolean validate(java.lang.Object data)
           
 
Methods inherited from class velosurf.validation.FieldConstraint
getMessage, setMessage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_db

protected Database _db

_table

protected java.lang.String _table

_column

protected java.lang.String _column
Constructor Detail

Reference

public Reference(Database db,
                 java.lang.String table,
                 java.lang.String column)
Constructor.

Parameters:
table - the table name
column - the column name
Method Detail

validate

public boolean validate(java.lang.Object data)
Overrides:
validate in class FieldConstraint
Parameters:
data - the data to be validated
Returns:
true if data respects the specified reference

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


~ooOoo~