Search in sources :

Example 6 with Parameter

use of com.sun.javadoc.Parameter in project cxf by apache.

the class DumpJavaDoc method start.

public static boolean start(RootDoc root) throws IOException {
    String dumpFileName = readOptions(root.options());
    OutputStream os = Files.newOutputStream(Paths.get(dumpFileName));
    Properties javaDocMap = new Properties();
    for (ClassDoc classDoc : root.classes()) {
        javaDocMap.put(classDoc.toString(), classDoc.commentText());
        for (MethodDoc method : classDoc.methods()) {
            javaDocMap.put(method.qualifiedName(), method.commentText());
            for (ParamTag paramTag : method.paramTags()) {
                Parameter[] parameters = method.parameters();
                for (int i = 0; i < parameters.length; ++i) {
                    if (parameters[i].name().equals(paramTag.parameterName())) {
                        javaDocMap.put(method.qualifiedName() + ".paramCommentTag." + i, paramTag.parameterComment());
                    }
                }
            }
            Tag[] retTags = method.tags("return");
            if (retTags != null && retTags.length == 1) {
                Tag retTag = method.tags("return")[0];
                javaDocMap.put(method.qualifiedName() + "." + "returnCommentTag", retTag.text());
            }
        }
    }
    javaDocMap.store(os, "");
    os.flush();
    os.close();
    return true;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) MethodDoc(com.sun.javadoc.MethodDoc) OutputStream(java.io.OutputStream) Parameter(com.sun.javadoc.Parameter) ParamTag(com.sun.javadoc.ParamTag) Tag(com.sun.javadoc.Tag) Properties(java.util.Properties) ClassDoc(com.sun.javadoc.ClassDoc)

Example 7 with Parameter

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

the class MethodBuilder method initPathParams.

/**
    * Initialises the path-parameters of this method.
    * 
    * @param params the method's path parameters.
    * @param tags the parameters' Java documentation tags.
    */
private void initPathParams(Method method, final Parameter[] params, final ParamTag[] tags) {
    LOG.debug(method.getName());
    ArrayList<PathParameter> pathParams = new ArrayList<PathParameter>();
    for (Parameter param : params) {
        if (isAnnotated(param, PathVariable.class)) {
            pathParams.add(new PathParameterBuilder().build(new PathParameter(), param, tags));
        }
    }
    method.setPathParams(pathParams);
}
Also used : ArrayList(java.util.ArrayList) ModelParameter(com.iggroup.oss.restdoclet.doclet.type.ModelParameter) Parameter(com.sun.javadoc.Parameter) PathParameter(com.iggroup.oss.restdoclet.doclet.type.PathParameter) ResponseParameter(com.iggroup.oss.restdoclet.doclet.type.ResponseParameter) RestParameter(com.iggroup.oss.restdoclet.doclet.type.RestParameter) RequestParameter(com.iggroup.oss.restdoclet.doclet.type.RequestParameter) BodyParameter(com.iggroup.oss.restdoclet.doclet.type.BodyParameter) PathParameter(com.iggroup.oss.restdoclet.doclet.type.PathParameter)

Example 8 with Parameter

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

the class MethodBuilder method initModelParams.

/**
    * Initialises the model-parameters of this method.
    * 
    * @param params the method's parameters.
    * @param tags the parameters' Java documentation tags.
    */
private void initModelParams(Method method, final Parameter[] params, final ParamTag[] tags) {
    LOG.debug(method.getName());
    ArrayList<ModelParameter> modelParams = new ArrayList<ModelParameter>();
    for (Parameter param : params) {
        if (isAnnotated(param, ModelAttribute.class)) {
            modelParams.add(new ModelParameterBuilder().build(new ModelParameter(), param, tags));
        }
    }
    method.setModelParams(modelParams);
}
Also used : ModelParameter(com.iggroup.oss.restdoclet.doclet.type.ModelParameter) ArrayList(java.util.ArrayList) ModelParameter(com.iggroup.oss.restdoclet.doclet.type.ModelParameter) Parameter(com.sun.javadoc.Parameter) PathParameter(com.iggroup.oss.restdoclet.doclet.type.PathParameter) ResponseParameter(com.iggroup.oss.restdoclet.doclet.type.ResponseParameter) RestParameter(com.iggroup.oss.restdoclet.doclet.type.RestParameter) RequestParameter(com.iggroup.oss.restdoclet.doclet.type.RequestParameter) BodyParameter(com.iggroup.oss.restdoclet.doclet.type.BodyParameter)

Example 9 with Parameter

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

the class ParameterParser method getParameters.

public JSONArray getParameters(ExecutableMemberDoc doc) {
    JSONArray array = new JSONArray();
    for (Parameter parameter : doc.parameters()) {
        JSONObject object = new JSONObject();
        object.put("type", typeParser.getTypeObject(parameter.type()));
        object.put("name", parameter.name());
        for (ParamTag paramTag : doc.paramTags()) {
            if (parameter.name().equals(paramTag.parameterName())) {
                object.put("description", paramTag.parameterComment());
            }
        }
        array.put(object);
    }
    return (array.length() > 0) ? array : null;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Parameter(com.sun.javadoc.Parameter)

Aggregations

Parameter (com.sun.javadoc.Parameter)9 BodyParameter (com.iggroup.oss.restdoclet.doclet.type.BodyParameter)4 ModelParameter (com.iggroup.oss.restdoclet.doclet.type.ModelParameter)4 PathParameter (com.iggroup.oss.restdoclet.doclet.type.PathParameter)4 RequestParameter (com.iggroup.oss.restdoclet.doclet.type.RequestParameter)4 ResponseParameter (com.iggroup.oss.restdoclet.doclet.type.ResponseParameter)4 RestParameter (com.iggroup.oss.restdoclet.doclet.type.RestParameter)4 ParamTag (com.sun.javadoc.ParamTag)4 ArrayList (java.util.ArrayList)4 ClassDoc (com.sun.javadoc.ClassDoc)2 MethodDoc (com.sun.javadoc.MethodDoc)2 Type (com.sun.javadoc.Type)2 AnnotationDesc (com.sun.javadoc.AnnotationDesc)1 ElementValuePair (com.sun.javadoc.AnnotationDesc.ElementValuePair)1 Tag (com.sun.javadoc.Tag)1 FileOutputStream (java.io.FileOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 Properties (java.util.Properties)1 AnnotationDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.AnnotationDocType)1