KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > util > StatsToString


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 /*
30  * StatsToString.java
31  * $Id: StatsToString.java,v 1.2 2005/12/25 03:52:33 tcfujii Exp $
32  * $Date: 2005/12/25 03:52:33 $
33  * $Revision: 1.2 $
34  */

35
36
37 package com.sun.enterprise.admin.monitor.util;
38 import javax.management.j2ee.statistics.Stats JavaDoc;
39 import javax.management.j2ee.statistics.Statistic JavaDoc;
40 /**
41  * Returns String implementation of all the statistics within the {@link Stats}
42  * instance passed in with one statistic per line.
43  * @author <a HREF="mailto:Kedar.Mhaswade@sun.com">Kedar Mhaswade</a>
44  * @since __PRODUCT__
45  * @version $Revision: 1.2 $
46  */

47 public class StatsToString {
48     private final Stats JavaDoc stats;
49     private final String JavaDoc NL = System.getProperty("line.separator");
50     /** Creates a new instance of StatsToString */
51     StatsToString(Stats JavaDoc stats) {
52         this.stats = stats;
53     }
54     public String JavaDoc toString() {
55         final StringBuffer JavaDoc s = new StringBuffer JavaDoc(stats.getClass().getName()).append(NL);
56         final Statistic JavaDoc[] ss = stats.getStatistics();
57         for(int i = 0 ; i < ss.length ; i++) {
58             s.append(ss[i].toString()).append(NL);
59         }
60         return s.toString();
61     }
62 }
63
Popular Tags