Stringify by accessing all public getXXX() methods that return a value
and don't throw exceptions.
final Statistic statistic = (Statistic)o;
final StringBuffer buf = new StringBuffer();
buf.append( statistic.getName() + ": " );
final SortedMap<String,Object> pairs =
new TreeMap<String,Object>( J2EEUtil.statisticToMap( statistic ) );
// first emit the standard value names in a proscribed order
for( int i = 0; i < ORDERED_VALUES.length; ++i )
{
final String name = ORDERED_VALUES[ i ];
if ( pairs.containsKey( name ) )
{
final Object value = pairs.get( name );
buf.append( createNameValuePair( name, value ) );
buf.append( DELIM );
pairs.remove( name );
}
}
final Iterator iter = pairs.keySet().iterator();
while ( iter.hasNext() )
{
final String name = (String)iter.next();
final Object value = pairs.get( name );
buf.append( createNameValuePair( name, value ) );
buf.append( DELIM );
}
String result = buf.toString();
if ( result.endsWith( DELIM ) )
{
result = result.substring( 0, result.length() - DELIM.length() );
}
return( result );