Documentation of 'org.apache.derby.iapi.services.loader.ClassInspector' Java class
ClassInspector
org.apache.derby.iapi.services.loader

Class ClassInspector



  • public class ClassInspector
    extends java.lang.Object
    Methods to find out relationships between classes and methods within a class. All class names within this interface are treated as java language class names, e.g. int, COM.foo.Myclass, int[], java.lang.Object[]. That is java internal class names as defined in the class file format are not understood.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ClassInspector(ClassFactory cf)
      DO NOT USE! use the method in ClassFactory.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean accessible(java.lang.String className)
      Does the named class exist, and is it accessible?
      boolean assignableTo(java.lang.String fromClassName, java.lang.String toClassName)
      Is one named class assignable to another named class or interface?
      java.lang.reflect.Member findPublicConstructor(java.lang.String receiverType, java.lang.String[] parmTypes, java.lang.String[] primParmTypes, boolean[] isParam)
      Find a public constructor that implements a given signature.
      java.lang.reflect.Member findPublicField(java.lang.String receiverType, java.lang.String fieldName, boolean staticField)
      Find a public field for a class.
      java.lang.reflect.Member findPublicMethod(java.lang.String receiverType, java.lang.String methodName, java.lang.String[] parmTypes, java.lang.String[] primParmTypes, boolean[] isParam, boolean staticMethod, boolean repeatLastParameter, boolean hasVarargs)
      Find a public method that implements a given signature.
      java.lang.Class<?> getClass(java.lang.String className)
      Get (load) the class for the given class name.
      java.lang.String getDeclaringClass(java.lang.reflect.Member method)
      Get the declaring class for a method.
      java.lang.Class<?>[] getGenericParameterTypes(java.lang.Class parameterizedType, java.lang.Class implementation)
      Given an implementation of a parameterized interface, return the actual types of the interface type variables.
      java.lang.String[] getParameterTypes(java.lang.reflect.Member method)
      Get the parameter types for a method described by a Member as a String[].
      java.lang.String getType(java.lang.reflect.Member member)
      Get the Java name of the return type from a Member representing a method or the type of a Member representing a field.
      java.lang.Class[][] getTypeBounds(java.lang.Class parameterizedInterface, java.lang.Class implementation)
      Given an implementation of a parameterized interface, return the bounds on the type variables.
      boolean instanceOf(java.lang.String className, java.lang.Object obj)
      Is the given object an instance of the named class?
      boolean isVarArgsMethod(java.lang.reflect.Member member)
      Return true if the method or constructor supports varargs.
      static boolean primitiveType(java.lang.String typeName)
      Determine whether a type is a Java primitive, like int or boolean
      static java.lang.String readableClassName(java.lang.Class clazz)
      Translate a JVM-style type descriptor to a Java-language-style type name.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassInspector

        public ClassInspector(ClassFactory cf)
        DO NOT USE! use the method in ClassFactory.
    • Method Detail

      • instanceOf

        public boolean instanceOf(java.lang.String className,
                                  java.lang.Object obj)
                           throws java.lang.ClassNotFoundException
        Is the given object an instance of the named class?
        Parameters:
        className - The name of the class
        obj - The object to test to see if it's an instance of the named class
        Returns:
        true if obj is an instanceof className, false if not
        Throws:
        java.lang.ClassNotFoundException
      • assignableTo

        public boolean assignableTo(java.lang.String fromClassName,
                                    java.lang.String toClassName)
        Is one named class assignable to another named class or interface?
        Parameters:
        fromClassName - The name of the class to be assigned
        toClassName - The name of the class to be assigned to
        Returns:
        true if an object of type fromClass can be assigned to an object of type toClass, false if not.
      • accessible

        public boolean accessible(java.lang.String className)
                           throws java.lang.ClassNotFoundException
        Does the named class exist, and is it accessible?
        Parameters:
        className - The name of the class to test for existence
        Returns:
        true if the class exists and is accessible, false if not
        Throws:
        java.lang.ClassNotFoundException
      • getType

        public java.lang.String getType(java.lang.reflect.Member member)
        Get the Java name of the return type from a Member representing a method or the type of a Member representing a field.
        Parameters:
        member - A Member representing the method for which we want the return type.
        Returns:
        A Java-language-style string describing the return type of the method (for example, it returns "int" instead of "I".
      • findPublicMethod

        public java.lang.reflect.Member findPublicMethod(java.lang.String receiverType,
                                                         java.lang.String methodName,
                                                         java.lang.String[] parmTypes,
                                                         java.lang.String[] primParmTypes,
                                                         boolean[] isParam,
                                                         boolean staticMethod,
                                                         boolean repeatLastParameter,
                                                         boolean hasVarargs)
                                                  throws java.lang.ClassNotFoundException,
                                                         StandardException
        Find a public method that implements a given signature. The signature is given using the full Java class names of the types.
        A untyped null parameter is indicated by passing in an empty string ("") as its class name.
        If receiverType represents an interface then the methods of java.lang.Object are included in the candidate list.
        If the caller is simply checking to see that a public method with the specified name exists, regardless of the signature, exists, then the caller should pass in a null for parmTypes. (This is useful for checking the validity of a method alias when creating one.)
        We use a two-pass algorithm to resolve methods. In the first pass, we use all "object" types to try to match a method. If this fails, in the second pass, an array of "primitive" types (if the parameter has one, otherwise the same object type is used) is passed in, as well as the "object" type array. For each parameter of a method, we try to match it against either the "object" type, or the "primitive" type. Of all the qualified candidate methods found, we choose the closest one to the input parameter types. This involves comparing methods whose parameters are mixed "object" and "primitive" types in the second pass. This is eventually handled in classConvertableFromTo.
        Parameters:
        receiverType - The class name of the receiver
        methodName - The name of the method
        parmTypes - An array of class names representing the parameter types. Pass a zero-element array if there are no parameters. Pass a null if it is okay to match any signature.
        primParmTypes - This is used in the second pass of the two-pass method resolution algorithm. Use primitive type if it has one, otherwise use same object type
        isParam - Array of booleans telling whether parameter is a ?.
        staticMethod - Find a static method.
        repeatLastParameter - If true the last parameter may be repeated any number of times (total count must be greater than one). If false the last parameter is matched as usual. This also requires an exact match on the last parameter type.
        Returns:
        A Member representing the matching method. Returns null if no such method.
        Throws:
        java.lang.ClassNotFoundException - One or more of the classes does not exist.
        StandardException - Thrown on ambiguous method invocation.
        See Also:
        Member, Modifier
      • findPublicField

        public java.lang.reflect.Member findPublicField(java.lang.String receiverType,
                                                        java.lang.String fieldName,
                                                        boolean staticField)
                                                 throws StandardException
        Find a public field for a class. This follows the semantics of the java compiler for locating a field. This means if a field fieldName exists in the class with package, private or protected then an error is raised. Even if the field hides a field fieldName in a super-class/super--interface. See the JVM spec on fields.
        Parameters:
        receiverType - The class name of the receiver
        fieldName - The name of the field
        staticField - Find a static field
        Returns:
        A Member representing the matching field.
        Throws:
        StandardException - Class or field does not exist or is not public or a security exception.
        See Also:
        Member, Modifier
      • findPublicConstructor

        public java.lang.reflect.Member findPublicConstructor(java.lang.String receiverType,
                                                              java.lang.String[] parmTypes,
                                                              java.lang.String[] primParmTypes,
                                                              boolean[] isParam)
                                                       throws java.lang.ClassNotFoundException,
                                                              StandardException
        Find a public constructor that implements a given signature. The signature is given using the full Java class names of the types.
        A untyped null parameter is indicated by passing in an empty string ("") as its class name.
        Parameters:
        receiverType - The class name of the receiver
        parmTypes - An array of class names representing the parameter types. Pass a zero-element array if there are no parameters.
        primParmTypes - This is used in the second pass of the two-pass method resolution algorithm. Use primitive type if it has one, otherwise use same object type
        isParam - Array of booleans telling whether parameter is a ?.
        Returns:
        A Member representing the matching constructor. Returns null if no such constructor.
        Throws:
        java.lang.ClassNotFoundException - One or more of the classes does not exist.
        StandardException - Thrown on ambiguous constructor invocation.
        See Also:
        Member, Modifier
      • getTypeBounds

        public java.lang.Class[][] getTypeBounds(java.lang.Class parameterizedInterface,
                                                 java.lang.Class implementation)
                                          throws StandardException
        Given an implementation of a parameterized interface, return the bounds on the type variables. May return null if type resolution fails.
        Throws:
        StandardException
      • isVarArgsMethod

        public boolean isVarArgsMethod(java.lang.reflect.Member member)
        Return true if the method or constructor supports varargs.
      • getGenericParameterTypes

        public java.lang.Class<?>[] getGenericParameterTypes(java.lang.Class parameterizedType,
                                                             java.lang.Class implementation)
                                                      throws StandardException
        Given an implementation of a parameterized interface, return the actual types of the interface type variables. May return null or an array of nulls if type resolution fails.
        Throws:
        StandardException
      • getParameterTypes

        public java.lang.String[] getParameterTypes(java.lang.reflect.Member method)
        Get the parameter types for a method described by a Member as a String[].
        Parameters:
        method - A Member describing a method
        Returns:
        A String[] describing the parameters of the method
      • primitiveType

        public static boolean primitiveType(java.lang.String typeName)
        Determine whether a type is a Java primitive, like int or boolean
        Parameters:
        typeName - The name of the Java type
        Returns:
        true if it's a primitive type
      • getClass

        public java.lang.Class<?> getClass(java.lang.String className)
                                    throws java.lang.ClassNotFoundException
        Get (load) the class for the given class name. This method converts any java language class name into a Class object. This includes cases like String[] and primitive types. This will attempt to load the class from the application set.
        Throws:
        java.lang.ClassNotFoundException - Class cannot be found, or a SecurityException or LinkageException was thrown loading the class.
      • readableClassName

        public static java.lang.String readableClassName(java.lang.Class clazz)
        Translate a JVM-style type descriptor to a Java-language-style type name.
        Parameters:
        clazz - The String that contains the JVM type name
        Returns:
        The Java-language-style type name
      • getDeclaringClass

        public java.lang.String getDeclaringClass(java.lang.reflect.Member method)
        Get the declaring class for a method.
        Parameters:
        method - A Member describing a method
        Returns:
        A String with the declaring class
        See Also:
        Member.getDeclaringClass()

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.