KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSX > ClassRefactor


1 /**
2     * Efficiency: the closetag also needs to match. At the moment,
3     * the hack is to also map the closetag - but it would be more efficient
4     * to instead save the first mapping. OTOH, hashing is very quick, and
5     * JSX efficiency is dominated by other factors than this - so not worth
6     * worrying about.
7     *
8     * Potential problem: not all Class.forName() calls are mapped through
9     * resolveClass(), and so the mappings won't be active there.
10     **/

11
12
13 package JSX;
14 import java.util.Map JavaDoc;
15 public class ClassRefactor implements Refactor {
16     Map JavaDoc map;
17     public ClassRefactor(Map JavaDoc map) { //takes a HashMap, HashTable etc
18
this.map = map;
19             //check for correct types: String, String
20
//check for no many:1
21
//Alt: load up from an array (of String[][]? or two String[]?)
22
}
23     public String JavaDoc mapClassname(String JavaDoc packageQualifiedClassname) {
24         String JavaDoc newClassname = (String JavaDoc) map.get(packageQualifiedClassname);
25         if (newClassname==null)
26             return packageQualifiedClassname;
27         else
28             return newClassname;
29     }
30 }
31
Free Books   Free Magazines  
Popular Tags