javax.ws.rs.core.UriBuilder.buildFromEncodedMap()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中javax.ws.rs.core.UriBuilder.buildFromEncodedMap()方法的一些代码示例,展示了UriBuilder.buildFromEncodedMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.buildFromEncodedMap()方法的具体详情如下:
包路径:javax.ws.rs.core.UriBuilder
类名称:UriBuilder
方法名:buildFromEncodedMap

UriBuilder.buildFromEncodedMap介绍

[英]Build a URI, any URI template parameters will be replaced by the value in the supplied map. Values are converted to String using their toString method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.
[中]构建URI时,任何URI模板参数都将被提供的映射中的值替换。使用toString方法将值转换为String,然后对其进行编码以匹配它们所属的URI组件的规则。字符串化值中未后跟两个十六进制数的所有%字符都将被编码。建筑商的状态不受影响;在同一个生成器实例上,可以多次调用此方法。

代码示例

代码示例来源:origin: io.github.ma1uta.matrix/client-sdk

/**
 * Build the request URI.
 *
 * @param params  The request params.
 * @param builder The URI builder.
 * @return The request URI.
 */
protected URI buildUri(RequestParams params, UriBuilder builder) {
  Map<String, String> encoded = params.getPathParams().entrySet().stream()
    .collect(toMap(Map.Entry::getKey, e -> encode(e.getValue())));
  return builder.buildFromEncodedMap(encoded);
}

代码示例来源:origin: org.apache.wink/wink-server

private List<SyndLink> build(List<SyndLink> out, UriBuilder builder) {
  if (AtomConstants.ATOM_REL_SELF.equals(rel) || AtomConstants.ATOM_REL_EDIT.equals(rel)) {
    SyndLink link = getLink(out, rel);
    if (link != null) {
      out.remove(link);
    }
  }
  URI href = builder.buildFromEncodedMap(pathParams);
  out.add(createLink(rel, type, href));
  return out;
}

代码示例来源:origin: RentTheRunway/alchemy

private URI assembleRequestURI(Map<String, ?> pathParams, ListMultimap<String, Object> queryParams, String path) {
  final UriBuilder builder =
    UriBuilder
      .fromUri(configuration.getService())
      .path(path);
  for (String queryParam : queryParams.keySet()) {
    final List<Object> values = queryParams.get(queryParam);
    for (Object value : values) {
      builder.queryParam(queryParam, value);
    }
  }
  return builder.buildFromEncodedMap(pathParams);
}

代码示例来源:origin: org.jclouds/jclouds-aws

public void bindToRequest(HttpRequest request, Object payload) {
   if (isVhostStyle) {
     bindAsHostPrefix.bindToRequest(request, payload);
     request.getHeaders().replaceValues(HttpHeaders.HOST,
         ImmutableSet.of(request.getEndpoint().getHost()));
   } else {
     UriBuilder builder = uriBuilderProvider.get().uri(request.getEndpoint());
     StringBuilder path = new StringBuilder(urlEncode(request.getEndpoint().getPath(),
         S3AsyncClient.class.getAnnotation(SkipEncoding.class).value()));
     int indexToInsert = path.indexOf(servicePath);
     indexToInsert = indexToInsert == -1 ? 0 : indexToInsert;
     indexToInsert += servicePath.length();
     path.insert(indexToInsert, "/" + payload.toString());
     builder.replacePath(path.toString());
     request.setEndpoint(builder.buildFromEncodedMap(Maps.<String, Object> newHashMap()));
   }
  }
}

代码示例来源:origin: org.apache.wink/wink-server

URI selfUri = selfUriBuilder.buildFromEncodedMap(pathParams);
if (systemLinksToGenerate.contains(LinkType.SELF) && getLink(set,
                               AtomConstants.ATOM_REL_SELF) == null) {
                     MediaTypeUtils.toEncodedString(mediaType));
  URI href = selfUriBuilder.buildFromEncodedMap(pathParams);
  if (MediaTypeUtils.equalsIgnoreParameters(mediaType, MediaTypeUtils.OPENSEARCH_TYPE)) {
    if (systemLinksToGenerate.contains(LinkType.OPENSEARCH)) {

代码示例来源:origin: org.apache.wink/wink-server

@Override
public List<SyndLink> build(List<SyndLink> out) {
  Set<SyndLink> set = new HashSet<SyndLink>();
  // if the search mode is "Continued Search" we need to generate links
  // for all
  // of the matching root resources and not just for the current one
  if (allResources) {
    // get the path to use for obtaining the matching root resources
    URI uri = UriBuilder.fromPath(resourcePath).buildFromEncodedMap(pathParams);
    String path = uri.toString();
    List<ResourceInstance> rootResources = registry.getMatchingRootResources(path);
    // go over all the root matching resources and generate links for
    // them
    for (ResourceInstance rootResource : rootResources) {
      UriBuilder uriBuilder = initUriBuilder(path);
      ResourceRecord record = rootResource.getRecord();
      build(set, uriBuilder, record);
    }
  } else {
    // generate links just for this one resource
    UriBuilder uriBuilder = initUriBuilder();
    build(set, uriBuilder, record);
  }
  if (out == null) {
    out = new LinkedList<SyndLink>();
  }
  out.addAll(set);
  return out;
}

代码示例来源:origin: bbilger/jrestless

actualPath = path;
} else if (pathParams != null) {
  actualPath = pathUriBuilder.buildFromEncodedMap(pathParams).toString();
} else {
  actualPath = pathUriBuilder.build().toString();

相关文章