1 19 package org.netbeans.modules.javadoc.comments; 20 21 import org.netbeans.jmi.javamodel.Resource; 22 import org.netbeans.jmi.javamodel.JavaClass; 23 import org.netbeans.jmi.javamodel.MultipartId; 24 25 import javax.jmi.reflect.JmiException; 26 import java.util.List ; 27 import java.util.LinkedList ; 28 import java.util.Iterator ; 29 30 33 public final class JMIUtils { 34 40 public static List getAllClasses(Resource res) throws JmiException { 41 List l = new LinkedList (); 42 Iterator it = res.getClassifiers().iterator(); 43 while (it.hasNext()) { 44 addAllClasses((JavaClass) it.next(), l); 45 } 46 return l; 47 } 48 49 public static String multipartIdToName(MultipartId id) { 50 LinkedList list = new LinkedList (); 51 while (id != null) { 52 53 if (id.getTypeArguments().size() > 0) { 54 return "java.lang.Object"; } 56 57 list.addFirst(id.getName()); 58 id = id.getParent(); 59 } 60 StringBuffer buf = new StringBuffer (); 61 for (Iterator iter = list.iterator(); iter.hasNext();) { 62 buf.append((String )iter.next()); 63 if (iter.hasNext()) 64 buf.append('.'); 65 } 66 return buf.toString(); 67 } 68 69 private static void addAllClasses(JavaClass jc, List container) throws JmiException { 70 container.add(jc); 71 Iterator it = jc.getFeatures().iterator(); 72 while (it.hasNext()) { 73 Object feature = it.next(); 74 if (feature instanceof JavaClass) { 75 addAllClasses((JavaClass) feature, container); 76 } 77 } 78 } 79 80 } 81 | Popular Tags |