Class ClassFinder

java.lang.Object
edu.gvsu.kurmasz.warszawa.dl.ClassFinder

public class ClassFinder
extends java.lang.Object
Find and generate the Class object for a class given its name. (Such a Class object is typically used to instantiate an object of a class that isn't known at compile time.)
Author:
Zachary Kurmas
  • Method Summary

    Modifier and Type Method Description
    static <T> java.lang.Class<T> getClass​(java.lang.String className, java.lang.Class<T> parentClass)
    Get the Class object for the named class and verify that className is a subclass of parentClass.
    static java.lang.Class loadClassByFile​(java.lang.String path, java.io.PrintStream err, int programmer_error, int invalid_parameters, int invalid_class)
    Loads the class contained in the specified .class file.
    static java.lang.Class loadClassByName​(java.lang.String testClassName, java.lang.String[] strings, java.io.PrintStream err, int programmer_error, int invalid_class)  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getClass

      public static <T> java.lang.Class<T> getClass​(java.lang.String className, java.lang.Class<T> parentClass) throws DLException
      Get the Class object for the named class and verify that className is a subclass of parentClass. Internally this method calls Class.forName(String). (See SimpleFactory.make(String, Class, Object...) for a discussion of the purpose of T and parentClass.)
      Type Parameters:
      T - The type of parentClass
      Parameters:
      className - the fully qualified name of the desired class
      parentClass - a superclass of className
      Returns:
      the Class object for the class className
      Throws:
      DLException - if the named class isn't found, or is not a subclass of parentClass
      java.lang.IllegalArgumentException - if className or parentClass are null
    • loadClassByFile

      public static java.lang.Class loadClassByFile​(java.lang.String path, java.io.PrintStream err, int programmer_error, int invalid_parameters, int invalid_class)
      Loads the class contained in the specified .class file.
      Parameters:
      path - The path of the class file.
      err - the PrintStream to which any error messages should be written
      programmer_error - the return value in the event of a programmer error
      invalid_parameters - the return value in the even that the specified file can't be found
      invalid_class - the return value in the event that the specified file is not a valid java .class file
      Returns:
      Returns the class object after the class has been loaded.
    • loadClassByName

      public static java.lang.Class loadClassByName​(java.lang.String testClassName, java.lang.String[] strings, java.io.PrintStream err, int programmer_error, int invalid_class)