1 package spoon.jdiet; 2 3 import java.util.Collection ; 4 import java.util.Iterator ; 5 import java.util.Map ; 6 7 import spoon.jdiet.rt.MapEntryImpl; 8 import spoon.processing.AbstractProcessor; 9 import spoon.reflect.declaration.CtVariable; 10 import spoon.reflect.factory.TypeFactory; 11 import spoon.reflect.reference.CtTypeReference; 12 13 19 public class VariableProcessor extends AbstractProcessor<CtVariable> { 20 21 public void process(CtVariable lv) { 22 23 TypeFactory tf = getFactory().Type(); 24 CtTypeReference ctr = lv.getType(); 25 26 if( !ctr.isPrimitif() ) { 27 28 if( ctr.isSubtypeOf(tf.createReference(Collection .class)) ) { 30 ctr.setSimpleName("Vector"); 31 } 32 33 else if( ctr.isSubtypeOf(tf.createReference(Iterator .class)) ) { 35 ctr.setSimpleName("Enumeration"); 36 } 37 38 else if( ctr.isSubtypeOf(tf.createReference(Map .class)) ) { 40 ctr.setSimpleName("Hashtable"); 41 } 42 43 else if( ctr.isSubtypeOf(tf.createReference(Map.Entry .class)) ) { 45 lv.setType(tf.createReference(MapEntryImpl.class)); 46 } 47 } 48 } 49 50 } 51 | Popular Tags |