Class Type

  • All Implemented Interfaces:
    java.lang.Cloneable, Constants, Constants, ContextElement, Constants, RuntimeConstants
    Direct Known Subclasses:
    ArrayType, CompoundType, PrimitiveType

    public abstract class Type
    extends java.lang.Object
    implements Constants, ContextElement, java.lang.Cloneable
    Type is an abstract base class for a family of types which provide conformance checking and name mapping as defined in the "Java to IDL Mapping" OMG specification. The family is composed of the following fixed set of types:
    
                                                  +- RemoteType <-- AbstractType
                                                  |
                               +- InterfaceType <-+- SpecialInterfaceType
             +- PrimitiveType  |                  |
             |                 |                  +- NCInterfaceType
      Type <-+- CompoundType <-|
             |                 |                  +- ValueType
             +- ArrayType      |                  |
                               +- ClassType <-----+- ImplementationType
                                                  |
                                                  +- SpecialClassType
                                                  |
                                                  +- NCClassType
    
     
    PrimitiveType represents a primitive or a void type.

    CompoundType is an abstract base representing any non-special class or interface type.

    InterfaceType is an abstract base representing any non-special interface type.

    RemoteType represents any non-special interface which inherits from java.rmi.Remote.

    AbstractType represents any non-special interface which does not inherit from java.rmi.Remote, for which all methods throw RemoteException.

    SpecialInterfaceType represents any one of the following types:

        java.rmi.Remote
        java.io.Serializable
        java.io.Externalizable
     
    all of which are treated as special cases.

    NCInterfaceType represents any non-special, non-conforming interface.

    ClassType is an abstract base representing any non-special class type.

    ValueType represents any non-special class which does inherit from java.io.Serializable and does not inherit from java.rmi.Remote.

    ImplementationType represents any non-special class which implements one or more interfaces which inherit from java.rmi.Remote.

    SpecialClassType represents any one of the following types:

        java.lang.Object
        java.lang.String
        org.omg.CORBA.Object
     
    all of which are treated as special cases. For all but CORBA.Object, the type must match exactly. For CORBA.Object, the type must either be CORBA.Object or inherit from it.

    NCClassType represents any non-special, non-conforming class.

    ArrayType is a wrapper for any of the other types. The getElementType() method can be used to get the array element type. The getArrayDimension() method can be used to get the array dimension.

    NOTE: None of these types is multi-thread-safe

    • Field Detail

      • typeCode

        private int typeCode
      • fullTypeCode

        private int fullTypeCode
      • name

        private java.lang.String name
      • packageName

        private java.lang.String packageName
      • qualifiedName

        private java.lang.String qualifiedName
      • idlName

        private java.lang.String idlName
      • idlModuleNames

        private java.lang.String[] idlModuleNames
      • qualifiedIDLName

        private java.lang.String qualifiedIDLName
      • repositoryID

        private java.lang.String repositoryID
      • ourClass

        private java.lang.Class<?> ourClass
      • status

        private int status
      • destroyed

        protected boolean destroyed
    • Constructor Detail

      • Type

        protected Type​(ContextStack stack,
                       int fullTypeCode)
        Create a Type instance for the given type. Requires that setName(Identifier) be called afterward.
      • Type

        private Type()
    • Method Detail

      • getName

        public java.lang.String getName()
        Return the unqualified name for this type (e.g. com.acme.Dynamite would return "Dynamite").
      • getPackageName

        public java.lang.String getPackageName()
        Return the package of this type (e.g. com.acme.Dynamite would return "com.acme"). Will return null if default package or if this type is a primitive.
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Return the fully qualified name of this type (e.g. com.acme.Dynamite would return "com.acme.Dynamite")
      • getSignature

        public abstract java.lang.String getSignature()
        Return signature for this type (e.g. com.acme.Dynamite would return "com.acme.Dynamite", byte = "B")
      • getIDLName

        public java.lang.String getIDLName()
        IDL_Naming Return the unqualified IDL name of this type (e.g. com.acme.Dynamite would return "Dynamite").
      • getIDLModuleNames

        public java.lang.String[] getIDLModuleNames()
        IDL_Naming Return the IDL module name for this type (e.g. com.acme.Dynamite would return a three element array of {"com","acme"). May be a zero length array if there is no module name.
      • getQualifiedIDLName

        public java.lang.String getQualifiedIDLName​(boolean global)
        IDL_Naming Return the fully qualified IDL name for this type (e.g. com.acme.Dynamite would return "com::acme::Dynamite").
        Parameters:
        global - If true, prepends "::".
      • getIdentifier

        public Identifier getIdentifier()
        Return the identifier for this type. May be qualified.
      • getRepositoryID

        public java.lang.String getRepositoryID()
        Return the repository ID for this type.
      • getBoxedRepositoryID

        public java.lang.String getBoxedRepositoryID()
        Return the repository ID for this "boxed" type.
      • getClassInstance

        public java.lang.Class<?> getClassInstance()
        Return the Class for this type.
      • getStatus

        public int getStatus()
        Return the status of this type.
      • setStatus

        public void setStatus​(int status)
        Set the status of this type.
      • getEnv

        public BatchEnvironment getEnv()
        Return the compiler environment for this type.
      • getTypeCode

        public int getTypeCode()
        Get type code, without modifiers. Type codes are defined in org.glassfish.rmic.iiop.Constants.
      • getFullTypeCode

        public int getFullTypeCode()
        Get type code, with modifiers. Type codes are defined in org.glassfish.rmic.iiop.Constants.
      • getTypeCodeModifiers

        public int getTypeCodeModifiers()
        Get type code modifiers. Type codes are defined in org.glassfish.rmic.iiop.Constants.
      • isType

        public boolean isType​(int typeCodeMask)
        Check for a certain type. Type codes are defined in org.glassfish.rmic.iiop.Constants. Returns true if all of the bits in typeCodeMask are present in the full type code of this object.
      • typeMatches

        public boolean typeMatches​(int typeCodeMask)
        Like isType(), but returns true if any of the bits in typeCodeMask are present in the full type code of this object.
      • getRootTypeCode

        public int getRootTypeCode()
        Return the fullTypeCode. If an array, returns the type code from the element type.
      • isInterface

        public boolean isInterface()
        Return true if this type is-a InterfaceType.
      • isClass

        public boolean isClass()
        Return true if this type is-a ClassType.
      • isInner

        public boolean isInner()
        Return true if this type is-a inner class or interface.
      • isSpecialInterface

        public boolean isSpecialInterface()
        Return true if this type is-a SpecialInterfaceType.
      • isSpecialClass

        public boolean isSpecialClass()
        Return true if this type is-a SpecialClassType.
      • isCompound

        public boolean isCompound()
        Return true if this type is-a CompoundType.
      • isPrimitive

        public boolean isPrimitive()
        Return true if this type is-a PrimitiveType.
      • isArray

        public boolean isArray()
        Return true if this type is-a ArrayType.
      • isConforming

        public boolean isConforming()
        Return true if this type is a conforming type.
      • toString

        public java.lang.String toString()
        Return a string representation of this type.
        Overrides:
        toString in class java.lang.Object
      • getElementType

        public Type getElementType()
        Get element type. Returns null if not an array.
      • getArrayDimension

        public int getArrayDimension()
        Get array dimension. Returns zero if not an array.
      • getArrayBrackets

        public java.lang.String getArrayBrackets()
        Get brackets string. Returns "" if not an array.
      • equals

        public boolean equals​(java.lang.Object obj)
        Equality check based on the string representation.
        Overrides:
        equals in class java.lang.Object
      • collectMatching

        public Type[] collectMatching​(int typeCodeFilter)
        Collect all the matching types referenced directly or indirectly by this type, including itself.
        Parameters:
        typeCodeFilter - The typeCode to use as a filter.
      • collectMatching

        public Type[] collectMatching​(int typeCodeFilter,
                                      java.util.HashSet<Type> alreadyChecked)
        Collect all the matching types referenced directly or indirectly by this type, including itself.
        Parameters:
        typeCodeFilter - The typeCode to use as a filter.
        alreadyChecked - Contains types which have previously been checked and will be ignored. Updated during collection.
      • getTypeDescription

        public abstract java.lang.String getTypeDescription()
        Return a string describing this type.
      • getTypeName

        public java.lang.String getTypeName​(boolean useQualifiedNames,
                                            boolean useIDLNames,
                                            boolean globalIDLNames)
        Return the name of this type. For arrays, will include "[]" if useIDLNames == false.
        Parameters:
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
      • print

        public void print​(IndentingWriter writer,
                          int typeCodeFilter,
                          boolean useQualifiedNames,
                          boolean useIDLNames,
                          boolean globalIDLNames)
                   throws java.io.IOException
        Print all types referenced directly or indirectly by this type which match the filter.
        Parameters:
        writer - The stream to print to.
        typeCodeFilter - The type codes to print.
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
        Throws:
        java.io.IOException
      • print

        public static void print​(IndentingWriter writer,
                                 Type[] theTypes,
                                 boolean useQualifiedNames,
                                 boolean useIDLNames,
                                 boolean globalIDLNames)
                          throws java.io.IOException
        Print an array of types.
        Parameters:
        writer - The stream to print to.
        theTypes - The types to print.
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
        Throws:
        java.io.IOException
      • print

        public void print​(IndentingWriter writer,
                          boolean useQualifiedNames,
                          boolean useIDLNames,
                          boolean globalIDLNames)
                   throws java.io.IOException
        Print this type.
        Parameters:
        writer - The stream to print to.
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
        Throws:
        java.io.IOException
      • println

        public void println​(IndentingWriter writer,
                            boolean useQualifiedNames,
                            boolean useIDLNames,
                            boolean globalIDLNames)
                     throws java.io.IOException
        Print this type, followed by a newline.
        Parameters:
        writer - The stream to print to.
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
        Throws:
        java.io.IOException
      • printTypeName

        public void printTypeName​(IndentingWriter writer,
                                  boolean useQualifiedNames,
                                  boolean useIDLNames,
                                  boolean globalIDLNames)
                           throws java.io.IOException
        Print the name of this type.
        Parameters:
        writer - The stream to print to.
        useQualifiedNames - If true, print qualified names; otherwise, print unqualified names.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        globalIDLNames - If true and useIDLNames true, prepends "::".
        Throws:
        java.io.IOException
      • getElementName

        public java.lang.String getElementName()
        Return context element name.
        Specified by:
        getElementName in interface ContextElement
      • printPackageOpen

        protected void printPackageOpen​(IndentingWriter writer,
                                        boolean useIDLNames)
                                 throws java.io.IOException
        Print the "opening" of the package or module of this type.
        Parameters:
        writer - The stream to print to.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        Throws:
        java.io.IOException
      • getType

        protected static Type getType​(Type key,
                                      ContextStack stack)
        Get a type out of the table.
      • getType

        protected static Type getType​(java.lang.String key,
                                      ContextStack stack)
        Get a type out of the table.
      • removeType

        protected static void removeType​(java.lang.String key,
                                         ContextStack stack)
        Remove a type from the table.
      • removeType

        protected static void removeType​(Type key,
                                         ContextStack stack)
        Remove a type from the table.
      • putType

        protected static void putType​(Type key,
                                      Type value,
                                      ContextStack stack)
        Put a type into the table.
      • putType

        protected static void putType​(java.lang.String key,
                                      Type value,
                                      ContextStack stack)
        Put a type into the table.
      • putInvalidType

        protected static void putInvalidType​(Type key,
                                             java.lang.String value,
                                             ContextStack stack)
        Put an invalid type into the.
      • removeInvalidTypes

        public void removeInvalidTypes()
        Remove all invalid types...
      • updateAllInvalidTypes

        protected static void updateAllInvalidTypes​(ContextStack stack)
        Walk all types and tell them to update invalid types...
      • countTypes

        protected int countTypes()
        Return count of previously parsed types.
      • resetTypes

        void resetTypes()
        Reset types removes all previously parsed types.
      • destroy

        protected void destroy()
        Release all resources.
      • swapInvalidTypes

        protected void swapInvalidTypes()
        Convert all invalid types to valid ones.
      • getValidType

        protected Type getValidType​(Type invalidType)
        Convert an invalid type to a valid one.
      • printPackageClose

        protected void printPackageClose​(IndentingWriter writer,
                                         boolean useIDLNames)
                                  throws java.io.IOException
        Print the "closing" of the package or module of this type.
        Parameters:
        writer - The stream to print to.
        useIDLNames - If true, print IDL names; otherwise, print java names.
        Throws:
        java.io.IOException
      • setTypeCode

        protected void setTypeCode​(int fullTypeCode)
        Set type codes. May only be called during initialization.
      • setNames

        protected void setNames​(Identifier id,
                                java.lang.String[] idlModuleNames,
                                java.lang.String idlName)
        Set name and package. May only be called during initialization.
      • setIDLNames

        protected void setIDLNames​(java.lang.String[] idlModuleNames,
                                   java.lang.String idlName)
        Set IDL name. May only be called during initialization.
      • classNotFound

        protected static void classNotFound​(ContextStack stack,
                                            ClassNotFound e)
        Report a ClassNotFoundException thru the compiler environment.
      • classNotFound

        protected static void classNotFound​(boolean quiet,
                                            ContextStack stack,
                                            ClassNotFound e)
        Report a ClassNotFoundException thru the compiler environment.
      • failedConstraint

        protected static boolean failedConstraint​(int constraintNum,
                                                  boolean quiet,
                                                  ContextStack stack,
                                                  java.lang.Object arg0,
                                                  java.lang.Object arg1,
                                                  java.lang.Object arg2)
        Report a constraint failure thru the compiler environment.
        Parameters:
        constraintNum - Used to generate a key of the form "rmic.iiop.constraint.N", which must identify a message in the "rmic.properties" file.
        quiet - True if should not cause failure or message.
        stack - The context stack.
        arg0 - An object to substitute for {0} in the message.
        arg1 - An object to substitute for {1} in the message.
        arg2 - An object to substitute for {2} in the message.
        Returns:
        false.
      • failedConstraint

        protected static boolean failedConstraint​(int constraintNum,
                                                  boolean quiet,
                                                  ContextStack stack,
                                                  java.lang.Object arg0,
                                                  java.lang.Object arg1)
        Report a constraint failure thru the compiler environment.
        Parameters:
        constraintNum - Used to generate a key of the form "rmic.iiop.constraint.N", which must identify a message in the "rmic.properties" file.
        quiet - True if should not cause failure or message.
        stack - The context stack.
        arg0 - An object to substitute for {0} in the message.
        arg1 - An object to substitute for {1} in the message.
        Returns:
        false.
      • failedConstraint

        protected static boolean failedConstraint​(int constraintNum,
                                                  boolean quiet,
                                                  ContextStack stack,
                                                  java.lang.Object arg0)
        Report a constraint failure thru the compiler environment.
        Parameters:
        constraintNum - Used to generate a key of the form "rmic.iiop.constraint.N", which must identify a message in the "rmic.properties" file.
        quiet - True if should not cause failure or message.
        stack - The context stack.
        arg0 - An object to substitute for {0} in the message.
        Returns:
        false.
      • failedConstraint

        protected static boolean failedConstraint​(int constraintNum,
                                                  boolean quiet,
                                                  ContextStack stack)
        Report a constraint failure thru the compiler environment.
        Parameters:
        quiet - True if should not cause failure or message.
        stack - The context stack.
        constraintNum - Used to generate a key of the form "rmic.iiop.constraint.N", which must identify a message in the "rmic.properties" file.
        Returns:
        false.
      • clone

        protected java.lang.Object clone()
        Cloning is supported by returning a shallow copy of this object.
        Overrides:
        clone in class java.lang.Object
      • addTypes

        protected boolean addTypes​(int typeCodeFilter,
                                   java.util.HashSet<Type> checked,
                                   java.util.Vector<Type> matching)
      • loadClass

        protected abstract java.lang.Class<?> loadClass()
      • initClass

        private boolean initClass()
      • setRepositoryID

        protected boolean setRepositoryID()