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.Map;
20:
21: /**
22: * This is a cached object as it is stored in the <code>EventCache</code>
23: *
24: * @deprecated by the {@link CachedResponse}
25: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
26: * @version CVS $Id: CachedEventObject.java 433543 2006-08-22 06:22:54Z crossley $
27: */
28: public final class CachedEventObject implements java.io.Serializable {
29:
30: private Map validityObjects;
31: private Object saxFragment;
32:
33: /**
34: * Create a new entry for the cache.
35: *
36: * @param validityObjects The CacheValidity objects hashed by their
37: * <code>ComponentCacheKey</code>
38: * @param saxFragment The cached sax stream
39: */
40: public CachedEventObject(Map validityObjects, Object 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
51: .get(componentKey);
52: if (ownValidity != null
53: && ownValidity.isValid(componentValidity)) {
54: return true;
55: }
56: return false;
57: }
58:
59: /**
60: * Get the validity object
61: * @return The <CODE>CacheValidity</CODE> object or <CODE>null</CODE>.
62: */
63: public CacheValidity getCacheValidity(ComponentCacheKey componentKey) {
64: return (CacheValidity) this .validityObjects.get(componentKey);
65: }
66:
67: /**
68: * Get the cached sax stream.
69: *
70: * @return The sax stream
71: */
72: public Object getSAXFragment() {
73: return this.saxFragment;
74: }
75: }
|