KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > parser > LocalClassNameRef


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.modules.javacore.parser;
21
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import org.netbeans.jmi.javamodel.JavaClass;
26 import org.netbeans.mdr.storagemodel.StorableBaseObject;
27 import org.openide.util.Utilities;
28
29 public class LocalClassNameRef extends NameRef {
30     private int hashCode;
31     public String JavaDoc mofId;
32
33     public static Object JavaDoc read(InputStream JavaDoc stream, StorableBaseObject storable) throws IOException JavaDoc {
34         throw new UnsupportedOperationException JavaDoc();
35     }
36
37     public void write(OutputStream JavaDoc outputStream, StorableBaseObject storable) throws IOException JavaDoc {
38         throw new UnsupportedOperationException JavaDoc();
39     }
40     
41     public LocalClassNameRef(JavaClass jcls) {
42         this(jcls,null,null);
43     }
44     
45     public LocalClassNameRef(JavaClass jcls,TypeParamRef par,TypeRef[] args) {
46         super(jcls.getName(),par,args);
47         mofId=jcls.refMofId();
48     }
49
50     public boolean equals(Object JavaDoc typeRef) {
51         LocalClassNameRef ref;
52         
53         if (this==typeRef)
54             return true;
55         if (!(typeRef instanceof LocalClassNameRef))
56             return false;
57         ref=(LocalClassNameRef)typeRef;
58         if (!mofId.equals(ref.mofId))
59             return false;
60         if (!Utilities.compareObjects(parent,ref.parent))
61             return false;
62         return Utilities.compareObjects(args,ref.args);
63     }
64     
65     String JavaDoc getName() {
66         String JavaDoc parentString="";
67         
68         if (parent!=null) {
69             parentString=parent.getName().concat("."); // NOI18N
70
}
71         return parentString.concat(name);
72     }
73     
74     public int hashCode() {
75         if (hashCode!=0) {
76             hashCode=mofId.hashCode();
77         
78             if (parent!=null)
79                 hashCode^=parent.hashCode();
80             hashCode^=args.hashCode();
81         }
82         return hashCode;
83     }
84 }
85
Popular Tags