1 18 package org.objectweb.jac.ide; 19 20 import org.apache.log4j.Logger; 21 import org.objectweb.jac.aspects.persistence.StringConverter; 22 import org.objectweb.jac.core.rtti.ClassItem; 23 import org.objectweb.jac.core.rtti.ClassRepository; 24 import org.objectweb.jac.core.rtti.MethodItem; 25 26 29 public class MethodItemConverter implements StringConverter { 30 static Logger logger = Logger.getLogger("ide"); 31 32 37 public String objectToString(Object obj){ 38 String result=null; 39 try{ 40 MethodItem method=(MethodItem)obj; 41 ClassItem cl=method.getClassItem(); 42 result=cl.getName()+":"+method.getFullName(); 43 }catch(Exception e){ 44 result=null; 45 } 46 return result; 47 } 48 49 56 public Object stringToObject(String str){ 57 int pos = str.indexOf(":"); 59 if (pos==-1) { 61 logger.warn("Malformed method string (must be <classname>:<methodname>)"+str); 62 } 63 ClassItem classItem = ClassRepository.get().getClass(str.substring(0,pos)); 64 if (classItem==null) { 66 logger.warn("The class "+str.substring(0,pos)+" couldn't be found in the Repository"); 67 return null; 68 } 69 return classItem.getMethod(str.substring(pos+1)); 70 } 71 } 72 | Popular Tags |