org.tigris.scarab.util
Class EmailLink

java.lang.Object
  extended byorg.tigris.scarab.util.EmailLink
All Implemented Interfaces:
org.apache.fulcrum.pool.InitableRecyclable, org.apache.fulcrum.pool.Recyclable, SkipFiltering
Direct Known Subclasses:
EmailLinkFactory.ErrorEmailLink

public class EmailLink
extends java.lang.Object
implements org.apache.fulcrum.pool.InitableRecyclable, SkipFiltering

Version:
$Id: EmailLink.java 9476 2005-03-16 22:56:11Z dabbous $
Author:
Jon S. Stevens

Field Summary
static java.lang.String HTTP
          HTTP protocol.
static java.lang.String HTTPS
          HTTPS protocol.
 
Constructor Summary
EmailLink()
          Constructor to allow factory instantiation of EmailLinks. setCurrentModule must be called before first use.
EmailLink(Module currentModule)
          Constructor.
 
Method Summary
protected  void addPair(java.util.List list, java.lang.String name, java.lang.String value)
          Add a key value pair (in the form of a 2 object array) to the provided list
 EmailLink addPathInfo(java.lang.String name, boolean value)
          Adds a name=value pair to the path_info string.
 EmailLink addPathInfo(java.lang.String name, double value)
          Adds a name=value pair to the path_info string.
 EmailLink addPathInfo(java.lang.String name, int value)
          Adds a name=value pair to the path_info string.
 EmailLink addPathInfo(java.lang.String name, long value)
          Adds a name=value pair to the path_info string.
 EmailLink addPathInfo(java.lang.String name, java.lang.Object value)
          Adds a name=value pair to the path_info string.
 EmailLink addPathInfo(java.lang.String name, java.lang.String value)
          Adds a name=value pair to the path_info string.
 void dispose()
          Disposes the object by setting its disposed flag.
 Module getCurrentModule()
           
 EmailLink getIssueIdLink(Issue issue)
          Returns a short link for viewing a single issue
 java.lang.String getScriptName()
          Gets the server scriptName (/scarab/issues).
 java.lang.String getServerName()
          Gets the server name.
 int getServerPort()
          Gets the server port.
 java.lang.String getServerScheme()
          Gets the server scheme (HTTP or HTTPS).
 boolean hasPathInfo()
          Does this URI have path info.
 void init(java.lang.Object obj)
           
 boolean isDisposed()
          Checks whether the object is disposed.
 EmailLink omitModule()
          Causes the link to not include the module id.
 void recycle()
          Recycles the object by removing its disposed flag.
 void refresh()
           
protected  void removePairByName(java.util.List pairs, java.lang.String name)
          Helper method to remove one or more pairs by its name (ie key).
 void removePathInfo()
          Removes all the path info elements.
 void removePathInfo(java.lang.String name)
          Removes a name=value pair from the path info.
protected  java.lang.String renderPairs(java.util.List pairs, char pairSep, char keyValSep)
          This method takes a List of key/value arrays and converts it into a URL encoded key/value pair format with the appropriate separator.
protected  java.lang.String renderPathInfo(java.util.List pairs)
          This method takes a Vector of key/value arrays and writes it to the supplied StringBuffer as encoded path info.
 EmailLink setAction(java.lang.String action)
          Sets the action= value for this URL.
 void setCurrentModule(Module cM)
           
 EmailLink setPage(java.lang.String t)
          Sets the template variable used by the Template Service.
 EmailLink setPathInfo(java.lang.String key, java.lang.String value)
           
 java.lang.String toString()
          Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HTTP

public static final java.lang.String HTTP
HTTP protocol.

See Also:
Constant Field Values

HTTPS

public static final java.lang.String HTTPS
HTTPS protocol.

See Also:
Constant Field Values
Constructor Detail

EmailLink

public EmailLink()
Constructor to allow factory instantiation of EmailLinks. setCurrentModule must be called before first use.


EmailLink

public EmailLink(Module currentModule)
Constructor.

Method Detail

init

public void init(java.lang.Object obj)
Specified by:
init in interface org.apache.fulcrum.pool.InitableRecyclable

getCurrentModule

public Module getCurrentModule()

setCurrentModule

public void setCurrentModule(Module cM)

refresh

public void refresh()

addPair

protected void addPair(java.util.List list,
                       java.lang.String name,
                       java.lang.String value)
Add a key value pair (in the form of a 2 object array) to the provided list

Parameters:
list - List to add to.
name - A String with the name to add.
value - A String with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             java.lang.String value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - A String with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             java.lang.Object value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - An Object with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             double value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - A double with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             int value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - An int with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             long value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - A long with the value to add.

addPathInfo

public EmailLink addPathInfo(java.lang.String name,
                             boolean value)
Adds a name=value pair to the path_info string.

Parameters:
name - A String with the name to add.
value - A double with the value to add.

setPathInfo

public EmailLink setPathInfo(java.lang.String key,
                             java.lang.String value)

removePairByName

protected void removePairByName(java.util.List pairs,
                                java.lang.String name)
Helper method to remove one or more pairs by its name (ie key). It is intended to be used with queryData and pathInfo.

Parameters:
pairs - the list of pairs to look over for removal.
name - the name of the pair(s) to remove.

removePathInfo

public void removePathInfo()
Removes all the path info elements.


removePathInfo

public void removePathInfo(java.lang.String name)
Removes a name=value pair from the path info.

Parameters:
name - A String with the name to be removed.

getServerName

public java.lang.String getServerName()
Gets the server name.

Returns:
A String with the server name.

getServerPort

public int getServerPort()
Gets the server port.

Returns:
A the server port, or -1 if unknown.

getServerScheme

public java.lang.String getServerScheme()
Gets the server scheme (HTTP or HTTPS).

Returns:
A String with the server scheme.

getScriptName

public java.lang.String getScriptName()
Gets the server scriptName (/scarab/issues).

Returns:
A String with the server scriptName.

hasPathInfo

public boolean hasPathInfo()
Does this URI have path info.


renderPathInfo

protected java.lang.String renderPathInfo(java.util.List pairs)
This method takes a Vector of key/value arrays and writes it to the supplied StringBuffer as encoded path info.

Parameters:
pairs - A Vector of key/value arrays.
Returns:
a String to which encoded path info is written

renderPairs

protected java.lang.String renderPairs(java.util.List pairs,
                                       char pairSep,
                                       char keyValSep)
This method takes a List of key/value arrays and converts it into a URL encoded key/value pair format with the appropriate separator.

Parameters:
pairs - A List of key/value arrays.
pairSep - the character to use as a separator between pairs. For example for a query-like rendering it would be '&'.
keyValSep - the character to use as a separator between key and value. For example for a query-like rendering, it would be '='.
Returns:
a String to which the pairs are written to.

toString

public java.lang.String toString()
Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl().

 DynamicURI dui = new DynamicURI (data, "UserScreen" );
 dui.addPathInfo("user","jon");
 dui.toString();
 
The above call to toString() would return the String:

http://www.server.com/servlets/Turbine/screen/UserScreen/user/jon

Specified by:
toString in interface SkipFiltering
Returns:
A String with the built URL.

omitModule

public EmailLink omitModule()
Causes the link to not include the module id. Useful for templates where a module is not required or desired.

Returns:
a EmailLink value

setPage

public EmailLink setPage(java.lang.String t)
Sets the template variable used by the Template Service. The module id of the new selected module is given.

Parameters:
t - A String with the template name.
Returns:
A EmailLink.

setAction

public EmailLink setAction(java.lang.String action)
Sets the action= value for this URL.

By default it adds the information to the path_info instead of the query data.

Parameters:
action - A String with the action value.
Returns:
A EmailLink (self).

getIssueIdLink

public EmailLink getIssueIdLink(Issue issue)
                         throws java.lang.Exception
Returns a short link for viewing a single issue

Parameters:
issue - an Issue value
Returns:
a String value
Throws:
java.lang.Exception - if an error occurs

recycle

public void recycle()
Recycles the object by removing its disposed flag.

Specified by:
recycle in interface org.apache.fulcrum.pool.Recyclable

dispose

public void dispose()
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface org.apache.fulcrum.pool.Recyclable

isDisposed

public boolean isDisposed()
Checks whether the object is disposed.

Specified by:
isDisposed in interface org.apache.fulcrum.pool.Recyclable
Returns:
true, if the object is disposed.


Copyright © 2000-2004 Tigris.org. All Rights Reserved.