use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.
the class CseUriTemplateHandler method expandInternal.
@Override
protected URI expandInternal(String uriTemplate, Map<String, ?> uriVariables) {
UriComponentsBuilder uriComponentsBuilder = initUriComponentsBuilder(uriTemplate);
UriComponents uriComponents = expandAndEncode(uriComponentsBuilder, uriVariables);
return createUri(uriTemplate, uriComponents);
}
use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.
the class CseUriTemplateHandler method fromUriString.
private static UriComponentsBuilder fromUriString(String uri) {
Assert.notNull(uri, "URI must not be null");
Matcher matcher = URI_PATTERN.matcher(uri);
if (matcher.matches()) {
UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
String scheme = matcher.group(2);
String userInfo = matcher.group(5);
String host = matcher.group(6);
String port = matcher.group(8);
String path = matcher.group(9);
String query = matcher.group(11);
String fragment = matcher.group(13);
boolean opaque = false;
if (StringUtils.hasLength(scheme)) {
String rest = uri.substring(scheme.length());
if (!rest.startsWith(":/")) {
opaque = true;
}
}
builder.scheme(scheme);
if (opaque) {
String ssp = uri.substring(scheme.length()).substring(1);
if (StringUtils.hasLength(fragment)) {
ssp = ssp.substring(0, ssp.length() - (fragment.length() + 1));
}
builder.schemeSpecificPart(ssp);
} else {
builder.userInfo(userInfo);
builder.host(host);
if (StringUtils.hasLength(port)) {
builder.port(port);
}
builder.path(path);
builder.query(query);
}
if (StringUtils.hasText(fragment)) {
builder.fragment(fragment);
}
return builder;
} else {
throw new IllegalArgumentException("[" + uri + "] is not a valid URI");
}
}
use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.
the class CseUriTemplateHandler method initUriComponentsBuilder.
@Override
protected UriComponentsBuilder initUriComponentsBuilder(String uriTemplate) {
UriComponentsBuilder builder = fromUriString(uriTemplate);
if (shouldParsePath() && !isStrictEncoding()) {
List<String> pathSegments = builder.build().getPathSegments();
builder.replacePath(null);
for (String pathSegment : pathSegments) {
builder.pathSegment(pathSegment);
}
}
return builder;
}
use of org.springframework.web.util.UriComponentsBuilder in project java-chassis by ServiceComb.
the class CseUriTemplateHandler method expandInternal.
@Override
protected URI expandInternal(String uriTemplate, Object... uriVariables) {
UriComponentsBuilder uriComponentsBuilder = initUriComponentsBuilder(uriTemplate);
UriComponents uriComponents = expandAndEncode(uriComponentsBuilder, uriVariables);
return createUri(uriTemplate, uriComponents);
}
use of org.springframework.web.util.UriComponentsBuilder in project cf-java-client by cloudfoundry.
the class FilterBuilderTest method test.
@Test
public void test() {
UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
FilterBuilder.augment(builder, new StubFilterParamsSubClass());
MultiValueMap<String, String> queryParams = builder.build().encode().getQueryParams();
List<String> q = queryParams.get("q");
assertThat(q).hasSize(8).containsOnly("test-greater-than%3Etest-value-1", "test-greater-than-or-equal-to%3E%3Dtest-value-2", "test-in%20IN%20test-value-3,test-value-4", "test-is:test-value-5", "test-less-than%3Ctest-value-6", "test-less-than-or-equal-to%3C%3Dtest-value-7", "test-default%20IN%20test-value-8,test-value-9", "test-override:test-value-10");
}
Aggregations