1
2
3
4
5
6
7 package ca.uhn.cache.impl;
8
9 import java.util.Date;
10
11 import ca.uhn.cache.CacheReasonEnum;
12 import ca.uhn.cache.IQuery;
13 import ca.uhn.cache.VolatilityEnum;
14 import ca.uhn.cache.internal.IChunk;
15
16 /***
17 * A block of data that is retrieved and cached together. The
18 * boundaries of a <code>IChunk</code> are defined according to
19 * <code>QueryParameter</code>s. Data items may have attributes
20 * such as category, date, name, etc. Some of these, for example
21 * category and date, will correspond to <code>QueryParameter</code>s.
22 * A <code>IChunk</code> is a grouping of data items in the same part
23 * of the <code>QueryParameter</code> space. How this space is divided
24 * is determined by a <code>ISemanticCache</code>.
25 *
26 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
27 * @version $Revision: 1.1 $ updated on $Date: 2005/01/24 22:52:36 $ by $Author: bryan_tripp $
28 */
29 public class Chunk implements IChunk {
30
31 private String myId;
32 private VolatilityEnum myVolatility;
33 private Date myLastUpdateTime;
34 private Date myCacheTime;
35 private Date myLastAccessTime;
36 private CacheReasonEnum[] myReasons;
37 private IQuery myBoundaries;
38
39 /***
40 * @param theId the id
41 * @param theVolatility the volatility
42 * @param theLastUpdateTime the last update time
43 * @param theCacheTime the cache time
44 * @param theLastAccessTime the last access time
45 * @param theReasons the reasons
46 * @param theBoundaries the boundaries
47 */
48 public Chunk(String theId, VolatilityEnum theVolatility, Date theLastUpdateTime, Date theCacheTime,
49 Date theLastAccessTime, CacheReasonEnum[] theReasons, IQuery theBoundaries)
50 {
51 myId = theId;
52 myVolatility = theVolatility;
53 myLastUpdateTime = theLastUpdateTime;
54 myCacheTime = theCacheTime;
55 myLastAccessTime = theLastAccessTime;
56 myReasons = theReasons;
57 myBoundaries = theBoundaries;
58 }
59
60 /***
61 * @return the unique ID of the chunk
62 */
63 public String getId()
64 {
65 return myId;
66 }
67
68 /***
69 * @return the greatest volatility of all data in the chunk
70 */
71 public VolatilityEnum getVolatility()
72 {
73 return myVolatility;
74 }
75
76 /***
77 * @return the most recent time of update of all data in the chunk
78 */
79 public Date getLastUpdateTime()
80 {
81 return myLastUpdateTime;
82 }
83
84 /***
85 * @return the time at which the data in the chunk were cached
86 */
87 public Date getCacheTime()
88 {
89 return myCacheTime;
90 }
91
92 /***
93 * @return the most recent time at which data in the the chunk were accessed
94 */
95 public Date getLastAccessTime()
96 {
97 return myLastAccessTime;
98 }
99
100
101 /***
102 * @return a list of reasons why this chunk was cached
103 */
104 public CacheReasonEnum[] getReasons()
105 {
106 return myReasons;
107 }
108
109
110 /***
111 * @return <code>IQuery</code> describing the limits of the chunk
112 * TODO: possibly replace with method to see if a data item fits here
113 */
114 public IQuery getBoundaries()
115 {
116 return myBoundaries;
117 }
118
119 }