Project Wonder 5.0

er.extensions.foundation
Class ERXMutableURL

java.lang.Object
  extended by er.extensions.foundation.ERXMutableURL

public class ERXMutableURL
extends java.lang.Object

ERXMutableURL provides a mutable model of a URL, including support for storing relative "URLs" in addition to the traditional absolute URL provided by the core Java URL object.

Author:
mschrag

Constructor Summary
ERXMutableURL()
          Constructs a blank ERXMutableURL.
ERXMutableURL(java.lang.String str)
          Constructs an ERXMutableURL with all of the properties of the given external form of a URL.
ERXMutableURL(java.net.URL url)
          Constructs an ERXMutableURL with all of the properties of the given URL.
 
Method Summary
 void addQueryParameter(java.lang.String key, java.lang.String value)
          Adds an additional query parameter to this URL.
 void addQueryParameters(com.webobjects.foundation.NSDictionary<java.lang.String,? extends java.lang.Object> queryParameters)
          Adds additional query parameters to this URL from those defined in the given NSDictionary.
 void addQueryParameters(java.lang.String queryParameters)
          Appends the query parameters of this URL with the given k=v&k2=v2 format string.
 void addQueryParametersMap(java.util.Map<java.lang.String,java.lang.String> queryParameters)
          Adds additional query parameters to this URL from those defined in the given Map.
 ERXMutableURL appendPath(java.lang.String path)
          Appends the given path to the end of the existing path.
 void clearQueryParameters()
          Clears the query parameters of this URL.
 boolean containsQueryParameter(java.lang.String key)
          Returns true if the given key is a query parameter key in this URL.
 java.lang.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(java.lang.String[] args)
           
 java.lang.String path()
          Returns the path of this URL.
 java.lang.Integer port()
          Returns the port of this URL (can be null).
 java.lang.String protocol()
          Returns the protocol of this URL.
 java.lang.String queryParameter(java.lang.String key)
          Returns the first query parameter for the given key.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> queryParameters()
          Returns the query parameters of this URL as a Map.
 java.util.List<java.lang.String> queryParameters(java.lang.String key)
          Returns the query parameters for the given key.
 java.lang.String queryParametersAsString()
          Returns the query parameters of this URL as a String (in x=y&a=b syntax).
protected  void queryParametersAsString(java.lang.StringBuffer sb)
           
 java.lang.String ref()
          Returns the ref of this URL.
 void removeQueryParameter(java.lang.String key)
          Removes the query parameters with the given key.
 void removeQueryParameter(java.lang.String key, java.lang.String value)
          Removes the query parameter value for the given key for multivalue parameters.
 void setHost(java.lang.String host)
          Sets the host of this URL.
 void setPath(java.lang.String path)
          Sets the path of this URL.
 void setPort(java.lang.Integer port)
          Sets the port of this URL.
 void setProtocol(java.lang.String protocol)
          Sets the protocol of this URL (http, https, etc).
 void setQueryParameter(java.lang.String key, java.lang.String value)
          Sets the given query parameter to the given value.
 void setQueryParameters(com.webobjects.foundation.NSDictionary<java.lang.String,? extends java.lang.Object> queryParameters)
          Replaces the query parameters of this URL with those defined in the given NSDictionary.
 void setQueryParameters(java.lang.String queryParameters)
          Replaces the query parameters of this URL with the given k=v&k2=v2 format string.
 void setQueryParametersMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> queryParameters)
          Replaces the query parameters of this URL with those defined in the given Map.
 void setRef(java.lang.String ref)
          Sets the ref of this URL (the #whatever part).
 void setURL(java.lang.String str)
          Sets the contents of this ERXMutableURL to be the same as the given URL external form.
 void setURL(java.net.URL url)
          Sets the contents of this ERXMutableURL to be the same as the given URL.
 java.lang.String toExternalForm()
          Returns a String form of this URL.
 java.lang.String toString()
           
 java.net.URL toURL()
          Returns a java.net.URL object of this URL (which might fail if you have a relative URL).
 java.util.Map<java.lang.String,java.lang.String> uniqueQueryParameters()
          Returns the query parameters of this URL as a Map uniqued by key (which avoids multivalue properties at the expense of predictability).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXMutableURL

public ERXMutableURL()
Constructs a blank ERXMutableURL.


ERXMutableURL

public ERXMutableURL(java.net.URL url)
              throws java.net.MalformedURLException
Constructs an ERXMutableURL with all of the properties of the given URL.

Parameters:
url - the URL to copy data from
Throws:
java.net.MalformedURLException - if the URL is invalid

ERXMutableURL

public ERXMutableURL(java.lang.String str)
              throws java.net.MalformedURLException
Constructs an ERXMutableURL with all of the properties of the given external form of a URL.

Parameters:
str - a URL external form
Throws:
java.net.MalformedURLException - if the URL is invalid
Method Detail

setURL

public void setURL(java.net.URL url)
            throws java.net.MalformedURLException
Sets the contents of this ERXMutableURL to be the same as the given URL.

Parameters:
url - the url to copy the contents from
Throws:
java.net.MalformedURLException - if the URL is malformed

setURL

public void setURL(java.lang.String str)
            throws java.net.MalformedURLException
Sets the contents of this ERXMutableURL to be the same as the given URL external form.

Parameters:
str - the external form of a URL to copy the contents from
Throws:
java.net.MalformedURLException - if the external form of the URL is malformed

isFullyQualified

public boolean isFullyQualified()
Returns true if there is a host defined for this URL.

Returns:
true if there is a host defined for this URL

isAbsolute

public boolean isAbsolute()
Returns true if this is an absolute URL.

Returns:
true if this is an absolute URL

setProtocol

public void setProtocol(java.lang.String protocol)
Sets the protocol of this URL (http, https, etc).

Parameters:
protocol - the new protocol

protocol

public java.lang.String protocol()
Returns the protocol of this URL.

Returns:
the protocol of this URL

setHost

public void setHost(java.lang.String host)
Sets the host of this URL.

Parameters:
host - the host of this URL

host

public java.lang.String host()
Returns the host of this URL.

Returns:
the host of this URL

setPath

public void setPath(java.lang.String path)
Sets the path of this URL.

Parameters:
path - the path of this URL

path

public java.lang.String path()
Returns the path of this URL.

Returns:
the path of this URL

appendPath

public ERXMutableURL appendPath(java.lang.String path)
Appends the given path to the end of the existing path.

Parameters:
path - the path to append
Returns:
this

setPort

public void setPort(java.lang.Integer port)
Sets the port of this URL.

Parameters:
port - the port of this URL

port

public java.lang.Integer port()
Returns the port of this URL (can be null).

Returns:
the port of this URL (can be null)

setRef

public void setRef(java.lang.String ref)
Sets the ref of this URL (the #whatever part).

Parameters:
ref - the ref of this URL (the #whatever part)

ref

public java.lang.String ref()
Returns the ref of this URL.

Returns:
the ref of this URL

setQueryParameters

public void setQueryParameters(java.lang.String queryParameters)
                        throws java.net.MalformedURLException
Replaces the query parameters of this URL with the given k=v&k2=v2 format string.

Parameters:
queryParameters - the query parameters
Throws:
java.net.MalformedURLException - if the string is malformed

addQueryParameters

public void addQueryParameters(java.lang.String queryParameters)
                        throws java.net.MalformedURLException
Appends the query parameters of this URL with the given k=v&k2=v2 format string.

Parameters:
queryParameters - the query parameters
Throws:
java.net.MalformedURLException - if the string is malformed

setQueryParametersMap

public void setQueryParametersMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> queryParameters)
Replaces the query parameters of this URL with those defined in the given Map.

Parameters:
queryParameters - the new query parameters

clearQueryParameters

public void clearQueryParameters()
Clears the query parameters of this URL.


setQueryParameters

public void setQueryParameters(com.webobjects.foundation.NSDictionary<java.lang.String,? extends java.lang.Object> queryParameters)
Replaces the query parameters of this URL with those defined in the given NSDictionary.

Parameters:
queryParameters - the new query parameters

addQueryParameters

public void addQueryParameters(com.webobjects.foundation.NSDictionary<java.lang.String,? extends java.lang.Object> queryParameters)
Adds additional query parameters to this URL from those defined in the given NSDictionary.

Parameters:
queryParameters - the new query parameters

addQueryParametersMap

public void addQueryParametersMap(java.util.Map<java.lang.String,java.lang.String> queryParameters)
Adds additional query parameters to this URL from those defined in the given Map.

Parameters:
queryParameters - the new query parameters

addQueryParameter

public void addQueryParameter(java.lang.String key,
                              java.lang.String value)
Adds an additional query parameter to this URL.

Parameters:
key - the key of the new parameter
value - the value of the new parameter

containsQueryParameter

public boolean containsQueryParameter(java.lang.String key)
Returns true if the given key is a query parameter key in this URL.

Parameters:
key - the key of the parameter to lookup
Returns:
true if the given key is a query parameter key in this URL

removeQueryParameter

public void removeQueryParameter(java.lang.String key)
Removes the query parameters with the given key.

Parameters:
key - the key of the query parameters to remove

removeQueryParameter

public void removeQueryParameter(java.lang.String key,
                                 java.lang.String value)
Removes the query parameter value for the given key for multivalue parameters.

Parameters:
key - the key of the query parameters to lookup
value - the value to remove.

queryParameters

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> queryParameters()
Returns the query parameters of this URL as a Map.

Returns:
the query parameters of this URL as a Map

uniqueQueryParameters

public java.util.Map<java.lang.String,java.lang.String> uniqueQueryParameters()
Returns the query parameters of this URL as a Map uniqued by key (which avoids multivalue properties at the expense of predictability).

Returns:
the query parameters of this URL as a Map

queryParameters

public java.util.List<java.lang.String> queryParameters(java.lang.String key)
Returns the query parameters for the given key.

Parameters:
key - the key to lookup
Returns:
the query parmeters for the given key

queryParameter

public java.lang.String queryParameter(java.lang.String key)
Returns the first query parameter for the given key.

Parameters:
key - the key to lookup
Returns:
the first query parmeter for the given key

setQueryParameter

public void setQueryParameter(java.lang.String key,
                              java.lang.String value)
Sets the given query parameter to the given value.

Parameters:
key - the key to set
value - the value to set it to

toExternalForm

public java.lang.String toExternalForm()
Returns a String form of this URL.

Returns:
a String form of this URL

queryParametersAsString

public java.lang.String queryParametersAsString()
Returns the query parameters of this URL as a String (in x=y&a=b syntax).

Returns:
the query parameters of this URL as a String

queryParametersAsString

protected void queryParametersAsString(java.lang.StringBuffer sb)

toURL

public java.net.URL toURL()
                   throws java.net.MalformedURLException
Returns a java.net.URL object of this URL (which might fail if you have a relative URL).

Returns:
a java.net.URL that represents this URL
Throws:
java.net.MalformedURLException - if this URL cannot be represented as a java.net.URL

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.