01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.rule.impl;
10:
11: import com.completex.objective.components.persistency.PersistentEntry;
12: import com.completex.objective.components.persistency.rule.RuleException;
13:
14: /**
15: * Asserts that PersistentEntry contains data only if the field is "dirry"
16: *
17: * @author Gennady Krizhevsky
18: */
19: public class NotNullFieldValidator extends AbstractFieldValidator {
20:
21: /**
22: * Asserts that PersistentEntry contains data only if the field is "dirry"
23: *
24: * @param entry
25: * @param verbose not used
26: * @throws RuleException if PersistentEntry is "dirty" and contains no data (is null)
27: */
28: protected void performValidation(PersistentEntry entry,
29: boolean verbose) throws RuleException {
30: if (entry.isDirty() && entry.getValue() == null) {
31: throw new RuleException("Field ["
32: + entry.getColumn().getColumnName()
33: + "] is required but contains no data")
34: .setFieldName(entry.getColumn().getColumnName());
35: }
36: }
37: }
|