1 23 24 29 30 package com.sun.appserv.management.j2ee.statistics; 31 32 import java.io.Serializable ; 33 import java.util.Map ; 34 35 import javax.management.j2ee.statistics.Statistic ; 36 37 import com.sun.appserv.management.util.misc.MapUtil; 38 import com.sun.appserv.management.util.misc.ObjectUtil; 39 import com.sun.appserv.management.util.j2ee.stringifier.StatisticStringifier; 40 import com.sun.appserv.management.util.j2ee.J2EEUtil; 41 42 43 47 public class StatisticImpl implements Statistic , Serializable 48 { 49 static final long serialVersionUID = -8120492090789878204L; 50 51 52 53 private final String mName; 54 private final String mDescription; 55 private final String mUnit; 56 protected long mLastSampleTime; 57 private final long mStartTime; 58 59 public 60 StatisticImpl( 61 final String name, 62 final String description, 63 final String unit, 64 final long startTime, 65 final long lastSampleTime ) 66 { 67 mName = name; 68 mDescription = description; 69 mUnit = unit; 70 mLastSampleTime = lastSampleTime; 71 mStartTime = startTime; 72 } 73 74 public 75 StatisticImpl( final Statistic s ) 76 { 77 mName = s.getName(); 78 mDescription = s.getDescription(); 79 mUnit = s.getUnit(); 80 mLastSampleTime = s.getLastSampleTime(); 81 mStartTime = s.getStartTime(); 82 } 83 84 87 public String 88 getDescription() 89 { 90 return( mDescription ); 91 } 92 93 94 97 public long 98 getLastSampleTime() 99 { 100 return( mLastSampleTime ); 101 } 102 103 106 public String 107 getName() 108 { 109 return( mName ); 110 } 111 112 115 public long 116 getStartTime() 117 { 118 return( mStartTime ); 119 } 120 121 122 125 public String 126 getUnit() 127 { 128 return( mUnit ); 129 } 130 131 public String 132 toString() 133 { 134 return StatisticStringifier.DEFAULT.stringify( this ); 135 } 136 137 138 public int 139 hashCode() 140 { 141 return ObjectUtil.hashCode( mName, mDescription, mUnit) ^ 142 ObjectUtil.hashCode( mLastSampleTime ) ^ 143 ObjectUtil.hashCode( mStartTime ); 144 } 145 146 public boolean 147 equals( final Object rhs ) 148 { 149 boolean equals = false; 150 151 if ( rhs instanceof Statistic ) 152 { 153 final Statistic s = (Statistic )rhs; 154 155 equals = getName().equals( s.getName() ) && 156 getUnit().equals( s.getUnit() ) && 157 getDescription().equals( s.getDescription() ) && 158 getStartTime() == s.getStartTime() && 159 getLastSampleTime() == s.getLastSampleTime(); 160 } 161 return( equals ); 162 } 163 164 } 165 166 167 168 169 170 | Popular Tags |