1 8 package org.codehaus.aspectwerkz.reflect; 9 10 import com.thoughtworks.qdox.model.Type; 11 12 18 public class TypeConverter { 19 26 public static String [] convertTypeToJava(final Class [] types) { 27 String [] parameterTypeNames = new String [types.length]; 28 for (int i = 0; i < types.length; i++) { 29 parameterTypeNames[i] = convertTypeToJava(types[i]); 30 } 31 return parameterTypeNames; 32 } 33 34 40 public static String convertTypeToJava(final Class type) { 41 String rv = null; 42 43 if (type != null) { 45 StringBuffer dim = new StringBuffer (); 46 Class componentType = type.getComponentType(); 47 for (Class nestedType = type; nestedType.isArray(); nestedType = nestedType.getComponentType()) { 48 dim.append("[]"); 49 } 50 51 if (dim.length() > 0) { 53 rv = componentType.getName() + dim; 54 } else { 55 rv = type.getName(); 56 } 57 } else { 58 rv = "void"; 59 } 60 return rv; 61 } 62 63 69 public static String convertTypeToJava(final Type type) { 70 StringBuffer dim = new StringBuffer (); 71 if (type.isArray()) { 72 for (int i = type.getDimensions(); i > 0; --i) { 73 dim.append("[]"); 74 } 75 } 76 return type.getValue() + dim; 77 } 78 } | Popular Tags |