private String parseIdentifier(Doc doc) { if (doc instanceof ClassDoc) { ClassDoc classDoc = (ClassDoc) doc; return parseIdentifier((Doc) classDoc.containingPackage()) + classDoc.name() + "/"; } else if (doc instanceof AnnotationTypeElementDoc) { AnnotationTypeElementDoc annotationTypeElementDoc = (AnnotationTypeElementDoc) doc; return parseIdentifier((Doc) annotationTypeElementDoc.containingClass()) + "#" + annotationTypeElementDoc.name(); } else if (doc instanceof FieldDoc) { FieldDoc fieldDoc = (FieldDoc) doc; return parseIdentifier((Doc) fieldDoc.containingClass()) + "#" + fieldDoc.name(); } else if (doc instanceof ConstructorDoc) { ConstructorDoc constructorDoc = (ConstructorDoc) doc; return parseIdentifier((Doc) constructorDoc.containingClass()) + "#" + constructorDoc.name() + URLEncoder.encode(constructorDoc.flatSignature()); } else if (doc instanceof MethodDoc) { MethodDoc methodDoc = (MethodDoc) doc; return parseIdentifier((Doc) methodDoc.containingClass()) + "#" + methodDoc.name() + URLEncoder.encode(methodDoc.flatSignature()); } else { return "/" + doc.name() + "/"; } }
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; }
/** * * @return an "element" XML node for the element value pair. */ private static XMLNode toPairNode(ElementValuePair pair) { if (pair == null) return null; XMLNode node = new XMLNode("element"); AnnotationTypeElementDoc element = pair.element(); node.attribute("name", element.name()); node.child(toComment(element)); node.child(toAnnotationValueNode(pair.value())); return node; }
/** * @return the full JSON for the given annotation type */ protected JSONArray processAnnotationTypeElementDocs(AnnotationTypeElementDoc[] annoTypeElementDocs) { JSONArray retMe = new JSONArray(); for (AnnotationTypeElementDoc annoTypeElementDoc : annoTypeElementDocs) { retMe.add( processAnnotationTypeElementDoc( annoTypeElementDoc ) ); } return retMe; }
/** * @return the full JSON for the given annotation type */ protected JSONObject processAnnotationTypeElementDoc(AnnotationTypeElementDoc annoTypeElementDoc) { if (annoTypeElementDoc == null) { return null; } JSONObject retMe = processMethodDoc( annoTypeElementDoc ); // retMe.put("name", annoTypeElementDoc.name()); // retMe.put("qualifiedName", annoTypeElementDoc.qualifiedName()); // retMe.put("returnType", processTypeStub(annoTypeElementDoc.returnType())); retMe.put("defaultValue", processAnnotationValue( annoTypeElementDoc.defaultValue() ) ); return retMe; }
/** * @return the full JSON for the given annotation type */ protected JSONObject processAnnotationTypeElementDocStub(AnnotationTypeElementDoc annoTypeElementDoc) { if (annoTypeElementDoc == null) { return null; } JSONObject retMe = processMemberDocStub( annoTypeElementDoc ); retMe.put("returnType", processTypeStub(annoTypeElementDoc.returnType())); // JSONObject retMe = new JSONObject(); // retMe.put("name", annoTypeElementDoc.name()) return retMe; }
/** * * @return an "element" XML node for the element value pair. */ private static XMLNode toPairNode(ElementValuePair pair) { if (pair == null) return null; XMLNode node = new XMLNode("element"); AnnotationTypeElementDoc element = pair.element(); node.attribute("name", element.name()); node.child(toShortComment(element)); node.child(toComment(element)); node.child(toAnnotationValueNode(pair.value())); return node; }
/** * 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; }
/** * Parse the elements of an annotation * * @param element * A AnnotationTypeElementDoc instance * @return the annotation element node */ protected AnnotationElement parseAnnotationTypeElementDoc(AnnotationTypeElementDoc annotationTypeElementDoc) { AnnotationElement annotationElementNode = objectFactory.createAnnotationElement(); annotationElementNode.setName(annotationTypeElementDoc.name()); annotationElementNode.setIdentifier(parseIdentifier((Doc) annotationTypeElementDoc)); annotationElementNode.setId(annotationTypeElementDoc.name()); annotationElementNode.setFull(annotationTypeElementDoc.qualifiedName()); annotationElementNode.setComment(parseComment(annotationTypeElementDoc)); AnnotationValue value = annotationTypeElementDoc.defaultValue(); if (value != null) { annotationElementNode.setDefault(value.toString()); } Tag[] tags; SeeTag[] seeTags; tags = annotationTypeElementDoc.tags("@deprecated"); if (tags.length > 0) { annotationElementNode.setDeprecated(parseComment(tags[0])); } tags = annotationTypeElementDoc.tags("@since"); if (tags.length > 0) { annotationElementNode.setSince(tags[0].text()); } tags = annotationTypeElementDoc.tags("@version"); if (tags.length > 0) { annotationElementNode.setVersion(tags[0].text()); } Return returnNode = objectFactory.createReturn(); tags = annotationTypeElementDoc.tags("@return"); if (tags.length > 0) { returnNode.setComment(parseComment(tags[0])); } returnNode.setType(parseTypeInfo(annotationTypeElementDoc.returnType())); annotationElementNode.setReturn(returnNode); seeTags = annotationTypeElementDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { annotationElementNode.getLink().add(parseLink(seeTags[i])); } return annotationElementNode; }
public String getElemValue(AnnotationTypeElementDoc doc) { Object value = doc.defaultValue(); return value == null ? null : formatValue(value); }