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.IStatElement; 025import org.apache.commons.jcs3.engine.stats.behavior.IStats; 026 027/** 028 */ 029public class Stats 030 implements IStats 031{ 032 /** Don't change */ 033 private static final long serialVersionUID = 227327902875154010L; 034 035 /** The stats */ 036 private List<IStatElement<?>> stats; 037 038 /** The type of stat */ 039 private String typeName; 040 041 /** 042 * @return IStatElement[] 043 */ 044 @Override 045 public List<IStatElement<?>> getStatElements() 046 { 047 return stats; 048 } 049 050 /** 051 * @param stats 052 */ 053 @Override 054 public void setStatElements( final List<IStatElement<?>> stats ) 055 { 056 this.stats = stats; 057 } 058 059 /** 060 * @return typeName 061 */ 062 @Override 063 public String getTypeName() 064 { 065 return typeName; 066 } 067 068 /** 069 * @param name 070 */ 071 @Override 072 public void setTypeName( final String name ) 073 { 074 typeName = name; 075 } 076 077 /** 078 * @return the stats in a readable string 079 */ 080 @Override 081 public String toString() 082 { 083 final StringBuilder buf = new StringBuilder(); 084 085 buf.append( typeName ); 086 087 if ( stats != null ) 088 { 089 for (final Object stat : stats) 090 { 091 buf.append( "\n" ); 092 buf.append( stat ); 093 } 094 } 095 096 return buf.toString(); 097 } 098}