org.ow2.opensuit.core.util
Class UrlBuilder

java.lang.Object
  extended by org.ow2.opensuit.core.util.UrlBuilder
Direct Known Subclasses:
OpenSuitUrlBuilder

public class UrlBuilder
extends java.lang.Object

Helper interface for building Urls with parameters, and managing url encoding.


Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> name2value
           
protected  java.lang.String ref
           
protected  java.lang.String requestUri
           
 
Constructor Summary
UrlBuilder(java.lang.String iRequestURI)
          Creates a new UrlBuilder with given request uri.
 
Method Summary
 java.util.Set<java.lang.String> getParameterNames()
          Returns a set of parameter names in the Url.
 java.util.Map<java.lang.String,java.lang.String> getParametersMap()
          Returns the parameters map
 java.lang.String getParameterValue(java.lang.String iName)
          Returns the url parameter with given name.
 java.lang.String getRef()
          Gets the anchor (also known as the "reference") of this url.
 java.lang.String getRequestUri()
          Returns the url request uri.
static UrlBuilder parse(java.lang.String uriAndQuery, java.lang.String iCharSet)
           
 UrlBuilder removeParameter(java.lang.String iName)
          Removes the parameter with given name.
 UrlBuilder setParameter(java.lang.String iName, java.lang.String iValue)
          Sets the given Url parameter.
 void setRef(java.lang.String ref)
          Sets the anchor (also known as the "reference") of this url.
 java.lang.String toString()
           
 java.lang.String toUrl(java.lang.String iCharSet, boolean iEncodeHtml)
          Serializes the Url to its string form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requestUri

protected java.lang.String requestUri

name2value

protected java.util.Map<java.lang.String,java.lang.String> name2value

ref

protected java.lang.String ref
Constructor Detail

UrlBuilder

public UrlBuilder(java.lang.String iRequestURI)
Creates a new UrlBuilder with given request uri.

Parameters:
iRequestURI - The url request uri.
Method Detail

getRequestUri

public java.lang.String getRequestUri()
Returns the url request uri.

Returns:

setParameter

public UrlBuilder setParameter(java.lang.String iName,
                               java.lang.String iValue)
Sets the given Url parameter.

Parameters:
iName - Parameter name.
iValue - Parameter value.
Returns:
Returns this object, to allows chaining calls.

removeParameter

public UrlBuilder removeParameter(java.lang.String iName)
Removes the parameter with given name.

Parameters:
iName - The parameter name to remove.
Returns:
this object (to chain calls).

getParameterNames

public java.util.Set<java.lang.String> getParameterNames()
Returns a set of parameter names in the Url.

Returns:

getParameterValue

public java.lang.String getParameterValue(java.lang.String iName)
Returns the url parameter with given name.

Parameters:
iName - The parameter name.
Returns:
The parameter value.

getParametersMap

public java.util.Map<java.lang.String,java.lang.String> getParametersMap()
Returns the parameters map


toUrl

public java.lang.String toUrl(java.lang.String iCharSet,
                              boolean iEncodeHtml)
Serializes the Url to its string form.

Parameters:
iCharSet - Gives the charset to use to encode the url.
iEncodeHtml - Tells whether the url has to be HTML encoded (in addition to url encoding).
Returns:
The encoded url with all its parameters.

getRef

public java.lang.String getRef()
Gets the anchor (also known as the "reference") of this url.


setRef

public void setRef(java.lang.String ref)
Sets the anchor (also known as the "reference") of this url.


toString

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

parse

public static UrlBuilder parse(java.lang.String uriAndQuery,
                               java.lang.String iCharSet)


Copyright © 2008-2012 OW2 Consortium. All Rights Reserved.