View Javadoc
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.IStatElement;
23  import org.apache.commons.jcs.engine.stats.behavior.IStats;
24  
25  import java.util.List;
26  
27  /**
28   * @author aaronsm
29   */
30  public class Stats
31      implements IStats
32  {
33      /** Don't change */
34      private static final long serialVersionUID = 227327902875154010L;
35  
36      /** The stats */
37      private List<IStatElement<?>> stats = null;
38  
39      /** The type of stat */
40      private String typeName = null;
41  
42      /**
43       * @return IStatElement[]
44       */
45      @Override
46      public List<IStatElement<?>> getStatElements()
47      {
48          return stats;
49      }
50  
51      /**
52       * @param stats
53       */
54      @Override
55      public void setStatElements( List<IStatElement<?>> stats )
56      {
57          this.stats = stats;
58      }
59  
60      /**
61       * @return typeName
62       */
63      @Override
64      public String getTypeName()
65      {
66          return typeName;
67      }
68  
69      /**
70       * @param name
71       */
72      @Override
73      public void setTypeName( String name )
74      {
75          typeName = name;
76      }
77  
78      /**
79       * @return the stats in a readable string
80       */
81      @Override
82      public String toString()
83      {
84          StringBuilder buf = new StringBuilder();
85  
86          buf.append( typeName );
87  
88          if ( stats != null )
89          {
90              for (Object stat : stats)
91              {
92                  buf.append( "\n" );
93                  buf.append( stat );
94              }
95          }
96  
97          return buf.toString();
98      }
99  }