Package org.forgerock.http
Class MutableUri
java.lang.Object
org.forgerock.http.MutableUri
- All Implemented Interfaces:
Comparable<MutableUri>
A MutableUri is a modifiable
URI
substitute.
Unlike URIs, which are immutable, a MutableUri can have its fields updated independently.
That makes it easier if you just want to change a element of an Uri.- See Also:
-
Constructor Summary
ConstructorDescriptionMutableUri
(String uri) Builds a new MutableUri using the given URL encoded String URI.MutableUri
(String scheme, String userInfo, String host, int port, String path, String query, String fragment) Builds a new MutableUri using the given fields values (decoded values).MutableUri
(URI uri) Builds a new MutableUri using the given URI.MutableUri
(MutableUri mutableUri) Builds a new MutableUri with deep copy. -
Method Summary
Modifier and TypeMethodDescriptionasURI()
Returns the equivalentURI
instance.int
boolean
Returns the authority compound element.Returns the fragment element.getHost()
Returns the host element.getPath()
Returns the path element.Return the URI path elements as an immutableList
.int
getPort()
Returns the port element.getQuery()
Returns the path element.Returns the raw (encoded) authority compound element.Returns the raw (encoded) fragment element.Returns the raw (encoded) path element.Returns the raw (encoded) query element.Returns the raw (encoded) user info element.Returns the scheme name.Returns the user info element.int
hashCode()
Changes the base scheme, host and port of this MutableUri to that specified in a base URI, or leaves them unchanged if the base URI isnull
.rebase
(MutableUri base) Changes the base scheme, host and port of this MutableUri to that specified in a base URI, or leaves them unchanged if the base URI isnull
.relativize
(MutableUri uri) Relativizes the given URI against this URI.resolve
(MutableUri uri) Resolves the given URI against this URI.void
setFragment
(String fragment) Update the fragment (not encoded) of this MutableUri.void
Update the host name of this MutableUri.void
Update the path (not encoded) of this MutableUri.void
setPort
(int port) Update the port of this MutableUri.void
Update the query string (not encoded) of this MutableUri.void
setRawFragment
(String rawFragment) Update the fragment (encoded) of this MutableUri.void
setRawPath
(String rawPath) Update the path (encoded) of this MutableUri.void
setRawQuery
(String rawQuery) Update the query (encoded) of this MutableUri.void
setRawUserInfo
(String rawUserInfo) Update the user info (encoded) of this MutableUri.void
Update the scheme of this MutableUri.void
setUserInfo
(String userInfo) Update the user info (not encoded) of this MutableUri.Returns the content of this URI as a US-ASCII string.toString()
static MutableUri
Factory method for avoiding typingnew MutableUri("http://...")
.
-
Constructor Details
-
MutableUri
Builds a new MutableUri using the given URI.- Parameters:
uri
- URI
-
MutableUri
Builds a new MutableUri with deep copy.- Parameters:
mutableUri
- URI
-
MutableUri
Builds a new MutableUri using the given URL encoded String URI.- Parameters:
uri
- URL encoded URI- Throws:
URISyntaxException
- if the given Uri is not well-formed
-
MutableUri
public MutableUri(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws URISyntaxException Builds a new MutableUri using the given fields values (decoded values).- Parameters:
scheme
- Scheme nameuserInfo
- User name and authorization informationhost
- Host nameport
- Port numberpath
- Pathquery
- Queryfragment
- Fragment- Throws:
URISyntaxException
- if the produced URI is not well-formed
-
-
Method Details
-
uri
Factory method for avoiding typingnew MutableUri("http://...")
.- Parameters:
uri
- URL encoded URI- Returns:
- a new MutableUri instance
- Throws:
URISyntaxException
- if the given Uri is not well-formed
-
asURI
Returns the equivalentURI
instance.- Returns:
- the equivalent
URI
instance.
-
getScheme
Returns the scheme name.- Returns:
- the scheme name.
-
setScheme
Update the scheme of this MutableUri.- Parameters:
scheme
- new scheme name- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getUserInfo
Returns the user info element.- Returns:
- the user info element.
-
getRawUserInfo
Returns the raw (encoded) user info element.- Returns:
- the raw user info element.
-
setUserInfo
Update the user info (not encoded) of this MutableUri.- Parameters:
userInfo
- new user info element (not encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
setRawUserInfo
Update the user info (encoded) of this MutableUri.- Parameters:
rawUserInfo
- new user info element (encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getHost
Returns the host element.- Returns:
- the host element.
-
setHost
Update the host name of this MutableUri.- Parameters:
host
- new host element- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getPort
public int getPort()Returns the port element.- Returns:
- the port element.
-
setPort
Update the port of this MutableUri.- Parameters:
port
- new port number- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getPath
Returns the path element.- Returns:
- the path element.
-
getRawPath
Returns the raw (encoded) path element.- Returns:
- the raw path element.
-
setPath
Update the path (not encoded) of this MutableUri.- Parameters:
path
- new path element (not encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
setRawPath
Update the path (encoded) of this MutableUri.- Parameters:
rawPath
- new path element (encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getQuery
Returns the path element.- Returns:
- the path element.
-
getRawQuery
Returns the raw (encoded) query element.- Returns:
- the raw query element.
-
setQuery
Update the query string (not encoded) of this MutableUri.- Parameters:
query
- new query string element (not encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
setRawQuery
Update the query (encoded) of this MutableUri.- Parameters:
rawQuery
- new query element (encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getFragment
Returns the fragment element.- Returns:
- the fragment element.
-
getRawFragment
Returns the raw (encoded) fragment element.- Returns:
- the raw fragment element.
-
setFragment
Update the fragment (not encoded) of this MutableUri.- Parameters:
fragment
- new fragment element (not encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
setRawFragment
Update the fragment (encoded) of this MutableUri.- Parameters:
rawFragment
- new framgent element (encoded)- Throws:
URISyntaxException
- if the new equivalent URI is invalid
-
getAuthority
Returns the authority compound element.- Returns:
- the authority compound element.
-
getRawAuthority
Returns the raw (encoded) authority compound element.- Returns:
- the authority compound element.
-
getPathElements
Return the URI path elements as an immutableList
. ThetoString
method of the returned object will return the URL-encoded path elements joined with"/"
.- Returns:
- The URI path elements as an immutable
List
.
-
rebase
Changes the base scheme, host and port of this MutableUri to that specified in a base URI, or leaves them unchanged if the base URI isnull
. This implementation only uses scheme, host and port. The remaining components of the URI remain intact.- Parameters:
base
- the URI to base the other URI on.- Returns:
- this (rebased) instance
-
rebase
Changes the base scheme, host and port of this MutableUri to that specified in a base URI, or leaves them unchanged if the base URI isnull
. This implementation only uses scheme, host and port. The remaining components of the URI remain intact.- Parameters:
base
- the URI to base the other URI on.- Returns:
- this (rebased) instance
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MutableUri>
-
relativize
Relativizes the given URI against this URI.- Parameters:
uri
- the uri to relativizes against this instance- Returns:
- this instance (mutated)
- See Also:
-
resolve
Resolves the given URI against this URI.- Parameters:
uri
- the uri to resolve against this instance- Returns:
- this instance (mutated)
- See Also:
-
toString
-
toASCIIString
Returns the content of this URI as a US-ASCII string.- Returns:
- the content of this URI as a US-ASCII string.
-
equals
-
hashCode
public int hashCode()
-