KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > cache > validator > AndValidator


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.cache.validator;
9
10 import org.apache.avalon.excalibur.cache.CacheValidator;
11
12 /**
13  * @author <a HREF="mailto:colus@apache.org">Eung-ju Park</a>
14  */

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 JavaDoc key, final Object JavaDoc 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