Class IDLGenerator

    • Field Detail

      • valueMethods

        private boolean valueMethods
      • factory

        private boolean factory
      • ifHash

        private java.util.Hashtable<java.lang.String,​java.lang.String> ifHash
      • imHash

        private java.util.Hashtable<java.lang.String,​java.lang.String> imHash
    • Constructor Detail

      • IDLGenerator

        public IDLGenerator()
        Default constructor for Main to use.
    • Method Detail

      • requireNewInstance

        protected boolean requireNewInstance()
        Return true if a new instance should be created for each class on the command line. Subclasses which return true should override newInstance() to return an appropriately constructed instance.
        Specified by:
        requireNewInstance in class Generator
      • parseNonConforming

        protected boolean parseNonConforming​(ContextStack stack)
        Return true if non-conforming types should be parsed.
        Specified by:
        parseNonConforming in class Generator
        Parameters:
        stack - The context stack.
      • getTopType

        protected CompoundType getTopType​(ClassDefinition cdef,
                                          ContextStack stack)
        Create and return a top-level type.
        Specified by:
        getTopType in class Generator
        Parameters:
        cdef - The top-level class definition.
        stack - The context stack.
        Returns:
        An RemoteType or null if is non-conforming.
      • getOutputId

        protected Identifier getOutputId​(Generator.OutputType ot)
        Return an Identifier which contains the fully-qualified IDL filename for the given OutputType. The OutputType contains a filename string (not directory) and Type.
        Overrides:
        getOutputId in class Generator
        Parameters:
        ot - the OutputType for which directory nesting is to be defined.
        Returns:
        the new identifier.
      • getFileNameExtensionFor

        protected java.lang.String getFileNameExtensionFor​(Generator.OutputType outputType)
        Return the file name extension for the given file name (e.g. ".java"). All files generated with the ".java" extension will be compiled. To change this behavior for ".java" files, override the compileJavaSourceFile method to return false.
        Specified by:
        getFileNameExtensionFor in class Generator
        Parameters:
        outputType - One of the items returned by getOutputTypesFor(...)
      • parseArgs

        public boolean parseArgs​(java.lang.String[] argv,
                                 Main main)
        Examine and consume command line arguments.
        Specified by:
        parseArgs in interface Generator
        Overrides:
        parseArgs in class Generator
        Parameters:
        argv - The command line arguments. Ignore null and unknown arguments. Set each consumed argument to null.
        main - Report any errors using the main.error() methods.
        Returns:
        true if no errors, false otherwise.
      • getOutputTypesFor

        protected Generator.OutputType[] getOutputTypesFor​(CompoundType topType,
                                                           java.util.HashSet<Type> alreadyChecked)
        Return an array of OutputTypes for the IDL files that need to be generated for the given top-level type. OutputTypes contain filename string (not directory) and Type.
        Specified by:
        getOutputTypesFor in class Generator
        Parameters:
        topType - The type returned by getTopType().
        alreadyChecked - A set of Types which have already been checked.
        Returns:
        Array of OutputTypes to generate
      • getAllReferencesFor

        protected java.util.Vector<Type> getAllReferencesFor​(CompoundType ct)
        Get all referenced types of a given tyoe for which an IDL file needs to be generated.
        Parameters:
        ct - The given type.
        Returns:
        Vector of Types for which IDL must be generated.
      • accumulateReferences

        protected void accumulateReferences​(java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                            java.util.Hashtable<java.lang.String,​CompoundType> spcHash,
                                            java.util.Hashtable<java.lang.String,​ArrayType> arrHash)
        Accumulate and filter all those types that are referenced by the given referenced types. Keep only those for which IDL is to be generated.
        Parameters:
        refHash - Hashtable containing the given types
        spcHash - Hashtable containing referenced specials (IDL typedefs)
        arrHash - Hashtable containing referenced arrays (dimensioned)
      • isIDLGeneratedFor

        protected boolean isIDLGeneratedFor​(CompoundType t)
        Determine if IDL should be generated for a referenced type. Do not generate IDL for a CORBA Object reference. It gets mapped to the original IDL or to Object (if exactly org.omg.CORBA.Object) Generate (boxed) IDL for an IDL Entity unless it is an IDL user exception, a ValueBase, an AbstractBase (or a CORBA Object). Do not generate IDL for Implementation classes..unless they inherit from multiple distinct remote interfaces
        Parameters:
        t - The type to check.
        Returns:
        true or false
      • writeOutputFor

        protected void writeOutputFor​(Generator.OutputType ot,
                                      java.util.HashSet<Type> alreadyChecked,
                                      IndentingWriter p)
                               throws java.io.IOException
        Write the output for the given OutputFileName into the output stream. (The IDL mapping for java.lang.Class is generated from javax.rmi.CORBA.ClassDesc in the tools workspace)
        Specified by:
        writeOutputFor in class Generator
        Parameters:
        ot - One of the items returned by getOutputTypesFor(...)
        alreadyChecked - A set of Types which have already been checked. Intended to be passed to Type.collectMatching(filter,alreadyChecked).
        p - The output stream.
        Throws:
        java.io.IOException
      • writeImplementation

        protected void writeImplementation​(ImplementationType t,
                                           IndentingWriter p)
                                    throws java.io.IOException
        Write an IDL interface definition for a Java implementation class
        Parameters:
        t - The current ImplementationType
        p - The output stream.
        Throws:
        java.io.IOException
      • writeNCType

        protected void writeNCType​(CompoundType type,
                                   IndentingWriter stream)
                            throws java.io.IOException
        Write an IDL valuetype definition for 1) a nonconforming Java class 2) a nonconforming Java interface (that is not an AbstractType)
        Parameters:
        type - The current NC Type (NCClassType or NCInterfaceType)
        stream - The output stream.
        Throws:
        java.io.IOException
      • writeRemote

        protected void writeRemote​(RemoteType t,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write an IDL interface definition for either: 1) a conforming Java remote interface (RemoteType)..or 2) a non-conforming Java interface whose methods all throw java.rmi.RemoteException (AbstractType)
        Parameters:
        t - The current RemoteType
        p - The output stream.
        Throws:
        java.io.IOException
      • writeValue

        protected void writeValue​(ValueType type,
                                  IndentingWriter outputStream)
                           throws java.io.IOException
        Write an IDL valuetype definition for a conforming Java class. Methods and constructors are optional..controlled by -valueMethods flag
        Parameters:
        type - The current ValueType
        outputStream - The output stream.
        Throws:
        java.io.IOException
      • writeProlog

        protected void writeProlog​(CompoundType t,
                                   java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                   java.util.Hashtable<java.lang.String,​CompoundType> spcHash,
                                   java.util.Hashtable<java.lang.String,​ArrayType> arrHash,
                                   java.util.Hashtable<java.lang.String,​CompoundType> excHash,
                                   java.util.Hashtable<java.lang.String,​CompoundType> inhHash,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write IDL prolog for a CompoundType.
        Parameters:
        t - The CompoundType.
        refHash - Hashtable loaded with type references.
        spcHash - Hashtable loaded with special type references.
        arrHash - Hashtable loaded with array references.
        excHash - Hashtable loaded with exceptions thrown.
        inhHash - Hashtable loaded with inherited types.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeEpilog

        protected void writeEpilog​(CompoundType t,
                                   java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write IDL epilog for a CompoundType.
        Parameters:
        t - The CompoundType.
        refHash - Hashtable loaded with type references.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeSpecial

        protected void writeSpecial​(Type t,
                                    IndentingWriter p)
                             throws java.io.IOException
        Write special typedef
        Parameters:
        t - A special Type.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeJavaIoSerializable

        protected void writeJavaIoSerializable​(Type t,
                                               IndentingWriter p)
                                        throws java.io.IOException
        Write a hard-coded IDL typedef definition for the special case java.io.Serializable.
        Parameters:
        t - The current Type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeJavaIoExternalizable

        protected void writeJavaIoExternalizable​(Type t,
                                                 IndentingWriter p)
                                          throws java.io.IOException
        Write a hard-coded IDL typedef definition for the special case java.io.Externalizable.
        Parameters:
        t - The current Type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeJavaLangObject

        protected void writeJavaLangObject​(Type t,
                                           IndentingWriter p)
                                    throws java.io.IOException
        Write a hard-coded IDL typedef definition for the special case java.lang.Object.
        Parameters:
        t - The current Type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeJavaRmiRemote

        protected void writeJavaRmiRemote​(Type t,
                                          IndentingWriter p)
                                   throws java.io.IOException
        Write a hard-coded IDL typedef definition for the special case java.rmi.Remote.
        Parameters:
        t - The current Type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeIDLEntity

        protected void writeIDLEntity​(Type t,
                                      IndentingWriter p)
                               throws java.io.IOException
        Write a hard-coded IDL typedef definition for the special case org.omg.CORBA.portable.IDLEntity
        Parameters:
        t - The current Type
        p - The output stream.
        Throws:
        java.io.IOException
      • getInterfaces

        protected void getInterfaces​(CompoundType ct,
                                     java.util.Hashtable<java.lang.String,​CompoundType> inhHash)
        Filter and collect non-duplicate inherited interfaces for a type
        Parameters:
        ct - The current CompoundType
        inhHash - Hashtable containing the inherited interfaces
      • getInheritance

        protected void getInheritance​(CompoundType ct,
                                      java.util.Hashtable<java.lang.String,​CompoundType> inhHash)
        Filter and add base class inheritance for a class type
        Parameters:
        ct - The current CompoundType
        inhHash - Hashtable containing inherited types
      • getMethodReferences

        protected void getMethodReferences​(java.util.Vector<CompoundType.Method> mthVec,
                                           java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                           java.util.Hashtable<java.lang.String,​CompoundType> spcHash,
                                           java.util.Hashtable<java.lang.String,​ArrayType> arrHash,
                                           java.util.Hashtable<java.lang.String,​CompoundType> excHash)
        Collect and filter type and array references from methods
        Parameters:
        mthVec - Given Vector of methods
        refHash - Hashtable for type references
        spcHash - Hashtable for special type references
        arrHash - Hashtable for array references
        excHash - Hashtable for exceptions thrown
      • getMemberReferences

        protected void getMemberReferences​(java.util.Vector<CompoundType.Member> datVec,
                                           java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                           java.util.Hashtable<java.lang.String,​CompoundType> spcHash,
                                           java.util.Hashtable<java.lang.String,​ArrayType> arrHash)
        Collect and filter type and array references from data members
        Parameters:
        datVec - Given Vector of data members
        refHash - Hashtable for type references
        spcHash - Hashtable for special type references
        arrHash - Hashtable for array references
      • addReference

        protected void addReference​(Type ref,
                                    java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                    java.util.Hashtable<java.lang.String,​CompoundType> spcHash,
                                    java.util.Hashtable<java.lang.String,​ArrayType> arrHash)
        Add reference for given type avoiding duplication. Sort into specials, arrays and regular references. Filter out types which are not required.
        Parameters:
        ref - Given Type
        refHash - Hashtable for type references
        spcHash - Hashtable for special type references
        arrHash - Hashtable for array references
      • isSpecialReference

        protected boolean isSpecialReference​(Type ref)
        Determine whether given Type is a special reference. Special cases are: java.io.Serializable, java.io.Externalizable, java.lang.Object, java.rmi.Remote and org.omg.CORBA.portable.IDLEntity They are special because they have a hard-coded typedef defined in the spec.
        Parameters:
        ref - A referenced Type
        Returns:
        boolean indicating whether it's a special reference
      • getExceptions

        protected void getExceptions​(CompoundType.Method mth,
                                     java.util.Hashtable<java.lang.String,​CompoundType> excHash)
        Collect and filter thrown exceptions for a given pre-filtered method. Keep only 'checked' exception classes minus java.rmi.RemoteException and its subclasses
        Parameters:
        mth - The current method
        excHash - Hashtable containing non-duplicate thrown exceptions
      • getMethods

        protected java.util.Vector<CompoundType.Method> getMethods​(CompoundType ct)
        Collect and filter methods for a type. Remove any private or inherited methods.
        Parameters:
        ct - The current CompoundType
        Returns:
        Vector containing the methods
      • getConstants

        protected java.util.Vector<CompoundType.Member> getConstants​(CompoundType ct)
        Collect constants for a type. A valid constant is a "public final static" field with a compile-time constant value for a primitive type or String
        Parameters:
        ct - The current CompoundType
        Returns:
        Vector containing the constants
      • getData

        protected java.util.Vector<CompoundType.Member> getData​(CompoundType t)
        Collect and sort data fields for a ValueType. Sort in Java (not IDL) Unicode name string lexicographic increasing order. Non-static, non-transient fields are mapped. If the type is a custom valuetype, only public fields are mapped.
        Parameters:
        t - The current CompoundType
        Returns:
        Vector containing the data fields
      • writeForwardReferences

        protected void writeForwardReferences​(java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                              IndentingWriter p)
                                       throws java.io.IOException
        Write forward references for referenced interfaces and valuetypes ...but not if the reference is to a boxed IDLEntity,
        Parameters:
        refHash - Hashtable loaded with referenced types
        p - The output stream.
        Throws:
        java.io.IOException
      • writeForwardReference

        protected void writeForwardReference​(Type t,
                                             IndentingWriter p)
                                      throws java.io.IOException
        Write forward reference for given type
        Parameters:
        t - Given type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeForwardReference

        protected void writeForwardReference​(ArrayType at,
                                             int dim,
                                             IndentingWriter p)
                                      throws java.io.IOException
        Write forward reference for boxed valuetype for single dimension of IDL sequence. If the dimension is < 1 and the element is a CompoundType, write a forward declare for the element
        Parameters:
        at - ArrayType for forward declare
        dim - The dimension to write
        p - The output stream.
        Throws:
        java.io.IOException
      • writeIDLEntityIncludes

        protected void writeIDLEntityIncludes​(java.util.Hashtable<java.lang.String,​CompoundType> refHash,
                                              IndentingWriter p)
                                       throws java.io.IOException
        Write #includes for boxed IDLEntity references.
        Parameters:
        refHash - Hashtable loaded with referenced types
        p - The output stream.
        Throws:
        java.io.IOException
      • writeIncludes

        protected void writeIncludes​(java.util.Hashtable<java.lang.String,​CompoundType> incHash,
                                     boolean isThrown,
                                     IndentingWriter p)
                              throws java.io.IOException
        Write #includes
        Parameters:
        incHash - Hashtable loaded with Types to include
        isThrown - true if Types are thrown exceptions
        p - The output stream.
        Throws:
        java.io.IOException
      • writeBoxedRMIIncludes

        protected void writeBoxedRMIIncludes​(java.util.Hashtable<java.lang.String,​ArrayType> arrHash,
                                             IndentingWriter p)
                                      throws java.io.IOException
        Write includes for boxedRMI valuetypes for IDL sequences. Write only the maximum dimension found for an ArrayType.
        Parameters:
        arrHash - Hashtable loaded with array types
        p - The output stream.
        Throws:
        java.io.IOException
      • writeInheritedIncludes

        protected void writeInheritedIncludes​(java.util.Hashtable<java.lang.String,​CompoundType> inhHash,
                                              IndentingWriter p)
                                       throws java.io.IOException
        Write #includes
        Parameters:
        inhHash - Hashtable loaded with Types to include
        p - The output stream.
        Throws:
        java.io.IOException
      • writeInclude

        protected void writeInclude​(Type t,
                                    int dim,
                                    boolean isThrown,
                                    IndentingWriter p)
                             throws java.io.IOException
        Write a #include.
        Parameters:
        t - Type to include
        dim - The dimension to write if t is an array.
        isThrown - boolean indicating if include is for thrown exception.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeInclude

        protected void writeInclude​(Type t,
                                    java.lang.String[] modNames,
                                    java.lang.String tName,
                                    IndentingWriter p)
                             throws java.io.IOException
        Write a #include doing user specified -idlFile translation (if any) for IDLEntities.
        Parameters:
        t - Type to include.
        modNames - Preprocessed module names (default).
        tName - Preprocessed Type name (default).
        p - The output stream.
        Throws:
        java.io.IOException
      • getQualifiedName

        protected java.lang.String getQualifiedName​(Type t)
        Return the fully qualified Java Name for a Type. IDLEntity preprocessing done by getIDLModuleNames(t)
        Parameters:
        t - Given Type
        Returns:
        Array containing the original module nesting.
      • getQualifiedIDLName

        protected java.lang.String getQualifiedIDLName​(Type t)
        Return the global fully qualified IDL Name for a Type. IDLEntity preprocessing done by getIDLModuleNames(t)
        Parameters:
        t - Given Type
        Returns:
        Array containing the original module nesting.
      • getIDLModuleNames

        protected java.lang.String[] getIDLModuleNames​(Type t)
        Return the IDL module nesting of the given Type. For IDLEntity CompoundTypes (or their arrays) apply any user specified -idlModule translation or, if none applicable, strip any package prefix. Add boxedIDL or boxedRMI modules if required.
        Parameters:
        t - Given Type
        Returns:
        Array containing the original module nesting.
      • translateJavaPackage

        protected boolean translateJavaPackage​(CompoundType ct,
                                               java.util.Vector<java.lang.String> vec)
        Apply user specified -idlModule translation to package names of given IDLEntity ct. Example: -idlModule foo.bar real::mod::nesting
        Parameters:
        ct - CompoundType containing given IDLEntity.
        vec - Returned Vector of translated IDL module names.
        Returns:
        boolean true if any translation was done.
      • stripJavaPackage

        protected void stripJavaPackage​(CompoundType ct,
                                        java.util.Vector<java.lang.String> vec)
        Strip Java #pragma prefix and/or -pkgPrefix prefix package names from given IDLEntity ct. Strip any package prefix which may have been added by comparing with repository id. For example in Java package fake.omega: repid = IDL:phoney.pfix/omega/Juliet:1.0 gives { "omega" }
        Parameters:
        ct - CompoundType containing given IDLEntity.
        vec - Returned Vector of stripped IDL module names.
      • writeSequence

        protected void writeSequence​(Generator.OutputType ot,
                                     IndentingWriter p)
                              throws java.io.IOException
        Write boxedRMI valuetype for a single dimension of an IDL sequence indicated by the given OutputType. The filename for the OutputType is of the form "seqn_elemName" where n is the dimension required.
        Parameters:
        ot - Given OutputType.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeBoxedIDL

        protected void writeBoxedIDL​(CompoundType t,
                                     IndentingWriter p)
                              throws java.io.IOException
        Write valuetype for a boxed IDLEntity.
        Parameters:
        t - Given CompoundType representing the IDLEntity.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeException

        protected void writeException​(ClassType t,
                                      IndentingWriter p)
                               throws java.io.IOException
        Write an exception.
        Parameters:
        t - Given ClassType representing the exception.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeRepositoryID

        protected void writeRepositoryID​(Type t,
                                         IndentingWriter p)
                                  throws java.io.IOException
        Write #pragma to identify the repository ID of the given type
        Parameters:
        t - The given Type.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeInherits

        protected void writeInherits​(java.util.Hashtable<java.lang.String,​CompoundType> inhHash,
                                     boolean forValuetype,
                                     IndentingWriter p)
                              throws java.io.IOException
        Write inheritance for an IDL interface or valuetype. Any class inheritance precedes any interface inheritance. For a valutype any inheritance from abstract interfaces then follows the "supports" keyword.
        Parameters:
        inhHash - Hashtable loaded with inherited Types
        forValuetype - true if writing inheritance for a valuetype
        p - The output stream.
        Throws:
        java.io.IOException
      • writeConstant

        protected void writeConstant​(CompoundType.Member constant,
                                     IndentingWriter p)
                              throws java.io.IOException
        Write an IDL constant
        Parameters:
        constant - The current CompoundType.Member constant
        p - The output stream.
        Throws:
        java.io.IOException
      • writeData

        protected void writeData​(CompoundType.Member data,
                                 IndentingWriter p)
                          throws java.io.IOException
        Write an IDL data member
        Parameters:
        data - The current CompoundType.Member data member
        p - The output stream.
        Throws:
        java.io.IOException
      • writeAttribute

        protected void writeAttribute​(CompoundType.Method attr,
                                      IndentingWriter p)
                               throws java.io.IOException
        Write an IDL Attribute
        Parameters:
        attr - The current CompoundType.Method attribute
        p - The output stream.
        Throws:
        java.io.IOException
      • writeMethod

        protected void writeMethod​(CompoundType.Method method,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write an IDL method
        Parameters:
        method - The current CompoundType.Method
        p - The output stream.
        Throws:
        java.io.IOException
      • unEsc

        protected java.lang.String unEsc​(java.lang.String name)
        Remove escape character ("_"), if any, from given String
        Parameters:
        name - Given String
        Returns:
        String with any escape character removed
      • writeBanner

        protected void writeBanner​(Type t,
                                   int dim,
                                   boolean isException,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write IDL banner into the output stream for a given Type
        Parameters:
        t - The given Type.
        dim - The dimension required if t is an ArrayType.
        isException - true if writing an exception.
        p - The output stream.
        Throws:
        java.io.IOException
      • writeIncOrb

        protected void writeIncOrb​(IndentingWriter p)
                            throws java.io.IOException
        Write #include for orb.idl
        Parameters:
        p - The output stream.
        Throws:
        java.io.IOException
      • writeIfndef

        protected void writeIfndef​(Type t,
                                   int dim,
                                   boolean isException,
                                   boolean isForward,
                                   IndentingWriter p)
                            throws java.io.IOException
        Write #ifndef guard into the output stream for a given Type
        Parameters:
        t - The given Type.
        dim - The dimension required if t is an ArrayType.
        isException - true if writing an exception.
        isForward - No #define needed if it's a forward declare
        p - The output stream.
        Throws:
        java.io.IOException
      • writeEndif

        protected void writeEndif​(IndentingWriter p)
                           throws java.io.IOException
        Write #endif bracket into the output stream
        Parameters:
        p - The output stream.
        Throws:
        java.io.IOException
      • writeModule1

        protected void writeModule1​(Type t,
                                    IndentingWriter p)
                             throws java.io.IOException
        Write Module start bracketing for the given type into the output stream
        Parameters:
        t - The given Type
        p - The output stream.
        Throws:
        java.io.IOException
      • writeModule2

        protected void writeModule2​(Type t,
                                    IndentingWriter p)
                             throws java.io.IOException
        Write Module end bracketing for the given type into the output stream
        Parameters:
        t - The given Type
        p - The output stream.
        Throws:
        java.io.IOException