public class UriTemplate extends ObjectSE implements SerializableSE
expand(Map)
、expand(Object[])
を介して URI 変数で展開できる、match(String)
を介して URL に一致させることができる URI テンプレートの表現。このクラスは、スレッドセーフで再利用できるように設計されており、任意の数の展開呼び出しまたは一致呼び出しを許可します。 注 : このクラスは内部で UriComponentsBuilder
を使用して URI テンプレートを展開し、すでに準備されている URI テンプレートへのショートカットにすぎません。URI エンコーディングなど、より動的な準備と追加の柔軟性のために、UriComponentsBuilder
にいくつかのエンコーディングモードを追加する UriComponentsBuilder
またはより高レベルの DefaultUriBuilderFactory
の使用を検討してください。詳細については、リファレンスドキュメントを参照してください。
コンストラクターと説明 |
---|
UriTemplate(StringSE uriTemplate) 指定された URI 文字列で新しい UriTemplate を構築します。 |
修飾子と型 | メソッドと説明 |
---|---|
URISE | expand(MapSE<StringSE,?> uriVariables) 変数のマップを指定すると、このテンプレートを URI に展開します。 |
URISE | expand(ObjectSE... uriVariableValues) 変数の配列を指定して、このテンプレートを完全な URI に展開します。 |
ListSE<StringSE> | getVariableNames() テンプレート内の変数の名前を順番に返します。 |
MapSE<StringSE, StringSE> | match(StringSE uri) 指定された URI を変数値のマップに一致させます。 |
boolean | matches(StringSE uri) 指定された URI がこのテンプレートと一致するかどうかを示します。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public UriTemplate(StringSE uriTemplate)
UriTemplate
を構築します。uriTemplate
- URI テンプレート文字列 public URISE expand(MapSE<StringSE,?> uriVariables)
例:
UriTemplate template = new UriTemplate("https://example.com/hotels/{hotel}/bookings/{booking}"); Map<String, String> uriVariables = new HashMap<String, String>(); uriVariables.put("booking", "42"); uriVariables.put("hotel", "Rest & Relax"); System.out.println(template.expand(uriVariables));出力されます:
https://example.com/hotels/Rest%20%26%20Relax/bookings/42
uriVariables
- URI 変数のマップ IllegalArgumentExceptionSE
- uriVariables
が null
の場合。または、すべての変数名の値が含まれていない場合 public URISE expand(ObjectSE... uriVariableValues)
例:
UriTemplate template = new UriTemplate("https://example.com/hotels/{hotel}/bookings/{booking}"); System.out.println(template.expand("Rest & Relax", 42));出力されます:
https://example.com/hotels/Rest%20%26%20Relax/bookings/42
uriVariableValues
- URI 変数の配列 IllegalArgumentExceptionSE
- uriVariables
が null
である場合、または十分な変数が含まれていない場合 public boolean matches(@Nullable StringSE uri)
uri
- 照合する URItrue
。それ以外の場合は false
public MapSE<StringSE,StringSE> match(StringSE uri)
例:
UriTemplate template = new UriTemplate("https://example.com/hotels/{hotel}/bookings/{booking}"); System.out.println(template.match("https://example.com/hotels/1/bookings/42"));出力されます:
{hotel=1, booking=42}
uri
- 照合する URIpublic StringSE toString()
ObjectSE
の toStringSE