View Javadoc

1   /*
2    * Copyright 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 at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * 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 and
14   * limitations under the License.
15   */
16  package org.apache.commons.cache;
17  
18  import java.io.Serializable;
19  
20  /**
21   * .
22   *
23   * @ATVERSION@
24   * @author Rodney Waldhoff
25   */
26  public final class CacheStat implements Serializable {
27    private static int _counter = 0;
28  
29    public final String strVal;
30    public final int intVal = _counter++;
31  
32    private CacheStat() {
33      strVal= null;
34    }
35  
36    private CacheStat(String name) {
37      strVal= name;
38    }
39  
40    public String toString() {
41      return strVal;
42    }
43  
44    public int getIntValue() {
45      return intVal;
46    }
47  
48    public String getStrValue() {
49      return strVal;
50    }
51  
52    public boolean equals(CacheStat stat) {
53      return (null != stat && stat.strVal.equals(strVal));
54    }
55  
56    public int hashCode() {
57      return intVal;
58    }
59  
60    public static final CacheStat NUM_RETRIEVE_REQUESTED = new CacheStat("number of retrievals requested");
61    public static final CacheStat NUM_RETRIEVE_FOUND = new CacheStat("number of retrievals found");
62    public static final CacheStat NUM_RETRIEVE_NOT_FOUND = new CacheStat("number of retrievals not found");
63    public static final CacheStat NUM_STORE_REQUESTED = new CacheStat("number of stores requested");
64    public static final CacheStat NUM_STORE_STORED = new CacheStat("number of objects stored");
65    public static final CacheStat NUM_STORE_NOT_STORED = new CacheStat("number of objects not stored");
66    public static final CacheStat NUM_CLEARED = new CacheStat("number of objects cleared");
67    public static final CacheStat CUR_CAPACITY = new CacheStat("current capacity");
68  }