Class ClassWrapper

  • All Implemented Interfaces:
    IClass
    Direct Known Subclasses:
    ClassSourceWrapper

    public class ClassWrapper
    extends java.lang.Object
    implements IClass
    Wrapper for class information. This wraps the BCEL-based class handling implementation to support the interface defined for use with the binding model.
    Author:
    Dennis M. Sosnoski
    • Constructor Detail

      • ClassWrapper

        public ClassWrapper​(IClassLocator loc,
                            ClassFile clas)
        Constructor.
        Parameters:
        loc -
        clas -
    • Method Detail

      • buildItem

        protected IClassItem buildItem​(ClassItem item)
        Build an item wrapper. This method may be overridden by subclasses to return a specialized form of wrapper.
        Parameters:
        item -
        Returns:
        wrapper
      • getName

        public java.lang.String getName()
        Description copied from interface: IClass
        Get fully qualified class name.
        Specified by:
        getName in interface IClass
        Returns:
        fully qualified name for class
      • getSignature

        public java.lang.String getSignature()
        Description copied from interface: IClass
        Get signature for class as type.
        Specified by:
        getSignature in interface IClass
        Returns:
        signature for class used as type
      • getPackage

        public java.lang.String getPackage()
        Description copied from interface: IClass
        Get package name.
        Specified by:
        getPackage in interface IClass
        Returns:
        package name for class
      • getSuperClass

        public IClass getSuperClass()
        Description copied from interface: IClass
        Get superclass.
        Specified by:
        getSuperClass in interface IClass
        Returns:
        superclass information
      • getInterfaces

        public java.lang.String[] getInterfaces()
        Description copied from interface: IClass
        Get names of all interfaces implemented directly by class.
        Specified by:
        getInterfaces in interface IClass
        Returns:
        names of all interfaces implemented directly by class (non-null, empty array if none)
      • getInstanceSigs

        public java.lang.String[] getInstanceSigs()
        Description copied from interface: IClass
        Get signatures for all types of which instances of this type are instances.
        Specified by:
        getInstanceSigs in interface IClass
        Returns:
        all signatures supported by instances
      • isImplements

        public boolean isImplements​(java.lang.String sig)
        Description copied from interface: IClass
        Check if class implements an interface.
        Specified by:
        isImplements in interface IClass
        Parameters:
        sig - signature of interface to be checked
        Returns:
        true if interface is implemented by class, false if not
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: IClass
        Check if class is abstract.
        Specified by:
        isAbstract in interface IClass
        Returns:
        true if class is abstract, false if not
      • isInterface

        public boolean isInterface()
        Description copied from interface: IClass
        Check if class is an interface.
        Specified by:
        isInterface in interface IClass
        Returns:
        true if class is an interface, false if not
      • isModifiable

        public boolean isModifiable()
        Description copied from interface: IClass
        Check if class is modifiable.
        Specified by:
        isModifiable in interface IClass
        Returns:
        true if class is modifiable, false if not
      • isSuperclass

        public boolean isSuperclass​(java.lang.String name)
        Description copied from interface: IClass
        Check if another class is a superclass of this one.
        Specified by:
        isSuperclass in interface IClass
        Parameters:
        name - potential superclass to be checked
        Returns:
        true if named class is a superclass of this one, false if not
      • getDirectField

        public IClassItem getDirectField​(java.lang.String name)
        Description copied from interface: IClass
        Get information for field. This only checks for fields that are actually members of the class (not superclasses). TODO: make this work with both static and member fields
        Specified by:
        getDirectField in interface IClass
        Parameters:
        name - field name
        Returns:
        field information, or null if field not found
      • getField

        public IClassItem getField​(java.lang.String name)
        Description copied from interface: IClass
        Get information for field. If the field is not found directly, superclasses are checked for inherited fields matching the supplied name. TODO: make this work with both static and member fields
        Specified by:
        getField in interface IClass
        Parameters:
        name - field name
        Returns:
        field information, or null if field not found
      • getMethod

        public IClassItem getMethod​(java.lang.String name,
                                    java.lang.String sig)
        Description copied from interface: IClass
        Get information for method without respect to potential trailing arguments or return value. If the method is not found directly, superclasses are checked for inherited methods matching the supplied name. This compares the supplied partial signature against the actual method signature, and considers it a match if the actual sigature starts with the supplied signature. TODO: make this work with both static and member methods
        Specified by:
        getMethod in interface IClass
        Parameters:
        name - method name
        sig - partial method signature to be matched
        Returns:
        method information, or null if method not found
      • getMethod

        public IClassItem getMethod​(java.lang.String name,
                                    java.lang.String[] sigs)
        Description copied from interface: IClass
        Get information for method matching one of several possible signatures. If a match is not found directly, superclasses are checked for inherited methods matching the supplied name and signatures. The signature variations are checked in the order supplied. TODO: make this work with both static and member methods
        Specified by:
        getMethod in interface IClass
        Parameters:
        name - method name
        sigs - possible signatures for method (including return type)
        Returns:
        method information, or null if method not found
      • getInitializerMethod

        public IClassItem getInitializerMethod​(java.lang.String sig)
        Description copied from interface: IClass
        Get information for initializer. Only the class itself is checked for an initializer matching the argument list signature.
        Specified by:
        getInitializerMethod in interface IClass
        Parameters:
        sig - encoded argument list signature
        Returns:
        method information, or null if method not found
      • getStaticMethod

        public IClassItem getStaticMethod​(java.lang.String name,
                                          java.lang.String sig)
        Description copied from interface: IClass
        Get information for static method without respect to return value. Only the class itself is checked for a method matching the supplied name and argument list signature.
        Specified by:
        getStaticMethod in interface IClass
        Parameters:
        name - method name
        sig - encoded argument list signature
        Returns:
        method information, or null if method not found
      • isAccessible

        public boolean isAccessible​(IClassItem item)
        Description copied from interface: IClass
        Check accessible method. Check if a field or method in another class is accessible from within this class.
        Specified by:
        isAccessible in interface IClass
        Parameters:
        item - field or method information
        Returns:
        true if accessible, false if not
      • isAssignable

        public boolean isAssignable​(IClass other)
        Description copied from interface: IClass
        Check if a value of this type can be directly assigned to another type. This is basically the equivalent of the instanceof operator.
        Specified by:
        isAssignable in interface IClass
        Parameters:
        other - type to be assigned to
        Returns:
        true if assignable, false if not
      • getBestMethod

        public IClassItem getBestMethod​(java.lang.String name,
                                        java.lang.String type,
                                        java.lang.String[] args)
        Description copied from interface: IClass
        Get information for best matching method. This tries to find a method which matches the specified name, return type, and argument types. If an exact match is not found it looks for a method with a return type that is extended or implemented by the specified type and arguments that are extended or implemented by the specified types. If no match is found for this class superclasses are checked. TODO: make this work with both static and member methods
        Specified by:
        getBestMethod in interface IClass
        Parameters:
        name - method name
        type - return value type name (null if indeterminant)
        args - argument value type names (null if indeterminant)
        Returns:
        method information, or null if method not found
      • getClassFile

        public ClassFile getClassFile()
        Description copied from interface: IClass
        Get class file information. TODO: eliminate this sucker
        Specified by:
        getClassFile in interface IClass
        Returns:
        class file information
      • loadClass

        public java.lang.Class loadClass()
        Description copied from interface: IClass
        Load class in executable form.
        Specified by:
        loadClass in interface IClass
        Returns:
        loaded class, or null if unable to load
      • getFields

        public IClassItem[] getFields()
        Description copied from interface: IClass
        Get all fields of class.
        Specified by:
        getFields in interface IClass
        Returns:
        fields
      • getMethods

        public IClassItem[] getMethods()
        Description copied from interface: IClass
        Get all methods of class.
        Specified by:
        getMethods in interface IClass
        Returns:
        methods
      • getJavaDoc

        public java.lang.String getJavaDoc()
        Description copied from interface: IClass
        Get the JavaDoc comment for this class.
        Specified by:
        getJavaDoc in interface IClass
        Returns:
        comment text, or null if none or no source available
      • getLocator

        public IClassLocator getLocator()
        Description copied from interface: IClass
        Get the locator which provided this class.
        Specified by:
        getLocator in interface IClass
        Returns:
        locator