org.displaytag.util
Class DefaultHref

java.lang.Object
  extended by org.displaytag.util.DefaultHref
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Href

public class DefaultHref
extends java.lang.Object
implements Href

Version:
$Revision$ ($Author$)
Author:
Fabrizio Giustina
See Also:
Serialized Form

Constructor Summary
DefaultHref(java.lang.String baseUrl)
          Construct a new Href parsing a URL.
 
Method Summary
 Href addParameter(java.lang.String name, int value)
          Adds an int parameter to the href.
 Href addParameter(java.lang.String name, java.lang.Object value)
          Adds a parameter to the href.
 void addParameterMap(java.util.Map parametersMap)
          Adds all the parameters contained in the map to the Href.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object object)
           
 java.lang.String getAnchor()
          Returns the URI anchor.
 java.lang.String getBaseUrl()
          Getter for the base url (without parameters).
 java.util.Map getParameterMap()
          Getter for the map containing link parameters.
 int hashCode()
           
 void removeParameter(java.lang.String name)
          Removes a parameter from the href.
 void setAnchor(java.lang.String name)
          Setter for the URI anchor.
 void setFullUrl(java.lang.String baseUrl)
          Set the full url, overriding any existing parameter.
 void setParameterMap(java.util.Map parametersMap)
          Adds all the parameters contained in the map to the Href.
 java.lang.String toString()
          toString: output the full url with parameters.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultHref

public DefaultHref(java.lang.String baseUrl)
Construct a new Href parsing a URL. Parameters are stripped from the base url and saved in the parameters map.

Parameters:
baseUrl - String
Method Detail

setFullUrl

public void setFullUrl(java.lang.String baseUrl)
Description copied from interface: Href
Set the full url, overriding any existing parameter.

Specified by:
setFullUrl in interface Href
Parameters:
baseUrl - full url
See Also:
Href.setFullUrl(java.lang.String)

addParameter

public Href addParameter(java.lang.String name,
                         java.lang.Object value)
Adds a parameter to the href.

Specified by:
addParameter in interface Href
Parameters:
name - String
value - Object
Returns:
this Href instance, useful for concatenation.

removeParameter

public void removeParameter(java.lang.String name)
Removes a parameter from the href.

Specified by:
removeParameter in interface Href
Parameters:
name - String

addParameter

public Href addParameter(java.lang.String name,
                         int value)
Adds an int parameter to the href.

Specified by:
addParameter in interface Href
Parameters:
name - String
value - int
Returns:
this Href instance, useful for concatenation.

getParameterMap

public java.util.Map getParameterMap()
Getter for the map containing link parameters. The returned map is always a copy and not the original instance.

Specified by:
getParameterMap in interface Href
Returns:
parameter Map (copy)

setParameterMap

public void setParameterMap(java.util.Map parametersMap)
Adds all the parameters contained in the map to the Href. The value in the given Map will be escaped before added. Any parameter already present in the href object is removed.

Specified by:
setParameterMap in interface Href
Parameters:
parametersMap - Map containing parameters

addParameterMap

public void addParameterMap(java.util.Map parametersMap)
Adds all the parameters contained in the map to the Href. The value in the given Map will be escaped before added. Parameters in the original href are kept and not overridden.

Specified by:
addParameterMap in interface Href
Parameters:
parametersMap - Map containing parameters

getBaseUrl

public java.lang.String getBaseUrl()
Getter for the base url (without parameters).

Specified by:
getBaseUrl in interface Href
Returns:
String

getAnchor

public java.lang.String getAnchor()
Returns the URI anchor.

Specified by:
getAnchor in interface Href
Returns:
anchor or null if no anchor has been set.

setAnchor

public void setAnchor(java.lang.String name)
Setter for the URI anchor.

Specified by:
setAnchor in interface Href
Parameters:
name - string to be used as anchor name (without #).

toString

public java.lang.String toString()
toString: output the full url with parameters.

Specified by:
toString in interface Href
Overrides:
toString in class java.lang.Object
Returns:
String

clone

public java.lang.Object clone()
Specified by:
clone in interface Href
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

equals

public boolean equals(java.lang.Object object)
Specified by:
equals in interface Href
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()


Copyright © 2002-2010 the Displaytag team. All Rights Reserved.