public class ERXMutableURL extends Object
Constructor and Description |
---|
ERXMutableURL()
Constructs a blank ERXMutableURL.
|
ERXMutableURL(String str)
Constructs an ERXMutableURL with all of the properties of the given
external form of a URL.
|
ERXMutableURL(URL url)
Constructs an ERXMutableURL with all of the properties of the given URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addQueryParameter(String key,
String value)
Adds an additional query parameter to this URL.
|
void |
addQueryParameters(NSDictionary<String,? extends Object> queryParameters)
Adds additional query parameters to this URL from those defined in the
given NSDictionary.
|
void |
addQueryParameters(String queryParameters)
Appends the query parameters of this URL with the given k=v&k2=v2 format
string.
|
void |
addQueryParametersMap(Map<String,String> queryParameters)
Adds additional query parameters to this URL from those defined in the
given Map.
|
ERXMutableURL |
appendPath(String path)
Appends the given path to the end of the existing path.
|
void |
clearQueryParameters()
Clears the query parameters of this URL.
|
boolean |
containsQueryParameter(String key)
Returns true if the given key is a query parameter key in this URL.
|
String |
host()
Returns the host of this URL.
|
boolean |
isAbsolute()
Returns true if this is an absolute URL.
|
boolean |
isFullyQualified()
Returns true if there is a host defined for this URL.
|
static void |
main(String[] args) |
String |
path()
Returns the path of this URL.
|
Integer |
port()
Returns the port of this URL (can be null).
|
String |
protocol()
Returns the protocol of this URL.
|
String |
queryParameter(String key)
Returns the first query parameter for the given key.
|
Map<String,List<String>> |
queryParameters()
Returns the query parameters of this URL as a Map.
|
List<String> |
queryParameters(String key)
Returns the query parameters for the given key.
|
String |
queryParametersAsString()
Returns the query parameters of this URL as a String (in x=y&a=b syntax).
|
protected void |
queryParametersAsString(StringBuffer sb) |
String |
ref()
Returns the ref of this URL.
|
void |
removeQueryParameter(String key)
Removes the query parameters with the given key.
|
void |
removeQueryParameter(String key,
String value)
Removes the query parameter value for the given key for multivalue
parameters.
|
void |
setHost(String host)
Sets the host of this URL.
|
void |
setPath(String path)
Sets the path of this URL.
|
void |
setPort(Integer port)
Sets the port of this URL.
|
void |
setProtocol(String protocol)
Sets the protocol of this URL (http, https, etc).
|
void |
setQueryParameter(String key,
String value)
Sets the given query parameter to the given value.
|
void |
setQueryParameters(NSDictionary<String,? extends Object> queryParameters)
Replaces the query parameters of this URL with those defined in the given
NSDictionary.
|
void |
setQueryParameters(String queryParameters)
Replaces the query parameters of this URL with the given k=v&k2=v2 format
string.
|
void |
setQueryParametersMap(Map<String,List<String>> queryParameters)
Replaces the query parameters of this URL with those defined in the given
Map.
|
void |
setRef(String ref)
Sets the ref of this URL (the #whatever part).
|
void |
setURL(String str)
Sets the contents of this ERXMutableURL to be the same as the given URL
external form.
|
void |
setURL(URL url)
Sets the contents of this ERXMutableURL to be the same as the given URL.
|
String |
toExternalForm()
Returns a String form of this URL.
|
String |
toString() |
URL |
toURL()
Returns a java.net.URL object of this URL (which might fail if you have a
relative URL).
|
Map<String,String> |
uniqueQueryParameters()
Returns the query parameters of this URL as a Map uniqued by key (which
avoids multivalue properties at the expense of predictability).
|
public ERXMutableURL()
public ERXMutableURL(URL url) throws MalformedURLException
url
- the URL to copy data fromMalformedURLException
- if the URL is invalidpublic ERXMutableURL(String str) throws MalformedURLException
str
- a URL external formMalformedURLException
- if the URL is invalidpublic void setURL(URL url) throws MalformedURLException
url
- the url to copy the contents fromMalformedURLException
- if the URL is malformedpublic void setURL(String str) throws MalformedURLException
str
- the external form of a URL to copy the contents fromMalformedURLException
- if the external form of the URL is malformedpublic boolean isFullyQualified()
public boolean isAbsolute()
public void setProtocol(String protocol)
protocol
- the new protocolpublic String protocol()
public void setHost(String host)
host
- the host of this URLpublic String host()
public void setPath(String path)
path
- the path of this URLpublic String path()
public ERXMutableURL appendPath(String path)
path
- the path to appendpublic void setPort(Integer port)
port
- the port of this URLpublic Integer port()
public void setRef(String ref)
ref
- the ref of this URL (the #whatever part)public String ref()
public void setQueryParameters(String queryParameters) throws MalformedURLException
queryParameters
- the query parametersMalformedURLException
- if the string is malformedpublic void addQueryParameters(String queryParameters) throws MalformedURLException
queryParameters
- the query parametersMalformedURLException
- if the string is malformedpublic void setQueryParametersMap(Map<String,List<String>> queryParameters)
queryParameters
- the new query parameterspublic void clearQueryParameters()
public void setQueryParameters(NSDictionary<String,? extends Object> queryParameters)
queryParameters
- the new query parameterspublic void addQueryParameters(NSDictionary<String,? extends Object> queryParameters)
queryParameters
- the new query parameterspublic void addQueryParametersMap(Map<String,String> queryParameters)
queryParameters
- the new query parameterspublic void addQueryParameter(String key, String value)
key
- the key of the new parametervalue
- the value of the new parameterpublic boolean containsQueryParameter(String key)
key
- the key of the parameter to lookuppublic void removeQueryParameter(String key)
key
- the key of the query parameters to removepublic void removeQueryParameter(String key, String value)
key
- the key of the query parameters to lookupvalue
- the value to remove.public Map<String,List<String>> queryParameters()
public Map<String,String> uniqueQueryParameters()
public List<String> queryParameters(String key)
key
- the key to lookuppublic String queryParameter(String key)
key
- the key to lookuppublic void setQueryParameter(String key, String value)
key
- the key to setvalue
- the value to set it topublic String toExternalForm()
public String queryParametersAsString()
protected void queryParametersAsString(StringBuffer sb)
public URL toURL() throws MalformedURLException
MalformedURLException
- if this URL cannot be represented as a java.net.URLpublic static void main(String[] args) throws MalformedURLException
MalformedURLException
Copyright © 2002 – 2024 Project Wonder.