KickJava   Java API By Example, From Geeks To Geeks.

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


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  * <code>SourceValidity</code> 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: CacheValidityToSourceValidity.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  */

29 public final class CacheValidityToSourceValidity
30 implements SourceValidity {
31
32     protected CacheValidity cacheValidity;
33
34     /**
35      * Create a new instance
36      */

37     public static CacheValidityToSourceValidity createValidity(CacheValidity validity) {
38         if ( null != validity) {
39             return new CacheValidityToSourceValidity(validity);
40         }
41         return null;
42     }
43
44     /**
45      * Constructor
46      */

47     protected CacheValidityToSourceValidity(CacheValidity validity) {
48         this.cacheValidity = validity;
49     }
50
51
52     /**
53      * Check if the component is still valid.
54      * If <code>0</code> is returned the isValid(SourceValidity) must be
55      * called afterwards!
56      * If -1 is returned, the component is not valid anymore and if +1
57      * is returnd, the component is valid.
58      */

59     public int isValid() {
60         return 0;
61     }
62
63     /**
64      * Check if the component is still valid.
65      * This is only true, if the incoming Validity is of the same
66      * type and has the same values.
67      * The invocation order is that the isValid method of the
68      * old Validity object is called with the new one as a parameter
69      */

70     public int isValid( SourceValidity newValidity ) {
71         if (newValidity instanceof CacheValidityToSourceValidity) {
72             if (this.cacheValidity.isValid(((CacheValidityToSourceValidity)newValidity).cacheValidity)) {
73                 return 1;
74             }
75             return -1;
76         }
77         return -1;
78     }
79
80     public String JavaDoc toString() {
81         return "Cache Validity To Source Validity[" + this.cacheValidity + ']';
82     }
83 }
84
Popular Tags