本文整理了Java中javax.ws.rs.core.UriBuilder.replaceQuery()
方法的一些代码示例,展示了UriBuilder.replaceQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.replaceQuery()
方法的具体详情如下:
包路径:javax.ws.rs.core.UriBuilder
类名称:UriBuilder
方法名:replaceQuery
[英]Set the URI query string. This method will overwrite any existing query parameters.
[中]设置URI查询字符串。此方法将覆盖任何现有的查询参数。
代码示例来源:origin: prestodb/presto
private synchronized URI createNextResultsUri(String scheme, UriInfo uriInfo)
{
return uriInfo.getBaseUriBuilder()
.scheme(scheme)
.replacePath("/v1/statement")
.path(queryId.toString())
.path(String.valueOf(resultId.incrementAndGet()))
.replaceQuery("")
.build();
}
代码示例来源:origin: com.sun.jersey/jersey-server
@Override
public URI getAbsolutePath() {
if (absolutePathUri != null) return absolutePathUri;
return absolutePathUri = UriBuilder.fromUri(requestUri).
replaceQuery("").fragment("").
build();
}
代码示例来源:origin: Netflix/eureka
private URI getRedirectBaseUri(URI locationURI) {
if (locationURI == null) {
throw new TransportException("Missing Location header in the redirect reply");
}
Matcher pathMatcher = REDIRECT_PATH_REGEX.matcher(locationURI.getPath());
if (pathMatcher.matches()) {
return UriBuilder.fromUri(locationURI)
.host(dnsService.resolveIp(locationURI.getHost()))
.replacePath(pathMatcher.group(1))
.replaceQuery(null)
.build();
}
logger.warn("Invalid redirect URL {}", locationURI);
return null;
}
}
代码示例来源:origin: jersey/jersey
private void addHint(Application wadlApplication) {
// TODO: this not-null check is here only because of unit tests
if (uriInfo != null) {
Doc d = new Doc();
String message;
if (detailedWadl) {
final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build()
.toString();
message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam);
} else {
final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri())
.queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString();
message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam);
}
d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message);
wadlApplication.getDoc().add(d);
}
}
代码示例来源:origin: jersey/jersey
private void addHint(Application wadlApplication) {
// TODO: this not-null check is here only because of unit tests
if (uriInfo != null) {
Doc d = new Doc();
String message;
if (detailedWadl) {
final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build()
.toString();
message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam);
} else {
final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri())
.queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString();
message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam);
}
d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message);
wadlApplication.getDoc().add(d);
}
}
代码示例来源:origin: com.sun.jersey/jersey-server
private void setHeaders(MultivaluedMap<String, Object> headers) {
this.headers = headers;
Object location = headers.getFirst(HttpHeaders.LOCATION);
if (location != null) {
if (location instanceof URI) {
final URI locationUri = (URI)location;
if (!locationUri.isAbsolute()) {
final URI base = (statusType.getStatusCode() == Status.CREATED.getStatusCode())
? request.getAbsolutePath()
: request.getBaseUri();
location = UriBuilder.fromUri(base).
path(locationUri.getRawPath()).
replaceQuery(locationUri.getRawQuery()).
fragment(locationUri.getRawFragment()).
build();
}
headers.putSingle(HttpHeaders.LOCATION, location);
}
}
}
代码示例来源:origin: apache/nifi
/**
* This method checks path of the incoming request, and
* redirects following URIs:
* <li>/controller -> SiteToSiteResource
* @param requestContext request to be modified
*/
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
final UriInfo uriInfo = requestContext.getUriInfo();
if (uriInfo.getPath().equals("controller")){
UriBuilder builder = UriBuilder.fromUri(uriInfo.getBaseUri())
.path(SiteToSiteResource.class)
.replaceQuery(uriInfo.getRequestUri().getRawQuery());
URI redirectTo = builder.build();
requestContext.setRequestUri(uriInfo.getBaseUri(), redirectTo);
}
}
}
代码示例来源:origin: jersey/jersey
.replaceQuery(ContainerUtils.encodeUnsafeCharacters(queryString))
.build();
} catch (final IllegalArgumentException iae) {
代码示例来源:origin: jersey/jersey
.replaceQuery(ContainerUtils.encodeUnsafeCharacters(queryString))
.build();
} catch (final IllegalArgumentException iae) {
代码示例来源:origin: com.sun.jersey/jersey-server
public WebApplicationContext createMatchResourceContext(URI u) {
final URI base = request.getBaseUri();
if (u.isAbsolute()) {
// TODO check if base is a base of u
URI r = base.relativize(u);
if (r == u) {
throw new ContainerException("The URI " + u + " is not relative to the base URI " + base);
}
} else {
u = UriBuilder.fromUri(base).
path(u.getRawPath()).
replaceQuery(u.getRawQuery()).
fragment(u.getRawFragment()).
build();
}
final ContainerRequest _request = new ContainerRequest(app,
HTTP_METHOD_MATCH_RESOURCE,
base, u,
new InBoundHeaders(), new ByteArrayInputStream(new byte[0]));
_request.setSecurityContext(request.getSecurityContext());
// Propagate security context
final ContainerResponse _response = new ContainerResponse(app,
_request, null);
return new WebApplicationContext(app,
_request,
_response);
}
代码示例来源:origin: jersey/jersey
.replaceQuery(queryParameters)
.build();
} catch (final UriBuilderException | IllegalArgumentException ex) {
代码示例来源:origin: jersey/jersey
.replaceQuery(queryParameters)
.build();
} catch (final UriBuilderException | IllegalArgumentException ex) {
代码示例来源:origin: prestodb/presto
.scheme(scheme)
.replacePath("ui/query.html")
.replaceQuery(queryId.toString())
.build();
代码示例来源:origin: org.apache.hadoop/hadoop-hdfs
/** Rebuild the URI query with lower case parameter names. */
private static URI rebuildQuery(final URI uri,
final MultivaluedMap<String, String> parameters) {
UriBuilder b = UriBuilder.fromUri(uri).replaceQuery("");
for(Map.Entry<String, List<String>> e : parameters.entrySet()) {
final String key = StringUtils.toLowerCase(e.getKey());
for(String v : e.getValue()) {
b = b.queryParam(key, v);
}
}
return b.build();
}
}
代码示例来源:origin: resteasy/Resteasy
@Override
public URI relativize(URI uri)
{
URI from = getRequestUri();
URI to = uri;
if (uri.getScheme() == null && uri.getHost() == null)
{
to = getBaseUriBuilder().replaceQuery(null).path(uri.getPath()).replaceQuery(uri.getQuery()).fragment(uri.getFragment()).build();
}
return ResteasyUriBuilderImpl.relativize(from, to);
}
代码示例来源:origin: resteasy/Resteasy
public ResteasyUriInfo(final URI base, final URI relative)
{
String b = base.toString();
if (!b.endsWith("/")) b += "/";
String r = relative.getRawPath();
if (r.startsWith("/"))
{
encodedPath = r;
path = relative.getPath();
}
else
{
encodedPath = "/" + r;
path = "/" + relative.getPath();
}
UriBuilder requestUriBuilder = UriBuilder.fromUri(base).path(relative.getRawPath()).replaceQuery(relative.getRawQuery());
requestURI = requestUriBuilder.build();
absolutePath = requestUriBuilder.replaceQuery(null).build();
baseURI = base;
processPath();
}
代码示例来源:origin: resteasy/Resteasy
private static MockHttpRequest initWithUri(URI absoluteUri, URI baseUri)
{
if (baseUri == null) baseUri = EMPTY_URI;
MockHttpRequest request = new MockHttpRequest();
request.httpHeaders = new ResteasyHttpHeaders(new CaseInsensitiveMap<String>());
//request.uri = new UriInfoImpl(absoluteUri, absoluteUri, absoluteUri.getPath(), absoluteUri.getQuery(), PathSegmentImpl.parseSegments(absoluteUri.getPath()));
// remove query part
URI absolutePath = UriBuilder.fromUri(absoluteUri).replaceQuery(null).build();
// path must be relative to the application's base uri
URI relativeUri = baseUri.relativize(absoluteUri);
relativeUri = UriBuilder.fromUri(relativeUri.getRawPath()).replaceQuery(absoluteUri.getRawQuery()).build();
request.uri = new ResteasyUriInfo(absoluteUri.toString(), absoluteUri.getRawQuery(), baseUri.getRawPath());
return request;
}
代码示例来源:origin: resteasy/Resteasy
public void initializeFromRequest(URI requestURI)
{
String r = requestURI.getRawPath();
if (r.startsWith("/"))
{
encodedPath = r;
path = requestURI.getPath();
}
else
{
encodedPath = "/" + r;
path = "/" + requestURI.getPath();
}
this.requestURI = requestURI;
baseURI = UriBuilder.fromUri(requestURI).replacePath("").build();
absolutePath = UriBuilder.fromUri(requestURI).replaceQuery(null).build();
processPath();
}
代码示例来源:origin: resteasy/Resteasy
public void setUri(URI base, URI relative)
{
clearQueryParameters(true);
clearQueryParameters(false);
URI rel = base.resolve(relative);
String absoluteUri = UriBuilder.fromUri(rel).replaceQuery(null).toTemplate();
initialize(absoluteUri, rel.getRawQuery(), base.getRawPath());
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
private void addHint(Application wadlApplication) {
// TODO: this not-null check is here only because of unit tests
if (uriInfo != null) {
Doc d = new Doc();
String message;
if (detailedWadl) {
final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build()
.toString();
message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam);
} else {
final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri())
.queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString();
message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam);
}
d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message);
wadlApplication.getDoc().add(d);
}
}
内容来源于网络,如有侵权,请联系作者删除!