public class UrlBuilder extends Object
Modifier and Type | Method and Description |
---|---|
UrlBuilder |
add(String contextPath)
Adds a context path to an existing URL.
|
URL |
build()
Builds an http URL from the base URL information provided and all the context paths added.
|
URL |
buildSecure()
Builds an https URL from the base URL information provided and all the context paths added.
|
static UrlBuilder |
from(String hostname,
String port,
String securePort,
String rootContext)
Creates a
UrlBuilder from static values. |
static UrlBuilder |
fromSystemProperties(String hostnameSystemProperty,
String portSystemProperty,
String securePortSystemProperty,
String rootContextSystemProperty)
Creates a
UrlBuilder from system property values. |
public static UrlBuilder from(String hostname, String port, String securePort, String rootContext)
UrlBuilder
from static values.hostname
- host name to use in the URLport
- port to use in the URLsecurePort
- secure port to use in the URLrootContext
- root context of the URLUrlBuilder
instancepublic static UrlBuilder fromSystemProperties(String hostnameSystemProperty, String portSystemProperty, String securePortSystemProperty, String rootContextSystemProperty)
UrlBuilder
from system property values.hostnameSystemProperty
- name of the system property that contains the host name to use in
the URLportSystemProperty
- name of the system property that contains the port to use in the URLsecurePortSystemProperty
- name of the system property that contains the secure port to
use in the URLrootContextSystemProperty
- name of the system property that contains the root context of
the URLUrlBuilder
instancepublic UrlBuilder add(String contextPath)
/
at the beginning or end of the context path provided to guarantee that the
URL is always valid.contextPath
- context path to add to the URLUrlBuilder
public URL build()
public URL buildSecure()
This work is licensed under a Creative Commons Attribution 4.0 International License.