View Javadoc
1 /*** 2 * QuiltRegistry 3 * 4 * This is a superclass of all registries which 5 * keep track of Coverage Information. 6 */ 7 8 package junit.quilt.framework; 9 10 import java.net.URL; 11 12 import junit.quilt.util.Registry; 13 import javax.swing.tree.TreePath; 14 15 import java.util.List; 16 import java.util.ArrayList; 17 18 public abstract class QuiltRegistry 19 extends Registry 20 { 21 private String levels[]; 22 private List packages = new ArrayList(); 23 private List urls = new ArrayList(); 24 25 private ClassLoader loader = null; 26 private ClassLoader parent = 27 junit.quilt.framework. 28 QuiltRegistry.class.getClassLoader(); 29 30 /*** 31 * This constructor is used to initialize the 32 * levels. For example, you may pass in: 33 * {"Class", "Method"} if you have two levels 34 * in the registry. 35 */ 36 protected QuiltRegistry( String root ) { 37 super( root ); 38 } 39 40 protected void setLevels( String levels[] ) { 41 this.levels = levels; 42 } 43 44 public String [] getLevels() { 45 return levels; 46 } 47 48 protected boolean registerCollector( Object keys[], 49 QuiltCollector collector ) { 50 return register(keys, collector); 51 } 52 53 public QuiltCollector getCollector( Object keys[] ) { 54 return (QuiltCollector) get(keys); 55 } 56 57 public QuiltCollector getCollector( TreePath path ) { 58 return (QuiltCollector) get(path); 59 } 60 61 /*** 62 * getInstClassLoader 63 * 64 * Get a ClassLoader which will instrument the classes 65 * it loads, such that the instrumentation can be 66 * reported by the collectors stored in this registry. 67 */ 68 public void addPackage( String pack ) { 69 packages.add( pack ); 70 loader = null; 71 } 72 73 public void removePackage( String pack ) { 74 packages.remove( pack ); 75 loader = null; 76 } 77 78 public List getPackages() { 79 return> packages; 80 } 81 82 public void setPackages(List ips) { 83 packages = ips; 84 loader = null; 85 } 86 87 public void addPath( URL path ) { 88 urls.add( path ); 89 loader = null; 90 } 91 92 public void removePath( URL path ) { 93 urls.remove( path ); 94 loader = null; 95 } 96 97 public List getPaths() { 98 return urls; 99 } 100 101 public void setPaths( List paths ) { 102 this.urls = paths; 103 loader = null; 104 } 105 106 public void setParentClassLoader( ClassLoader parent ) { 107 this.parent = parent; 108 loader = null; 109 } 110 111 public ClassLoader getParentClassLoader() { 112 return parent; 113 } 114 115 public ClassLoader getInstClassLoader() { 116 // if (loader == null) { 117 Object pack[] = packages.toArray(); 118 String packs[] = new String[pack.length]; 119 120 for (int i = 0; i < pack.length; i++) { 121 packs[i] = (String) pack[i]; 122 } 123 124 Object path[] = urls.toArray(); 125 URL paths[] = new URL[path.length]; 126 127 for (int i = 0; i < path.length; i++) { 128 paths[i] = (URL) path[i]; 129 } 130 131 loader = newInstClassLoader( packs, paths, parent ); 132 return loader; 133 // } else { 134 // return loader; 135 // } 136 } 137 138 protected abstract ClassLoader newInstClassLoader( String packages[], 139 URL path[], 140 ClassLoader parent ); 141 142 }

This page was automatically generated by Maven