KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > caching > SourceCacheValidity


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.caching;
17
18 import org.apache.excalibur.source.SourceValidity;
19
20 /**
21  * A CacheValidity object wrapping the Avalon Excalibur
22  * {@link SourceValidity} object.
23  *
24  * @since 2.1
25  * @deprecated Use the Avalon Excalibur SourceValidity implementations instead
26  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
27  * @version CVS $Id: SourceCacheValidity.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  */

29 public final class SourceCacheValidity
30 implements CacheValidity {
31
32     protected SourceValidity sourceValidity;
33
34     /**
35      * Constructor
36      */

37     public SourceCacheValidity(SourceValidity validity) {
38         this.sourceValidity = validity;
39     }
40
41     /**
42      * Check if the component is still valid.
43      * This is only true, if the incoming CacheValidity is of the same
44      * type and has the same values.
45      */

46     public boolean isValid(CacheValidity validity) {
47         final int valid = this.sourceValidity.isValid();
48         if (valid == 1) return true;
49         if (valid == 0 && validity instanceof SourceCacheValidity) {
50             if (this.sourceValidity.isValid(((SourceCacheValidity)validity).getSourceValidity()) == 1) {
51                 return true;
52             }
53             
54         }
55         return false;
56     }
57
58     /**
59      * Get the real validity
60      */

61     public SourceValidity getSourceValidity() {
62         return this.sourceValidity;
63     }
64
65     public String JavaDoc toString() {
66         return "Source Validity[" + this.sourceValidity + ']';
67     }
68 }
69
Popular Tags