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
private  java.lang.String column
          column
private  Database db
          database
private  java.lang.String table
          table
 
Constructor Summary
Reference(Database db, java.lang.String table, java.lang.String column)
          Constructor.
 
Method Summary
 java.lang.String toString()
          return a string representation for this constraint.
 boolean validate(java.lang.Object data)
          Validate data against this constraint.
 
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

private Database db
database


table

private java.lang.String table
table


column

private java.lang.String column
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)
Validate data against this constraint.

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()
return a string representation for this constraint.

Overrides:
toString in class java.lang.Object
Returns:
string


~ooOoo~