1 23 package com.sun.appserv.management.util.j2ee.stringifier; 24 25 import java.util.Arrays ; 26 27 import javax.management.j2ee.statistics.Stats ; 28 import javax.management.j2ee.statistics.Statistic ; 29 30 import com.sun.appserv.management.util.stringifier.Stringifier; 31 import com.sun.appserv.management.util.stringifier.SmartStringifier; 32 import com.sun.appserv.management.util.stringifier.ArrayStringifier; 33 34 37 public class StatsStringifier implements Stringifier 38 { 39 public static final StatsStringifier DEFAULT = new StatsStringifier(); 40 41 public 42 StatsStringifier( ) 43 { 44 } 45 46 public String 47 stringify( Object o ) 48 { 49 final Stats stats = (Stats )o; 50 final String [] names = stats.getStatisticNames(); 51 52 Arrays.sort( names ); 53 54 final StringBuffer buf = new StringBuffer (); 55 56 buf.append( "Stats: " + ArrayStringifier.stringify( names, ", " ) + "\n" ); 57 58 for( int i = 0; i < names.length; ++i ) 59 { 60 final Object statistic = stats.getStatistic( names[ i ] ); 61 62 buf.append( SmartStringifier.toString( statistic ) ); 63 buf.append( "---\n" ); 64 } 65 buf.append( "\n" ); 66 67 return( buf.toString() ); 68 } 69 } 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | Popular Tags |