public void process() {
   for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) {
     ExtractInterface annot = typeDecl.getAnnotation(ExtractInterface.class);
     if (annot == null) break;
     for (MethodDeclaration m : typeDecl.getMethods())
       if (m.getModifiers().contains(Modifier.PUBLIC)
           && !(m.getModifiers().contains(Modifier.STATIC))) interfaceMethods.add(m);
     if (interfaceMethods.size() > 0) {
       try {
         PrintWriter writer = env.getFiler().createSourceFile(annot.value());
         writer.println("package " + typeDecl.getPackage().getQualifiedName() + ";");
         writer.println("public interface " + annot.value() + " {");
         for (MethodDeclaration m : interfaceMethods) {
           writer.print("  public ");
           writer.print(m.getReturnType() + " ");
           writer.print(m.getSimpleName() + " (");
           int i = 0;
           for (ParameterDeclaration parm : m.getParameters()) {
             writer.print(parm.getType() + " " + parm.getSimpleName());
             if (++i < m.getParameters().size()) writer.print(", ");
           }
           writer.println(");");
         }
         writer.println("}");
         writer.close();
       } catch (IOException ioe) {
         throw new RuntimeException(ioe);
       }
     }
   }
 }
  @Override
  public void process() {
    EclipseMessager messager = (EclipseMessager) _env.getMessager();

    // obtain the declaration of the annotation we want to process
    AnnotationTypeDeclaration annoDecl =
        (AnnotationTypeDeclaration) _env.getTypeDeclaration(JSFillChildrenMethod.class.getName());

    // get the annotated types
    Collection<Declaration> annotatedTypes = _env.getDeclarationsAnnotatedWith(annoDecl);

    for (Declaration decl : annotatedTypes) {
      Collection<AnnotationMirror> mirrors = decl.getAnnotationMirrors();

      // for each annotation found, get a map of element name/value pairs
      for (AnnotationMirror mirror : mirrors) {
        if (!"JSFillChildrenMethod"
            .equals(mirror.getAnnotationType().getDeclaration().getSimpleName())) {
          continue;
        }
        MethodDeclaration methodDeclaration = (MethodDeclaration) decl;
        JSJPQLMethodProcessor.checkReturnType(mirror, methodDeclaration, messager);
        JSJPQLMethodProcessor.checkTransferInfo(mirror, methodDeclaration, true, messager);
        JSJPQLMethodProcessor.checkIfAnnotationValueAttributeIsEntity(mirror, "parent", messager);
      }
    }
  }
  /**
   * Loads the specified entity parameter according to the method signature override.
   *
   * @param signatureOverride The signature override.
   * @return The resource entity parameter.
   */
  protected ResourceEntityParameter loadEntityParameter(ResourceMethodSignature signatureOverride) {
    try {
      Class<?> entityType = signatureOverride.input();
      if (entityType != ResourceMethodSignature.NONE.class) {
        AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
        TypeDeclaration type = env.getTypeDeclaration(entityType.getName());
        return new ResourceEntityParameter(type, env.getTypeUtils().getDeclaredType(type));
      }
    } catch (MirroredTypeException e) {
      DecoratedTypeMirror typeMirror =
          (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
      if (typeMirror.isDeclared()) {
        if (typeMirror.isInstanceOf(ResourceMethodSignature.class.getName() + ".NONE")) {
          return null;
        } else {
          return new ResourceEntityParameter(
              ((DeclaredType) typeMirror).getDeclaration(), typeMirror);
        }
      } else {
        throw new ValidationException(
            getPosition(), "Illegal input type (must be a declared type): " + typeMirror);
      }
    }

    return null;
  }
  /**
   * Loads the explicit output payload.
   *
   * @param signatureOverride The method signature override.
   * @return The output payload (explicit in the signature override.
   */
  protected ResourceRepresentationMetadata loadOutputPayload(
      ResourceMethodSignature signatureOverride) {
    DecoratedTypeMirror returnType = (DecoratedTypeMirror) getReturnType();

    try {
      Class<?> outputType = signatureOverride.output();
      if (outputType != ResourceMethodSignature.NONE.class) {
        AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
        TypeDeclaration type = env.getTypeDeclaration(outputType.getName());
        return new ResourceRepresentationMetadata(
            env.getTypeUtils().getDeclaredType(type), returnType.getDocValue());
      }
    } catch (MirroredTypeException e) {
      DecoratedTypeMirror typeMirror =
          (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
      if (typeMirror.isDeclared()) {
        if (typeMirror.isInstanceOf(ResourceMethodSignature.class.getName() + ".NONE")) {
          return null;
        }
        return new ResourceRepresentationMetadata(typeMirror, returnType.getDocValue());
      } else {
        throw new ValidationException(
            getPosition(), "Illegal output type (must be a declared type): " + typeMirror);
      }
    }

    return null;
  }
  @Override
  public void generate() {
    if (!comp.isEnable() || comp.isOnlyBuildComponentFile()) {
      return;
    }

    String projectBase = System.getProperty("projectBase");
    String filename = comp.getComponentConfigFileURL(projectBase);
    // 读取文件
    Document document = XmlFileHelper.read(filename);
    if (document == null) {
      env.getMessager().printError("读取以下文件失败:" + filename);
      return;
    }

    // 如果节点存在,更新节点
    boolean exists = false;
    NodeList components = document.getElementsByTagName("component");
    componentLabel:
    for (int i = 0; i < components.getLength(); i++) {
      Node component = components.item(i);
      for (int j = 0; j < component.getChildNodes().getLength(); j++) {
        Node child = component.getChildNodes().item(j);
        if ("component-type".equals(child.getNodeName())
            && child.getTextContent().equals(comp.getComponentType())) {
          exists = true;
        }
        if ("component-class".equals(child.getNodeName()) && exists) {
          child.setTextContent(comp.getQualifiedComponentClassName());
          break componentLabel;
        }
      }
    }

    // 如果节点不存在,插入节点
    if (!exists) {
      Element newComponent = document.createElement("component");
      Element newType = document.createElement("component-type");
      newType.appendChild(document.createTextNode(comp.getComponentType()));
      Element newClass = document.createElement("component-class");
      newClass.appendChild(document.createTextNode(comp.getQualifiedComponentClassName()));
      newComponent.appendChild(newType);
      newComponent.appendChild(newClass);

      Node facesConfig = document.getElementsByTagName("faces-config").item(0);
      facesConfig.appendChild(document.createTextNode("\t"));
      facesConfig.appendChild(newComponent);
    }

    // 写回文件
    if (!XmlFileHelper.write(filename, document, false)) {
      env.getMessager().printError("写回以下文件失败:" + filename);
    }
  }
  public AnnotationProcessor getProcessorFor(
      Set<AnnotationTypeDeclaration> annotations, AnnotationProcessorEnvironment env) {
    String name = null;
    // this seems like it shouldn't be necessary
    for (String key : env.getOptions().keySet()) {
      if (key.startsWith(USE_CASES_ANNOTATION_CLASS_NAME_OPT)) {
        name = key.substring(USE_CASES_ANNOTATION_CLASS_NAME_OPT.length());
        break;
      }
    }
    if (name == null) {
      throw new CommonsSystemException(
          USE_CASES_ANNOTATION_CLASS_NAME_OPT + " option not provided: " + env.getOptions());
    }

    return new UseCaseTraceabilityAnnotationProcessor(env, useCasesAnnotationClass(name));
  }
Example #7
0
  public AnnotationProcessor getProcessorFor(
      Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {

    if (bcproc == null) bcproc = new BuildCompleteProcessor(env);

    ArrayList<AnnotationProcessor> aps = new ArrayList<AnnotationProcessor>();
    for (AnnotationTypeDeclaration atdecl : atds) {

      if (atdecl.getQualifiedName().equals(Exportable.class.getName())) {
        // System.out.println("Getting Exportable processor");
        aps.add(new ExportableProcessor(env, bcproc));
      }
      if (atdecl.getQualifiedName().equals(Service.class.getName())) {
        aps.add(new ServiceProcessor(env, bcproc));
      }
      if (atdecl.getQualifiedName().equals(LocalService.class.getName())) {
        aps.add(new LocalServiceProcessor(env, bcproc));
      }
      if (atdecl.getQualifiedName().equals(ServiceUI.class.getName())) {
        aps.add(new ServiceUIProcessor(env, bcproc));
      }
      if (atdecl.getQualifiedName().equals(LeasedResource.class.getName())) {
        aps.add(new LeasedResourceProcessor(env, bcproc));
      }
      if (atdecl.getQualifiedName().equals(Client.class.getName())) {
        aps.add(new ClientProcessor(env, bcproc));
      }
    }
    // We return a combined processor for all the annotations in the file
    if (aps.size() > 0) return AnnotationProcessors.getCompositeAnnotationProcessor(aps);
    else {
      env.getMessager().printNotice("Checking for any more final processing");
      if (bcproc.awaitingPostProcessing()) return bcproc;
      else {
        env.getMessager().printNotice("Current Glyph processing complete.....");
        return AnnotationProcessors.NO_OP;
      }
    }
  }
  private static void generateMethodStub(
      AnnotationProcessorEnvironment env,
      TypeMap type_map,
      PrintWriter writer,
      String interface_name,
      MethodDeclaration method,
      Mode mode,
      boolean generate_error_checks,
      boolean context_specific) {
    if (!context_specific && method.getAnnotation(Alternate.class) == null) writer.print("static ");
    else writer.print("JNIEXPORT ");

    TypeMirror result_type = Utils.getMethodReturnType(method);

    if (method.getAnnotation(GLpointer.class) != null) {
      writer.print("jlong");
    } else {
      JNITypeTranslator translator = new JNITypeTranslator();
      result_type.accept(translator);
      writer.print(translator.getSignature());
    }
    writer.print(" JNICALL ");

    writer.print(
        Utils.getQualifiedNativeMethodName(
            interface_name, method, generate_error_checks, context_specific));
    if (mode == Mode.BUFFEROBJECT) writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
    writer.print("(JNIEnv *env, jclass clazz");
    generateParameters(writer, method.getParameters(), mode);
    if (Utils.getNIOBufferType(result_type) != null) {
      CachedResult cached_result_annotation = method.getAnnotation(CachedResult.class);
      if (cached_result_annotation == null || !cached_result_annotation.isRange())
        writer.print(", jlong " + Utils.RESULT_SIZE_NAME);
      if (cached_result_annotation != null) writer.print(", jobject " + Utils.CACHED_BUFFER_NAME);
    }
    if (context_specific) {
      writer.print(", jlong " + Utils.FUNCTION_POINTER_VAR_NAME);
    }
    writer.println(") {");
    generateBufferParameterAddresses(type_map, writer, method, mode);
    Alternate alt_annotation = method.getAnnotation(Alternate.class);
    if (context_specific) {
      String typedef_name = Utils.getTypedefName(method);
      writer.print(
          "\t"
              + typedef_name
              + " "
              + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()));
      writer.print(" = (" + typedef_name + ")((intptr_t)");
      writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
    }
    generateStringListInits(writer, method.getParameters());
    writer.print("\t");
    if (!result_type.equals(env.getTypeUtils().getVoidType())) {
      Declaration return_declaration;
      ParameterDeclaration result_param = Utils.getResultParameter(method);
      if (result_param != null) return_declaration = result_param;
      else return_declaration = method;
      NativeTypeTranslator native_translator =
          new NativeTypeTranslator(type_map, return_declaration);
      result_type.accept(native_translator);
      writer.print(native_translator.getSignature() + " " + Utils.RESULT_VAR_NAME);
      if (result_param != null) {
        writer.println(";");
        writer.print("\t");
      } else writer.print(" = ");
    }
    writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "(");
    generateCallParameters(writer, type_map, method.getParameters());
    writer.print(")");
    writer.println(";");
    generateStringDeallocations(writer, method.getParameters());
    if (!result_type.equals(env.getTypeUtils().getVoidType())) {
      writer.print("\treturn ");
      Class java_result_type = Utils.getJavaType(result_type);
      if (Buffer.class.isAssignableFrom(java_result_type)) {
        if (method.getAnnotation(CachedResult.class) != null)
          writer.print("safeNewBufferCached(env, ");
        else writer.print("safeNewBuffer(env, ");
      } else if (String.class.equals(java_result_type)) {
        writer.print("NewStringNativeUnsigned(env, ");
      } else if (method.getAnnotation(GLpointer.class) != null) {
        writer.print("(intptr_t)");
      }
      writer.print(Utils.RESULT_VAR_NAME);
      if (Buffer.class.isAssignableFrom(java_result_type)) {
        writer.print(", ");
        if (method.getAnnotation(CachedResult.class) != null
            && method.getAnnotation(CachedResult.class).isRange())
          Utils.printExtraCallArguments(
              writer, method, method.getAnnotation(AutoResultSize.class).value());
        else Utils.printExtraCallArguments(writer, method, Utils.RESULT_SIZE_NAME);
      }
      if (Buffer.class.isAssignableFrom(java_result_type) || String.class.equals(java_result_type))
        writer.print(")");
      writer.println(";");
    }
    writer.println("}");
    writer.println();
  }
  @Override
  public void process() {
    final AnnotationTypeDeclaration beanAnn =
        (AnnotationTypeDeclaration) env_.getTypeDeclaration(Bean.class.getName());
    for (Declaration declaration : env_.getDeclarationsAnnotatedWith(beanAnn)) {
      try {
        if (!(declaration instanceof ClassDeclaration)) {
          error(declaration, "You can only annotate class declarations with @Bean");
          return;
        }

        Thing data = new Thing("data");

        ClassDeclaration classDeclaration = (ClassDeclaration) declaration;
        PackageDeclaration packageDeclaration = classDeclaration.getPackage();

        Map<String, AnnotationValue> beanValues =
            getAnnotationValues(classDeclaration, "com.javadude.annotation.Bean");

        checkExtends(classDeclaration, packageDeclaration); // check that the class extends XXXGen
        processSuperclass(data, beanValues); // process the superclass attribute
        processProperties(data, beanValues);
        processObservers(data, beanValues);
        processNullObjects(data, beanValues);
        processDelegates(data, beanValues);
        processDefaultMethods(data, classDeclaration);

        setValue(data, beanValues, "cloneable", false);
        setValue(data, beanValues, "defineEqualsAndHashCode", false);
        setValue(data, beanValues, "equalsAndHashCodeCallSuper", false);
        setValue(data, beanValues, "definePropertyNameConstants", false);
        setValue(data, beanValues, "defineCreatePropertyMap", false);
        data.put("date", new Date());
        data.put("year", Calendar.getInstance().get(Calendar.YEAR));
        data.put("className", classDeclaration.getSimpleName());
        data.put("packageName", packageDeclaration.getQualifiedName());

        data.checkAllValuesSet(declaration, this);

        Filer f = env_.getFiler();
        PrintWriter pw = f.createSourceFile(classDeclaration.getQualifiedName() + "Gen");

        if (nestedEclipse) {
          // debugging in eclipse -- reread the template each time
          FileReader fileReader =
              new FileReader(
                  workspace
                      + "/com.javadude.annotation/template/$packageName$/$className$Gen.java");
          template = new TemplateReader().readTemplate(fileReader);
        }
        int spacesForLeadingTabs = i(beanValues, "spacesForLeadingTabs", -1);
        String padding = null;
        if (spacesForLeadingTabs != -1) {
          padding = "";
          for (int i = 0; i < spacesForLeadingTabs; i++) {
            padding += ' ';
          }
        }
        template.process(new Symbols(data), pw, -1, padding);
        pw.close();
      } catch (ThreadDeath e) {
        throw e;
      } catch (ExpressionException e) {
        error(declaration, "@Bean generator error: " + e.getMessage());
      } catch (Throwable t) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        t.printStackTrace(printWriter);
        printWriter.close();
        error(declaration, "Unexpected exception: " + stringWriter.toString());
      }
    }
  }
 public void error(AnnotationValue value, String message) {
   env_.getMessager().printError(value.getPosition(), message);
 }
 public void error(Declaration declaration, String message) {
   env_.getMessager().printError(declaration.getPosition(), message);
 }
 public void error(AnnotationMirror annotationMirror, String message) {
   env_.getMessager().printError(annotationMirror.getPosition(), message);
 }
Example #13
0
  public ResourceMethod(MethodDeclaration delegate, Resource parent) {
    super(delegate);

    Set<String> httpMethods = new TreeSet<String>();
    Collection<AnnotationMirror> mirrors = delegate.getAnnotationMirrors();
    for (AnnotationMirror mirror : mirrors) {
      AnnotationTypeDeclaration annotationDeclaration = mirror.getAnnotationType().getDeclaration();
      HttpMethod httpMethodInfo = annotationDeclaration.getAnnotation(HttpMethod.class);
      if (httpMethodInfo != null) {
        // request method designator found.
        httpMethods.add(httpMethodInfo.value());
      }
    }

    if (httpMethods.isEmpty()) {
      throw new IllegalStateException(
          "A resource method must specify an HTTP method by using a request method designator annotation.");
    }

    this.httpMethods = httpMethods;

    Set<String> consumes;
    Consumes consumesInfo = delegate.getAnnotation(Consumes.class);
    if (consumesInfo != null) {
      consumes = new TreeSet<String>(Arrays.asList(JAXRSUtils.value(consumesInfo)));
    } else {
      consumes = new TreeSet<String>(parent.getConsumesMime());
    }
    this.consumesMime = consumes;

    Set<String> produces;
    Produces producesInfo = delegate.getAnnotation(Produces.class);
    if (producesInfo != null) {
      produces = new TreeSet<String>(Arrays.asList(JAXRSUtils.value(producesInfo)));
    } else {
      produces = new TreeSet<String>(parent.getProducesMime());
    }
    this.producesMime = produces;

    String subpath = null;
    Path pathInfo = delegate.getAnnotation(Path.class);
    if (pathInfo != null) {
      subpath = pathInfo.value();
    }

    ResourceEntityParameter entityParameter;
    List<ResourceEntityParameter> declaredEntityParameters =
        new ArrayList<ResourceEntityParameter>();
    List<ResourceParameter> resourceParameters;
    ResourceRepresentationMetadata outputPayload;
    ResourceMethodSignature signatureOverride =
        delegate.getAnnotation(ResourceMethodSignature.class);
    if (signatureOverride == null) {
      entityParameter = null;
      resourceParameters = new ArrayList<ResourceParameter>();
      // if we're not overriding the signature, assume we use the real method signature.
      for (ParameterDeclaration parameterDeclaration : getParameters()) {
        if (ResourceParameter.isResourceParameter(parameterDeclaration)) {
          resourceParameters.add(new ResourceParameter(parameterDeclaration));
        } else if (ResourceParameter.isFormBeanParameter(parameterDeclaration)) {
          resourceParameters.addAll(ResourceParameter.getFormBeanParameters(parameterDeclaration));
        } else if (parameterDeclaration.getAnnotation(Context.class) == null) {
          entityParameter = new ResourceEntityParameter(this, parameterDeclaration);
          declaredEntityParameters.add(entityParameter);
        }
      }

      DecoratedTypeMirror returnTypeMirror;
      TypeHint hintInfo = getAnnotation(TypeHint.class);
      if (hintInfo != null) {
        try {
          Class hint = hintInfo.value();
          AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
          if (TypeHint.NO_CONTENT.class.equals(hint)) {
            returnTypeMirror =
                (DecoratedTypeMirror)
                    TypeMirrorDecorator.decorate(env.getTypeUtils().getVoidType());
          } else {
            String hintName = hint.getName();

            if (TypeHint.NONE.class.equals(hint)) {
              hintName = hintInfo.qualifiedName();
            }

            if (!"##NONE".equals(hintName)) {
              TypeDeclaration type = env.getTypeDeclaration(hintName);
              returnTypeMirror =
                  (DecoratedTypeMirror)
                      TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
            } else {
              returnTypeMirror = (DecoratedTypeMirror) getReturnType();
            }
          }
        } catch (MirroredTypeException e) {
          returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
        }
        returnTypeMirror.setDocComment(((DecoratedTypeMirror) getReturnType()).getDocComment());
      } else {
        returnTypeMirror = (DecoratedTypeMirror) getReturnType();

        if (getJavaDoc().get("returnWrapped")
            != null) { // support jax-doclets. see http://jira.codehaus.org/browse/ENUNCIATE-690
          String fqn = getJavaDoc().get("returnWrapped").get(0);
          AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
          TypeDeclaration type = env.getTypeDeclaration(fqn);
          if (type != null) {
            returnTypeMirror =
                (DecoratedTypeMirror)
                    TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
          }
        }

        // in the case where the return type is com.sun.jersey.api.JResponse,
        // we can use the type argument to get the entity type
        if (returnTypeMirror.isClass()
            && returnTypeMirror.isInstanceOf("com.sun.jersey.api.JResponse")) {
          DecoratedClassType jresponse = (DecoratedClassType) returnTypeMirror;
          if (!jresponse.getActualTypeArguments().isEmpty()) {
            DecoratedTypeMirror responseType =
                (DecoratedTypeMirror)
                    TypeMirrorDecorator.decorate(
                        jresponse.getActualTypeArguments().iterator().next());
            if (responseType.isDeclared()) {
              responseType.setDocComment(returnTypeMirror.getDocComment());
              returnTypeMirror = responseType;
            }
          }
        }
      }

      outputPayload =
          returnTypeMirror.isVoid() ? null : new ResourceRepresentationMetadata(returnTypeMirror);
    } else {
      entityParameter = loadEntityParameter(signatureOverride);
      declaredEntityParameters.add(entityParameter);
      resourceParameters = loadResourceParameters(signatureOverride);
      outputPayload = loadOutputPayload(signatureOverride);
    }

    JavaDoc.JavaDocTagList doclets =
        getJavaDoc()
            .get(
                "RequestHeader"); // support jax-doclets. see
                                  // http://jira.codehaus.org/browse/ENUNCIATE-690
    if (doclets != null) {
      for (String doclet : doclets) {
        int firstspace = doclet.indexOf(' ');
        String header = firstspace > 0 ? doclet.substring(0, firstspace) : doclet;
        String doc =
            ((firstspace > 0) && (firstspace + 1 < doclet.length()))
                ? doclet.substring(firstspace + 1)
                : "";
        resourceParameters.add(
            new ExplicitResourceParameter(this, doc, header, ResourceParameterType.HEADER));
      }
    }

    ArrayList<ResponseCode> statusCodes = new ArrayList<ResponseCode>();
    ArrayList<ResponseCode> warnings = new ArrayList<ResponseCode>();
    StatusCodes codes = getAnnotation(StatusCodes.class);
    if (codes != null) {
      for (org.codehaus.enunciate.jaxrs.ResponseCode code : codes.value()) {
        ResponseCode rc = new ResponseCode();
        rc.setCode(code.code());
        rc.setCondition(code.condition());
        statusCodes.add(rc);
      }
    }

    doclets =
        getJavaDoc()
            .get("HTTP"); // support jax-doclets. see http://jira.codehaus.org/browse/ENUNCIATE-690
    if (doclets != null) {
      for (String doclet : doclets) {
        int firstspace = doclet.indexOf(' ');
        String code = firstspace > 0 ? doclet.substring(0, firstspace) : doclet;
        String doc =
            ((firstspace > 0) && (firstspace + 1 < doclet.length()))
                ? doclet.substring(firstspace + 1)
                : "";
        try {
          ResponseCode rc = new ResponseCode();
          rc.setCode(Integer.parseInt(code));
          rc.setCondition(doc);
          statusCodes.add(rc);
        } catch (NumberFormatException e) {
          // fall through...
        }
      }
    }

    Warnings warningInfo = getAnnotation(Warnings.class);
    if (warningInfo != null) {
      for (org.codehaus.enunciate.jaxrs.ResponseCode code : warningInfo.value()) {
        ResponseCode rc = new ResponseCode();
        rc.setCode(code.code());
        rc.setCondition(code.condition());
        warnings.add(rc);
      }
    }

    codes = parent.getAnnotation(StatusCodes.class);
    if (codes != null) {
      for (org.codehaus.enunciate.jaxrs.ResponseCode code : codes.value()) {
        ResponseCode rc = new ResponseCode();
        rc.setCode(code.code());
        rc.setCondition(code.condition());
        statusCodes.add(rc);
      }
    }

    warningInfo = parent.getAnnotation(Warnings.class);
    if (warningInfo != null) {
      for (org.codehaus.enunciate.jaxrs.ResponseCode code : warningInfo.value()) {
        ResponseCode rc = new ResponseCode();
        rc.setCode(code.code());
        rc.setCondition(code.condition());
        warnings.add(rc);
      }
    }

    ResponseHeaders responseHeaders = parent.getAnnotation(ResponseHeaders.class);
    if (responseHeaders != null) {
      for (ResponseHeader header : responseHeaders.value()) {
        this.responseHeaders.put(header.name(), header.description());
      }
    }

    responseHeaders = getAnnotation(ResponseHeaders.class);
    if (responseHeaders != null) {
      for (ResponseHeader header : responseHeaders.value()) {
        this.responseHeaders.put(header.name(), header.description());
      }
    }

    doclets =
        getJavaDoc()
            .get(
                "ResponseHeader"); // support jax-doclets. see
                                   // http://jira.codehaus.org/browse/ENUNCIATE-690
    if (doclets != null) {
      for (String doclet : doclets) {
        int firstspace = doclet.indexOf(' ');
        String header = firstspace > 0 ? doclet.substring(0, firstspace) : doclet;
        String doc =
            ((firstspace > 0) && (firstspace + 1 < doclet.length()))
                ? doclet.substring(firstspace + 1)
                : "";
        this.responseHeaders.put(header, doc);
      }
    }

    this.entityParameter = entityParameter;
    this.resourceParameters = resourceParameters;
    this.subpath = subpath;
    this.parent = parent;
    this.statusCodes = statusCodes;
    this.warnings = warnings;
    this.representationMetadata = outputPayload;
    this.declaredEntityParameters = declaredEntityParameters;
  }