Package com.sun.javadoc

Examples of com.sun.javadoc.AnnotationDesc


  /**
   * Check an array of annotations
   */
  private void checkAnnotations(Doc doc, AnnotationDesc[] annotations) {
    for (int i=0; i < annotations.length; i++) {
      AnnotationDesc annotationDesc = annotations[i];
      boolean isDocumented = false;
      for (AnnotationDesc a : annotationDesc.annotationType().annotations()) {
        if (java.lang.annotation.Documented.class.getName().equals(a.annotationType().qualifiedName())) {
          isDocumented = true;
        }
      }
      checkReference(doc, annotations[i], isDocumented ? WARNING_ANNOTATION : WARNING_PRIVATE_ANNOTATION);
View Full Code Here


    }
  }

  private void setupMethods() {
    for (Class<?> methodAnnotation : MethodAnnotations) {
      final AnnotationDesc annotation = Utils.findMethodAnnotation(declaringClass, method, methodAnnotation);
      if (annotation != null)
        methods.add(annotation);
    }
  }
View Full Code Here

  private void setupParameters() {
    int i = -1;
    for (final Parameter parameter : method.parameters()) {
      i++;
      final AnnotationDesc pathParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new RealMethodParameter(parameter, i, pathParamAnnotation, MethodParameterType.Path, declaringMethod));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(matrixParamAnnotation);
        matrixParameters.add(new RealMethodParameter(parameter, i, matrixParamAnnotation, MethodParameterType.Matrix, declaringMethod));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new RealMethodParameter(parameter, i, queryParamAnnotation, MethodParameterType.Query, declaringMethod));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new RealMethodParameter(parameter, i, cookieParamAnnotation, MethodParameterType.Cookie, declaringMethod));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, FormParam.class);
      if (formParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(formParamAnnotation);
        formParameters.add(new RealMethodParameter(parameter, i, formParamAnnotation, MethodParameterType.Form, declaringMethod));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new RealMethodParameter(parameter, i, headerParamAnnotation, MethodParameterType.Header, declaringMethod));
        continue;
      }
      if (formClass != null) {
        final AnnotationDesc formAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, formClass);
        if (formAnnotation != null) {
          walkFormParameter(parameter.type().asClassDoc());
          continue;
        }
      }
      final AnnotationDesc contextAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new RealMethodParameter(parameter, i, null, MethodParameterType.Input, declaringMethod);
      }
    }
  }
View Full Code Here

  }

  private void walkFormParameter(ClassDoc formDoc) {
    // walk all fields
    for (FieldDoc field : formDoc.fields(false)) {
      final AnnotationDesc pathParamAnnotation = Utils.findAnnotation(field, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new FormFieldParameter(field, pathParamAnnotation, MethodParameterType.Path));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findAnnotation(field, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        matrixParameters.add(new FormFieldParameter(field, matrixParamAnnotation, MethodParameterType.Matrix));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findAnnotation(field, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new FormFieldParameter(field, queryParamAnnotation, MethodParameterType.Query));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findAnnotation(field, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new FormFieldParameter(field, headerParamAnnotation, MethodParameterType.Header));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findAnnotation(field, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new FormFieldParameter(field, cookieParamAnnotation, MethodParameterType.Cookie));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findAnnotation(field, FormParam.class);
      if (formParamAnnotation != null) {
        formParameters.add(new FormFieldParameter(field, formParamAnnotation, MethodParameterType.Form));
        continue;
      }
      //Recurse into the embedded @Form field
      if(formClass != null) {
        final AnnotationDesc formAnnotation = Utils.findAnnotation(field, formClass);
        if(formAnnotation != null) {
            walkFormParameter(field.type().asClassDoc());
            continue;
        }
      }
     
      final AnnotationDesc contextAnnotation = Utils.findAnnotation(field, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new FormFieldParameter(field, null, MethodParameterType.Input);
        continue;
      }
    }
    // and methods
    for (MethodDoc method : formDoc.methods(false)) {
      if (!method.returnType().qualifiedTypeName().equals("void") || method.parameters().length != 1 || !method.name().startsWith("set"))
        continue;
      Parameter parameter = method.parameters()[0];
      final AnnotationDesc pathParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new FormMethodParameter(method, pathParamAnnotation, MethodParameterType.Path));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(matrixParamAnnotation);
        matrixParameters.add(new FormMethodParameter(method, matrixParamAnnotation, MethodParameterType.Matrix));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new FormMethodParameter(method, queryParamAnnotation, MethodParameterType.Query));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new FormMethodParameter(method, headerParamAnnotation, MethodParameterType.Header));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new FormMethodParameter(method, cookieParamAnnotation, MethodParameterType.Cookie));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, FormParam.class);
      if (formParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(formParamAnnotation);
        formParameters.add(new FormMethodParameter(method, formParamAnnotation, MethodParameterType.Form));
        continue;
      }
      // I'm not sure if @Form can be used on setter methods on an @Form field, but just in case...
      if(formClass != null) {
        //recurse into @Form parameters
        final AnnotationDesc formAnnotation = Utils.findParameterAnnotation(method, parameter, 0, formClass);
        if(formAnnotation != null) {
            walkFormParameter(parameter.type().asClassDoc());
            continue;
        }
      }
      final AnnotationDesc contextAnnotation = Utils.findParameterAnnotation(method, parameter, 0, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new FormMethodParameter(method, null, MethodParameterType.Input);
      }
    }
  }
View Full Code Here

      }
    }
  }

  private void setupPath() {
    final AnnotationDesc pathAnnotation = Utils.findMethodAnnotation(declaringClass, method, Path.class);
    final String rootPath = resource.getPath();
    if (pathAnnotation != null) {
      String path = (String) Utils.getAnnotationValue(pathAnnotation);
      path = Utils.removeFragmentRegexes(path, regexFragments);
      this.path = Utils.appendURLFragments(rootPath, path);
View Full Code Here

    }
    return httpMethods;
  }

  public List<String> getProduces() {
    AnnotationDesc produces = getProducesAnnotation();
    if (produces == null) {
      return Collections.emptyList();
    } else {
      return Arrays.asList(Utils.getAnnotationValues(produces));
    }
View Full Code Here

      return Arrays.asList(Utils.getAnnotationValues(produces));
    }
  }

  public List<String> getConsumes() {
    AnnotationDesc consumes = getConsumesAnnotation();
    if (consumes == null) {
      return Collections.emptyList();
    } else {
      return Arrays.asList(Utils.getAnnotationValues(consumes));
    }
View Full Code Here

  public JAXBClass(ClassDoc klass, Registry registry, JAXBDoclet doclet) {
    // System.err.println("Root: " + klass.name());
    this.klass = klass;
    this.registry = registry;
    this.doclet = doclet;
    AnnotationDesc rootAnnotation = Utils.findAnnotation(klass, XmlRootElement.class);
    if (rootAnnotation != null) {
      name = (String) Utils.getAnnotationValue(rootAnnotation, "name");
      namespace = (String) Utils.getAnnotationValue(rootAnnotation, "namespace");
    }
    if (name == null)
View Full Code Here

    setupMembers(klass);
  }

  private void setupMembers(ClassDoc klass) {
    ClassDoc accessorAnnotationType = Utils.findAnnotatedClass(klass, XmlAccessorType.class);
    AnnotationDesc accessorAnnotation = null;
    if (accessorAnnotationType != null) {
      accessorAnnotation = Utils.findAnnotation(accessorAnnotationType, XmlAccessorType.class);
    } else {
      accessorAnnotation = Utils.findAnnotation(klass.containingPackage(), XmlAccessorType.class);
    }
View Full Code Here

    if (property.isMethod() && !isProperty((MethodDoc) property))
      return;
    if (property.isStatic())
      return;

    AnnotationDesc xmlElementAnnotation = Utils.findAnnotation(property, XmlElement.class);
    AnnotationDesc xmlAttributeAnnotation = Utils.findAnnotation(property, XmlAttribute.class);
    AnnotationDesc xmlValueAnnotation = Utils.findAnnotation(property, XmlValue.class);
    AnnotationDesc xmlTransientAnnotation = Utils.findAnnotation(property, XmlTransient.class);
    boolean hasXmlAnnotation = xmlElementAnnotation != null || xmlAttributeAnnotation != null || xmlValueAnnotation != null;
    boolean isTransient = xmlTransientAnnotation != null;
    if (property.isField()) {
      isTransient |= ((FieldDoc) property).isTransient();
    }
View Full Code Here

TOP

Related Classes of com.sun.javadoc.AnnotationDesc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.