1 23 24 package org.infoglue.cms.util.validators; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 import org.apache.log4j.Logger; 31 32 33 34 43 public class ConstraintRuleList 44 { 45 private final static Logger logger = Logger.getLogger(ConstraintRuleList.class.getName()); 46 47 private Collection rules = new ArrayList (); 48 private Class entityClass; 49 50 54 public void addRule(ConstraintRule rule) 55 { 56 rules.add(rule); 57 } 58 59 63 public Collection getRules() 64 { 65 return rules; 66 } 67 68 public ConstraintRule getRule(String fieldName) 69 { 70 ConstraintRule res = null; 71 Iterator it = rules.iterator(); 72 while (it.hasNext()) 73 { 74 ConstraintRule s = (ConstraintRule) it.next(); 75 if (s.getFieldName().compareTo(fieldName) ==0 ) 76 { 77 res = s; 78 break; 79 } 80 } 81 82 return res; 83 } 84 85 public Class getEntityClass() 86 { 87 return entityClass; 88 } 89 90 public void setEntityClass(Class entityClass) 91 { 92 this.entityClass = entityClass; 93 logger.info("RULELIST:: ENTITYCLASS : " + entityClass.getName()); 94 } 95 96 } 97 | Popular Tags |