public class HttpAddress
extends java.lang.Object
Encapsulates a parsed HTTP URL.
Constructor and Description |
---|
HttpAddress() |
Modifier and Type | Method and Description |
---|---|
boolean |
getAbsolute()
Return true for absolute URL,
false for relative URL. |
java.lang.String |
getAuthority()
Return (nullable) Authority component, e.g.
|
java.lang.String |
getFragment()
Return (nullable) Optional fragment component, e.g.
|
java.lang.String |
getHost()
Return host subcomponent of
HttpAddress.authority , e.g. |
java.lang.String |
getPath()
Return (nullable) Optional path component, e.g.
|
int |
getPort()
Return port subcomponent of
HttpAddress.authority , e.g. |
java.lang.String |
getQuery()
Return (nullable) Optional query component, e.g.
|
java.lang.String |
getScheme()
Return scheme component, e.g.
|
static boolean |
isAbsolute(java.lang.String address)
Return
true if address is absolute. |
static boolean |
isRelative(java.lang.String address)
Return
true if address is relative. |
static HttpAddress |
parse(java.lang.String url)
|
static HttpAddress |
parse(java.lang.String url,
boolean absolute)
Parse a URL.
|
java.lang.String |
pathAndQuery()
Return the path and query portions of the address, e.g.
|
HttpAddress |
relativeTo(HttpAddress other)
If this address is absolute, then return it.
|
java.lang.String |
schemeAndAuthority()
Return the scheme and authority portions of the address, e.g.
|
void |
setAbsolute(boolean value)
Set true for absolute URL,
false for relative URL. |
void |
setAuthority(java.lang.String value)
Set authority component, e.g.
|
void |
setFragment(java.lang.String value)
Set optional fragment component, e.g.
|
void |
setHost(java.lang.String value)
Set host subcomponent of
HttpAddress.authority , e.g. |
void |
setPath(java.lang.String value)
Set optional path component, e.g.
|
void |
setPort(int value)
Set port subcomponent of
HttpAddress.authority , e.g. |
void |
setQuery(java.lang.String value)
Set optional query component, e.g.
|
void |
setScheme(java.lang.String value)
Set scheme component, e.g.
|
java.lang.String |
toString()
Return the URL in string form, e.g.
|
public boolean getAbsolute()
Return true for absolute URL, false
for relative URL.
false
for relative URL.public java.lang.String getAuthority()
Return (nullable) Authority component, e.g. host ("myhost") or host and port ("myhost:8080").
public java.lang.String getFragment()
Return (nullable) Optional fragment component, e.g. "#myfragment".
public java.lang.String getHost()
Return host subcomponent of HttpAddress.authority
, e.g. "myhost".
HttpAddress.authority
, e.g. "myhost".public java.lang.String getPath()
Return (nullable) Optional path component, e.g. "/mypath".
public int getPort()
Return port subcomponent of HttpAddress.authority
, e.g. 8080.
HttpAddress.authority
, e.g. 8080.public java.lang.String getQuery()
Return (nullable) Optional query component, e.g. "?myquery".
public java.lang.String getScheme()
Return scheme component, e.g. "http" or "https".
public static boolean isAbsolute(java.lang.String address)
Return true
if address
is absolute.
address
- Absolute or relative URL.true
if address
is absolute.public static boolean isRelative(java.lang.String address)
Return true
if address
is relative.
address
- Absolute or relative URL.true
if address
is relative.public static HttpAddress parse(java.lang.String url)
url
- Url parameter.public static HttpAddress parse(java.lang.String url, boolean absolute)
Parse a URL.
URL.
url
- The address URL.absolute
- `true` if the `url` must be absolute. False if the `url` may be relative.public java.lang.String pathAndQuery()
Return the path and query portions of the address, e.g. "/mypath?myquery".
public HttpAddress relativeTo(HttpAddress other)
If this address is absolute, then return it. If this address is relative, then apply it to other
and rerturn the resulting address.
other
- Other HTTP address.other
.public java.lang.String schemeAndAuthority()
Return the scheme and authority portions of the address, e.g. "http://myhost:8080".
public void setAbsolute(boolean value)
Set true for absolute URL, false
for relative URL.
value
- True for absolute URL, false
for relative URL.public void setAuthority(java.lang.String value)
Set authority component, e.g. host ("myhost") or host and port ("myhost:8080").
value
- Authority component, e.g. host ("myhost") or host and port ("myhost:8080").public void setFragment(java.lang.String value)
Set optional fragment component, e.g. "#myfragment".
value
- Optional fragment component, e.g. "#myfragment".public void setHost(java.lang.String value)
Set host subcomponent of HttpAddress.authority
, e.g. "myhost".
value
- Host subcomponent of HttpAddress.authority
, e.g. "myhost".public void setPath(java.lang.String value)
Set optional path component, e.g. "/mypath".
value
- Optional path component, e.g. "/mypath".public void setPort(int value)
Set port subcomponent of HttpAddress.authority
, e.g. 8080.
value
- Port subcomponent of HttpAddress.authority
, e.g. 8080.public void setQuery(java.lang.String value)
Set optional query component, e.g. "?myquery".
value
- Optional query component, e.g. "?myquery".public void setScheme(java.lang.String value)
Set scheme component, e.g. "http" or "https".
value
- Scheme component, e.g. "http" or "https".public java.lang.String toString()
Return the URL in string form, e.g. "http://myhost:8080/path?query#fragment".
toString
in class java.lang.Object