@Override protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) { Assert.state(!this.encodeState.equals(EncodeState.FULLY_ENCODED), "URI components already encoded, and could not possibly contain '{' or '}'."); String schemeTo = expandUriComponent(getScheme(), uriVariables, this.variableEncoder); String fragmentTo = expandUriComponent(getFragment(), uriVariables, this.variableEncoder); String userInfoTo = expandUriComponent(this.userInfo, uriVariables, this.variableEncoder); String hostTo = expandUriComponent(this.host, uriVariables, this.variableEncoder); String portTo = expandUriComponent(this.port, uriVariables, this.variableEncoder); PathComponent pathTo = this.path.expand(uriVariables, this.variableEncoder); MultiValueMap<String, String> queryParamsTo = expandQueryParams(uriVariables); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, portTo, pathTo, queryParamsTo, this.encodeState, this.variableEncoder); }
@Override public URI toUri() { try { if (this.encodeState.isEncoded()) { return new URI(toUriString()); } else { String path = getPath(); if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) { // Only prefix the path delimiter if something exists before it if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { path = PATH_DELIMITER + path; } } return new URI(getScheme(), getUserInfo(), getHost(), getPort(), path, getQuery(), getFragment()); } } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
@Override public URI toUri() { try { if (this.encodeState.isEncoded()) { return new URI(toUriString()); } else { String path = getPath(); if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) { // Only prefix the path delimiter if something exists before it if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { path = PATH_DELIMITER + path; } } return new URI(getScheme(), getUserInfo(), getHost(), getPort(), path, getQuery(), getFragment()); } } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
@Override public URI toUri() { try { if (this.encodeState.isEncoded()) { return new URI(toUriString()); } else { String path = getPath(); if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) { // Only prefix the path delimiter if something exists before it if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { path = PATH_DELIMITER + path; } } return new URI(getScheme(), getUserInfo(), getHost(), getPort(), path, getQuery(), getFragment()); } } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
/** * Identical to {@link #encode()} but skipping over URI variable placeholders. * Also {@link #variableEncoder} is initialized with the given charset for * use later when URI variables are expanded. */ HierarchicalUriComponents encodeTemplate(Charset charset) { if (this.encodeState.isEncoded()) { return this; } // Remember the charset to encode URI variables later.. this.variableEncoder = value -> encodeUriComponent(value, charset, Type.URI); UriTemplateEncoder encoder = new UriTemplateEncoder(charset); String schemeTo = (getScheme() != null ? encoder.apply(getScheme(), Type.SCHEME) : null); String fragmentTo = (getFragment() != null ? encoder.apply(getFragment(), Type.FRAGMENT) : null); String userInfoTo = (getUserInfo() != null ? encoder.apply(getUserInfo(), Type.USER_INFO) : null); String hostTo = (getHost() != null ? encoder.apply(getHost(), getHostType()) : null); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.TEMPLATE_ENCODED, this.variableEncoder); }
/** * Identical to {@link #encode()} but skipping over URI variable placeholders. * Also {@link #variableEncoder} is initialized with the given charset for * use later when URI variables are expanded. */ HierarchicalUriComponents encodeTemplate(Charset charset) { if (this.encodeState.isEncoded()) { return this; } // Remember the charset to encode URI variables later.. this.variableEncoder = value -> encodeUriComponent(value, charset, Type.URI); UriTemplateEncoder encoder = new UriTemplateEncoder(charset); String schemeTo = (getScheme() != null ? encoder.apply(getScheme(), Type.SCHEME) : null); String fragmentTo = (getFragment() != null ? encoder.apply(getFragment(), Type.FRAGMENT) : null); String userInfoTo = (getUserInfo() != null ? encoder.apply(getUserInfo(), Type.USER_INFO) : null); String hostTo = (getHost() != null ? encoder.apply(getHost(), getHostType()) : null); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.TEMPLATE_ENCODED, this.variableEncoder); }
@Override public HierarchicalUriComponents encode(Charset charset) { if (this.encodeState.isEncoded()) { return this; } String scheme = getScheme(); String fragment = getFragment(); String schemeTo = (scheme != null ? encodeUriComponent(scheme, charset, Type.SCHEME) : null); String fragmentTo = (fragment != null ? encodeUriComponent(fragment, charset, Type.FRAGMENT) : null); String userInfoTo = (this.userInfo != null ? encodeUriComponent(this.userInfo, charset, Type.USER_INFO) : null); String hostTo = (this.host != null ? encodeUriComponent(this.host, charset, getHostType()) : null); BiFunction<String, Type, String> encoder = (s, type) -> encodeUriComponent(s, charset, type); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.FULLY_ENCODED, null); }
@Override public HierarchicalUriComponents encode(Charset charset) { if (this.encodeState.isEncoded()) { return this; } String scheme = getScheme(); String fragment = getFragment(); String schemeTo = (scheme != null ? encodeUriComponent(scheme, charset, Type.SCHEME) : null); String fragmentTo = (fragment != null ? encodeUriComponent(fragment, charset, Type.FRAGMENT) : null); String userInfoTo = (this.userInfo != null ? encodeUriComponent(this.userInfo, charset, Type.USER_INFO) : null); String hostTo = (this.host != null ? encodeUriComponent(this.host, charset, getHostType()) : null); BiFunction<String, Type, String> encoder = (s, type) -> encodeUriComponent(s, charset, type); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.FULLY_ENCODED, null); }
@Override protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) { Assert.state(!this.encodeState.equals(EncodeState.FULLY_ENCODED), "URI components already encoded, and could not possibly contain '{' or '}'."); String schemeTo = expandUriComponent(getScheme(), uriVariables, this.variableEncoder); String fragmentTo = expandUriComponent(getFragment(), uriVariables, this.variableEncoder); String userInfoTo = expandUriComponent(this.userInfo, uriVariables, this.variableEncoder); String hostTo = expandUriComponent(this.host, uriVariables, this.variableEncoder); String portTo = expandUriComponent(this.port, uriVariables, this.variableEncoder); PathComponent pathTo = this.path.expand(uriVariables, this.variableEncoder); MultiValueMap<String, String> queryParamsTo = expandQueryParams(uriVariables); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, portTo, pathTo, queryParamsTo, this.encodeState, this.variableEncoder); }
@Override protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) { Assert.state(!this.encodeState.equals(EncodeState.FULLY_ENCODED), "URI components already encoded, and could not possibly contain '{' or '}'."); String schemeTo = expandUriComponent(getScheme(), uriVariables, this.variableEncoder); String fragmentTo = expandUriComponent(getFragment(), uriVariables, this.variableEncoder); String userInfoTo = expandUriComponent(this.userInfo, uriVariables, this.variableEncoder); String hostTo = expandUriComponent(this.host, uriVariables, this.variableEncoder); String portTo = expandUriComponent(this.port, uriVariables, this.variableEncoder); PathComponent pathTo = this.path.expand(uriVariables, this.variableEncoder); MultiValueMap<String, String> queryParamsTo = expandQueryParams(uriVariables); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, portTo, pathTo, queryParamsTo, this.encodeState, this.variableEncoder); }
/** * Identical to {@link #encode()} but skipping over URI variable placeholders. * Also {@link #variableEncoder} is initialized with the given charset for * use later when URI variables are expanded. */ HierarchicalUriComponents encodeTemplate(Charset charset) { if (this.encodeState.isEncoded()) { return this; } // Remember the charset to encode URI variables later.. this.variableEncoder = value -> encodeUriComponent(value, charset, Type.URI); UriTemplateEncoder encoder = new UriTemplateEncoder(charset); String schemeTo = (getScheme() != null ? encoder.apply(getScheme(), Type.SCHEME) : null); String fragmentTo = (getFragment() != null ? encoder.apply(getFragment(), Type.FRAGMENT) : null); String userInfoTo = (getUserInfo() != null ? encoder.apply(getUserInfo(), Type.USER_INFO) : null); String hostTo = (getHost() != null ? encoder.apply(getHost(), getHostType()) : null); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.TEMPLATE_ENCODED, this.variableEncoder); }
@Override public HierarchicalUriComponents encode(Charset charset) { if (this.encodeState.isEncoded()) { return this; } String scheme = getScheme(); String fragment = getFragment(); String schemeTo = (scheme != null ? encodeUriComponent(scheme, charset, Type.SCHEME) : null); String fragmentTo = (fragment != null ? encodeUriComponent(fragment, charset, Type.FRAGMENT) : null); String userInfoTo = (this.userInfo != null ? encodeUriComponent(this.userInfo, charset, Type.USER_INFO) : null); String hostTo = (this.host != null ? encodeUriComponent(this.host, charset, getHostType()) : null); BiFunction<String, Type, String> encoder = (s, type) -> encodeUriComponent(s, charset, type); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.FULLY_ENCODED, null); }
/** * Identical to {@link #encode()} but skipping over URI variable placeholders. * Also {@link #variableEncoder} is initialized with the given charset for * use later when URI variables are expanded. */ HierarchicalUriComponents encodeTemplate(Charset charset) { if (this.encodeState.isEncoded()) { return this; } // Remember the charset to encode URI variables later.. this.variableEncoder = value -> encodeUriComponent(value, charset, Type.URI); UriTemplateEncoder encoder = new UriTemplateEncoder(charset); String schemeTo = (getScheme() != null ? encoder.apply(getScheme(), Type.SCHEME) : null); String fragmentTo = (getFragment() != null ? encoder.apply(getFragment(), Type.FRAGMENT) : null); String userInfoTo = (getUserInfo() != null ? encoder.apply(getUserInfo(), Type.USER_INFO) : null); String hostTo = (getHost() != null ? encoder.apply(getHost(), getHostType()) : null); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.TEMPLATE_ENCODED, this.variableEncoder); }
@Override public URI toUri() { try { if (this.encodeState.isEncoded()) { return new URI(toUriString()); } else { String path = getPath(); if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) { // Only prefix the path delimiter if something exists before it if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { path = PATH_DELIMITER + path; } } return new URI(getScheme(), getUserInfo(), getHost(), getPort(), path, getQuery(), getFragment()); } } catch (URISyntaxException ex) { throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); } }
@Override public HierarchicalUriComponents encode(Charset charset) { if (this.encodeState.isEncoded()) { return this; } String scheme = getScheme(); String fragment = getFragment(); String schemeTo = (scheme != null ? encodeUriComponent(scheme, charset, Type.SCHEME) : null); String fragmentTo = (fragment != null ? encodeUriComponent(fragment, charset, Type.FRAGMENT) : null); String userInfoTo = (this.userInfo != null ? encodeUriComponent(this.userInfo, charset, Type.USER_INFO) : null); String hostTo = (this.host != null ? encodeUriComponent(this.host, charset, getHostType()) : null); BiFunction<String, Type, String> encoder = (s, type) -> encodeUriComponent(s, charset, type); PathComponent pathTo = this.path.encode(encoder); MultiValueMap<String, String> queryParamsTo = encodeQueryParams(encoder); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, this.port, pathTo, queryParamsTo, EncodeState.FULLY_ENCODED, null); }
@Override protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) { Assert.state(!this.encodeState.equals(EncodeState.FULLY_ENCODED), "URI components already encoded, and could not possibly contain '{' or '}'."); String schemeTo = expandUriComponent(getScheme(), uriVariables, this.variableEncoder); String fragmentTo = expandUriComponent(getFragment(), uriVariables, this.variableEncoder); String userInfoTo = expandUriComponent(this.userInfo, uriVariables, this.variableEncoder); String hostTo = expandUriComponent(this.host, uriVariables, this.variableEncoder); String portTo = expandUriComponent(this.port, uriVariables, this.variableEncoder); PathComponent pathTo = this.path.expand(uriVariables, this.variableEncoder); MultiValueMap<String, String> queryParamsTo = expandQueryParams(uriVariables); return new HierarchicalUriComponents(schemeTo, fragmentTo, userInfoTo, hostTo, portTo, pathTo, queryParamsTo, this.encodeState, this.variableEncoder); }