View Javadoc
1   package org.apache.commons.jcs3.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(final String key, final boolean eternal, final String createTime,
56  			final long maxLifeSeconds, final long expiresInSeconds)
57      {
58  		this.key = key;
59  		this.eternal = eternal;
60  		this.createTime = createTime;
61  		this.maxLifeSeconds = maxLifeSeconds;
62  		this.expiresInSeconds = expiresInSeconds;
63  	}
64  
65  	/**
66       * @return a string representation of the key
67       */
68      public String getKey()
69      {
70          return this.key;
71      }
72  
73      /**
74       * @return true if the item does not expire
75       */
76      public boolean isEternal()
77      {
78          return this.eternal;
79      }
80  
81      /**
82       * @return the time the object was created
83       */
84      public String getCreateTime()
85      {
86          return this.createTime;
87      }
88  
89      /**
90       * Ignored if isEternal
91       * @return the longest this object can live.
92       */
93      public long getMaxLifeSeconds()
94      {
95          return this.maxLifeSeconds;
96      }
97  
98      /**
99       * Ignored if isEternal
100      * @return how many seconds until this object expires.
101      */
102     public long getExpiresInSeconds()
103     {
104         return this.expiresInSeconds;
105     }
106 
107     /**
108      * @return string info on the item
109      */
110     @Override
111     public String toString()
112     {
113         final StringBuilder buf = new StringBuilder();
114         buf.append( "\nCacheElementInfo " );
115         buf.append( "\n Key [" ).append( getKey() ).append( "]" );
116         buf.append( "\n Eternal [" ).append( isEternal() ).append( "]" );
117         buf.append( "\n CreateTime [" ).append( getCreateTime() ).append( "]" );
118         buf.append( "\n MaxLifeSeconds [" ).append( getMaxLifeSeconds() ).append( "]" );
119         buf.append( "\n ExpiresInSeconds [" ).append( getExpiresInSeconds() ).append( "]" );
120 
121         return buf.toString();
122     }
123 }