01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.caching;
18:
19: import java.util.ArrayList;
20: import java.util.Iterator;
21: import java.util.List;
22:
23: /**
24: * A validation object aggregating several validity objects. This is similar to the
25: * {@link CompositeCacheValidity} with the difference that the amount of
26: * aggregated objects is not limited.
27: *
28: * @deprecated Use the Avalon Excalibur SourceValidity implementations instead
29: * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
30: * @version CVS $Id: AggregatedCacheValidity.java 433543 2006-08-22 06:22:54Z crossley $
31: */
32: public final class AggregatedCacheValidity implements CacheValidity {
33:
34: private List a;
35:
36: /**
37: * Constructor
38: */
39: public AggregatedCacheValidity() {
40: this .a = new ArrayList();
41: }
42:
43: /**
44: * Add another validity object
45: */
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
56: .hasNext();) {
57: if (!((CacheValidity) i.next())
58: .isValid((CacheValidity) j.next()))
59: return false;
60: }
61: return true;
62: }
63: return false;
64: }
65:
66: public String toString() {
67: StringBuffer b = new StringBuffer("Aggregated Validity[");
68: for (Iterator i = a.iterator(); i.hasNext();) {
69: b.append(i.next());
70: if (i.hasNext())
71: b.append(':');
72: }
73: b.append(']');
74: return b.toString();
75: }
76: }
|