public class UriComponentsBuilder extends ObjectSE implements UriBuilder, CloneableSE
UriComponents のビルダー。典型的な使用箇所は次のとおりです。
UriComponentsBuilder を作成します (fromPath(String) や fromUri(URI) など)scheme(String)、userInfo(String)、host(String)、port(int)、path(String)、pathSegment(String...)、queryParam(String, Object...)、fragment(String) を介してさまざまな URI コンポーネントを設定します。build() メソッドを使用して UriComponents インスタンスを構築します。newInstance(), fromPath(String), fromUri(URI)| 修飾子 | コンストラクターと説明 |
|---|---|
protected | UriComponentsBuilder() デフォルトコンストラクター。 |
protected | UriComponentsBuilder(UriComponentsBuilder other) 指定された UriComponentsBuilder のディープコピーを作成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
UriComponents | build() このビルダーに含まれるさまざまなコンポーネントから UriComponents インスタンスを構築します。 |
UriComponents | build(boolean encoded) このビルダーに含まれるさまざまなコンポーネントから UriComponents インスタンスを構築します。 |
URISE | build(MapSE<StringSE,?> uriVariables)URISE インスタンスを構築し、URI テンプレート変数をマップの値で置き換えます。 |
URISE | build(ObjectSE... uriVariables)URISE インスタンスを構築し、URI テンプレート変数を配列の値で置き換えます。 |
UriComponents | buildAndExpand(MapSE<StringSE,?> uriVariables)UriComponents インスタンスを作成し、URI テンプレート変数をマップの値で置き換えます。 |
UriComponents | buildAndExpand(ObjectSE... uriVariableValues)UriComponents インスタンスを構築し、URI テンプレート変数を配列の値で置き換えます。 |
ObjectSE | clone() オブジェクトの clone() メソッドのパブリック宣言。 |
UriComponentsBuilder | cloneBuilder() この UriComponentsBuilder を複製します。 |
UriComponentsBuilder | fragment(StringSE fragment)URI フラグメントを設定します。 |
static UriComponentsBuilder | fromHttpRequest(HttpRequest request) 指定された HttpRequest に関連付けられた URI から新しい UriComponents オブジェクトを作成すると同時に、ヘッダー "Forwarded" (RFC 7239)、または "X-Forwarded-Host"、"X-Forwarded-Port"、「X-Forwarded 「転送」が見つからない場合は「プロト」。 |
static UriComponentsBuilder | fromHttpUrl(StringSE httpUrl) 指定された HTTP URL 文字列から URI コンポーネントビルダーを作成します。 |
static UriComponentsBuilder | fromOriginHeader(StringSE origin)HTTP リクエストの "Origin" ヘッダーを解析してインスタンスを作成します。 |
static UriComponentsBuilder | fromPath(StringSE path) 指定されたパスで初期化されるビルダーを作成します。 |
static UriComponentsBuilder | fromUri(URISE uri) 指定された URI で初期化されるビルダーを作成します。 |
static UriComponentsBuilder | fromUriString(StringSE uri) 指定された URI 文字列で初期化されるビルダーを作成します。 |
UriComponentsBuilder | host(StringSE host)URI ホストを設定します。 |
static UriComponentsBuilder | newInstance() 新しい空のビルダーを作成します。 |
UriComponentsBuilder | path(StringSE path) 指定したパスをこのビルダーの既存のパスに追加します。 |
UriComponentsBuilder | pathSegment(StringSE... pathSegments) 既存のパスにパスセグメントを追加します。 |
UriComponentsBuilder | port(int port)URI ポートを設定します。 |
UriComponentsBuilder | port(StringSE port)URI ポートを設定します。 |
UriComponentsBuilder | query(StringSE query) 指定されたクエリをこのビルダーの既存のクエリに追加します。 |
UriComponentsBuilder | queryParam(StringSE name, ObjectSE... values) 指定されたクエリパラメーターを既存のクエリパラメーターに追加します。 |
UriComponentsBuilder | queryParams(MultiValueMap<StringSE, StringSE> params) 指定されたクエリパラメーターを追加します。 |
UriComponentsBuilder | replacePath(StringSE path) このビルダーのパスを設定して、既存のすべてのパスおよびパスセグメント値をオーバーライドします。 |
UriComponentsBuilder | replaceQuery(StringSE query) このビルダーのクエリを設定して、既存のすべてのクエリパラメーターをオーバーライドします。 |
UriComponentsBuilder | replaceQueryParam(StringSE name, ObjectSE... values) 同じパラメーターの既存のすべてのクエリ値をオーバーライドして、クエリパラメーター値を設定します。 |
UriComponentsBuilder | replaceQueryParams(MultiValueMap<StringSE, StringSE> params) 既存のすべてのクエリ値をオーバーライドして、クエリパラメーター値を設定します。 |
UriComponentsBuilder | scheme(StringSE scheme)URI スキームを設定します。 |
UriComponentsBuilder | schemeSpecificPart(StringSE ssp)URI スキーム固有部分を設定します。 |
StringSE | toUriString()URI 文字列を作成します。 |
UriComponentsBuilder | uri(URISE uri) 指定された URI のコンポーネントからこのビルダーのコンポーネントを初期化します。 |
UriComponentsBuilder | uriComponents(UriComponents uriComponents) 指定された UriComponents インスタンスの値から、このビルダーの個々の URI コンポーネントを設定または追加します。 |
UriComponentsBuilder | userInfo(StringSE userInfo)URI ユーザー情報を設定します。 |
equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEprotected UriComponentsBuilder()
protected UriComponentsBuilder(UriComponentsBuilder other)
other - コピー元の他のビルダー public static UriComponentsBuilder newInstance()
UriComponentsBuilderpublic static UriComponentsBuilder fromPath(StringSE path)
path - 初期化するパス UriComponentsBuilderpublic static UriComponentsBuilder fromUri(URISE uri)
URI で初期化されるビルダーを作成します。uri - 初期化する URIUriComponentsBuilderpublic static UriComponentsBuilder fromUriString(StringSE uri)
注意 : 予約文字の存在は、URI 文字列の正しい解析を妨げる可能性があります。たとえば、クエリパラメーターに '=' または '&' 文字が含まれている場合、クエリ文字列を明確に解析することはできません。正しい解析を可能にするために、そのような値を URI 変数に置き換える必要があります。
String uriString = "/hotels/42?filter={value}";
UriComponentsBuilder.fromUriString(uriString).buildAndExpand("hot&cold");
uri - 初期化する URI 文字列 UriComponentsBuilderpublic static UriComponentsBuilder fromHttpUrl(StringSE httpUrl)
注意 : 予約文字の存在は、URI 文字列の正しい解析を妨げる可能性があります。たとえば、クエリパラメーターに '=' または '&' 文字が含まれている場合、クエリ文字列を明確に解析することはできません。正しい解析を可能にするために、そのような値を URI 変数に置き換える必要があります。
String urlString = "https://example.com/hotels/42?filter={value}";
UriComponentsBuilder.fromHttpUrl(urlString).buildAndExpand("hot&cold");
httpUrl - ソース URIpublic static UriComponentsBuilder fromHttpRequest(HttpRequest request)
UriComponents オブジェクトを作成すると同時に、ヘッダー "Forwarded" (RFC 7239)、または "X-Forwarded-Host"、"X-Forwarded-Port"、「X-Forwarded 「転送」が見つからない場合は「プロト」。request - ソースリクエスト public static UriComponentsBuilder fromOriginHeader(StringSE origin)
public UriComponents build()
UriComponents インスタンスを構築します。public UriComponents build(boolean encoded)
UriComponents インスタンスを構築します。encoded - このビルダーで設定されたすべてのコンポーネントがエンコードされているか(true) (false)public UriComponents buildAndExpand(MapSE<StringSE,?> uriVariables)
UriComponents インスタンスを作成し、URI テンプレート変数をマップの値で置き換えます。これは、build() への呼び出しと UriComponents.expand(Map) への呼び出しを組み合わせたショートカットメソッドです。uriVariables - URI 変数のマップ public UriComponents buildAndExpand(ObjectSE... uriVariableValues)
UriComponents インスタンスを構築し、URI テンプレート変数を配列の値で置き換えます。これは、build() への呼び出しと UriComponents.expand(Object...) への呼び出しを組み合わせたショートカットメソッドです。uriVariableValues - URI 変数値 public URISE build(ObjectSE... uriVariables)
URISE インスタンスを構築し、URI テンプレート変数を配列の値で置き換えます。UriBuilder 内の build uriVariables - URI 変数のマップ public URISE build(MapSE<StringSE,?> uriVariables)
URISE インスタンスを構築し、URI テンプレート変数をマップの値で置き換えます。UriBuilder 内の build uriVariables - URI 変数のマップ public StringSE toUriString()
build()、次に UriComponents.encode()、最後に UriComponents.toUriString() の呼び出しを組み合わせるショートカットメソッドです。UriComponents.toUriString()public UriComponentsBuilder uri(URISE uri)
uri - URIpublic UriComponentsBuilder uriComponents(UriComponents uriComponents)
UriComponents インスタンスの値から、このビルダーの個々の URI コンポーネントを設定または追加します。 各コンポーネントのセマンティクス(つまり、設定と追加)については、このクラスのビルダーメソッドを確認してください。たとえば、host(String) が設定され、path(String) が追加されます。
uriComponents - コピー元の UriComponentspublic UriComponentsBuilder scheme(@Nullable StringSE scheme)
null にすることもできます。UriBuilder 内の scheme scheme - URI スキーム public UriComponentsBuilder schemeSpecificPart(StringSE ssp)
ssp - URI スキーム固有部分には、URI テンプレートパラメーターが含まれる場合があります public UriComponentsBuilder userInfo(@Nullable StringSE userInfo)
null になる場合もあります。UriBuilder 内の userInfo userInfo - URI ユーザー情報 public UriComponentsBuilder host(@Nullable StringSE host)
null にすることもできます。UriBuilder 内の host host - URI ホスト public UriComponentsBuilder port(int port)
-1 を渡すと、このビルダーのポートがクリアされます。UriBuilder 内の port port - URI ポート public UriComponentsBuilder port(@Nullable StringSE port)
port(int) を使用します。null を渡すと、このビルダーのポートがクリアされます。UriBuilder 内の port port - URI ポート public UriComponentsBuilder path(StringSE path)
UriBuilder 内の path path - URI パス public UriComponentsBuilder pathSegment(StringSE... pathSegments) throws IllegalArgumentExceptionSE
path("/") を使用して、末尾のスラッシュを確認します。UriBuilder 内の pathSegment pathSegments - URI パスセグメント IllegalArgumentExceptionSEpublic UriComponentsBuilder replacePath(@Nullable StringSE path)
UriBuilder 内の replacePath path - URI パス (null 値は空のパスになります)public UriComponentsBuilder query(@Nullable StringSE query)
注意 : 予約文字の存在は、URI 文字列の正しい解析を妨げる可能性があります。たとえば、クエリパラメーターに '=' または '&' 文字が含まれている場合、クエリ文字列を明確に解析することはできません。正しい解析を可能にするために、そのような値を URI 変数に置き換える必要があります。
UriComponentsBuilder.fromUriString("/hotels/42")
.query("filter={value}")
.buildAndExpand("hot&cold");
UriBuilder 内の query query - クエリ文字列 public UriComponentsBuilder replaceQuery(@Nullable StringSE query)
UriBuilder 内の replaceQuery query - クエリ文字列。null 値は、すべてのクエリパラメーターを削除します。public UriComponentsBuilder queryParam(StringSE name, ObjectSE... values)
?foo=bar ではなく ?foo になります)。UriBuilder 内の queryParam name - クエリパラメーター名 values - クエリパラメーター値 public UriComponentsBuilder queryParams(@Nullable MultiValueMap<StringSE,StringSE> params)
UriBuilder 内の queryParams params - パラメーター public UriComponentsBuilder replaceQueryParam(StringSE name, ObjectSE... values)
UriBuilder 内の replaceQueryParam name - クエリパラメーター名 values - クエリパラメーター値 public UriComponentsBuilder replaceQueryParams(@Nullable MultiValueMap<StringSE,StringSE> params)
UriBuilder 内の replaceQueryParams params - クエリパラメーター名 public UriComponentsBuilder fragment(@Nullable StringSE fragment)
null になる場合もあります。UriBuilder 内の fragment fragment - URI フラグメント public ObjectSE clone()
clone() メソッドのパブリック宣言。cloneBuilder() へのデリゲート。public UriComponentsBuilder cloneBuilder()
UriComponentsBuilder を複製します。UriComponentsBuilder オブジェクト