@Override
 public String print(int length) throws Exception {
   String space = TransformUtil.spaces(length);
   String space1 = TransformUtil.spaces(length + 4);
   String space2 = TransformUtil.spaces(length + 8);
   String result = "";
   try {
     result += space + "RuntimeVisibleParameterAnnotations : \n";
     result +=
         space1
             + "num_parameters : "
             + TransformUtil.bytesToInt(new byte[] {getNum_parameters()})
             + "\n";
     List<Parameter> parameters = getParameters();
     for (Parameter parameter : parameters) {
       result += space1 + "parameter: \n";
       result +=
           space2
               + "num_annotations: "
               + TransformUtil.bytesToInt(parameter.getNum_annotations())
               + "\n";
       List<Annotation> annotations = parameter.getAnnotations();
       for (Annotation annotation : annotations) {
         result += annotation.print(length + 8);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
Exemplo n.º 2
0
  public void visit(Parameter n, Object arg) {
    printAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    n.getType().accept(this, arg);
    if (n.isVarArgs()) {}
    n.getId().accept(this, arg);
  }
Exemplo n.º 3
0
    public T fromAnnotations() {
      Annotation[] annotations = parameter.getAnnotations();
      AccessibleObject injectTarget = parameter.getAccessibleObject();
      Class<?> type = parameter.getResourceClass().getClazz();

      parameter.encoded =
          findAnnotation(annotations, Encoded.class) != null
              || injectTarget.isAnnotationPresent(Encoded.class)
              || type.isAnnotationPresent(Encoded.class);
      DefaultValue defaultValue = findAnnotation(annotations, DefaultValue.class);
      if (defaultValue != null) parameter.defaultValue = defaultValue.value();

      QueryParam query;
      HeaderParam header;
      MatrixParam matrix;
      PathParam uriParam;
      CookieParam cookie;
      FormParam formParam;
      Form form;
      Suspend suspend;
      Suspended suspended;

      if ((query = findAnnotation(annotations, QueryParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.QUERY_PARAM;
        parameter.paramName = query.value();
      } else if ((header = findAnnotation(annotations, HeaderParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.HEADER_PARAM;
        parameter.paramName = header.value();
      } else if ((formParam = findAnnotation(annotations, FormParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.FORM_PARAM;
        parameter.paramName = formParam.value();
      } else if ((cookie = findAnnotation(annotations, CookieParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.COOKIE_PARAM;
        parameter.paramName = cookie.value();
      } else if ((uriParam = findAnnotation(annotations, PathParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.PATH_PARAM;
        parameter.paramName = uriParam.value();
      } else if ((form = findAnnotation(annotations, Form.class)) != null) {
        parameter.paramType = Parameter.ParamType.FORM;
        parameter.paramName = form.prefix();
      } else if (findAnnotation(annotations, BeanParam.class) != null) {
        parameter.paramType = Parameter.ParamType.BEAN_PARAM;
      } else if ((matrix = findAnnotation(annotations, MatrixParam.class)) != null) {
        parameter.paramType = Parameter.ParamType.MATRIX_PARAM;
        parameter.paramName = matrix.value();
      } else if ((suspend = findAnnotation(annotations, Suspend.class)) != null) {
        parameter.paramType = Parameter.ParamType.SUSPEND;
        parameter.suspendTimeout = suspend.value();
      } else if (findAnnotation(annotations, Context.class) != null) {
        parameter.paramType = Parameter.ParamType.CONTEXT;
      } else if ((suspended = findAnnotation(annotations, Suspended.class)) != null) {
        parameter.paramType = Parameter.ParamType.SUSPENDED;
      } else if (javax.ws.rs.container.AsyncResponse.class.isAssignableFrom(type)) {
        parameter.paramType = Parameter.ParamType.SUSPENDED;
      } else if (findAnnotation(annotations, Body.class) != null) {
        parameter.paramType = Parameter.ParamType.MESSAGE_BODY;
      } else {
        parameter.paramType = Parameter.ParamType.UNKNOWN;
      }
      return (T) this;
    }