437
438 /**
439 * Load a configuration file to be edited, using a specified class loader
440 * to load the interview class.
441 * @param inFile the file to be loaded
442 * @param loader the class loader to be used to load the interview class
443 * @throws IOException if there is a problem reading the file
444 * @throws Interview.Fault if there is a problem loading the interview data from the file
445 * @throws EditJTI.Fault if there is a problem creating the interview for the testsuite
446 */
447 public void load(File inFile, URLClassLoader loader)
448 throws IOException, Interview.Fault, Fault
449 {
450 InputStream in = new BufferedInputStream(new FileInputStream(inFile));
451 Properties p = new Properties();
452 p.load(in);
453 in.close();
454
455 String interviewClassName = (String) (p.get("INTERVIEW"));
456 try {
457 Class interviewClass = loader.loadClass(interviewClassName);
458
459 interview = (InterviewParameters)(interviewClass.newInstance());
460 }
461 catch (ClassCastException e) {
462 throw new Fault(i18n, "editJTI.invalidInterview", inFile);
463 }
464 catch (ClassNotFoundException e) {
465 throw new Fault(i18n, "editJTI.cantFindClass",
466 new Object[] { interviewClassName, inFile });
467 }
468 catch (InstantiationException e) {
469 throw new Fault(i18n, "editJTI.cantInstantiateClass",
470 new Object[] { interviewClassName, inFile });
471 }
472 catch (IllegalAccessException e) {
473 throw new Fault(i18n, "editJTI.cantAccessClass",
474 new Object[] { interviewClassName, inFile });
475 }
476 finally {
477 try { if (in != null) in.close(); } catch (IOException e) {}
478 }
479
|
437
438 /**
439 * Load a configuration file to be edited, using a specified class loader
440 * to load the interview class.
441 * @param inFile the file to be loaded
442 * @param loader the class loader to be used to load the interview class
443 * @throws IOException if there is a problem reading the file
444 * @throws Interview.Fault if there is a problem loading the interview data from the file
445 * @throws EditJTI.Fault if there is a problem creating the interview for the testsuite
446 */
447 public void load(File inFile, URLClassLoader loader)
448 throws IOException, Interview.Fault, Fault
449 {
450 InputStream in = new BufferedInputStream(new FileInputStream(inFile));
451 Properties p = new Properties();
452 p.load(in);
453 in.close();
454
455 String interviewClassName = (String) (p.get("INTERVIEW"));
456 try {
457 Class<InterviewParameters> interviewClass = (Class<InterviewParameters>) loader.loadClass(interviewClassName);
458
459 interview = interviewClass.newInstance();
460 }
461 catch (ClassCastException e) {
462 throw new Fault(i18n, "editJTI.invalidInterview", inFile);
463 }
464 catch (ClassNotFoundException e) {
465 throw new Fault(i18n, "editJTI.cantFindClass",
466 new Object[] { interviewClassName, inFile });
467 }
468 catch (InstantiationException e) {
469 throw new Fault(i18n, "editJTI.cantInstantiateClass",
470 new Object[] { interviewClassName, inFile });
471 }
472 catch (IllegalAccessException e) {
473 throw new Fault(i18n, "editJTI.cantAccessClass",
474 new Object[] { interviewClassName, inFile });
475 }
476 finally {
477 try { if (in != null) in.close(); } catch (IOException e) {}
478 }
479
|