KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > MonitoringLevel


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  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 /* MonitoringLevel.java
30  * $Id: MonitoringLevel.java,v 1.2 2005/12/25 03:52:07 tcfujii Exp $
31  * $Revision: 1.2 $
32  * $Date: 2005/12/25 03:52:07 $
33  * Indentation Information:
34  * 0. Please (try to) preserve these settings.
35  * 1. Tabs are preferred over spaces.
36  * 2. In vi/vim -
37  * :set tabstop=4 :set shiftwidth=4 :set softtabstop=4
38  * 3. In S1 Studio -
39  * 1. Tools->Options->Editor Settings->Java Editor->Tab Size = 4
40  * 2. Tools->Options->Indentation Engines->Java Indentation Engine->Expand Tabs to Spaces = False.
41  * 3. Tools->Options->Indentation Engines->Java Indentation Engine->Number of Spaces per Tab = 4.
42  */

43
44 package com.sun.enterprise.admin.monitor.registry;
45
46 /**
47  * Provides enumerated constants related to various levels
48  * at which monitoring could be set
49  * @author Shreedhar Ganapathy<mailto:shreedhar.ganapathy@sun.com>
50  * @author <a HREF="mailto:Kedar.Mhaswade@sun.com">Kedar Mhaswade</a>
51  */

52 public class MonitoringLevel {
53
54     public static final MonitoringLevel OFF = new MonitoringLevel("OFF");
55     public static final MonitoringLevel LOW = new MonitoringLevel("LOW");
56     public static final MonitoringLevel HIGH = new MonitoringLevel("HIGH");
57
58     private final String JavaDoc name;
59     
60     /**
61      * Constructor
62      */

63     private MonitoringLevel(String JavaDoc name ) {
64         this.name = name;
65     }
66     
67     public String JavaDoc toString() {
68         return ( name );
69     }
70     
71     /**
72      * Returns an instance of MonitoringLevel for the given String.
73      * The given String has to correspond to one of the public fields declared
74      * in this class.
75      *
76      * @param name String representing the MonitoringLevel
77      * @return MonitoringLevel corresponding to given parameter, or null
78      * if the parameter is null or does not correspond to any of the
79      * Monitoring Levels supported.
80      * For $Revision: 1.2 $ of this class, "off", "high" and "low" are
81      * supported strings. The comparison is done case insensitively.
82      */

83     public static MonitoringLevel instance(String JavaDoc name) {
84         if (OFF.toString().equalsIgnoreCase(name))
85             return ( OFF );
86         else if (LOW.toString().equalsIgnoreCase(name))
87             return ( LOW );
88         else if (HIGH.toString().equalsIgnoreCase(name))
89             return ( HIGH );
90         return ( null );
91     }
92
93     /**
94      * Checks two MonitoringLevel objects for equality.
95      *
96      * <p>Checks that <i>obj</i> is a MonitoringLevel, and has the same name as
97      * this object.
98      *
99      * @param obj the object we are testing for equality with this object.
100      * @return true if obj is a MonitoringLevel, and has the same name as this
101      * MonitoringLevel object.
102      */

103     public boolean equals(Object JavaDoc obj) {
104     if (obj == this)
105         return true;
106
107     if (! (obj instanceof MonitoringLevel))
108         return false;
109
110     MonitoringLevel that = (MonitoringLevel) obj;
111
112     return (this.name.equals(that.name));
113     }
114
115     /**
116      * Returns the hash code value for this object.
117      *
118      * <p>The hash code returned is the hash code of the name of this
119      * MonitoringLevel object.
120      *
121      * @return Hash code value for this object.
122      */

123     public int hashCode() {
124     return this.name.hashCode();
125     }
126
127 }
128
Popular Tags