/** * Renders a package documentation to an AsciiDoc file. * * @param doc the package documentation object */ private void renderPackage(PackageDoc doc){ try { PrintWriter writer = getWriter(doc, "package-info"); writer.println(doc.name()); if (doc.position() != null) { outputText(doc.name(), doc.getRawCommentText(), writer); } if (doc instanceof AnnotationTypeDoc) { for (MemberDoc member : ((AnnotationTypeDoc) doc).elements()) { outputText(member.name(), member.getRawCommentText(), writer); } } writer.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
public AnnotationTypeElementDoc[] getAnnotElems() { Vector myDocs = new Vector(); ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem"); //System.out.println(mainDoc.typeName()); //System.out.println(mainDoc instanceof AnnotationTypeDoc); AnnotationTypeDoc doc = (AnnotationTypeDoc) mainDoc; AnnotationTypeElementDoc[] docs = doc.elements(); for (int i = 0; i != docs.length; i++) { if (docs[i].isPrivate()) { continue; } myDocs.add(docs[i]); } AnnotationTypeElementDoc[] docArray = (AnnotationTypeElementDoc[]) myDocs.toArray(new AnnotationTypeElementDoc[0]); Arrays.sort(docArray); return docArray; }
public static PSOperatorWrapperDoc build(ClassDoc classDoc) { AnnotationDesc[] annotations = classDoc.annotations(); for (AnnotationDesc annotation : annotations) { AnnotationTypeDoc annotationType = annotation.annotationType(); if (Consts.OPERATOR_WRAPPER_ANNOTATION.equals(annotationType.toString())) { return new PSOperatorWrapperDoc(classDoc); } } return null; }
public static PSPipelineDoc build(ClassDoc classDoc, MethodDoc methodDoc) { AnnotationDesc[] annotations = methodDoc.annotations(); for (AnnotationDesc annotation : annotations) { AnnotationTypeDoc annotationType = annotation.annotationType(); if (Consts.TRANSFORMATION_ANNOTATION.equals(annotationType.toString())) { return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_TRANSFORMATION); } else if (Consts.ACTION_ANNOTATION.equals(annotationType.toString())) { return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_ACTION); } } return null; }
public static PSItemFieldDoc build(PSItemDoc psItemDoc, FieldDoc fieldDoc) { AnnotationDesc[] annotations = fieldDoc.annotations(); for (AnnotationDesc annotation : annotations) { AnnotationTypeDoc annotationType = annotation.annotationType(); if (Consts.ITEM_FIELD_ANNOTATION.equals(annotationType.toString())) { return new PSItemFieldDoc(psItemDoc, fieldDoc, annotation); } } return null; }
public static boolean isValidPSItem(ClassDoc classDoc) { AnnotationDesc[] annotations = classDoc.annotations(); for (AnnotationDesc annotation : annotations) { AnnotationTypeDoc annotationType = annotation.annotationType(); if (Consts.ITEM_ANNOTATION.equals(annotationType.toString())) { return true; } } return false; }
@Override protected void generateClassFiles(ClassDoc[] arr, ClassTree classtree) { Arrays.sort(arr); for (int i = 0; i < arr.length; i++) { if (!(configurationEx.isGeneratedDoc(arr[i]) && arr[i].isIncluded())) { continue; } ClassDoc prev = (i == 0) ? null : arr[i - 1]; ClassDoc curr = arr[i]; ClassDoc next = (i + 1 == arr.length) ? null : arr[i + 1]; try { if (curr.isAnnotationType()) { AbstractBuilder annotationTypeBuilder = configurationEx .getBuilderFactory().getAnnotationTypeBuilder( (AnnotationTypeDoc) curr, prev, next); annotationTypeBuilder.build(); } else { AbstractBuilder classBuilder = configurationEx .getBuilderFactory().getClassBuilder(curr, prev, next, classtree); classBuilder.build(); } } catch (Exception e) { e.printStackTrace(); throw new DocletAbortException(e.getMessage()); } } }
@Override protected void generateClassFiles(ClassDoc[] arr, ClassTree classtree) { Arrays.sort(arr); for (int i = 0; i < arr.length; i++) { if (!(configurationEx.isGeneratedDoc(arr[i]) && arr[i].isIncluded())) { continue; } ClassDoc prev = (i == 0) ? null : arr[i - 1]; ClassDoc curr = arr[i]; ClassDoc next = (i + 1 == arr.length) ? null : arr[i + 1]; try { if (curr.isAnnotationType()) { AbstractBuilder annotationTypeBuilder = configurationEx .getBuilderFactory().getAnnotationTypeBuilder( (AnnotationTypeDoc) curr, prev, next); annotationTypeBuilder.build(); } else { AbstractBuilder classBuilder = configurationEx .getBuilderFactory().getClassBuilder(curr, prev, next, classtree); classBuilder.build(); } } catch (Exception e) { e.printStackTrace(); throw new DocletAbortException(); } } }
public static AnnotationDesc findAnnotation(final AnnotationDesc[] annotations, final Class<?>... classes) { if (null != annotations && null != classes) { for (final AnnotationDesc annotation : annotations) { AnnotationTypeDoc docAnnotation = annotation.annotationType(); for (final Class<?> clazz : classes) { if (docAnnotation.qualifiedName().equals(clazz.getName())) { return annotation; } } } } return null; }
/** * @return the full JSON for the given annotation type */ protected JSONObject processAnnotationTypeDoc(AnnotationTypeDoc annoTypeDoc) { JSONObject retMe = processClassDoc(annoTypeDoc); retMe.put( "elements", processAnnotationTypeElementDocs( annoTypeDoc.elements() ) ); return retMe; }
/** * @return JSON stubs for the given AnnotationTypeDoc[]. * * */ protected JSONArray processAnnotationTypeDocStubs(AnnotationTypeDoc[] annotationTypeDocs) { JSONArray retMe = new JSONArray(); for (AnnotationTypeDoc annotationTypeDoc : annotationTypeDocs) { retMe.add( processAnnotationTypeDocStub(annotationTypeDoc) ); } return retMe; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (target instanceof Doc) { if (methodName.equals("isIncluded")) { Doc doc = (Doc) target; return !exclude(doc) && doc.isIncluded(); } if (target instanceof RootDoc) { if (methodName.equals("classes")) { return filter(((RootDoc) target).classes(), ClassDoc.class); } else if (methodName.equals("specifiedClasses")) { return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class); } else if (methodName.equals("specifiedPackages")) { return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class); } } else if (target instanceof ClassDoc) { if (isFiltered(args)) { if (methodName.equals("methods")) { return filter(((ClassDoc) target).methods(true), MethodDoc.class); } else if (methodName.equals("fields")) { return filter(((ClassDoc) target).fields(true), FieldDoc.class); } else if (methodName.equals("innerClasses")) { return filter(((ClassDoc) target).innerClasses(true), ClassDoc.class); } else if (methodName.equals("constructors")) { return filter(((ClassDoc) target).constructors(true), ConstructorDoc.class); } } } else if (target instanceof PackageDoc) { if (methodName.equals("allClasses")) { if (isFiltered(args)) { return filter(((PackageDoc) target).allClasses(true), ClassDoc.class); } else { return filter(((PackageDoc) target).allClasses(), ClassDoc.class); } } else if (methodName.equals("annotationTypes")) { return filter(((PackageDoc) target).annotationTypes(), AnnotationTypeDoc.class); } else if (methodName.equals("enums")) { return filter(((PackageDoc) target).enums(), ClassDoc.class); } else if (methodName.equals("errors")) { return filter(((PackageDoc) target).errors(), ClassDoc.class); } else if (methodName.equals("exceptions")) { return filter(((PackageDoc) target).exceptions(), ClassDoc.class); } else if (methodName.equals("interfaces")) { return filter(((PackageDoc) target).interfaces(), ClassDoc.class); } else if (methodName.equals("ordinaryClasses")) { return filter(((PackageDoc) target).ordinaryClasses(), ClassDoc.class); } } } if (args != null) { if (methodName.equals("compareTo") || methodName.equals("equals") || methodName.equals("overrides") || methodName.equals("subclassOf")) { args[0] = unwrap(args[0]); } } try { return process(method.invoke(target, args), method.getReturnType()); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
public AnnotationTypeWriter getAnnotationTypeWriter(AnnotationTypeDoc arg0, Type arg1, Type arg2) throws Exception { // TODO Auto-generated method stub return null; }
private static boolean isAnnotatedAsBoundedContext(final AnnotationTypeDoc annotationType) { return BusinessDomain.class.getCanonicalName().equals(annotationType.qualifiedTypeName()); }
private static boolean isAnnotatedAsLink(final AnnotationTypeDoc annotationType) { return Link.class.getCanonicalName().equals(annotationType.qualifiedTypeName()); }
private static boolean isAnnotatedAsLinks(final AnnotationTypeDoc annotationType) { return Links.class.getCanonicalName().equals(annotationType.qualifiedTypeName()); }
private static boolean isAnnotatedAsConcept(final AnnotationTypeDoc annotationType) { return Concept.class.getCanonicalName().equals(annotationType.qualifiedTypeName()); }
/** * Parse an annotation. * * @param annotationTypeDoc * A AnnotationTypeDoc instance * @return the annotation node */ protected Annotation parseAnnotationTypeDoc(ClassDoc classDoc) { Annotation annotationNode = objectFactory.createAnnotation(); annotationNode.setName(classDoc.name()); annotationNode.setDisplayName(classDoc.simpleTypeName()); annotationNode.setIdentifier(parseIdentifier((Doc) classDoc)); annotationNode.setFull(classDoc.qualifiedName()); annotationNode.setComment(parseComment(classDoc)); annotationNode.setScope(parseScope(classDoc)); Tag[] tags; SeeTag[] seeTags; tags = classDoc.tags("@deprecated"); if (tags.length > 0) { annotationNode.setDeprecated(parseComment(tags[0])); } tags = classDoc.tags("@since"); if (tags.length > 0) { annotationNode.setSince(tags[0].text()); } tags = classDoc.tags("@version"); if (tags.length > 0) { annotationNode.setVersion(tags[0].text()); } tags = classDoc.tags("@author"); for (int i = 0; i < tags.length; i++) { annotationNode.getAuthor().add(tags[i].text()); } seeTags = classDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { annotationNode.getLink().add(parseLink(seeTags[i])); } for (AnnotationTypeElementDoc annotationTypeElementDoc : ((AnnotationTypeDoc) classDoc).elements()) { annotationNode.getElement().add(parseAnnotationTypeElementDoc(annotationTypeElementDoc)); } return annotationNode; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (target instanceof Doc) { if (methodName.equals("isIncluded")) { Doc doc = (Doc) target; return !exclude(doc) && doc.isIncluded(); } if (target instanceof RootDoc) { if (methodName.equals("classes")) { return filter(((RootDoc) target).classes(), ClassDoc.class); } else if (methodName.equals("specifiedClasses")) { return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class); } else if (methodName.equals("specifiedPackages")) { return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class); } } else if (target instanceof ClassDoc) { if (isFiltered(args)) { if (methodName.equals("methods")) { return filter(((ClassDoc) target).methods(true), MethodDoc.class); } else if (methodName.equals("fields")) { return filter(((ClassDoc) target).fields(true), FieldDoc.class); } else if (methodName.equals("innerClasses")) { return filter(((ClassDoc) target).innerClasses(true), ClassDoc.class); } else if (methodName.equals("constructors")) { return filter(((ClassDoc) target).constructors(true), ConstructorDoc.class); } } else { if (methodName.equals("methods")) { return filter(((ClassDoc) target).methods(true), MethodDoc.class); } } } else if (target instanceof PackageDoc) { if (methodName.equals("allClasses")) { if (isFiltered(args)) { return filter(((PackageDoc) target).allClasses(true), ClassDoc.class); } else { return filter(((PackageDoc) target).allClasses(), ClassDoc.class); } } else if (methodName.equals("annotationTypes")) { return filter(((PackageDoc) target).annotationTypes(), AnnotationTypeDoc.class); } else if (methodName.equals("enums")) { return filter(((PackageDoc) target).enums(), ClassDoc.class); } else if (methodName.equals("errors")) { return filter(((PackageDoc) target).errors(), ClassDoc.class); } else if (methodName.equals("exceptions")) { return filter(((PackageDoc) target).exceptions(), ClassDoc.class); } else if (methodName.equals("interfaces")) { return filter(((PackageDoc) target).interfaces(), ClassDoc.class); } else if (methodName.equals("ordinaryClasses")) { return filter(((PackageDoc) target).ordinaryClasses(), ClassDoc.class); } } } if (args != null) { if (methodName.equals("compareTo") || methodName.equals("equals") || methodName.equals("overrides") || methodName.equals("subclassOf")) { args[0] = unwrap(args[0]); } } try { return process(method.invoke(target, args), method.getReturnType()); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
/** * Process the given classDoc along with all its methods, constructors, fields, enumConstants, etc. * * @return a list of javadoc models. */ protected JSONArray processClass(ClassDoc classDoc) { JSONArray retMe = new JSONArray(); retMe.add( classDoc.isAnnotationType() ? processAnnotationTypeDoc( (AnnotationTypeDoc) classDoc ) : processClassDoc(classDoc) ); retMe.addAll( processMethodDocs( classDoc.methods() ) ); retMe.addAll( processConstructorDocs( classDoc.constructors() ) ); retMe.addAll( processFieldDocs( classDoc.fields() ) ); retMe.addAll( processFieldDocs( classDoc.enumConstants() ) ); return retMe; }
/** * @return a JSON stub for the given AnnotationTypeDoc. */ protected JSONObject processAnnotationTypeDocStub(AnnotationTypeDoc annotationTypeDoc) { return processClassDocStub(annotationTypeDoc); }