1 8 package org.apache.avalon.excalibur.cache.validator; 9 10 import org.apache.avalon.excalibur.cache.CacheValidator; 11 12 15 public class AndValidator 16 implements CacheValidator 17 { 18 private CacheValidator[] m_validators; 19 20 public AndValidator( final CacheValidator validator1, 21 final CacheValidator validator2 ) 22 { 23 m_validators = new CacheValidator[ 2 ]; 24 m_validators[ 0 ] = validator1; 25 m_validators[ 1 ] = validator2; 26 } 27 28 public AndValidator( final CacheValidator[] validators ) 29 { 30 m_validators = validators; 31 } 32 33 public boolean validate( final Object key, final Object value ) 34 { 35 for ( int i = 0; i < m_validators.length; i++ ) 36 { 37 if ( ! m_validators[ i ].validate( key, value ) ) 38 { 39 return false; 40 } 41 } 42 43 return true; 44 } 45 } 46 | Popular Tags |