1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.cache.file;
19
20 import java.io.File;
21 import java.util.Date;
22
23 /***
24 * FileCache entry keeps the cached content along with last access information.
25 *
26 * @author David S. Taylor <a href="mailto:taylor@apache.org">David Sean Taylor</a>
27 * @version $Id: FileCacheEntryImpl.java 516448 2007-03-09 16:25:47Z ate $
28 */
29
30 public class FileCacheEntryImpl implements FileCacheEntry
31 {
32 protected File file;
33 protected Object document;
34
35 protected long lastAccessed;
36 protected Date lastModified;
37
38 private FileCacheEntryImpl()
39 {
40 }
41
42 /***
43 * Constructs a FileCacheEntry object
44 *
45 * @param document The user specific content being cached
46 * @param lastModified The document's last modified stamp
47 */
48 public FileCacheEntryImpl(File file, Object document)
49 {
50 this.file = file;
51 this.document = document;
52 this.lastModified = new Date(file.lastModified());
53 this.lastAccessed = new Date().getTime();
54 }
55
56 /***
57 * Get the file descriptor
58 *
59 * @return the file descriptor
60 */
61 public File getFile()
62 {
63 return new File(this.file.getAbsolutePath());
64 }
65
66 /***
67 * Set the file descriptor
68 *
69 * @param file the new file descriptor
70 */
71 public void setFile(File file)
72 {
73 this.file = file;
74 }
75
76 /***
77 * Set the cache's last accessed stamp
78 *
79 * @param lastAccessed the cache's last access stamp
80 */
81 public void setLastAccessed(long lastAccessed)
82 {
83 this.lastAccessed = lastAccessed;
84 }
85
86 /***
87 * Get the cache's lastAccessed stamp
88 *
89 * @return the cache's last accessed stamp
90 */
91 public long getLastAccessed()
92 {
93 return this.lastAccessed;
94 }
95
96 /***
97 * Set the cache's last modified stamp
98 *
99 * @param lastModified the cache's last modified stamp
100 */
101 public void setLastModified(Date lastModified)
102 {
103 this.lastModified = lastModified;
104 }
105
106 /***
107 * Get the entry's lastModified stamp (which may be stale compared to file's stamp)
108 *
109 * @return the last modified stamp
110 */
111 public Date getLastModified()
112 {
113 return this.lastModified;
114 }
115
116 /***
117 * Set the Document in the cache
118 *
119 * @param document the document being cached
120 */
121 public void setDocument(Object document)
122 {
123 this.document = document;
124 }
125
126 /***
127 * Get the Document
128 *
129 * @return the document being cached
130 */
131 public Object getDocument()
132 {
133 return this.document;
134 }
135
136 }
137
138