View Javadoc

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