View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.portals.applications.transform;
18  
19  import java.util.Date;
20  
21  
22  /***
23   * TransformCacheEntry
24   * 
25   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
26   * @version $Id: TransformCacheEntry.java 516448 2007-03-09 16:25:47Z ate $
27   */
28  public class TransformCacheEntry
29  {
30      protected String key;
31      protected Object document;
32      protected long lastAccessed;
33      protected long timeToLive = 15 * 60 * 1000; // in seconds, 15 minutes
34      
35      private TransformCacheEntry()
36      {
37      }
38  
39      /***
40       * Constructs a TransformCacheEntry object
41       *
42       * @param key 
43       * @param timeToLive seconds to keep this in the cache
44       * @param document The user specific content being cached
45       */
46      public TransformCacheEntry(String key, Object document, long timeToLive)
47      {
48          this.key = key;
49          this.document = document;
50          this.timeToLive = timeToLive;
51          this.lastAccessed = new Date().getTime();
52      }
53  
54  
55      /***
56       * Set the cache's last accessed stamp
57       *
58       * @param lastAccessed the cache's last access stamp
59       */
60      public void setLastAccessed(long lastAccessed)
61      {
62          this.lastAccessed = lastAccessed;
63      }
64  
65      /***
66       * Get the cache's lastAccessed stamp
67       *
68       * @return the cache's last accessed stamp
69       */
70      public long getLastAccessed()
71      {
72          return this.lastAccessed;
73      }
74  
75      /***
76       * Set the Document in the cache
77       *
78       * @param document the document being cached
79       */
80      public void setDocument(Object document)
81      {
82          this.document = document;
83      }
84  
85      /***
86       * Get the Document
87       *
88       * @return the document being cached
89       */
90      public Object getDocument()
91      {
92          return this.document;
93      }
94      
95  
96      /***
97       * @return Returns the key.
98       */
99      public String getKey()
100     {
101         return key;
102     }
103     /***
104      * @param key The key to set.
105      */
106     public void setKey(String key)
107     {
108         this.key = key;
109     }
110     /***
111      * @return Returns the timeToLive.
112      */
113     public long getTimeToLive()
114     {
115         return timeToLive;
116     }
117     /***
118      * @param timeToLive The timeToLive in seconds
119      */
120     public void setTimeToLive(long timeToLive)
121     {
122         this.timeToLive = timeToLive;
123     }
124 }