duke@1: /* ohair@158: * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@158: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@158: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@158: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@158: * or visit www.oracle.com if you need additional information or have any ohair@158: * questions. duke@1: */ duke@1: duke@1: /* duke@1: * Licensed Materials - Property of IBM duke@1: * RMI-IIOP v1.0 duke@1: * Copyright IBM Corp. 1998 1999 All Rights Reserved duke@1: * duke@1: */ duke@1: duke@1: package sun.rmi.rmic.iiop; duke@1: duke@1: import java.io.IOException; duke@1: import sun.tools.java.CompilerError; duke@1: import sun.tools.java.ClassDefinition; duke@1: import sun.rmi.rmic.IndentingWriter; duke@1: duke@1: /** duke@1: * InterfaceType is an abstract base representing any non-special duke@1: * interface type. duke@1: * duke@1: * @author Bryan Atsatt duke@1: */ duke@1: public abstract class InterfaceType extends CompoundType { duke@1: duke@1: //_____________________________________________________________________ duke@1: // Public Interfaces duke@1: //_____________________________________________________________________ duke@1: duke@1: /** duke@1: * Print this type. duke@1: * @param writer The stream to print to. duke@1: * @param useQualifiedNames If true, print qualified names; otherwise, print unqualified names. duke@1: * @param useIDLNames If true, print IDL names; otherwise, print java names. duke@1: * @param globalIDLNames If true and useIDLNames true, prepends "::". duke@1: */ duke@1: public void print ( IndentingWriter writer, duke@1: boolean useQualifiedNames, duke@1: boolean useIDLNames, duke@1: boolean globalIDLNames) throws IOException { duke@1: duke@1: if (isInner()) { duke@1: writer.p("// " + getTypeDescription() + " (INNER)"); duke@1: } else { duke@1: writer.p("// " + getTypeDescription() + ""); duke@1: } duke@1: writer.pln(" (" + getRepositoryID() + ")\n"); duke@1: printPackageOpen(writer,useIDLNames); duke@1: duke@1: if (!useIDLNames) { duke@1: writer.p("public "); duke@1: } duke@1: duke@1: writer.p("interface " + getTypeName(false,useIDLNames,false)); duke@1: printImplements(writer,"",useQualifiedNames,useIDLNames,globalIDLNames); duke@1: writer.plnI(" {"); duke@1: printMembers(writer,useQualifiedNames,useIDLNames,globalIDLNames); duke@1: writer.pln(); duke@1: printMethods(writer,useQualifiedNames,useIDLNames,globalIDLNames); duke@1: writer.pln(); duke@1: duke@1: if (useIDLNames) { duke@1: writer.pOln("};"); duke@1: } else { duke@1: writer.pOln("}"); duke@1: } duke@1: printPackageClose(writer,useIDLNames); duke@1: } duke@1: duke@1: //_____________________________________________________________________ duke@1: // Subclass/Internal Interfaces duke@1: //_____________________________________________________________________ duke@1: duke@1: /** duke@1: * Create a InterfaceType instance for the given class. NOTE: This constructor duke@1: * is ONLY for SpecialInterfaceType. duke@1: */ duke@1: protected InterfaceType(ContextStack stack, int typeCode, ClassDefinition classDef) { duke@1: super(stack,typeCode,classDef); // Call special parent constructor. duke@1: duke@1: if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) { duke@1: throw new CompilerError("Not an interface"); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Create a InterfaceType instance for the given class. The resulting duke@1: * object is not yet completely initialized. Subclasses must call duke@1: * initialize(directInterfaces,directInterfaces,directConstants); duke@1: */ duke@1: protected InterfaceType(ContextStack stack, duke@1: ClassDefinition classDef, duke@1: int typeCode) { duke@1: super(stack,classDef,typeCode); duke@1: duke@1: if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) { duke@1: throw new CompilerError("Not an interface"); duke@1: } duke@1: } duke@1: }