// File: Package.java // Classes: Package // Original Author: Jason Robbins // $Id: Package.java,v 1.1.1.1 1997/02/27 20:53:43 chandra Exp $ package uci.util; import java.util.*; /** * This class can reply a vector of the names of all classes stored in * a given package. That list is supplied by the programmer, not * determined from looking at the directory structure. This works with * the Preloader class to load lots of code at once (important for * netscape 2.0 users). User packages should implement a subclass of this * class with a list of their *.class files.
* * PackageGraphEdit and Example provide an example usage. * * @see uci.graphedit.PackageGraphEdit * @see uci.graphedit.Example */ public class Package { /** The name of the package for all classes being loaded. */ private String _packageName; /** The list of classes to load. Normally this is set by a series of * calls to add(). */ private Vector _classNames = new Vector(); /** Make a new Package with the given package name. Then call add() * for each class in your package. Then iterate over the vector * returned by classNames(). * @param packageName The name of the package. * @see Preloader */ public Package(String packageName) { _packageName = packageName; } /** Add a class to this Package. * @param className The name of the class to be added, do not * include the full package name, that is supplied to the constructor. */ public void add(String className) { _classNames.addElement(className); } /** * Returns a vector of all classes in this package, each is a * String with the full package and class names. */ public Vector classNames() { Vector v = new Vector(_classNames.size()); Enumeration cls = _classNames.elements(); while (cls.hasMoreElements()) { String next = (String) cls.nextElement(); v.addElement(_packageName + "." + next); } return v; } } /* end class Package */