Search in sources :

Example 6 with FieldDoc

use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.

the class DocTypeUtils method getFieldDoc.

/**
    * Return the documentation for a field
    * 
    * @param type
    * @param attributeName
    * @return
    */
private static String getFieldDoc(final Type type, final String attributeName, final String methodComment) {
    LOG.debug("getFieldDoc " + type.simpleTypeName() + " - " + attributeName + " - " + methodComment);
    String fieldComment = "";
    if (type.asClassDoc() != null) {
        for (FieldDoc field : type.asClassDoc().fields(false)) {
            if (field.name().equalsIgnoreCase(attributeName)) {
                fieldComment = field.commentText();
                if (methodComment.length() > fieldComment.length()) {
                    fieldComment = methodComment;
                }
                // see if there are any validation
                // constraints
                AnnotationDesc[] annotations = field.annotations();
                for (AnnotationDesc annotation : annotations) {
                    if (annotation.toString().contains("@javax.validation.constraints.")) {
                        String constraint = annotation.toString().replace("@javax.validation.constraints.", "");
                        fieldComment += "<br>[Rule: " + constraint + "]";
                    }
                }
                break;
            }
        }
    }
    return fieldComment;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc) AnnotationDesc(com.sun.javadoc.AnnotationDesc)

Example 7 with FieldDoc

use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.

the class DocTypeUtils method getGetterNames.

/**
    * Return a list of getter names
    * 
    * @param type
    * @return
    */
private static Collection<String> getGetterNames(final Type type) {
    FieldDoc[] fields = type.asClassDoc().fields(false);
    ArrayList<String> getterNames = new ArrayList<String>();
    for (FieldDoc field : fields) {
        if (!(field.isPublic() && field.isFinal() && StringUtils.equals(field.name(), field.name().toUpperCase()))) {
            getterNames.add(GETTER_PREFIX + field.name().substring(0, 1).toUpperCase() + field.name().substring(1));
            getterNames.add(IS_PREFIX + field.name().substring(0, 1).toUpperCase() + field.name().substring(1));
        }
    }
    return getterNames;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc) ArrayList(java.util.ArrayList)

Example 8 with FieldDoc

use of com.sun.javadoc.FieldDoc in project Orchid by JavaEden.

the class ClassDocParser method getClassFields.

public JSONArray getClassFields(ClassDoc classDoc) {
    JSONArray fields = new JSONArray();
    for (FieldDoc fDoc : classDoc.fields()) {
        JSONObject field = new JSONObject();
        field.put("comment", commentParser.getCommentObject(fDoc));
        field.put("annotations", annotationParser.getAnnotations(fDoc));
        field.put("name", fDoc.name());
        field.put("type", typeParser.getTypeObject(fDoc.type()));
        fields.put(field);
    }
    return fields;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Aggregations

FieldDoc (com.sun.javadoc.FieldDoc)8 MethodDoc (com.sun.javadoc.MethodDoc)2 ArrayList (java.util.ArrayList)2 FieldParameter (com.iggroup.oss.restdoclet.doclet.type.FieldParameter)1 FieldParameterBuilder (com.iggroup.oss.restdoclet.doclet.type.builder.FieldParameterBuilder)1 AnnotationDesc (com.sun.javadoc.AnnotationDesc)1 ClassDoc (com.sun.javadoc.ClassDoc)1 ApiClassDocumentation (com.zimbra.doc.soap.ApiClassDocumentation)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1