1 package org.apache.commons.jcs.admin;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.beans.ConstructorProperties;
23
24
25 /**
26 * Stores info on a cache element for the template
27 */
28 public class CacheElementInfo
29 {
30 /** element key */
31 private final String key;
32
33 /** is it eternal */
34 private final boolean eternal;
35
36 /** when it was created */
37 private final String createTime;
38
39 /** max life */
40 private final long maxLifeSeconds;
41
42 /** when it will expire */
43 private final long expiresInSeconds;
44
45 /**
46 * Parameterized constructor
47 *
48 * @param key element key
49 * @param eternal is it eternal
50 * @param createTime when it was created
51 * @param maxLifeSeconds max life
52 * @param expiresInSeconds when it will expire
53 */
54 @ConstructorProperties({"key", "eternal", "createTime", "maxLifeSeconds", "expiresInSeconds"})
55 public CacheElementInfo(String key, boolean eternal, String createTime,
56 long maxLifeSeconds, long expiresInSeconds)
57 {
58 super();
59 this.key = key;
60 this.eternal = eternal;
61 this.createTime = createTime;
62 this.maxLifeSeconds = maxLifeSeconds;
63 this.expiresInSeconds = expiresInSeconds;
64 }
65
66 /**
67 * @return a string representation of the key
68 */
69 public String getKey()
70 {
71 return this.key;
72 }
73
74 /**
75 * @return true if the item does not expire
76 */
77 public boolean isEternal()
78 {
79 return this.eternal;
80 }
81
82 /**
83 * @return the time the object was created
84 */
85 public String getCreateTime()
86 {
87 return this.createTime;
88 }
89
90 /**
91 * Ignored if isEternal
92 * @return the longest this object can live.
93 */
94 public long getMaxLifeSeconds()
95 {
96 return this.maxLifeSeconds;
97 }
98
99 /**
100 * Ignored if isEternal
101 * @return how many seconds until this object expires.
102 */
103 public long getExpiresInSeconds()
104 {
105 return this.expiresInSeconds;
106 }
107
108 /**
109 * @return string info on the item
110 */
111 @Override
112 public String toString()
113 {
114 StringBuilder buf = new StringBuilder();
115 buf.append( "\nCacheElementInfo " );
116 buf.append( "\n Key [" ).append( getKey() ).append( "]" );
117 buf.append( "\n Eternal [" ).append( isEternal() ).append( "]" );
118 buf.append( "\n CreateTime [" ).append( getCreateTime() ).append( "]" );
119 buf.append( "\n MaxLifeSeconds [" ).append( getMaxLifeSeconds() ).append( "]" );
120 buf.append( "\n ExpiresInSeconds [" ).append( getExpiresInSeconds() ).append( "]" );
121
122 return buf.toString();
123 }
124 }