1 16 package org.apache.cocoon.caching; 17 18 import java.util.ArrayList ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 31 public final class AggregatedCacheValidity 32 implements CacheValidity { 33 34 private List a; 35 36 39 public AggregatedCacheValidity() { 40 this.a = new ArrayList (); 41 } 42 43 46 public void add(CacheValidity validity) { 47 this.a.add(validity); 48 } 49 50 public boolean isValid(CacheValidity validity) { 51 if (validity instanceof AggregatedCacheValidity) { 52 List b = ((AggregatedCacheValidity)validity).a; 53 if(a.size() != b.size()) 54 return false; 55 for(Iterator i = a.iterator(), j = b.iterator(); i.hasNext();) { 56 if(!((CacheValidity)i.next()).isValid((CacheValidity)j.next())) 57 return false; 58 } 59 return true; 60 } 61 return false; 62 } 63 64 public String toString() { 65 StringBuffer b = new StringBuffer ("Aggregated Validity["); 66 for(Iterator i = a.iterator(); i.hasNext();) { 67 b.append(i.next()); 68 if(i.hasNext()) b.append(':'); 69 } 70 b.append(']'); 71 return b.toString(); 72 } 73 } 74 75 | Popular Tags |