src/share/classes/sun/rmi/rmic/iiop/InterfaceType.java

changeset 1
55540e827aef
child 158
91006f157c46
equal deleted inserted replaced
-1:000000000000 1:55540e827aef
1 /*
2 * Portions Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 /*
27 * Licensed Materials - Property of IBM
28 * RMI-IIOP v1.0
29 * Copyright IBM Corp. 1998 1999 All Rights Reserved
30 *
31 */
32
33 package sun.rmi.rmic.iiop;
34
35 import java.io.IOException;
36 import sun.tools.java.CompilerError;
37 import sun.tools.java.ClassDefinition;
38 import sun.rmi.rmic.IndentingWriter;
39
40 /**
41 * InterfaceType is an abstract base representing any non-special
42 * interface type.
43 *
44 * @author Bryan Atsatt
45 */
46 public abstract class InterfaceType extends CompoundType {
47
48 //_____________________________________________________________________
49 // Public Interfaces
50 //_____________________________________________________________________
51
52 /**
53 * Print this type.
54 * @param writer The stream to print to.
55 * @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names.
56 * @param useIDLNames If true, print IDL names; otherwise, print java names.
57 * @param globalIDLNames If true and useIDLNames true, prepends "::".
58 */
59 public void print ( IndentingWriter writer,
60 boolean useQualifiedNames,
61 boolean useIDLNames,
62 boolean globalIDLNames) throws IOException {
63
64 if (isInner()) {
65 writer.p("// " + getTypeDescription() + " (INNER)");
66 } else {
67 writer.p("// " + getTypeDescription() + "");
68 }
69 writer.pln(" (" + getRepositoryID() + ")\n");
70 printPackageOpen(writer,useIDLNames);
71
72 if (!useIDLNames) {
73 writer.p("public ");
74 }
75
76 writer.p("interface " + getTypeName(false,useIDLNames,false));
77 printImplements(writer,"",useQualifiedNames,useIDLNames,globalIDLNames);
78 writer.plnI(" {");
79 printMembers(writer,useQualifiedNames,useIDLNames,globalIDLNames);
80 writer.pln();
81 printMethods(writer,useQualifiedNames,useIDLNames,globalIDLNames);
82 writer.pln();
83
84 if (useIDLNames) {
85 writer.pOln("};");
86 } else {
87 writer.pOln("}");
88 }
89 printPackageClose(writer,useIDLNames);
90 }
91
92 //_____________________________________________________________________
93 // Subclass/Internal Interfaces
94 //_____________________________________________________________________
95
96 /**
97 * Create a InterfaceType instance for the given class. NOTE: This constructor
98 * is ONLY for SpecialInterfaceType.
99 */
100 protected InterfaceType(ContextStack stack, int typeCode, ClassDefinition classDef) {
101 super(stack,typeCode,classDef); // Call special parent constructor.
102
103 if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
104 throw new CompilerError("Not an interface");
105 }
106 }
107
108 /**
109 * Create a InterfaceType instance for the given class. The resulting
110 * object is not yet completely initialized. Subclasses must call
111 * initialize(directInterfaces,directInterfaces,directConstants);
112 */
113 protected InterfaceType(ContextStack stack,
114 ClassDefinition classDef,
115 int typeCode) {
116 super(stack,classDef,typeCode);
117
118 if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
119 throw new CompilerError("Not an interface");
120 }
121 }
122 }

mercurial