KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSX > Refactor


1 /** Use "Refactor" for mapping classnames after package refactoring or evolution
2
3     * WHEN TO USE, and WHAT IT CAN DO.
4     * It is most useful when you have serialized objects, and then want to
5     * migrant them to a new version of your application, but in the meantime the
6     * classes have evolved, so that the old objects won't "fit". You can now
7     * refactor the serialized versions so they do fit, and you can read them back
8     * in.
9     *
10     * Various implementations of this interface enable you to change the names of
11     * classes, move them across packages, and rename whole packages. And, of
12     * course, you can write your own.
13
14     * ClassRefactor
15     * The "ClassRefactor" implementation maps between specific classnames, both
16     * of which are fully qualified by their package. Thus, you can use this to
17     * rename a class, or to move it to another package.
18
19     * PackageRefactor
20     * "PackageRefactor" is a convenience class, which enables you to move
21     * all the classes in a package into another. You could do this with
22     * ClassRefactor, but you would have to specify them all individually.
23     * WARNING: if you map two packages to the same package (or if a package
24     * already exists of the destination name), you can have two classes with
25     * the same name, which is probably not what you wanted. The standard
26     * behaviour of the Java classloader is to always load the first one it
27     * finds in the classpath - it will not signal any ambiguity.
28     
29     * Planned: AutoDiscoveryPackageRefactor
30     * (Not written yet) for each class in a package listed in "oldPackages", JSX
31     * will search for that class in a specified list of "newPackages". This
32     * enables you to leave it all to JSX - however, name clashes become more
33     * likely now, and you may need to disambiguate them, by specifying individual
34     * mappings as in ClassRefactor. Note that when only some classes in an
35     * "old package" are moving, you can arrange for the others to stay by also
36     * listing that "old package" as a "new package". Alternatively, you could
37     * write your own, that would first check to see if a class in an "old
38     * package" is actually still there; and if so, not move it. But this would
39     * not detect the case where you forgot to delete the old class files!
40     **/

41
42
43 package JSX;
44 public interface Refactor {
45     public String JavaDoc mapClassname(String JavaDoc packageQualifiedClassname);
46 }
47
Popular Tags