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

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

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

UriBuilder.replaceQueryParam介绍

[英]Replace the existing value(s) of a query parameter. If multiple values are supplied the parameter will be added once per value.
[中]替换查询参数的现有值。如果提供了多个值,则每个值将添加一次参数。

代码示例

代码示例来源:origin: jersey/jersey

private static UriBuilder setQueryParam(UriBuilder uriBuilder, String name, Object[] values) {
  if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
    return uriBuilder.replaceQueryParam(name, (Object[]) null);
  }
  checkForNullValues(name, values);
  return uriBuilder.queryParam(name, values);
}

代码示例来源:origin: jersey/jersey

private static UriBuilder setQueryParam(UriBuilder uriBuilder, String name, Object[] values) {
  if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
    return uriBuilder.replaceQueryParam(name, (Object[]) null);
  }
  checkForNullValues(name, values);
  return uriBuilder.queryParam(name, values);
}

代码示例来源:origin: liferay/liferay-portal

public static URI updateWithQueryParameters(
  URI uri, Map<String, String> queryParameters) {
  if ((queryParameters == null) || queryParameters.isEmpty()) {
    return uri;
  }
  for (Map.Entry<String, String> parameter : queryParameters.entrySet()) {
    UriBuilder uriBuilder = UriBuilder.fromUri(uri);
    uri = uriBuilder.replaceQueryParam(
      parameter.getKey(), parameter.getValue()
    ).build();
  }
  return uri;
}

代码示例来源:origin: org.glassfish.jersey.core/jersey-client

private static UriBuilder setQueryParam(UriBuilder uriBuilder, String name, Object[] values) {
  if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
    return uriBuilder.replaceQueryParam(name, (Object[]) null);
  }
  checkForNullValues(name, values);
  return uriBuilder.queryParam(name, values);
}

代码示例来源:origin: liferay/liferay-portal

public static URI updateWithQueryParameters(
  String url, Map<String, String> queryParameters) {
  if ((queryParameters == null) || queryParameters.isEmpty()) {
    return getURI(url);
  }
  URI uri = null;
  for (Map.Entry<String, String> parameter : queryParameters.entrySet()) {
    UriBuilder uriBuilder = UriBuilder.fromUri(url);
    uri = uriBuilder.replaceQueryParam(
      parameter.getKey(), parameter.getValue()
    ).build();
  }
  return uri;
}

代码示例来源:origin: resteasy/Resteasy

@Override
public ResteasyWebTarget queryParam(String name, Object... values) throws NullPointerException
{
 client.abortIfClosed();
 if (name == null) throw new NullPointerException(Messages.MESSAGES.nameWasNull());
 UriBuilder copy = uriBuilder.clone();
 if (values == null || (values.length == 1 && values[0] == null))
 {
   copy.replaceQueryParam(name, null);
 }
 else
 {
   String[] stringValues = toStringValues(values);
   copy.queryParam(name, stringValues);
 }
 return newInstance(client, copy, configuration);
}

代码示例来源:origin: org.gatein.management/gatein-management-rest

public LinkBuilder replaceQueryParam(String name, Object... values) throws IllegalArgumentException
{
 uriBuilder.replaceQueryParam(name, values);
 return this;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-api

public Builder<T> setLinks(String self, int limit)
{
  this.self = UriBuilder.fromUri(self).replaceQueryParam("startAt", startAt).replaceQueryParam("maxResults", limit).build();
  if (!isLastPage)
  {
    this.nextPage = UriBuilder.fromUri(self).replaceQueryParam("startAt", startAt + values.size()).replaceQueryParam("maxResults", limit).build();
  }
  return this;
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor-hadoop

public static URI setHostsOverride(URI location, String... hosts) {
  return UriBuilder.fromUri(location)
      .replaceQueryParam(HOST_PARAM, hosts)
      .build();
}

代码示例来源:origin: bazaarvoice/emodb

public static URI setZkConnectionStringOverride(URI location, String zkConnectionString) {
  return UriBuilder.fromUri(location)
      .replaceQueryParam(ZK_CONNECTION_STRING_PARAM, zkConnectionString)
      .build();
}

代码示例来源:origin: org.jboss.resteasy/skeleton-key-as7

/**
* strip out unwanted query parameters and redirect so bookmarks don't retain oauth protocol bits
*/
protected String stripOauthParametersFromRedirect()
{
 StringBuffer buf = request.getRequestURL().append("?").append(request.getQueryString());
 UriBuilder builder = UriBuilder.fromUri(buf.toString())
    .replaceQueryParam("code", null)
    .replaceQueryParam("state", null);
 return builder.build().toString();
}

代码示例来源:origin: apache/cxf

/**
 * Replaces the current query with the new value.
 * @param queryParam query param name
 * @param value the new value, providing a null is
 *        equivalent to calling resetQuery().
 * @return updated WebClient
 */
public WebClient replaceQueryParam(String queryParam, Object... value) {
  getCurrentBuilder().replaceQueryParam(queryParam, value);
  return this;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Replaces the current query with the new value.
 * @param queryParam query param name
 * @param value the new value, providing a null is
 *        equivalent to calling resetQuery().
 * @return updated WebClient
 */
public WebClient replaceQueryParam(String queryParam, Object... value) {
  getCurrentBuilder().replaceQueryParam(queryParam, value);
  return this;
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

private static UriBuilder setQueryParam(UriBuilder uriBuilder, String name, Object[] values) {
  if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
    return uriBuilder.replaceQueryParam(name, (Object[]) null);
  }
  checkForNullValues(name, values);
  return uriBuilder.queryParam(name, values);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

private static UriBuilder setQueryParam(UriBuilder uriBuilder, String name, Object[] values) {
  if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
    return uriBuilder.replaceQueryParam(name, (Object[]) null);
  }
  checkForNullValues(name, values);
  return uriBuilder.queryParam(name, values);
}

代码示例来源:origin: com.github.arucard21.simplyrestful/SimplyRESTful

protected HALLink createHALLinkFromURIWithModifiedPageNumber(URI requestURI, int pageNumber){
  UriBuilder hrefBuilder = UriBuilder.fromUri(requestURI);
  hrefBuilder.replaceQueryParam(AbstractWebResource.QUERY_PARAM_PAGE, pageNumber);
  HALLink link = new HALLink.Builder(hrefBuilder.build()).build();
  return link;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

@Override
public WebTarget queryParam(String name, Object... values) {
  checkClosed();
  checkNullValues(name, values);
  UriBuilder thebuilder = getUriBuilder();
  if (values == null || values.length == 1 && values[0] == null) {
    thebuilder.replaceQueryParam(name, (Object[])null);
  } else {
    thebuilder.queryParam(name, values);
  }
  return newWebTarget(thebuilder);
}

代码示例来源:origin: apache/cxf

@Override
public WebTarget queryParam(String name, Object... values) {
  checkClosed();
  checkNullValues(name, values);
  UriBuilder thebuilder = getUriBuilder();
  if (values == null || values.length == 1 && values[0] == null) {
    thebuilder.replaceQueryParam(name, (Object[])null);
  } else {
    thebuilder.queryParam(name, values);
  }
  return newWebTarget(thebuilder);
}

代码示例来源:origin: FamilySearch/gedcomx-java

@Override
 protected Model loadEntity(ClientResponse response) {
  Model model = ModelFactory.createDefaultModel();
  model.read(response.getEntityInputStream(), null, "JSONLD");

  // remove the flag=fs query param from the url if there.  Any gedcomx-java hyperlinks used to get to this endpoint would have the flag=fs parameter
  // as of 06/14/2018.  This Uri becomes the name/id of the Resource object and should not have that query param as part of the name/id for
  // getVocabElementList() to work.
  this.resourceDescribingList = model.getResource(UriBuilder.fromUri(this.request.getURI()).replaceQueryParam("flag", (Object[]) null).build().toString());
//    this.resourceDescribingList = model.getResource(this.request.getURI().toString());

  return model;
 }

代码示例来源:origin: FamilySearch/gedcomx-java

public PersonMatchResultsState updateMatchStatus(Entry entry, MatchStatus status, StateTransitionOption... options) {
 URI updateStatusUri = UriBuilder.fromUri(getSelfUri()).replaceQueryParam(FamilySearchOptions.STATUS, status.name().toLowerCase()).build();
 ClientRequest request = createAuthenticatedRequest()
  .type(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE)
  .accept(AtomModel.ATOM_GEDCOMX_JSON_MEDIA_TYPE)
  .entity(new Gedcomx().person(new Person().identifier(new Identifier(entry.getId(), IdentifierType.Persistent))))
  .build(updateStatusUri, HttpMethod.POST);
 return ((FamilySearchStateFactory)this.stateFactory).newPersonMatchResultsState(request, invoke(request, options), this.accessToken);
}

相关文章