@SuppressWarnings("deprecation") public static Type resolveType(String typeName, ClassDoc klass, JAXDoclet<?> doclet) { log("resolving " + typeName + " in " + klass.qualifiedTypeName()); // first look in inner classes for (ClassDoc innerClass : klass.innerClasses(false)) { if (innerClass.simpleTypeName().equals(typeName)) return innerClass; } // then the class itself if (klass.typeName().equals(typeName)) return klass; try { // then go through the named imports for (ClassDoc importedClass : klass.importedClasses()) { if (importedClass.typeName().equals(typeName)) return importedClass; } // then the package imports for (PackageDoc importedPackage : klass.importedPackages()) { for (ClassDoc importedClass : importedPackage.allClasses(false)) { if (importedClass.typeName().equals(typeName)) return importedClass; } } } catch (NullPointerException e) { } // now try FQDN Type type = doclet.forName(typeName); if (type != null) return type; log("resolving failed for " + typeName + " in " + klass.qualifiedTypeName()); return null; }
private Object resolveJavaElement(Context context, ClassDoc classDoc, MemberDoc memberDoc) { String packageName = classDoc.containingPackage().name(); for (Documentation documentation : context.getDocumentations()) { File projectFolder = documentation.getProjectFolder(); File javadocFolder = new File(projectFolder, "javadoc"); File packageFolder = new File(javadocFolder, packageName.replace('.', '/')); File classFile = new File(packageFolder, classDoc.typeName() + ".html"); if (classFile.isFile()) { return new JavaElementImpl(documentation, classDoc, classFile); } } String externalLink = context.getExternalLink(packageName); if (externalLink != null) { String url = externalLink + "/" + classDoc.typeName() + ".html"; return new ExternalTargetImpl(context, classDoc, url); } return null; }
private static List<DocController> generateControllers(final ClassDoc classDoc) throws Exception { List<DocController> controllers = new LinkedList<DocController>(); List<DocAnnotation> annotations = generateAnnotations(classDoc.annotations()); if (Utils.filterOutControllerClass(classDoc, annotations)) { return null; } String controllerClassName = classDoc.typeName(); DocRequestMappingAnnotation requestMappingAnnotation = Utils.getRequestMappingAnnotation(annotations); if (requestMappingAnnotation == null) { throw new IllegalArgumentException( "controller class " + controllerClassName + " is missing request mapping annotation"); } String[] uriArray = requestMappingAnnotation.getValue(); if (uriArray == null || uriArray.length == 0) { throw new IllegalArgumentException( "controller class " + controllerClassName + " is missing request mapping annotation's value (uri)."); } for (String uri : uriArray) { DocController controller = new DocController(controllerClassName); SortedMap<String, DocMethod> generatedMethods = generateMethods(classDoc.methods()); if (generatedMethods.isEmpty()) { throw new IllegalArgumentException( "controller class " + controller.getName() + " doesn't have methods."); } controller.setMethods(generatedMethods); controller.setUri(uri); controller.setDescription(classDoc.commentText()); controllers.add(controller); } return controllers; }