1 package org.apache.commons.jcs.engine.stats;
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 org.apache.commons.jcs.engine.stats.behavior.ICacheStats;
23 import org.apache.commons.jcs.engine.stats.behavior.IStats;
24
25 import java.util.List;
26
27 /**
28 * This class stores cache historical and statistics data for a region.
29 * <p>
30 * Only the composite cache knows what the hit count across all auxiliaries is.
31 */
32 public class CacheStats
33 extends Stats
34 implements ICacheStats
35 {
36 /** Don't change. */
37 private static final long serialVersionUID = 529914708798168590L;
38
39 /** The region */
40 private String regionName = null;
41
42 /** What that auxiliaries are reporting. */
43 private List<IStats> auxStats = null;
44
45 /**
46 * Stats are for a region, though auxiliary data may be for more.
47 * <p>
48 * @return The region name
49 */
50 @Override
51 public String getRegionName()
52 {
53 return regionName;
54 }
55
56 /**
57 * Stats are for a region, though auxiliary data may be for more.
58 * <p>
59 * @param name - The region name
60 */
61 @Override
62 public void setRegionName( String name )
63 {
64 regionName = name;
65 }
66
67 /**
68 * @return IStats[]
69 */
70 @Override
71 public List<IStats> getAuxiliaryCacheStats()
72 {
73 return auxStats;
74 }
75
76 /**
77 * @param stats
78 */
79 @Override
80 public void setAuxiliaryCacheStats( List<IStats> stats )
81 {
82 auxStats = stats;
83 }
84
85 /**
86 * @return readable string that can be logged.
87 */
88 @Override
89 public String toString()
90 {
91 StringBuilder buf = new StringBuilder();
92
93 buf.append( "Region Name = " + regionName );
94
95 if ( getStatElements() != null )
96 {
97 for ( Object stat : getStatElements() )
98 {
99 buf.append( "\n" );
100 buf.append( stat );
101 }
102 }
103
104 if ( auxStats != null )
105 {
106 for ( Object auxStat : auxStats )
107 {
108 buf.append( "\n" );
109 buf.append( "---------------------------" );
110 buf.append( auxStat );
111 }
112 }
113
114 return buf.toString();
115 }
116 }