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