this.pathBuilder = new CompositePathComponentBuilder(); this.pathBuilder.addPath(uri.getRawPath());
private UriComponents buildInternal(EncodingHint hint) { UriComponents result; if (this.ssp != null) { result = new OpaqueUriComponents(this.scheme, this.ssp, this.fragment); } else { HierarchicalUriComponents uric = new HierarchicalUriComponents(this.scheme, this.fragment, this.userInfo, this.host, this.port, this.pathBuilder.build(), this.queryParams, hint == EncodingHint.FULLY_ENCODED); result = hint == EncodingHint.ENCODE_TEMPLATE ? uric.encodeTemplate(this.charset) : uric; } if (!this.uriVariables.isEmpty()) { result = result.expand(name -> this.uriVariables.getOrDefault(name, UriTemplateVariables.SKIP_VALUE)); } return result; }
public void addPath(String path) { if (StringUtils.hasText(path)) { PathSegmentComponentBuilder psBuilder = getLastBuilder(PathSegmentComponentBuilder.class); FullPathComponentBuilder fpBuilder = getLastBuilder(FullPathComponentBuilder.class); if (psBuilder != null) { path = (path.startsWith("/") ? path : "/" + path); } if (fpBuilder == null) { fpBuilder = new FullPathComponentBuilder(); this.builders.add(fpBuilder); } fpBuilder.append(path); } }
this.pathBuilder = new CompositePathComponentBuilder(); this.pathBuilder.addPath(uri.getRawPath());
this.pathBuilder = new CompositePathComponentBuilder(); this.pathBuilder.addPath(uri.getRawPath());
/** * Build a {@code UriComponents} instance from the various components * contained in this builder. * @param encoded whether all the components set in this builder are * encoded ({@code true}) or not ({@code false}) * @return the URI components */ public UriComponents build(boolean encoded) { UriComponents result; if (this.ssp != null) { result = new OpaqueUriComponents(this.scheme, this.ssp, this.fragment); } else { HierarchicalUriComponents uric = new HierarchicalUriComponents(this.scheme, this.fragment, this.userInfo, this.host, this.port, this.pathBuilder.build(), this.queryParams, encoded); result = this.encodeTemplate ? uric.encodeTemplate(this.charset) : uric; } if (!this.uriVariables.isEmpty()) { result = result.expand(name -> this.uriVariables.getOrDefault(name, UriTemplateVariables.SKIP_VALUE)); } return result; }
/** * Create a deep copy of the given UriComponentsBuilder. * @param other the other builder to copy from * @since 4.1.3 */ protected UriComponentsBuilder(UriComponentsBuilder other) { this.scheme = other.scheme; this.ssp = other.ssp; this.userInfo = other.userInfo; this.host = other.host; this.port = other.port; this.pathBuilder = other.pathBuilder.cloneBuilder(); this.queryParams.putAll(other.queryParams); this.fragment = other.fragment; this.encodeTemplate = other.encodeTemplate; this.charset = other.charset; }
private UriComponents buildInternal(EncodingHint hint) { UriComponents result; if (this.ssp != null) { result = new OpaqueUriComponents(this.scheme, this.ssp, this.fragment); } else { HierarchicalUriComponents uric = new HierarchicalUriComponents(this.scheme, this.fragment, this.userInfo, this.host, this.port, this.pathBuilder.build(), this.queryParams, hint == EncodingHint.FULLY_ENCODED); result = hint == EncodingHint.ENCODE_TEMPLATE ? uric.encodeTemplate(this.charset) : uric; } if (!this.uriVariables.isEmpty()) { result = result.expand(name -> this.uriVariables.getOrDefault(name, UriTemplateVariables.SKIP_VALUE)); } return result; }
/** * Create a deep copy of the given UriComponentsBuilder. * @param other the other builder to copy from * @since 4.1.3 */ protected UriComponentsBuilder(UriComponentsBuilder other) { this.scheme = other.scheme; this.ssp = other.ssp; this.userInfo = other.userInfo; this.host = other.host; this.port = other.port; this.pathBuilder = other.pathBuilder.cloneBuilder(); this.queryParams.putAll(other.queryParams); this.fragment = other.fragment; this.encodeTemplate = other.encodeTemplate; this.charset = other.charset; }
public void addPath(String path) { if (StringUtils.hasText(path)) { PathSegmentComponentBuilder psBuilder = getLastBuilder(PathSegmentComponentBuilder.class); FullPathComponentBuilder fpBuilder = getLastBuilder(FullPathComponentBuilder.class); if (psBuilder != null) { path = (path.startsWith("/") ? path : "/" + path); } if (fpBuilder == null) { fpBuilder = new FullPathComponentBuilder(); this.builders.add(fpBuilder); } fpBuilder.append(path); } }
public void addPath(String path) { if (StringUtils.hasText(path)) { PathSegmentComponentBuilder psBuilder = getLastBuilder(PathSegmentComponentBuilder.class); FullPathComponentBuilder fpBuilder = getLastBuilder(FullPathComponentBuilder.class); if (psBuilder != null) { path = (path.startsWith("/") ? path : "/" + path); } if (fpBuilder == null) { fpBuilder = new FullPathComponentBuilder(); this.builders.add(fpBuilder); } fpBuilder.append(path); } }
public void addPathSegments(String... pathSegments) { if (!ObjectUtils.isEmpty(pathSegments)) { PathSegmentComponentBuilder psBuilder = getLastBuilder(PathSegmentComponentBuilder.class); FullPathComponentBuilder fpBuilder = getLastBuilder(FullPathComponentBuilder.class); if (psBuilder == null) { psBuilder = new PathSegmentComponentBuilder(); this.builders.add(psBuilder); if (fpBuilder != null) { fpBuilder.removeTrailingSlash(); } } psBuilder.append(pathSegments); } }
/** * Set the path of this builder overriding all existing path and path segment values. * @param path the URI path (a {@code null} value results in an empty path) * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replacePath(@Nullable String path) { this.pathBuilder = new CompositePathComponentBuilder(); if (path != null) { this.pathBuilder.addPath(path); } resetSchemeSpecificPart(); return this; }
/** * Set the path of this builder overriding all existing path and path segment values. * @param path the URI path (a {@code null} value results in an empty path) * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replacePath(@Nullable String path) { this.pathBuilder = new CompositePathComponentBuilder(); if (path != null) { this.pathBuilder.addPath(path); } resetSchemeSpecificPart(); return this; }
/** * Append path segments to the existing path. Each path segment may contain * URI template variables and should not contain any slashes. * Use {@code path("/")} subsequently to ensure a trailing slash. * @param pathSegments the URI path segments * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException { this.pathBuilder.addPathSegments(pathSegments); resetSchemeSpecificPart(); return this; }
/** * Default constructor. Protected to prevent direct instantiation. * @see #newInstance() * @see #fromPath(String) * @see #fromUri(URI) */ protected UriComponentsBuilder() { this.pathBuilder = new CompositePathComponentBuilder(); }
/** * Append path segments to the existing path. Each path segment may contain * URI template variables and should not contain any slashes. * Use {@code path("/")} subsequently to ensure a trailing slash. * @param pathSegments the URI path segments * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException { this.pathBuilder.addPathSegments(pathSegments); resetSchemeSpecificPart(); return this; }
private void resetHierarchicalComponents() { this.userInfo = null; this.host = null; this.port = null; this.pathBuilder = new CompositePathComponentBuilder(); this.queryParams.clear(); }
@Override public CompositePathComponentBuilder cloneBuilder() { CompositePathComponentBuilder compositeBuilder = new CompositePathComponentBuilder(); for (PathComponentBuilder builder : this.builders) { compositeBuilder.builders.add(builder.cloneBuilder()); } return compositeBuilder; } }
/** * Default constructor. Protected to prevent direct instantiation. * @see #newInstance() * @see #fromPath(String) * @see #fromUri(URI) */ protected UriComponentsBuilder() { this.pathBuilder = new CompositePathComponentBuilder(); }