Class Type

java.lang.Object
org.glassfish.rmic.iiop.Type
All Implemented Interfaces:
Cloneable, Constants, Constants, ContextElement, Constants, RuntimeConstants
Direct Known Subclasses:
ArrayType, CompoundType, PrimitiveType

public abstract class Type extends Object implements Constants, ContextElement, 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 Details

    • typeCode

      private int typeCode
    • fullTypeCode

      private int fullTypeCode
    • id

      private Identifier id
    • name

      private String name
    • packageName

      private String packageName
    • qualifiedName

      private String qualifiedName
    • idlName

      private String idlName
    • idlModuleNames

      private String[] idlModuleNames
    • qualifiedIDLName

      private String qualifiedIDLName
    • repositoryID

      private String repositoryID
    • ourClass

      private Class<?> ourClass
    • status

      private int status
    • env

      protected BatchEnvironment env
    • stack

      protected ContextStack stack
    • destroyed

      protected boolean destroyed
  • Constructor Details

    • 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 Details

    • getName

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

      public 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 String getQualifiedName()
      Return the fully qualified name of this type (e.g. com.acme.Dynamite would return "com.acme.Dynamite")
    • getSignature

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

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

      public 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 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 String getRepositoryID()
      Return the repository ID for this type.
    • getBoxedRepositoryID

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

      public 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 String toString()
      Return a string representation of this type.
      Overrides:
      toString in class 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 String getArrayBrackets()
      Get brackets string. Returns "" if not an array.
    • equals

      public boolean equals(Object obj)
      Equality check based on the string representation.
      Overrides:
      equals in class 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, 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 String getTypeDescription()
      Return a string describing this type.
    • getTypeName

      public 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 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:
      IOException
    • print

      public static void print(IndentingWriter writer, Type[] theTypes, boolean useQualifiedNames, boolean useIDLNames, boolean globalIDLNames) throws 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:
      IOException
    • print

      public void print(IndentingWriter writer, boolean useQualifiedNames, boolean useIDLNames, boolean globalIDLNames) throws 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:
      IOException
    • println

      public void println(IndentingWriter writer, boolean useQualifiedNames, boolean useIDLNames, boolean globalIDLNames) throws 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:
      IOException
    • printTypeName

      public void printTypeName(IndentingWriter writer, boolean useQualifiedNames, boolean useIDLNames, boolean globalIDLNames) throws 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:
      IOException
    • getElementName

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

      protected void printPackageOpen(IndentingWriter writer, boolean useIDLNames) throws 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:
      IOException
    • getType

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

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

      protected static void removeType(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(String key, Type value, ContextStack stack)
      Put a type into the table.
    • putInvalidType

      protected static void putInvalidType(Type key, 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 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:
      IOException
    • setTypeCode

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

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

      protected void setIDLNames(String[] idlModuleNames, 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, Object arg0, Object arg1, 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, Object arg0, 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, 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:
      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.
      Returns:
      false.
    • clone

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

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

      protected abstract Class<?> loadClass()
    • initClass

      private boolean initClass()
    • setRepositoryID

      protected boolean setRepositoryID()