KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
19
20 /**
21  * This is a cached object as it is stored in the <code>EventCache</code>
22  *
23  * @deprecated by the {@link CachedResponse}
24  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
25  * @version CVS $Id: CachedEventObject.java 30932 2004-07-29 17:35:38Z vgritsenko $
26  */

27 public final class CachedEventObject implements java.io.Serializable JavaDoc {
28
29     private Map JavaDoc validityObjects;
30     private Object JavaDoc saxFragment;
31
32     /**
33      * Create a new entry for the cache.
34      *
35      * @param validityObjects The CacheValidity objects hashed by their
36      * <code>ComponentCacheKey</code>
37      * @param saxFragment The cached sax stream
38      */

39     public CachedEventObject(Map JavaDoc validityObjects,
40                              Object JavaDoc saxFragment) {
41         this.validityObjects = validityObjects;
42         this.saxFragment = saxFragment;
43     }
44
45     /**
46      * Checks if the CacheValidity object is still valid.
47      */

48     public boolean isValid(ComponentCacheKey componentKey,
49                            CacheValidity componentValidity) {
50         CacheValidity ownValidity = (CacheValidity)this.validityObjects.get(componentKey);
51         if (ownValidity != null && ownValidity.isValid(componentValidity)) {
52             return true;
53         }
54         return false;
55     }
56
57     /**
58      * Get the validity object
59      * @return The <CODE>CacheValidity</CODE> object or <CODE>null</CODE>.
60      */

61     public CacheValidity getCacheValidity(ComponentCacheKey componentKey) {
62         return (CacheValidity)this.validityObjects.get(componentKey);
63     }
64
65     /**
66      * Get the cached sax stream.
67      *
68      * @return The sax stream
69      */

70     public Object JavaDoc getSAXFragment() {
71         return this.saxFragment;
72     }
73 }
74
Popular Tags