public final class SystemBaseUrl extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_HOST |
static String |
DEFAULT_HTTP_PORT |
static String |
DEFAULT_HTTPS_PORT |
static String |
DEFAULT_PROTOCOL |
static String |
HOST |
static String |
HTTP_PORT |
static String |
HTTPS_PORT |
static String |
PORT |
static String |
PROTOCOL |
static String |
ROOT_CONTEXT |
Modifier and Type | Method and Description |
---|---|
static String |
constructUrl(String context)
Construct a url for the given context
|
static String |
constructUrl(String context,
boolean includeRootContext)
Construct a url for the given context
|
static String |
constructUrl(String proto,
String context)
Construct a url based on the protocol and context
|
static String |
constructUrl(String proto,
String context,
boolean includeRootContext)
Construct a url based on the protocol and context
|
static String |
getBaseUrl()
Constructs and returns the base url for the system using the system default protocol
|
static String |
getBaseUrl(String proto)
Constructs and returns the base url for the system given a protocol
|
static String |
getHost()
Gets the current host name or IP address from the system properties, or
DEFAULT_HOST
if not set. |
static String |
getHttpPort() |
static String |
getHttpsPort() |
static String |
getPort()
Gets the port number based on the the system protocol
|
static String |
getPort(String proto)
Gets the port number for the given protocol.
|
static String |
getProtocol() |
static String |
getRootContext() |
public static final String HTTP_PORT
public static final String HTTPS_PORT
public static final String PORT
public static final String HOST
public static final String PROTOCOL
public static final String ROOT_CONTEXT
public static final String DEFAULT_HTTP_PORT
public static final String DEFAULT_HTTPS_PORT
public static final String DEFAULT_HOST
public static final String DEFAULT_PROTOCOL
public static String getPort()
public static String getBaseUrl()
public static String getBaseUrl(String proto)
proto
- Protocol to use during url construction. A null value will cause the system
default protocol to be usedpublic static String constructUrl(String context)
context
- The context path to be appened to the end of the base urlpublic static String constructUrl(String context, boolean includeRootContext)
context
- The context path to be appened to the end of the base urlincludeRootContext
- Flag to indicated whether the rootcontext should be included in the
url.public static String constructUrl(String proto, String context)
proto
- Protocol to use during url construction. A null value will cause the system
default protocol to be usedcontext
- The context path to be appened to the end of the base urlpublic static String constructUrl(String proto, String context, boolean includeRootContext)
proto
- Protocol to use during url construction. A null value will cause the system
default protocol to be usedcontext
- The context path to be appened to the end of the base urlincludeRootContext
- Flag to indicated whether the rootcontext should be included in the
url.public static String getPort(String proto)
proto
- protocol (http or https)public static String getHttpPort()
public static String getHttpsPort()
public static String getHost()
DEFAULT_HOST
if not set.DEFAULT_HOST
public static String getProtocol()
public static String getRootContext()
This work is licensed under a Creative Commons Attribution 4.0 International License.