org.apache.turbine.util
Class DynamicURI

java.lang.Object
  extended byorg.apache.turbine.util.DynamicURI
All Implemented Interfaces:
URI
Direct Known Subclasses:
JspLink

Deprecated. Use TurbineURI instead.

public class DynamicURI
extends java.lang.Object
implements URI

This creates a Dynamic URI for use within the Turbine system

If you use this class to generate all of your href tags as well as all of your URI's, then you will not need to worry about having session data setup for you or using HttpServletRequest.encodeUrl() since this class does everything for you.

 DynamicURI dui = new DynamicURI (data, "UserScreen" );
 dui.setName("Click Here").addPathInfo("user","jon");
 dui.getA();
 
The above call to getA() would return the String: <A HREF="http://www.server.com:80/servlets/Turbine/screen=UserScreen&amp;user=jon">Click Here</A>

Version:
$Id: DynamicURI.java 534527 2007-05-02 16:10:59Z tv $
Author:
Jon S. Stevens, Jason van Zyl, Quinton McCombs

Field Summary
protected  RunData data
          Deprecated. The RunData object.
protected  boolean hasPathInfo
          Deprecated. Fast shortcut to determine if there is any data in the path info.
protected  boolean hasQueryData
          Deprecated. Fast shortcut to determine if there is any data in the query data.
static java.lang.String HTTP
          Deprecated. Use URIConstants.HTTP
static java.lang.String HTTPS
          Deprecated. Use URIConstants.HTTPS
protected static int PATH_INFO
          Deprecated. P = 0 for path info.
protected  java.util.List pathInfo
          Deprecated. A List that contains all the path info if any.
protected static int QUERY_DATA
          Deprecated. Q = 1 for query data.
protected  java.util.List queryData
          Deprecated. A List that contains all the query data if any.
protected  boolean redirect
          Deprecated. Whether we want to redirect or not.
protected  java.lang.String reference
          Deprecated. #ref
 javax.servlet.http.HttpServletResponse res
          Deprecated. Servlet response interface.
protected  ServerData sd
          Deprecated. The ServerData object.
 
Constructor Summary
DynamicURI()
          Deprecated. Default constructor - one of the init methods must be called before use.
DynamicURI(RunData data)
          Deprecated. Constructor sets up some variables.
DynamicURI(RunData data, boolean redirect)
          Deprecated. Constructor sets up some variables.
DynamicURI(RunData data, java.lang.String screen)
          Deprecated. Constructor sets up some variables.
DynamicURI(RunData data, java.lang.String screen, boolean redirect)
          Deprecated. Constructor sets up some variables.
DynamicURI(RunData data, java.lang.String screen, java.lang.String action)
          Deprecated. Constructor sets up some variables.
DynamicURI(RunData data, java.lang.String screen, java.lang.String action, boolean redirect)
          Deprecated. Constructor sets up some variables.
DynamicURI(ServerData sd)
          Deprecated. Main constructor for DynamicURI.
DynamicURI(ServerData serverData, boolean redirect)
          Deprecated. Main constructor for DynamicURI.
DynamicURI(ServerData sd, java.lang.String screen)
          Deprecated. Main constructor for DynamicURI.
DynamicURI(ServerData serverData, java.lang.String screen, boolean redirect)
          Deprecated. Main constructor for DynamicURI.
DynamicURI(ServerData sd, java.lang.String screen, java.lang.String action)
          Deprecated. Main constructor for DynamicURI.
DynamicURI(ServerData sd, java.lang.String screen, java.lang.String action, boolean redirect)
          Deprecated. Main constructor for DynamicURI.
 
Method Summary
protected  void add(int type, ParameterParser pp)
          Deprecated. Method for a quick way to add all the parameters in a ParameterParser.
protected  void add(int type, java.lang.String name, java.lang.String value)
          Deprecated. If the type is PATH_INFO, then add name/value to the pathInfo.
 DynamicURI addPathInfo(ParameterParser pp)
          Deprecated. Adds a name=value pair for every entry in a ParameterParser object to the path_info string.
 DynamicURI addPathInfo(java.lang.String name, double value)
          Deprecated. Adds a name=value pair to the path_info string.
 DynamicURI addPathInfo(java.lang.String name, int value)
          Deprecated. Adds a name=value pair to the path_info string.
 DynamicURI addPathInfo(java.lang.String name, long value)
          Deprecated. Adds a name=value pair to the path_info string.
 DynamicURI addPathInfo(java.lang.String name, java.lang.Object value)
          Deprecated. Adds a name=value pair to the path_info string.
 DynamicURI addPathInfo(java.lang.String name, java.lang.String value)
          Deprecated. Adds a name=value pair to the path_info string.
 DynamicURI addQueryData(ParameterParser pp)
          Deprecated. Adds a name=value pair for every entry in a ParameterParser object to the query string.
 DynamicURI addQueryData(java.lang.String name, double value)
          Deprecated. Adds a name=value pair to the query string.
 DynamicURI addQueryData(java.lang.String name, int value)
          Deprecated. Adds a name=value pair to the query string.
 DynamicURI addQueryData(java.lang.String name, long value)
          Deprecated. Adds a name=value pair to the query string.
 DynamicURI addQueryData(java.lang.String name, java.lang.Object value)
          Deprecated. Adds a name=value pair to the query string.
 DynamicURI addQueryData(java.lang.String name, java.lang.String value)
          Deprecated. Adds a name=value pair to the query string.
protected  void assertInitialized()
          Deprecated. Verifies that one of the init() methods has been called
 java.lang.String getA(java.lang.String name)
          Deprecated. Create an anchor object.
 java.lang.String getContextPath()
          Deprecated. Gets the context path
 java.lang.String getReference()
          Deprecated. Gets the reference (#ref).
 java.lang.String getScriptName()
          Deprecated. Gets the script name (/servlets/Turbine).
 ServerData getServerData()
          Deprecated. Returns the ServerData used to initialize this DynamicURI.
 java.lang.String getServerName()
          Deprecated. Gets the server name.
 int getServerPort()
          Deprecated. Gets the server port.
 java.lang.String getServerScheme()
          Deprecated. Gets the server scheme (HTTP or HTTPS).
 void init(RunData data)
          Deprecated. Initialize with a RunData object
 void init(ServerData serverData)
          Deprecated. Initialize with a ServerData object.
protected  void remove(int type, java.lang.String name)
          Deprecated. If the type is PATH_INFO, then remove name/value from the pathInfo.
 void removePathInfo()
          Deprecated. Removes all the path info elements.
 void removePathInfo(java.lang.String name)
          Deprecated. Removes a name=value pair from the path info.
 void removeQueryData()
          Deprecated. Removes all the query string elements.
 void removeQueryData(java.lang.String name)
          Deprecated. Removes a name=value pair from the query string.
protected  java.lang.String renderPathInfo(java.util.List data)
          Deprecated. This method takes a List of key/value arrays and converts it into a URL encoded querystring format.
protected  java.lang.String renderQueryString(java.util.List data)
          Deprecated. This method takes a List of key/value arrays and converts it into a URL encoded querystring format.
 DynamicURI setAction(java.lang.String action)
          Deprecated. Sets the action= value for this URL.
 DynamicURI setActionEvent(java.lang.String actionName, java.lang.String eventName)
          Deprecated. Sets the action= value for this URL and added eventSubmit_[eventName] to the path_info.
 DynamicURI setContextPath(java.lang.String contextPath)
          Deprecated. Sets the context path
 DynamicURI setReference(java.lang.String reference)
          Deprecated. Sets the reference (#ref).
 DynamicURI setScreen(java.lang.String screen)
          Deprecated. Sets the screen= value for this URL.
 DynamicURI setScriptName(java.lang.String name)
          Deprecated. Sets the script name (/servlets/Turbine).
 DynamicURI setSecure()
          Deprecated. Method to specify that a URI should use SSL.
 DynamicURI setSecure(int port)
          Deprecated. Method to specify that a URI should use SSL.
 void setServerData(ServerData serverData)
          Deprecated. no replacement. This value is set during initialization and should not be changed.
 DynamicURI setServerName(java.lang.String name)
          Deprecated. Sets the server name.
 DynamicURI setServerPort(int port)
          Deprecated. Sets the server port.
 DynamicURI setServerScheme(java.lang.String scheme)
          Deprecated. Sets the scheme (HTTP or HTTPS).
 java.lang.String toString()
          Deprecated. Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl().
static java.lang.String toString(RunData data)
          Deprecated. Given a RunData object, get a URI for the request.
 
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
Deprecated. Use URIConstants.HTTP

See Also:
Constant Field Values

HTTPS

public static final java.lang.String HTTPS
Deprecated. Use URIConstants.HTTPS

See Also:
Constant Field Values

sd

protected ServerData sd
Deprecated. 
The ServerData object.


data

protected RunData data
Deprecated. 
The RunData object.


reference

protected java.lang.String reference
Deprecated. 
#ref


res

public javax.servlet.http.HttpServletResponse res
Deprecated. 
Servlet response interface.


pathInfo

protected java.util.List pathInfo
Deprecated. 
A List that contains all the path info if any.


queryData

protected java.util.List queryData
Deprecated. 
A List that contains all the query data if any.


hasPathInfo

protected boolean hasPathInfo
Deprecated. 
Fast shortcut to determine if there is any data in the path info.


hasQueryData

protected boolean hasQueryData
Deprecated. 
Fast shortcut to determine if there is any data in the query data.


redirect

protected boolean redirect
Deprecated. 
Whether we want to redirect or not.


PATH_INFO

protected static final int PATH_INFO
Deprecated. 
P = 0 for path info.

See Also:
Constant Field Values

QUERY_DATA

protected static final int QUERY_DATA
Deprecated. 
Q = 1 for query data.

See Also:
Constant Field Values
Constructor Detail

DynamicURI

public DynamicURI(RunData data)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.

DynamicURI

public DynamicURI()
Deprecated. 
Default constructor - one of the init methods must be called before use.


DynamicURI

public DynamicURI(RunData data,
                  java.lang.String screen)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.
screen - A String with the name of a screen.

DynamicURI

public DynamicURI(RunData data,
                  java.lang.String screen,
                  java.lang.String action)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.
screen - A String with the name of a screen.
action - A String with the name of an action.

DynamicURI

public DynamicURI(RunData data,
                  java.lang.String screen,
                  java.lang.String action,
                  boolean redirect)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.
screen - A String with the name of a screen.
action - A String with the name of an action.
redirect - True if it should redirect.

DynamicURI

public DynamicURI(RunData data,
                  java.lang.String screen,
                  boolean redirect)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.
screen - A String with the name of a screen.
redirect - True if it should redirect.

DynamicURI

public DynamicURI(RunData data,
                  boolean redirect)
Deprecated. 
Constructor sets up some variables.

Parameters:
data - A Turbine RunData object.
redirect - True if it should redirect.

DynamicURI

public DynamicURI(ServerData sd)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
sd - A ServerData.

DynamicURI

public DynamicURI(ServerData sd,
                  java.lang.String screen)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
sd - A ServerData.
screen - A String with the name of a screen.

DynamicURI

public DynamicURI(ServerData sd,
                  java.lang.String screen,
                  java.lang.String action)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
sd - A ServerData.
screen - A String with the name of a screen.
action - A String with the name of an action.

DynamicURI

public DynamicURI(ServerData sd,
                  java.lang.String screen,
                  java.lang.String action,
                  boolean redirect)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
sd - A ServerData.
screen - A String with the name of a screen.
action - A String with the name of an action.
redirect - True if it should redirect.

DynamicURI

public DynamicURI(ServerData serverData,
                  java.lang.String screen,
                  boolean redirect)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
serverData - A ServerData.
screen - A String with the name of a screen.
redirect - True if it should redirect.

DynamicURI

public DynamicURI(ServerData serverData,
                  boolean redirect)
Deprecated. 
Main constructor for DynamicURI. Uses ServerData.

Parameters:
serverData - A ServerData.
redirect - True if it should redirect.
Method Detail

init

public void init(RunData data)
Deprecated. 
Initialize with a RunData object

Parameters:
data - RunData instance

init

public void init(ServerData serverData)
Deprecated. 
Initialize with a ServerData object.

Parameters:
serverData -

add

protected void add(int type,
                   java.lang.String name,
                   java.lang.String value)
Deprecated. 
If the type is PATH_INFO, then add name/value to the pathInfo.

If the type is QUERY_DATA, then add name/value to the queryData.

Parameters:
type - Type of insertion.
name - A String with the name to add.
value - A String with the value to add.

add

protected void add(int type,
                   ParameterParser pp)
Deprecated. 
Method for a quick way to add all the parameters in a ParameterParser.

If the type is PATH_INFO, then add name/value to the pathInfo.

If the type is QUERY_DATA, then add name/value to the queryData.

Parameters:
type - Type of insertion.
pp - A ParameterParser.

addPathInfo

public DynamicURI addPathInfo(java.lang.String name,
                              java.lang.Object value)
Deprecated. 
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.
Returns:
A DynamicURI (self).

addPathInfo

public DynamicURI addPathInfo(java.lang.String name,
                              java.lang.String value)
Deprecated. 
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.
Returns:
A DynamicURI (self).

addPathInfo

public DynamicURI addPathInfo(java.lang.String name,
                              double value)
Deprecated. 
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.
Returns:
A DynamicURI (self).

addPathInfo

public DynamicURI addPathInfo(java.lang.String name,
                              int value)
Deprecated. 
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.
Returns:
A DynamicURI (self).

addPathInfo

public DynamicURI addPathInfo(java.lang.String name,
                              long value)
Deprecated. 
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.
Returns:
A DynamicURI (self).

addPathInfo

public DynamicURI addPathInfo(ParameterParser pp)
Deprecated. 
Adds a name=value pair for every entry in a ParameterParser object to the path_info string.

Parameters:
pp - A ParameterParser.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(java.lang.String name,
                               java.lang.Object value)
Deprecated. 
Adds a name=value pair to the query string.

Parameters:
name - A String with the name to add.
value - An Object with the value to add.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(java.lang.String name,
                               java.lang.String value)
Deprecated. 
Adds a name=value pair to the query string.

Parameters:
name - A String with the name to add.
value - A String with the value to add.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(java.lang.String name,
                               double value)
Deprecated. 
Adds a name=value pair to the query string.

Parameters:
name - A String with the name to add.
value - A double with the value to add.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(java.lang.String name,
                               int value)
Deprecated. 
Adds a name=value pair to the query string.

Parameters:
name - A String with the name to add.
value - An int with the value to add.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(java.lang.String name,
                               long value)
Deprecated. 
Adds a name=value pair to the query string.

Parameters:
name - A String with the name to add.
value - A long with the value to add.
Returns:
A DynamicURI (self).

addQueryData

public DynamicURI addQueryData(ParameterParser pp)
Deprecated. 
Adds a name=value pair for every entry in a ParameterParser object to the query string.

Parameters:
pp - A ParameterParser.
Returns:
A DynamicURI (self).

getA

public java.lang.String getA(java.lang.String name)
Deprecated. 
Create an anchor object. This call to getA():
 DynamicURI dui = new DynamicURI (data, "UserScreen" );
 dui.setName("Click Here").addPathInfo("user","jon");
 dui.getA();
 
would return the String:

<A HREF="http://www.server.com:80/servlets/Turbine/screen=UserScreen&amp;user=jon">Click Here</A>

Parameters:
name - A String with the name for the anchor.
Returns:
The anchor as a <A HREF="">name</A>.

getScriptName

public java.lang.String getScriptName()
Deprecated. 
Gets the script name (/servlets/Turbine).

Specified by:
getScriptName in interface URI
Returns:
A String with the script name.

getContextPath

public java.lang.String getContextPath()
Deprecated. 
Gets the context path

Specified by:
getContextPath in interface URI
Returns:
A String with the servlet context path

getReference

public java.lang.String getReference()
Deprecated. 
Gets the reference (#ref).

Specified by:
getReference in interface URI
Returns:
A String containing the reference.

getServerName

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

Specified by:
getServerName in interface URI
Returns:
A String with the server name.

getServerPort

public int getServerPort()
Deprecated. 
Gets the server port.

Specified by:
getServerPort in interface URI
Returns:
A String with the server port.

getServerScheme

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

Specified by:
getServerScheme in interface URI
Returns:
A String with the server scheme.

remove

protected void remove(int type,
                      java.lang.String name)
Deprecated. 

If the type is PATH_INFO, then remove name/value from the pathInfo.

If the type is QUERY_DATA, then remove name/value from the queryData.

Parameters:
type - Type of removal.
name - A String with the name to be removed.

removePathInfo

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


removePathInfo

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

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

removeQueryData

public void removeQueryData()
Deprecated. 
Removes all the query string elements.


removeQueryData

public void removeQueryData(java.lang.String name)
Deprecated. 
Removes a name=value pair from the query string.

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

renderPathInfo

protected java.lang.String renderPathInfo(java.util.List data)
Deprecated. 
This method takes a List of key/value arrays and converts it into a URL encoded querystring format.

Parameters:
data - A List of key/value arrays.
Returns:
A String with the URL encoded data.

renderQueryString

protected java.lang.String renderQueryString(java.util.List data)
Deprecated. 
This method takes a List of key/value arrays and converts it into a URL encoded querystring format.

Parameters:
data - A List of key/value arrays.
Returns:
A String with the URL encoded data.

setAction

public DynamicURI setAction(java.lang.String action)
Deprecated. 
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 DynamicURI (self).

setActionEvent

public DynamicURI setActionEvent(java.lang.String actionName,
                                 java.lang.String eventName)
Deprecated. 
Sets the action= value for this URL and added eventSubmit_[eventName] to the path_info. The value of eventSubmit_[eventName] will be [eventName].

Parameters:
actionName - name of the action to call
eventName - name of the event.
Returns:
A DynamicURI (self).

setScreen

public DynamicURI setScreen(java.lang.String screen)
Deprecated. 
Sets the screen= value for this URL.

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

Parameters:
screen - A String with the screen value.
Returns:
A DynamicURI (self).

setScriptName

public DynamicURI setScriptName(java.lang.String name)
Deprecated. 
Sets the script name (/servlets/Turbine).

Parameters:
name - A String with the script name.
Returns:
A DynamicURI (self).

setContextPath

public DynamicURI setContextPath(java.lang.String contextPath)
Deprecated. 
Sets the context path

Parameters:
contextPath - A String with the servlet context path
Returns:
A DynamicURI (self).

setReference

public DynamicURI setReference(java.lang.String reference)
Deprecated. 
Sets the reference (#ref).

Parameters:
reference - A String containing the reference.
Returns:
A DynamicURI (self).

setServerName

public DynamicURI setServerName(java.lang.String name)
Deprecated. 
Sets the server name.

Parameters:
name - A String with the server name.
Returns:
A DynamicURI (self).

setServerPort

public DynamicURI setServerPort(int port)
Deprecated. 
Sets the server port.

Parameters:
port - An int with the port.
Returns:
A DynamicURI (self).

setSecure

public DynamicURI setSecure()
Deprecated. 
Method to specify that a URI should use SSL. Whether or not it does is determined from TurbineResources.properties. Port number is 443.

Returns:
A DynamicURI (self).

setSecure

public DynamicURI setSecure(int port)
Deprecated. 
Method to specify that a URI should use SSL. Whether or not it does is determined from TurbineResources.properties.

Parameters:
port - An int with the port number.
Returns:
A DynamicURI (self).

setServerScheme

public DynamicURI setServerScheme(java.lang.String scheme)
Deprecated. 
Sets the scheme (HTTP or HTTPS).

Parameters:
scheme - A String with the scheme.
Returns:
A DynamicURI (self).

toString

public java.lang.String toString()
Deprecated. 
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

Returns:
A String with the built URL.

toString

public static java.lang.String toString(RunData data)
Deprecated. 
Given a RunData object, get a URI for the request. This is necessary sometimes when you want the exact URL and don't want DynamicURI to be too smart and remove actions, screens, etc. This also returns the Query Data where DynamicURI normally would not.

Parameters:
data - A Turbine RunData object.
Returns:
A String with the URL representing the RunData.

getServerData

public ServerData getServerData()
Deprecated. 
Returns the ServerData used to initialize this DynamicURI.

Returns:
A ServerData used to initialize this DynamicURI.

setServerData

public void setServerData(ServerData serverData)
Deprecated. no replacement. This value is set during initialization and should not be changed.

Sets the ServerData used to initialize this DynamicURI.

Parameters:
serverData - A ServerData used to initialize this DynamicURI.

assertInitialized

protected void assertInitialized()
Deprecated. 
Verifies that one of the init() methods has been called



Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.