java.lang.Iterable<UriSpec.Part>public class UriSpec extends java.lang.Object implements java.lang.Iterable<UriSpec.Part>
An abstraction for specifying a URI for an instance allowing for variable substitutions.
A Uri spec is a string with optional replacement fields. A replacement field begins with
an open brace and ends with a close brace. The value between the braces is the name of the
field. e.g. "{scheme}://foo.com:{port}" has two replacement fields named "scheme" and "port".
Several pre-defined fields are listed as constants in this class (e.g. FIELD_SCHEME).
| Modifier and Type | Class | Description |
|---|---|---|
static class |
UriSpec.Part |
Represents one token in the Uri spec
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
FIELD_ADDRESS |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getAddress() |
static java.lang.String |
FIELD_CLOSE_BRACE |
Always replaced with '}' - i.e.
|
static java.lang.String |
FIELD_ID |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getId() |
static java.lang.String |
FIELD_NAME |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getName() |
static java.lang.String |
FIELD_OPEN_BRACE |
Always replaced with '{' - i.e.
|
static java.lang.String |
FIELD_PORT |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getPort() |
static java.lang.String |
FIELD_REGISTRATION_TIME_UTC |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getRegistrationTimeUTC() |
static java.lang.String |
FIELD_SCHEME |
This defaults to "http".
|
static java.lang.String |
FIELD_SERVICE_TYPE |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getServiceType() |
static java.lang.String |
FIELD_SSL_PORT |
If a
ServiceInstance is passed when building, the replacement is ServiceInstance.getSslPort() |
| Constructor | Description |
|---|---|
UriSpec() |
|
UriSpec(java.lang.String rawSpec) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
add(UriSpec.Part part) |
Add a part to the end of the list
|
java.lang.String |
build() |
Build into a UriSpec string
|
java.lang.String |
build(java.util.Map<java.lang.String,java.lang.Object> variables) |
Build into a UriSpec string
|
java.lang.String |
build(ServiceInstance<?> serviceInstance) |
Build into a UriSpec string
|
java.lang.String |
build(ServiceInstance<?> serviceInstance,
java.util.Map<java.lang.String,java.lang.Object> variables) |
Build into a UriSpec string
|
boolean |
equals(java.lang.Object o) |
|
java.util.List<UriSpec.Part> |
getParts() |
|
int |
hashCode() |
|
java.util.Iterator<UriSpec.Part> |
iterator() |
|
void |
remove(UriSpec.Part part) |
Remove the given part
|
public static final java.lang.String FIELD_SCHEME
ServiceInstance is passed when building and an sslPort
is specified in the instance, the replacement is "https".public static final java.lang.String FIELD_NAME
ServiceInstance is passed when building, the replacement is ServiceInstance.getName()public static final java.lang.String FIELD_ID
ServiceInstance is passed when building, the replacement is ServiceInstance.getId()public static final java.lang.String FIELD_ADDRESS
ServiceInstance is passed when building, the replacement is ServiceInstance.getAddress()public static final java.lang.String FIELD_PORT
ServiceInstance is passed when building, the replacement is ServiceInstance.getPort()public static final java.lang.String FIELD_SSL_PORT
ServiceInstance is passed when building, the replacement is ServiceInstance.getSslPort()public static final java.lang.String FIELD_REGISTRATION_TIME_UTC
ServiceInstance is passed when building, the replacement is ServiceInstance.getRegistrationTimeUTC()public static final java.lang.String FIELD_SERVICE_TYPE
ServiceInstance is passed when building, the replacement is ServiceInstance.getServiceType()public static final java.lang.String FIELD_OPEN_BRACE
public static final java.lang.String FIELD_CLOSE_BRACE
public UriSpec()
public UriSpec(java.lang.String rawSpec)
rawSpec - the spec to parsepublic java.lang.String build()
public java.lang.String build(ServiceInstance<?> serviceInstance)
serviceInstance - instance to use for pre-defined replacement fieldspublic java.lang.String build(java.util.Map<java.lang.String,java.lang.Object> variables)
variables - a mapping of field replacement names to values. Note: any fields listed
in this map override pre-defined fieldspublic java.lang.String build(ServiceInstance<?> serviceInstance, java.util.Map<java.lang.String,java.lang.Object> variables)
serviceInstance - instance to use for pre-defined replacement fieldsvariables - a mapping of field replacement names to values. Note: any fields listed
in this map override pre-defined fieldspublic java.util.Iterator<UriSpec.Part> iterator()
iterator in interface java.lang.Iterable<UriSpec.Part>public java.util.List<UriSpec.Part> getParts()
public void add(UriSpec.Part part)
part - part to addpublic void remove(UriSpec.Part part)
part - the partpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.