コード例 #1
0
  /**
   * The applicable media types for this resource.
   *
   * @return The applicable media types for this resource.
   */
  public List<ResourceMethodMediaType> getApplicableMediaTypes() {
    HashMap<String, ResourceMethodMediaType> applicableTypes =
        new HashMap<String, ResourceMethodMediaType>();
    for (String consumesMime : getConsumesMime()) {
      String type;
      try {
        type = MimeType.parse(consumesMime).toString();
      } catch (Exception e) {
        type = consumesMime;
      }

      ResourceMethodMediaType supportedType = applicableTypes.get(type);
      if (supportedType == null) {
        supportedType = new ResourceMethodMediaType();
        supportedType.setType(type);
        applicableTypes.put(type, supportedType);
      }
      supportedType.setConsumable(true);
    }
    for (String producesMime : getProducesMime()) {
      String type;
      try {
        type = MimeType.parse(producesMime).toString();
      } catch (Exception e) {
        type = producesMime;
      }

      ResourceMethodMediaType supportedType = applicableTypes.get(type);
      if (supportedType == null) {
        supportedType = new ResourceMethodMediaType();
        supportedType.setType(type);
        applicableTypes.put(type, supportedType);
      }
      supportedType.setProduceable(true);
    }

    return new ArrayList<ResourceMethodMediaType>(applicableTypes.values());
  }
コード例 #2
0
  /**
   * Loads the overridden resource parameter values.
   *
   * @param signatureOverride The signature override.
   * @return The explicit resource parameters.
   */
  protected List<ResourceParameter> loadResourceParameters(
      ResourceMethodSignature signatureOverride) {
    HashMap<String, String> paramComments = parseParamComments(getJavaDoc());

    ArrayList<ResourceParameter> params = new ArrayList<ResourceParameter>();
    for (CookieParam cookieParam : signatureOverride.cookieParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(cookieParam.value()),
              cookieParam.value(),
              ResourceParameterType.COOKIE));
    }
    for (MatrixParam matrixParam : signatureOverride.matrixParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(matrixParam.value()),
              matrixParam.value(),
              ResourceParameterType.MATRIX));
    }
    for (QueryParam queryParam : signatureOverride.queryParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(queryParam.value()),
              queryParam.value(),
              ResourceParameterType.QUERY));
    }
    for (PathParam pathParam : signatureOverride.pathParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(pathParam.value()),
              pathParam.value(),
              ResourceParameterType.PATH));
    }
    for (HeaderParam headerParam : signatureOverride.headerParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(headerParam.value()),
              headerParam.value(),
              ResourceParameterType.HEADER));
    }
    for (FormParam formParam : signatureOverride.formParams()) {
      params.add(
          new ExplicitResourceParameter(
              this,
              paramComments.get(formParam.value()),
              formParam.value(),
              ResourceParameterType.FORM));
    }

    return params;
  }