KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jmi > javamodel > ErrorTypeEnum


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.jmi.javamodel;
21
22 /**
23  * ErrorType enumeration class implementation.
24  *
25  * <p><em><strong>Note:</strong> This type should not be subclassed or implemented
26  * by clients. It is generated from a MOF metamodel and automatically implemented
27  * by MDR (see <a HREF="http://mdr.netbeans.org/">mdr.netbeans.org</a>).</em></p>
28  */

29 public final class ErrorTypeEnum implements ErrorType {
30     /**
31      * Enumeration constant corresponding to literal error.
32      */

33     public static final ErrorTypeEnum ERROR = new ErrorTypeEnum("error");
34     /**
35      * Enumeration constant corresponding to literal warning.
36      */

37     public static final ErrorTypeEnum WARNING = new ErrorTypeEnum("warning");
38
39     private static final java.util.List JavaDoc typeName;
40     private final java.lang.String JavaDoc literalName;
41
42     static {
43         java.util.ArrayList JavaDoc temp = new java.util.ArrayList JavaDoc();
44         temp.add("JavaModel");
45         temp.add("ErrorType");
46         typeName = java.util.Collections.unmodifiableList(temp);
47     }
48
49     private ErrorTypeEnum(java.lang.String JavaDoc literalName) {
50         this.literalName = literalName;
51     }
52
53     /**
54      * Returns fully qualified name of the enumeration type.
55      * @return List containing all parts of the fully qualified name.
56      */

57     public java.util.List JavaDoc refTypeName() {
58         return typeName;
59     }
60
61     /**
62      * Returns a string representation of the enumeration value.
63      * @return A string representation of the enumeration value.
64      */

65     public java.lang.String JavaDoc toString() {
66         return literalName;
67     }
68
69     /**
70      * Returns a hash code for this the enumeration value.
71      * @return A hash code for this enumeration value.
72      */

73     public int hashCode() {
74         return literalName.hashCode();
75     }
76
77     /**
78      * Indicates whether some other object is equal to this enumeration value.
79      * @param o The reference object with which to compare.
80      * @return true if the other object is the enumeration of the same type and
81      * of the same value.
82      */

83     public boolean equals(java.lang.Object JavaDoc o) {
84         if (o instanceof ErrorTypeEnum) return (o == this);
85         else if (o instanceof ErrorType) return (o.toString().equals(literalName));
86         else return ((o instanceof javax.jmi.reflect.RefEnum) && ((javax.jmi.reflect.RefEnum) o).refTypeName().equals(typeName) && o.toString().equals(literalName));
87     }
88
89     /**
90      * Translates literal name to correspondent enumeration value.
91      * @param name Enumeration literal.
92      * @return Enumeration value corresponding to the passed literal.
93      */

94     public static ErrorType forName(java.lang.String JavaDoc name) {
95         if (name.equals("error")) return ERROR;
96         if (name.equals("warning")) return WARNING;
97         throw new java.lang.IllegalArgumentException JavaDoc("Unknown literal name '" + name + "' for enumeration 'JavaModel.ErrorType'");
98     }
99     /**
100      * Resolves serialized instance of enumeration value.
101      * @return Resolved enumeration value.
102      */

103     protected java.lang.Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
104         try {
105             return forName(literalName);
106         } catch (java.lang.IllegalArgumentException JavaDoc e) {
107             throw new java.io.InvalidObjectException JavaDoc(e.getMessage());
108         }
109     }
110 }
111
Popular Tags