001package org.apache.commons.jcs3.engine.stats; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.List; 023 024import org.apache.commons.jcs3.engine.stats.behavior.ICacheStats; 025import org.apache.commons.jcs3.engine.stats.behavior.IStats; 026 027/** 028 * This class stores cache historical and statistics data for a region. 029 * <p> 030 * Only the composite cache knows what the hit count across all auxiliaries is. 031 */ 032public class CacheStats 033 extends Stats 034 implements ICacheStats 035{ 036 /** Don't change. */ 037 private static final long serialVersionUID = 529914708798168590L; 038 039 /** The region */ 040 private String regionName; 041 042 /** What that auxiliaries are reporting. */ 043 private List<IStats> auxStats; 044 045 /** 046 * Stats are for a region, though auxiliary data may be for more. 047 * <p> 048 * @return The region name 049 */ 050 @Override 051 public String getRegionName() 052 { 053 return regionName; 054 } 055 056 /** 057 * Stats are for a region, though auxiliary data may be for more. 058 * <p> 059 * @param name - The region name 060 */ 061 @Override 062 public void setRegionName( final String name ) 063 { 064 regionName = name; 065 } 066 067 /** 068 * @return IStats[] 069 */ 070 @Override 071 public List<IStats> getAuxiliaryCacheStats() 072 { 073 return auxStats; 074 } 075 076 /** 077 * @param stats 078 */ 079 @Override 080 public void setAuxiliaryCacheStats( final List<IStats> stats ) 081 { 082 auxStats = stats; 083 } 084 085 /** 086 * @return readable string that can be logged. 087 */ 088 @Override 089 public String toString() 090 { 091 final StringBuilder buf = new StringBuilder(); 092 093 buf.append( "Region Name = " + regionName ); 094 095 if ( getStatElements() != null ) 096 { 097 for ( final Object stat : getStatElements() ) 098 { 099 buf.append( "\n" ); 100 buf.append( stat ); 101 } 102 } 103 104 if ( auxStats != null ) 105 { 106 for ( final Object auxStat : auxStats ) 107 { 108 buf.append( "\n" ); 109 buf.append( "---------------------------" ); 110 buf.append( auxStat ); 111 } 112 } 113 114 return buf.toString(); 115 } 116}