01: /*
02: * @(#)MemberName.java 1.13 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: /*
29: * A member name has 3 parts:
30: * 1) a pointer to the ClassEntry for the class holding the member.
31: * 2) the member name
32: * 3) a method's signature.
33: * The last two are concatenated into the name field. There is
34: * apparently little value in separating them.
35: *
36: * The only value to a signature is to resolve overloading.
37: * Since data fields do not overload, we do not carry a signature
38: * with them. And since even methods only overload based on parameter
39: * list, we do not need to carry the return-type part of their signatures.
40: *
41: * We construct these for ease of comparison, as we will often
42: * be doing lookup operations.
43: */
44:
45: package dependenceAnalyzer;
46:
47: import util.Localizer;
48:
49: public class MemberName implements Cloneable {
50: public ClassEntry classEntry;
51: public String name; // and type signature
52:
53: public MemberName(ClassEntry c, String nm) {
54: classEntry = c;
55: name = nm.intern();
56: }
57:
58: public boolean equals(Object other) {
59: try {
60: MemberName otherName = (MemberName) other;
61: return ((this .classEntry == otherName.classEntry) && (this .name == otherName.name));
62: } catch (ClassCastException e) {
63: return false;
64: }
65: }
66:
67: public int hashCode() {
68: return name.hashCode();
69: }
70:
71: public Object clone() {
72: try {
73: MemberName newName = (MemberName) super .clone();
74: return newName;
75: } catch (CloneNotSupportedException e) {
76: e.printStackTrace();
77: throw new Error(Localizer
78: .getString("membername.could_not_clone"));
79: }
80: }
81:
82: public String toString() {
83: String result;
84: if (classEntry == null) {
85: result = "<noclass>";
86: } else {
87: result = classEntry.name().toString();
88: }
89: result += "." + name;
90: return result;
91: }
92: }
|