# Class Repository

java.lang.Object
org.apache.bcel.Repository

public abstract class Repository extends Object
The repository maintains informations about class interdependencies, for example, whether a class is a sub-class of another. Delegates actual class loading to SyntheticRepository with current class path by default.

See Also:
  - `Repository`
  - `SyntheticRepository`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Repository()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static JavaClass`
  `addClass(JavaClass clazz)`
  Adds clazz to repository if there isn't an equally named class already in there.
  `static void`
  `clearCache()`
  Clears the repository.
  `static JavaClass[]`
  `getInterfaces(String className)`
  `static JavaClass[]`
  `getInterfaces(JavaClass clazz)`
  `static Repository`
  `getRepository()`
  `static JavaClass[]`
  `getSuperClasses(String className)`
  `static JavaClass[]`
  `getSuperClasses(JavaClass clazz)`
  `static boolean`
  `implementationOf(String clazz, String inter)`
  `static boolean`
  `implementationOf(String clazz, JavaClass inter)`
  `static boolean`
  `implementationOf(JavaClass clazz, String inter)`
  `static boolean`
  `implementationOf(JavaClass clazz, JavaClass inter)`
  `static boolean`
  `instanceOf(String clazz, String superclass)`
  `static boolean`
  `instanceOf(String clazz, JavaClass superclass)`
  `static boolean`
  `instanceOf(JavaClass clazz, String superclass)`
  `static boolean`
  `instanceOf(JavaClass clazz, JavaClass superclass)`
  Equivalent to runtime "instanceof" operator.
  `static JavaClass`
  `lookupClass(Class<?> clazz)`
  Tries to find class source using the internal repository instance.
  `static JavaClass`
  `lookupClass(String className)`
  Lookups class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.
  `static ClassPath.ClassFile`
  `lookupClassFile(String className)`
  `static void`
  `removeClass(String clazz)`
  Removes class with given (fully qualified) name from repository.
  `static void`
  `removeClass(JavaClass clazz)`
  Removes given class from repository.
  `static void`
  `setRepository(Repository rep)`
  Sets repository instance to be used for class loading

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Repository

    public Repository()

- ## Method Details

  - ### addClass

    public static JavaClass addClass(JavaClass clazz)
    Adds clazz to repository if there isn't an equally named class already in there.
    Returns:
      old entry in repository

  - ### clearCache

    public static void clearCache()
    Clears the repository.

  - ### getInterfaces

    public static JavaClass[] getInterfaces(JavaClass clazz) throws ClassNotFoundException
    Returns:
      all interfaces implemented by class and its super classes and the interfaces that those interfaces extend, and so on. (Some people call this a transitive hull).
    Throws:
      `ClassNotFoundException` - if any of the class's superclasses or superinterfaces can't be found

  - ### getInterfaces

    public static JavaClass[] getInterfaces(String className) throws ClassNotFoundException
    Returns:
      all interfaces implemented by class and its super classes and the interfaces that extend those interfaces, and so on
    Throws:
      `ClassNotFoundException` - if the named class can't be found, or if any of its superclasses or superinterfaces can't be found

  - ### getRepository

    public static Repository getRepository()
    Returns:
      currently used repository instance

  - ### getSuperClasses

    public static JavaClass[] getSuperClasses(JavaClass clazz) throws ClassNotFoundException
    Returns:
      list of super classes of clazz in ascending order, i.e., Object is always the last element
    Throws:
      `ClassNotFoundException` - if any of the superclasses can't be found

  - ### getSuperClasses

    public static JavaClass[] getSuperClasses(String className) throws ClassNotFoundException
    Returns:
      list of super classes of clazz in ascending order, i.e., Object is always the last element.
    Throws:
      `ClassNotFoundException` - if the named class or any of its superclasses can't be found

  - ### implementationOf

    public static boolean implementationOf(JavaClass clazz, JavaClass inter) throws ClassNotFoundException
    Returns:
      true, if clazz is an implementation of interface inter
    Throws:
      `ClassNotFoundException` - if any superclasses or superinterfaces of clazz can't be found

  - ### implementationOf

    public static boolean implementationOf(JavaClass clazz, String inter) throws ClassNotFoundException
    Returns:
      true, if clazz is an implementation of interface inter
    Throws:
      `ClassNotFoundException` - if inter or any superclasses or superinterfaces of clazz can't be found

  - ### implementationOf

    public static boolean implementationOf(String clazz, JavaClass inter) throws ClassNotFoundException
    Returns:
      true, if clazz is an implementation of interface inter
    Throws:
      `ClassNotFoundException` - if clazz or any superclasses or superinterfaces of clazz can't be found

  - ### implementationOf

    public static boolean implementationOf(String clazz, String inter) throws ClassNotFoundException
    Returns:
      true, if clazz is an implementation of interface inter
    Throws:
      `ClassNotFoundException` - if clazz, inter, or any superclasses or superinterfaces of clazz can't be found

  - ### instanceOf

    public static boolean instanceOf(JavaClass clazz, JavaClass superclass) throws ClassNotFoundException
    Equivalent to runtime "instanceof" operator.
    Returns:
      true, if clazz is an instance of superclass
    Throws:
      `ClassNotFoundException` - if any superclasses or superinterfaces of clazz can't be found

  - ### instanceOf

    public static boolean instanceOf(JavaClass clazz, String superclass) throws ClassNotFoundException
    Returns:
      true, if clazz is an instance of superclass
    Throws:
      `ClassNotFoundException` - if superclass can't be found

  - ### instanceOf

    public static boolean instanceOf(String clazz, JavaClass superclass) throws ClassNotFoundException
    Returns:
      true, if clazz is an instance of superclass
    Throws:
      `ClassNotFoundException` - if clazz can't be found

  - ### instanceOf

    public static boolean instanceOf(String clazz, String superclass) throws ClassNotFoundException
    Returns:
      true, if clazz is an instance of superclass
    Throws:
      `ClassNotFoundException` - if either clazz or superclass can't be found

  - ### lookupClass

    public static JavaClass lookupClass(Class<?> clazz) throws ClassNotFoundException
    Tries to find class source using the internal repository instance.
    Returns:
      JavaClass object for given runtime class
    Throws:
      `ClassNotFoundException` - if the class could not be found or parsed correctly
    See Also:
      - `Class`

  - ### lookupClass

    public static JavaClass lookupClass(String className) throws ClassNotFoundException
    Lookups class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.
    Returns:
      class object for given fully qualified class name
    Throws:
      `ClassNotFoundException` - if the class could not be found or parsed correctly

  - ### lookupClassFile

    public static ClassPath.ClassFile lookupClassFile(String className)
    Returns:
      class file object for given Java class by looking on the system class path; returns null if the class file can't be found

  - ### removeClass

    public static void removeClass(JavaClass clazz)
    Removes given class from repository.

  - ### removeClass

    public static void removeClass(String clazz)
    Removes class with given (fully qualified) name from repository.

  - ### setRepository

    public static void setRepository(Repository rep)
    Sets repository instance to be used for class loading