Class StubGenerator

    • Field Detail

      • DEFAULT_STUB_CLASS

        private static final java.lang.String DEFAULT_STUB_CLASS
        See Also:
        Constant Field Values
      • DEFAULT_TIE_CLASS

        private static final java.lang.String DEFAULT_TIE_CLASS
        See Also:
        Constant Field Values
      • DEFAULT_POA_TIE_CLASS

        private static final java.lang.String DEFAULT_POA_TIE_CLASS
        See Also:
        Constant Field Values
      • reverseIDs

        private boolean reverseIDs
      • localStubs

        private boolean localStubs
      • standardPackage

        private boolean standardPackage
      • useHash

        private boolean useHash
      • stubBaseClass

        private java.lang.String stubBaseClass
      • tieBaseClass

        private java.lang.String tieBaseClass
      • namesInUse

        private java.util.HashSet<java.lang.String> namesInUse
      • classesInUse

        private java.util.Hashtable<java.lang.String,​java.lang.String> classesInUse
      • imports

        private java.util.Hashtable<java.lang.String,​java.lang.String> imports
      • importCount

        private int importCount
      • currentPackage

        private java.lang.String currentPackage
      • currentClass

        private java.lang.String currentClass
      • castArray

        private boolean castArray
      • transactionalObjects

        private java.util.Hashtable<java.lang.String,​java.lang.Object> transactionalObjects
      • POATie

        private boolean POATie
      • emitPermissionCheck

        private boolean emitPermissionCheck
      • NO_IMPORT

        private static final java.lang.String NO_IMPORT
    • Constructor Detail

      • StubGenerator

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

      • generate

        public void generate​(BatchEnvironment env,
                             java.io.File destDir,
                             ClassDefinition cdef)
        Overridden in order to set the standardPackage flag.
        Specified by:
        generate in interface Generator
        Overrides:
        generate in class Generator
        Parameters:
        env - The compiler environment
        destDir - The directory for the root of the package hierarchy
        cdef - The definition for the implementation class or interface from which to generate output
      • 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:
        The compound type or null if is non-conforming.
      • 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 alreadyChecked)
        Return an array containing all the file names and types that need to be generated for the given top-level type. The file names must NOT have an extension (e.g. ".java").
        Specified by:
        getOutputTypesFor in class Generator
        Parameters:
        topType - The type returned by getTopType().
        alreadyChecked - A set of Types which have already been checked. Intended to be passed to topType.collectMatching(filter,alreadyChecked).
      • 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(...)
      • writeOutputFor

        protected void writeOutputFor​(Generator.OutputType outputType,
                                      java.util.HashSet alreadyChecked,
                                      IndentingWriter writer)
                               throws java.io.IOException
        Write the output for the given OutputFileName into the output stream.
        Specified by:
        writeOutputFor in class Generator
        Parameters:
        outputType - 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).
        writer - The output stream.
        Throws:
        java.io.IOException
      • writeStub

        private void writeStub​(Generator.OutputType outputType,
                               IndentingWriter p)
                        throws java.io.IOException
        Write a stub for the specified type.
        Throws:
        java.io.IOException
      • addClassInUse

        private void addClassInUse​(java.lang.String qualifiedName)
      • addClassInUse

        private void addClassInUse​(Type type)
      • addClassInUse

        private void addClassInUse​(Type[] types)
      • addStubInUse

        private void addStubInUse​(Type type)
      • getStubNameFor

        private java.lang.String getStubNameFor​(Type type,
                                                boolean qualified)
      • addStubInUse

        private void addStubInUse​(Type[] types)
      • addClassInUse

        void addClassInUse​(java.lang.String unqualifiedName,
                           java.lang.String qualifiedName,
                           java.lang.String packageName)
      • getName

        java.lang.String getName​(Type type)
      • getExceptionName

        java.lang.String getExceptionName​(Type type)
      • getName

        java.lang.String getName​(java.lang.String qualifiedName)
      • getName

        java.lang.String getName​(Identifier id)
      • getStubName

        java.lang.String getStubName​(Type type)
      • setStandardClassesInUse

        void setStandardClassesInUse​(CompoundType type,
                                     boolean stub)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writePackageAndImports

        private void writePackageAndImports​(IndentingWriter p)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • implementsRemote

        private boolean implementsRemote​(CompoundType theType)
      • allocateResult

        void allocateResult​(IndentingWriter p,
                            Type returnType)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getTypeCode

        int getTypeCode​(Type type)
      • writeMarshalArgument

        void writeMarshalArgument​(IndentingWriter p,
                                  java.lang.String streamName,
                                  Type type,
                                  java.lang.String name)
                           throws java.io.IOException
        Write a snippet of Java code to marshal a value named "name" of type "type" to the java.io.ObjectOutput stream named "stream".
        Throws:
        java.io.IOException
      • writeUnmarshalArgument

        void writeUnmarshalArgument​(IndentingWriter p,
                                    java.lang.String streamName,
                                    Type type,
                                    java.lang.String name)
                             throws java.io.IOException
        Write a snippet of Java code to unmarshal a value of type "type" from the java.io.ObjectInput stream named "stream" into a variable named "name" (if "name" is null, the value in unmarshalled and discarded).
        Throws:
        java.io.IOException
      • getAllRemoteRepIDs

        java.lang.String[] getAllRemoteRepIDs​(CompoundType theType)
        Get a list of all the RepositoryIDs for interfaces implemented directly or indirectly by theType. In the case of an ImplementationType which implements 2 or more remote interfaces, this list will begin with the Identifier for the implementation (see section 5.9 in the Java -> IDL mapping). Ensures that the most derived type is first in the list because the IOR is generated using that entry in the _ids array.
      • collectAllRemoteInterfaces

        Type[] collectAllRemoteInterfaces​(CompoundType theType)
        Collect all the inherited remote interfaces.
      • addRemoteInterfaces

        void addRemoteInterfaces​(java.util.Vector<CompoundType> list,
                                 CompoundType theType)
        Add all the inherited remote interfaces to list.
      • getDirectRemoteInterfaces

        RemoteType[] getDirectRemoteInterfaces​(CompoundType theType)
        Get a list of all the remote interfaces which this stub should declare.
      • countRemote

        int countRemote​(Type[] list,
                        boolean includeAbstract)
      • writeCastArray

        void writeCastArray​(IndentingWriter p)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIds

        void writeIds​(IndentingWriter p,
                      CompoundType theType,
                      boolean isTie)
               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTie

        protected void writeTie​(Generator.OutputType outputType,
                                IndentingWriter p)
                         throws java.io.IOException
        Write the Tie for the remote class to a stream.
        Throws:
        java.io.IOException
      • catchWrongPolicy

        public void catchWrongPolicy​(IndentingWriter p)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • catchServantNotActive

        public void catchServantNotActive​(IndentingWriter p)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • catchObjectNotActive

        public void catchObjectNotActive​(IndentingWriter p)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • write_tie_thisObject_method

        public void write_tie_thisObject_method​(IndentingWriter p,
                                                Identifier idCorbaObject)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • write_tie_deactivate_method

        public void write_tie_deactivate_method​(IndentingWriter p)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • write_tie_orb_method

        public void write_tie_orb_method​(IndentingWriter p)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • write_tie__ids_method

        public void write_tie__ids_method​(IndentingWriter p)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • needNewReadStreamClass

        static boolean needNewReadStreamClass​(Type type)
      • needNewWriteStreamClass

        static boolean needNewWriteStreamClass​(Type type)
      • getRepositoryID

        java.lang.String getRepositoryID​(Type type)
      • getExceptionRepositoryID

        java.lang.String getExceptionRepositoryID​(Type type)
      • getVariableName

        java.lang.String getVariableName​(java.lang.String proposed)
      • addNameInUse

        void addNameInUse​(java.lang.String name)
      • mustCopy

        static boolean mustCopy​(Type type)
      • writeMarshalArguments

        void writeMarshalArguments​(IndentingWriter p,
                                   java.lang.String streamName,
                                   Type[] types,
                                   java.lang.String[] names)
                            throws java.io.IOException
        Write Java statements to marshal a series of values in order as named in the "names" array, with types as specified in the "types" array", to the java.io.ObjectOutput stream named "stream".
        Throws:
        java.io.IOException
      • testUtil

        java.lang.String testUtil​(java.lang.String objectName,
                                  Type ttype)
        Added for IASRI 4987274. Remote classes named "Util" were getting confused with javax.rmi.CORBA.Util and the unqualifiedName "Util".
      • postProcessFile

        protected void postProcessFile​(BatchEnvironment env,
                                       java.io.File file)
                                throws java.io.FileNotFoundException
        Overrides:
        postProcessFile in class Generator
        Throws:
        java.io.FileNotFoundException