KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > apiscan > classfile > MethodRef


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 package com.sun.enterprise.tools.verifier.apiscan.classfile;
26
27 /**
28  * @author Sanjeeb.Sahoo@Sun.COM
29  */

30 public class MethodRef {
31     private String JavaDoc owningClassNameInternal; // in internal form, e.g. com/acme/Address
32

33     private String JavaDoc owningClassName; // in external form, i.e. java.lang.Object
34

35     private String JavaDoc name; // main
36

37     private String JavaDoc descriptor; // ([Ljava.lang.String;)I
38

39     public static final String JavaDoc CLINIT_NAME = "<clinit>"; // NOI18N
40

41     public static final String JavaDoc CLINIT_DESC = "()V"; // NOI18N
42

43     public MethodRef(String JavaDoc owningClassNameInternal, String JavaDoc name, String JavaDoc descriptor) {
44         this.owningClassNameInternal = owningClassNameInternal;
45         this.owningClassName = Util.convertToExternalClassName(owningClassNameInternal);
46         this.name = name;
47         this.descriptor = descriptor;
48     }
49
50     public String JavaDoc getDescriptor() {
51         return descriptor;
52     }
53
54     public String JavaDoc getOwningClassNameInternal() {
55         return owningClassNameInternal;
56     }
57
58     public String JavaDoc getOwningClassName(){
59         return owningClassName;
60     }
61
62     public String JavaDoc getName() {
63         return name;
64     }
65
66     public boolean equals(Object JavaDoc o) {
67         if (this == o) return true;
68         if (!(o instanceof MethodRef)) return false;
69         final MethodRef methodRef = (MethodRef) o;
70         if (descriptor != null ?
71                 !descriptor.equals(methodRef.descriptor) :
72                 methodRef.descriptor != null)
73             return false;
74         if (name != null ?
75                 !name.equals(methodRef.name) : methodRef.name != null)
76             return false;
77         if (owningClassNameInternal != null ?
78                 !owningClassNameInternal.equals(methodRef.owningClassNameInternal) :
79                 methodRef.owningClassNameInternal != null)
80             return false;
81         return true;
82     }
83
84     public int hashCode() {
85         int result;
86         result = (owningClassNameInternal != null ? owningClassNameInternal.hashCode() : 0);
87         result = 29 * result + (name != null ? name.hashCode() : 0);
88         result = 29 * result +
89                 (descriptor != null ? descriptor.hashCode() : 0);
90         return result;
91     }
92
93     @Override JavaDoc public String JavaDoc toString() {
94         return owningClassNameInternal + "." + name + descriptor; // NOI18N
95
}
96 }
97
Popular Tags