Search in sources :

Example 1 with Parameter

use of com.sun.javadoc.Parameter in project jersey by jersey.

the class ResourceDoclet method addParamDocs.

private static void addParamDocs(final MethodDoc methodDoc, final MethodDocType methodDocType, final DocProcessor docProcessor) {
    final Parameter[] parameters = methodDoc.parameters();
    final ParamTag[] paramTags = methodDoc.paramTags();
    /* only use both javadoc and reflection information when the number
         * of params are the same
         */
    if (parameters != null && paramTags != null && parameters.length == paramTags.length) {
        for (int i = 0; i < parameters.length; i++) {
            final Parameter parameter = parameters[i];
            /* TODO: this only works if the params and tags are in the same
                 * order. If the param tags are mixed up, the comments for parameters
                 * will be wrong.
                 */
            final ParamTag paramTag = paramTags[i];
            final ParamDocType paramDocType = new ParamDocType();
            paramDocType.setParamName(paramTag.parameterName());
            paramDocType.setCommentText(paramTag.parameterComment());
            docProcessor.processParamTag(paramTag, parameter, paramDocType);
            final AnnotationDesc[] annotations = parameter.annotations();
            if (annotations != null) {
                for (final AnnotationDesc annotationDesc : annotations) {
                    final AnnotationDocType annotationDocType = new AnnotationDocType();
                    final String typeName = annotationDesc.annotationType().qualifiedName();
                    annotationDocType.setAnnotationTypeName(typeName);
                    for (final ElementValuePair elementValuePair : annotationDesc.elementValues()) {
                        final NamedValueType namedValueType = new NamedValueType();
                        namedValueType.setName(elementValuePair.element().name());
                        namedValueType.setValue(elementValuePair.value().value().toString());
                        annotationDocType.getAttributeDocs().add(namedValueType);
                    }
                    paramDocType.getAnnotationDocs().add(annotationDocType);
                }
            }
            methodDocType.getParamDocs().add(paramDocType);
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag) ElementValuePair(com.sun.javadoc.AnnotationDesc.ElementValuePair) NamedValueType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.NamedValueType) Parameter(com.sun.javadoc.Parameter) AnnotationDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.AnnotationDocType) ParamDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType) AnnotationDesc(com.sun.javadoc.AnnotationDesc)

Example 2 with Parameter

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

the class MethodBuilder method initRequestParams.

/**
    * Initialises the request-parameters of this method.
    * 
    * @param params the method's parameters.
    * @param tags the parameters' Java documentation tags.
    */
private void initRequestParams(Method method, final Parameter[] params, final ParamTag[] tags) {
    LOG.debug(method.getName());
    ArrayList<RequestParameter> requestParams = new ArrayList<RequestParameter>();
    for (Parameter param : params) {
        if (isAnnotated(param, RequestParam.class)) {
            requestParams.add(new RequestParameterBuilder().build(new RequestParameter(), param, tags));
        }
    }
    method.setRequestParams(requestParams);
}
Also used : RequestParameter(com.iggroup.oss.restdoclet.doclet.type.RequestParameter) 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 3 with Parameter

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

the class MethodBuilder method initBodyParams.

/**
    * Initialises the request body parameters of this method.
    * 
    * @param params the method's parameters.
    * @param tags the parameters' Java documentation tags.
    */
private void initBodyParams(Method method, final Parameter[] params, final ParamTag[] tags) {
    LOG.debug(method.getName());
    ArrayList<BodyParameter> bodyParams = new ArrayList<BodyParameter>();
    for (Parameter param : params) {
        if (isAnnotated(param, RequestBody.class)) {
            LOG.debug("YYYYYYYYYYYYYYYYYY");
            bodyParams.add(new BodyParameterBuilder().build(new BodyParameter(), param, tags));
        }
    }
    method.setBodyParams(bodyParams);
}
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) BodyParameter(com.iggroup.oss.restdoclet.doclet.type.BodyParameter)

Example 4 with Parameter

use of com.sun.javadoc.Parameter in project jdk8u_jdk by JetBrains.

the class Util method getFriendlyUnqualifiedSignature.

/**
     * Returns a reader-friendly string representation of the
     * specified method's signature.  Names of reference types are not
     * package-qualified.
     **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
Also used : Type(com.sun.javadoc.Type) Parameter(com.sun.javadoc.Parameter)

Example 5 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)

Aggregations

Parameter (com.sun.javadoc.Parameter)7 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 ArrayList (java.util.ArrayList)4 ParamTag (com.sun.javadoc.ParamTag)2 AnnotationDesc (com.sun.javadoc.AnnotationDesc)1 ElementValuePair (com.sun.javadoc.AnnotationDesc.ElementValuePair)1 Type (com.sun.javadoc.Type)1 AnnotationDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.AnnotationDocType)1 NamedValueType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.NamedValueType)1 ParamDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1