/** Finds the first producer of a representation class. * Scans through the list of all loaders and returns the first one * whose representation class is a superclass of <code>clazz</code>. * * @param clazz class to find producer for * @return data loader or <CODE>null</CODE> if there is no loader that * can produce the class */ public final DataLoader firstProducerOf (Class clazz) { Enumeration en = allLoaders (); while (en.hasMoreElements ()) { DataLoader dl = (DataLoader)en.nextElement (); if (dl.getRepresentationClass ().isAssignableFrom (clazz)) { // representation class is super class of clazz return dl; } } return null; }
List before = s.getInstallBefore() == null ? null : Arrays.asList(s.getInstallBefore()); List after = s.getInstallAfter() == null ? null : Arrays.asList(s.getInstallAfter()); err.fine("add: " + l + " repclass: " + l.getRepresentationClass().getName() + " before: " + before + " after: " + after);
/** for sorting data objects by their classes */ private int compareClass (DataObject obj1, DataObject obj2) { Class c1 = obj1.getClass (); Class c2 = obj2.getClass (); if (c1 == c2) { return compareNames(obj1, obj2); } // sort by classes DataLoaderPool dlp = DataLoaderPool.getDefault(); final Enumeration loaders = dlp.allLoaders (); // PENDING, very very slow while (loaders.hasMoreElements ()) { Class clazz = ((DataLoader) (loaders.nextElement ())).getRepresentationClass (); // Sometimes people give generic DataObject as representation class. // It is not always avoidable: see e.g. org.netbeans.core.windows.layers.WSLoader. // In this case the overly flexible loader would "poison" sort-by-type, so we // make sure to ignore this. if (clazz == DataObject.class) continue; boolean r1 = clazz.isAssignableFrom (c1); boolean r2 = clazz.isAssignableFrom (c2); if (r1 && r2) return compareNames(obj1, obj2); if (r1) return -1; if (r2) return 1; } return compareNames(obj1, obj2); }