KickJava   Java API By Example, From Geeks To Geeks.

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


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.mdr.storagemodel.StorableBaseObject;
26 import org.netbeans.mdr.util.IOUtils;
27 import org.openide.util.Utilities;
28
29 public class WildCardRef extends TypeRef {
30     public final boolean isLower;
31     public final TypeRef bound;
32
33     public static Object JavaDoc read(InputStream JavaDoc stream, StorableBaseObject storable) throws IOException JavaDoc {
34         return new WildCardRef(IOUtils.readBoolean(stream), (TypeRef) IOUtils.read(stream, storable));
35     }
36     
37     public void write(OutputStream JavaDoc outputStream, StorableBaseObject storable) throws IOException JavaDoc {
38         IOUtils.writeBoolean(outputStream, isLower);
39         IOUtils.write(outputStream, bound, storable);
40     }
41     
42     public WildCardRef(boolean isLower, TypeRef bound) {
43         this.isLower = isLower;
44         this.bound = bound;
45     }
46
47     public boolean equals(Object JavaDoc typeRef) {
48         WildCardRef ref;
49         
50         if (this==typeRef)
51             return true;
52         if (!(typeRef instanceof WildCardRef))
53             return false;
54         ref=(WildCardRef)typeRef;
55         if (isLower!=ref.isLower)
56             return false;
57         return Utilities.compareObjects(bound, ref.bound);
58     }
59     
60     String JavaDoc getName() {
61         return (isLower? "+" : "-").concat(bound == null ? "" : bound.getName()); // NOI18N
62
}
63     
64     public int hashCode() {
65         return bound == null ? 0 : bound.hashCode();
66     }
67 }
Popular Tags