1/*2 * Copyright 2000-2001,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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.cache;
1819import java.util.Date;
20import java.io.File;
2122/***23 * FileCache entry keeps the cached content along with last access information.24 *25 * @author David S. Taylor <a href="mailto:taylor@apache.org">David Sean Taylor</a>26 * @version $Id: FileCacheEntry.java,v 1.3 2004/02/23 02:46:05 jford Exp $27 */2829publicclassFileCacheEntry30 {
31protected File file;
32protected Object document;
3334protectedlong lastAccessed;
35protected Date lastModified;
3637privateFileCacheEntry()
38 {
39 }
4041/***42 * Constructs a FileCacheEntry object43 *44 * @param document The user specific content being cached45 * @param lastModified The document's last modified stamp46 */47publicFileCacheEntry(File file, Object document)
48 {
49this.file = file;
50this.document = document;
51this.lastModified = new Date(file.lastModified());
52this.lastAccessed = new Date().getTime();
53 }
5455/***56 * Get the file descriptor57 *58 * @return the file descriptor59 */60public File getFile()
61 {
62returnthis.file;
63 }
6465/***66 * Set the file descriptor67 *68 * @param file the new file descriptor69 */70publicvoid setFile(File file)
71 {
72this.file = file;
73 }
7475/***76 * Set the cache's last accessed stamp77 *78 * @param lastAccessed the cache's last access stamp79 */80publicvoid setLastAccessed(long lastAccessed)
81 {
82this.lastAccessed = lastAccessed;
83 }
8485/***86 * Get the cache's lastAccessed stamp87 *88 * @return the cache's last accessed stamp89 */90publiclong getLastAccessed()
91 {
92returnthis.lastAccessed;
93 }
9495/***96 * Set the cache's last modified stamp97 *98 * @param lastModified the cache's last modified stamp99 */100publicvoid setLastModified(Date lastModified)
101 {
102this.lastModified = lastModified;
103 }
104105/***106 * Get the entry's lastModified stamp (which may be stale compared to file's stamp)107 *108 * @return the last modified stamp109 */110public Date getLastModified()
111 {
112returnthis.lastModified;
113 }
114115/***116 * Set the Document in the cache117 *118 * @param document the document being cached119 */120publicvoid setDocument(Object document)
121 {
122this.document = document;
123 }
124125/***126 * Get the Document127 *128 * @return the document being cached129 */130public Object getDocument()
131 {
132returnthis.document;
133 }
134135 }
136137