KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > j2ee > statistics > CountStatisticImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/j2ee/statistics/CountStatisticImpl.java,v 1.5 2006/03/09 20:30:28 llc Exp $
26  * $Revision: 1.5 $
27  * $Date: 2006/03/09 20:30:28 $
28  */

29
30 package com.sun.appserv.management.j2ee.statistics;
31
32 import java.util.Map JavaDoc;
33 import java.io.Serializable JavaDoc;
34
35 import javax.management.openmbean.CompositeData JavaDoc;
36
37 import javax.management.j2ee.statistics.Statistic JavaDoc;
38 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
39
40 import com.sun.appserv.management.util.jmx.OpenMBeanUtil;
41 import com.sun.appserv.management.util.misc.ObjectUtil;
42
43
44 /**
45     
46  */

47 public class CountStatisticImpl extends StatisticImpl
48     implements CountStatistic JavaDoc, Serializable JavaDoc
49 {
50     static final long serialVersionUID = -4868791714488583778L;
51     
52     /* member name as defined by JSR 77 */
53     private final long Count;
54     
55         public
56     CountStatisticImpl(
57         final String JavaDoc name,
58         final String JavaDoc description,
59         final String JavaDoc unit,
60         final long startTime,
61         final long lastSampleTime,
62         final long count )
63     {
64         super( name, description, unit, startTime, lastSampleTime );
65         Count = count;
66     }
67     
68         public
69     CountStatisticImpl( final CompositeData JavaDoc compositeData )
70     {
71         this( OpenMBeanUtil.compositeDataToMap( compositeData ) );
72     }
73     
74         public
75     CountStatisticImpl( final CountStatistic JavaDoc s )
76     {
77         super( s );
78         Count = s.getCount();
79     }
80     
81         public
82     CountStatisticImpl( final MapStatistic s )
83     {
84         super( s );
85         Count = s.getlong( "Count" );
86     }
87     
88         public
89     CountStatisticImpl( final Map JavaDoc<String JavaDoc,?> data )
90     {
91         this( new MapStatisticImpl( data ) );
92     }
93
94
95         public long
96     getCount()
97     {
98         return( Count );
99     }
100     
101         public int
102     hashCode()
103     {
104         return super.hashCode() ^ ObjectUtil.hashCode( Count );
105     }
106     
107     
108         public boolean
109     equals( final Object JavaDoc rhs )
110     {
111         boolean equals = super.equals( rhs ) && (rhs instanceof CountStatistic JavaDoc);
112         
113         if ( equals )
114         {
115             final CountStatistic JavaDoc s = (CountStatistic JavaDoc)rhs;
116             
117             equals = getCount() == s.getCount();
118         }
119         return( equals );
120     }
121 }
122
123
124
125
126
127
Popular Tags