Esempio n. 1
0
  public static void register(String crClassName, String dmClassName) {
    Class dmClass;
    try { dmClass = Class.forName(dmClassName); }
    catch (java.lang.ClassNotFoundException e) {
	System.out.println("Error loading dm " + dmClassName);
	return;
    }
    Critic cr = (Critic) _singletonCritics.get(crClassName);
    if (cr == null) {
      Class crClass;
      try { crClass = Class.forName(crClassName); }
      catch (java.lang.ClassNotFoundException e) {
	System.out.println("Error loading cr " + crClassName);
	return;
      }
      try { cr = (Critic) crClass.newInstance(); }
      catch (java.lang.IllegalAccessException e) {
	System.out.println("Error instancating cr " + crClassName);
	return;
      }
      catch (java.lang.InstantiationException e) {
	System.out.println("Error instancating cr " + crClassName);
	return;
      }
      _singletonCritics.put(crClassName, cr);
      addCritic(cr);
    }
    register(cr, dmClass);
  }
Esempio n. 2
0
  /** Return a Vector of all critics that can be applied to the
   * design material subclass, including inherited critics. */
  public static Vector criticsForClass(Class clazz) {
    Vector critics = (Vector) _cachedCritics.get(clazz);
    if (critics != null) return critics;
    Class origClazz = clazz;
    critics = new Vector();
    while (clazz != null) {
      Vector specificCritics = criticsForSpecificClass(clazz);
      Enumeration cur = specificCritics.elements();
      while (cur.hasMoreElements())
	critics.addElement(cur.nextElement());
      clazz = clazz.getSuperclass();
    }
    _cachedCritics.put(origClazz, critics);
    return critics;
  }