Search in sources :

Example 1 with FieldDoc

use of com.sun.javadoc.FieldDoc in project checkstyle by checkstyle.

the class TokenTypesDoclet method start.

/**
     * The doclet's starter method.
     * @param root {@code RootDoc} given to the doclet
     * @return true if the given {@code RootDoc} is processed.
     * @exception FileNotFoundException will be thrown if the doclet
     *            will be unable to write to the specified file.
     */
public static boolean start(RootDoc root) throws FileNotFoundException {
    final String fileName = getDestFileName(root.options());
    final FileOutputStream fos = new FileOutputStream(fileName);
    final Writer osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
    final PrintWriter writer = new PrintWriter(osw, false);
    try {
        final ClassDoc[] classes = root.classes();
        final FieldDoc[] fields = classes[0].fields();
        for (final FieldDoc field : fields) {
            if (field.isStatic() && field.isPublic() && field.isFinal() && "int".equals(field.type().qualifiedTypeName())) {
                if (field.firstSentenceTags().length != 1) {
                    final String message = "Should be only one tag.";
                    throw new IllegalArgumentException(message);
                }
                writer.println(field.name() + "=" + field.firstSentenceTags()[0].text());
            }
        }
    } finally {
        writer.close();
    }
    return true;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) PrintWriter(java.io.PrintWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) PrintWriter(java.io.PrintWriter) ClassDoc(com.sun.javadoc.ClassDoc)

Example 2 with FieldDoc

use of com.sun.javadoc.FieldDoc in project zm-mailbox by Zimbra.

the class DocletApiListener method processClass.

private void processClass(ClassDoc classDoc) {
    ApiClassDocumentation doc = new ApiClassDocumentation();
    processClassTags(doc, classDoc.tags());
    for (FieldDoc fieldDoc : classDoc.fields()) {
        processFieldTags(doc, fieldDoc);
    }
    for (MethodDoc methodDoc : classDoc.methods()) {
        processMethodTags(doc, methodDoc);
    }
    if (doc.hasDocumentation()) {
        docMap.put(classDoc.toString(), doc);
    }
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc) MethodDoc(com.sun.javadoc.MethodDoc) ApiClassDocumentation(com.zimbra.doc.soap.ApiClassDocumentation)

Example 3 with FieldDoc

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

the class DocTypeUtils method getEnumDoc.

/**
    * Return the documentation for an enum type
    * 
    * @param type
    * @return
    */
private static String getEnumDoc(final Type type) {
    String typeInfo = "";
    if (type.asClassDoc() != null) {
        FieldDoc[] enumConstants = type.asClassDoc().enumConstants();
        for (FieldDoc constant : enumConstants) {
            typeInfo += "<TR>";
            typeInfo += "<TD>" + constant.name() + "</TD>";
            typeInfo += "<TD>" + constant.commentText() + "</TD>";
            typeInfo += "</TR>";
        }
    }
    return typeInfo;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc)

Example 4 with FieldDoc

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

the class DocTypeUtils method getPublicConstantDoc.

/**
    * Return the documentation for a public constant
    * 
    * @param type
    * @return
    */
private static String getPublicConstantDoc(final Type type) {
    String typeInfo = "";
    FieldDoc[] fields = type.asClassDoc().fields(false);
    for (FieldDoc field : fields) {
        if (field.isPublic() && field.isFinal() && StringUtils.equals(field.name(), field.name().toUpperCase())) {
            typeInfo += "<tr><td>" + field.type().simpleTypeName() + " " + field.name() + "</td><td>" + field.commentText() + "</td></tr>";
        }
    }
    return typeInfo;
}
Also used : FieldDoc(com.sun.javadoc.FieldDoc)

Example 5 with FieldDoc

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

the class DocletUtils method getPublicFields.

/**
    * Return a list of all fields that have a public getter
    * 
    * @param classDoc class documentation
    * @return list of all fields that have a public getter
    */
public static Collection<FieldParameter> getPublicFields(final ClassDoc classDoc) {
    ArrayList<FieldParameter> fields = new ArrayList<FieldParameter>();
    MethodDoc[] methods = classDoc.methods();
    for (FieldDoc fieldDoc : classDoc.fields(false)) {
        boolean found = false;
        for (MethodDoc md : methods) {
            if (md.name().equalsIgnoreCase(GETTER_PREFIX + fieldDoc.name())) {
                found = true;
            }
        }
        if (found) {
            fields.add(new FieldParameterBuilder().build(new FieldParameter(), fieldDoc));
        }
    }
    return fields;
}
Also used : FieldParameterBuilder(com.iggroup.oss.restdoclet.doclet.type.builder.FieldParameterBuilder) FieldDoc(com.sun.javadoc.FieldDoc) MethodDoc(com.sun.javadoc.MethodDoc) ArrayList(java.util.ArrayList) FieldParameter(com.iggroup.oss.restdoclet.doclet.type.FieldParameter)

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