Methods Summary |
---|
private static java.util.Map | createStatisticsMap(javax.management.openmbean.CompositeData compositeData)
final CompositeType compositeType = compositeData.getCompositeType();
final Set keySet = compositeType.keySet();
final Iterator iter = keySet.iterator();
final Map<String,Statistic> map = new HashMap<String,Statistic>();
while ( iter.hasNext() )
{
final String name = (String)iter.next();
final CompositeData data = (CompositeData)compositeData.get( name );
map.put( name, StatisticFactory.create( data ) );
}
return( map );
|
private static java.util.Map | createStatisticsMap(javax.management.j2ee.statistics.Statistic[] statistics)
final Map<String,Statistic> m = new HashMap<String,Statistic>();
for( int i = 0; i < statistics.length; ++i )
{
final Statistic statistic = requireStatisticImpl( statistics[ i ] );
if ( statistic != null )
{
m.put( statistic.getName(), statistic );
}
}
return( m );
|
public boolean | equals(java.lang.Object rhs)
boolean equals = false;
if ( rhs != null && rhs instanceof Stats )
{
final Stats stats = (Stats)rhs;
final String[] myNames = getStatisticNames();
final String[] rhsNames = stats.getStatisticNames();
if ( myNames.length == rhsNames.length )
{
equals = true;
for( int i = 0; i < myNames.length; ++i )
{
final String statisticName = myNames[ i ];
final Statistic myStatistic = getStatistic( statisticName );
final Statistic rhsStatistic = stats.getStatistic( statisticName );
if ( ! myStatistic.equals( rhsStatistic ) )
{
equals = false;
break;
}
}
}
}
return( equals );
|
public javax.management.j2ee.statistics.Statistic | getStatistic(java.lang.String statisticName)
try
{
return( (Statistic)getValue( statisticName ) );
}
catch( Exception e )
{
final String msg = "NOT a Statistic: " + statisticName +
" of class " + getValue( statisticName ).getClass();
throw new RuntimeException( msg, e );
}
|
public java.lang.String[] | getStatisticNames()
final Set<String> names = getMap().keySet();
return( GSetUtil.toStringArray( names ) );
|
public javax.management.j2ee.statistics.Statistic[] | getStatistics()
final Collection<Statistic> values = getMap().values();
final Statistic[] statistics = new Statistic[ values.size() ];
return( (Statistic[])values.toArray( statistics ) );
|
public java.lang.Object | invoke(java.lang.Object myProxy, java.lang.reflect.Method method, java.lang.Object[] args)
Object result = null;
final String methodName = method.getName();
final int numArgs = args == null ? 0 : args.length;
if ( numArgs == 0 && methodName.equals( "getStatisticNames" ) )
{
result = getStatisticNames();
}
else if ( numArgs == 0 && methodName.equals( "getStatistics" ) )
{
result = getStatistics();
}
else if ( numArgs == 1 && methodName.equals( "getStatistic" ) &&
method.getReturnType() == Statistic.class &&
method.getParameterTypes()[ 0 ] == String.class )
{
result = getStatistic( (String)args[ 0 ] );
}
else
{
result = super.invoke( myProxy, method, args );
}
return( result );
|
private static java.util.Map | requireSerializableMap(java.util.Map m)
// required every entry to be a Statistic
for( final Statistic s : m.values() )
{
if ( ! (s instanceof Statistic ) )
{
throw new IllegalArgumentException();
}
}
Map<String,Statistic> sMap = null;
if ( m instanceof Serializable )
{
sMap = m;
}
else
{
sMap = new HashMap<String, Statistic>( m );
}
return( sMap );
|
private static javax.management.j2ee.statistics.Statistic | requireStatisticImpl(javax.management.j2ee.statistics.Statistic statisticIn)Ensure that every Statistic is an instance of one of our acceptable
implementations. If you are adding a custom statistic, add that
statistic here in the if clause.
Statistic statisticOut = null;
if ( statisticIn instanceof CountStatisticImpl ||
statisticIn instanceof RangeStatisticImpl ||
statisticIn instanceof BoundedRangeStatisticImpl ||
statisticIn instanceof BoundaryStatisticImpl ||
statisticIn instanceof TimeStatisticImpl ||
statisticIn instanceof NumberStatisticImpl ||
statisticIn instanceof StringStatisticImpl
)
{
statisticOut = statisticIn;
}
else if ( statisticIn instanceof MapStatistic )
{
final Class<? extends Statistic> theInterface =
StatisticFactory.getInterface( statisticIn );
if ( theInterface != MapStatistic.class )
{
statisticOut = StatisticFactory.create( theInterface,
J2EEUtil.statisticToMap( statisticIn ) );
}
else if ( ! ( statisticIn instanceof MapStatisticImpl ) )
{
// it's a MapStatistic, but not our implementation.
statisticOut = new MapStatisticImpl( statisticIn );
}
}
else
{
// some weird kind, convert it to generic Statistic
assert( false ) :
"requireStatisticImpl: unsupported Statistic type of class " + statisticIn.getClass().getName();
statisticOut = new MapStatisticImpl( statisticIn );
}
return( statisticOut );
|
private static javax.management.j2ee.statistics.Statistic[] | requireStatisticImpl(javax.management.j2ee.statistics.Statistic[] statisticsIn)Ensure that every Statistic is an instance of StatisticsImpl.
boolean convert = false;
// avoid conversion if already in desired form
for( int i = 0; i < statisticsIn.length; ++i )
{
if ( ! (statisticsIn[ i ] instanceof MapStatistic ) )
{
convert = true;
break;
}
}
Statistic[] statisticsOut = null;
if ( convert )
{
statisticsOut = new Statistic[ statisticsIn.length ];
for( int i = 0; i <
statisticsIn.length; ++i )
{
statisticsOut[ i ] = requireStatisticImpl( statisticsIn[ i ] );
}
}
else
{
statisticsOut = statisticsIn;
}
return( statisticsOut );
|
public java.lang.String | toString()
final StringBuffer buf = new StringBuffer();
final Statistic[] statistics = getStatistics();
buf.append( statistics.length + " Statistics:\n" );
for( int i = 0; i < statistics.length; ++i )
{
buf.append( statistics[ i ].toString() + "\n");
}
return( buf.toString() );
|