org.displaytag.util
Class Href

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

public class Href
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Object representing an URI (the href parameter of an <a> tag). Provides methods to insert new parameters. It doesn't support multiple parameter values

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

Constructor Summary
Href(Href href)
          Constructor for Href.
Href(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 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

Href

public Href(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

Href

public Href(Href href)
Constructor for Href.

Parameters:
href - Href
Method Detail

addParameter

public Href addParameter(java.lang.String name,
                         java.lang.Object value)
Adds a parameter to the 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.

Parameters:
name - String

addParameter

public Href addParameter(java.lang.String name,
                         int value)
Adds an int parameter to the 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.

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.

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.

Parameters:
parametersMap - Map containing parameters

getBaseUrl

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

Returns:
String

getAnchor

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

Returns:
anchor or null if no anchor has been set.

setAnchor

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

Parameters:
name - string to be used as anchor name (without #).

toString

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

Returns:
String

clone

public java.lang.Object clone()
See Also:
Object.clone()

equals

public boolean equals(java.lang.Object object)
See Also:
Object.equals(Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()


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