FileDocCategorySizeDatePackage
MapStatisticImpl.javaAPI DocGlassfish v2 API6092Fri May 04 22:30:52 BST 2007com.sun.appserv.management.j2ee.statistics

MapStatisticImpl

public class MapStatisticImpl extends Object implements Serializable, MapStatistic
Generic implementation of Statistic which contains its members in a Map.

Fields Summary
static final long
serialVersionUID
final Map
mItems
Constructors Summary
public MapStatisticImpl(Map map)

	
		 
		
	    
	
		mItems	= new HashMap<String,Object>( map );
	
public MapStatisticImpl(javax.management.j2ee.statistics.Statistic statistic)

		if ( statistic instanceof MapStatistic )
		{
			mItems	= new HashMap<String,Object>();
			
			mItems.putAll( ((MapStatistic)statistic).asMap() );
		}
		else
		{
			mItems	= J2EEUtil.statisticToMap( statistic );
		}
	
Methods Summary
public java.util.MapasMap()

		return( Collections.unmodifiableMap( mItems ) );
	
public booleanequals(java.lang.Object rhs)

		boolean	equals	= false;
		
		if ( rhs instanceof MapStatistic )
		{
			equals	= MapUtil.mapsEqual( asMap(), ((MapStatistic)rhs).asMap() );
		}
		return( equals );
	
public java.lang.StringgetDescription()
Get the description for this Statistic

 		return( getString( "Description" ) );
 	
public longgetLastSampleTime()
Get the last sample time for this Statistic

 		return( getlong( "LastSampleTime" ) );
 	
public java.lang.StringgetName()
Get the name of this Statistic

 		return( getString( "Name" ) );
	
public longgetStartTime()
Get the start time for this Statistic

 		return( getlong( "StartTime" ) );
	
public final java.lang.StringgetString(java.lang.String name)
Get a Statistic value which is expected to be a String

		return( (String)getValue( name ) );
	
public java.lang.StringgetUnit()
Get the units associated with this statistic.

 		return( getString( "Unit" ) );
	
public final java.lang.ObjectgetValue(java.lang.String name)
Get a Statistic value which is expected to be any Object

		final Object	value	= mItems.get( name );
		
		if ( value == null && ! mItems.containsKey( name ) )
		{
			throw new IllegalArgumentException( name );
		}
		
		return( value );
	
public final intgetint(java.lang.String name)
Get a Statistic value which is expected to be an Integer (int)

		return( ((Integer)getValue( name )).intValue() );
	
public final longgetlong(java.lang.String name)
Get a Statistic value which is expected to be a Long (long)

		final Object	value	= getValue( name );
		
		if ( ! (value instanceof Long) )
		{
			throw new IllegalArgumentException( 
				"MapStatisticImpl.getLong: expecting Long for " + name +
				", got " + value + " of class " + value.getClass() +
				", all values: " + toString() );
			
		}
			
		return( ((Long)value).longValue() );
	
public inthashCode()

 	    return mItems.hashCode();
 	
public java.lang.StringsetName(java.lang.String newName)
Get the name of this Statistic

		if ( newName == null || newName.length() == 0 )
		{
			throw new IllegalArgumentException();
		}
		
		final String	oldName	= getName();
		
		mItems.put( "Name", newName );
		
 		return( oldName  );
	
public java.lang.StringtoString()

		return( MapUtil.toString( mItems ) );
	
public java.util.SetvalueNames()
Get the fields associated with this statistic. Note the name--"get" is avoided so it won't be introspected as another Statistic field.

return
an unmodifiableSet of the field names (String)

 		return( Collections.unmodifiableSet( mItems.keySet() ) );