1 17 package org.apache.excalibur.source.impl.validity; 18 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.apache.excalibur.source.SourceValidity; 23 24 30 public final class AggregatedValidity 31 extends AbstractAggregatedValidity 32 implements SourceValidity 33 { 34 41 public int isValid() 42 { 43 for( final Iterator i = m_list.iterator(); i.hasNext(); ) 44 { 45 final int v = ( (SourceValidity)i.next() ).isValid(); 46 if( v < 1 ) 47 { 48 return v; 49 } 50 } 51 return 1; 52 } 53 54 public int isValid( final SourceValidity validity ) 55 { 56 if( validity instanceof AggregatedValidity ) 57 { 58 final AggregatedValidity other = (AggregatedValidity)validity; 59 final List otherList = other.m_list; 60 if( m_list.size() != otherList.size() ) 61 { 62 return -1; 63 } 64 65 for( final Iterator i = m_list.iterator(), j = otherList.iterator(); i.hasNext(); ) 66 { 67 final SourceValidity srcA = (SourceValidity)i.next(); 68 final SourceValidity srcB = (SourceValidity)j.next(); 69 int result = srcA.isValid(); 70 if ( result == -1) 71 { 72 return -1; 73 } 74 if ( result == 0 ) 75 { 76 result = srcA.isValid( srcB ); 77 if ( result < 1) 78 { 79 return result; 80 } 81 } 82 } 83 return 1; 84 } 85 return -1; 86 } 87 88 } 89 90 | Popular Tags |