| java.lang.Object org.apache.turbine.util.DynamicURI
All known Subclasses: org.apache.turbine.services.jsp.util.JspLink,
DynamicURI | public class DynamicURI implements URI(Code) | | 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&user=jon">Click Here</A>
author: Jon S. Stevens author: Jason van Zyl author: Quinton McCombs version: $Id: DynamicURI.java 534527 2007-05-02 16:10:59Z tv $org.apache.turbine.util.uri.TurbineURI |
Constructor Summary | |
public | DynamicURI(RunData data) Constructor sets up some variables. | public | DynamicURI() Default constructor - one of the init methods must be called
before use. | public | DynamicURI(RunData data, String screen) Constructor sets up some variables. | public | DynamicURI(RunData data, String screen, String action) Constructor sets up some variables. | public | DynamicURI(RunData data, String screen, String action, boolean redirect) Constructor sets up some variables. | public | DynamicURI(RunData data, String screen, boolean redirect) Constructor sets up some variables. | public | DynamicURI(RunData data, boolean redirect) Constructor sets up some variables. | public | DynamicURI(ServerData sd) Main constructor for DynamicURI. | public | DynamicURI(ServerData sd, String screen) Main constructor for DynamicURI. | public | DynamicURI(ServerData sd, String screen, String action) Main constructor for DynamicURI. | public | DynamicURI(ServerData sd, String screen, String action, boolean redirect) Main constructor for DynamicURI. | public | DynamicURI(ServerData serverData, String screen, boolean redirect) Main constructor for DynamicURI. | public | DynamicURI(ServerData serverData, boolean redirect) Main constructor for DynamicURI. |
Method Summary | |
protected void | add(int type, String name, String value) If the type is
DynamicURI.PATH_INFO , then add name/value to the
pathInfo. | protected void | add(int type, ParameterParser pp) Method for a quick way to add all the parameters in a
ParameterParser. | public DynamicURI | addPathInfo(String name, Object value) Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - An Object with the value to add. | public DynamicURI | addPathInfo(String name, String value) Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A String with the value to add. | public DynamicURI | addPathInfo(String name, double value) Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A double with the value to add. | public DynamicURI | addPathInfo(String name, int value) Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - An int with the value to add. | public DynamicURI | addPathInfo(String name, long value) Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A long with the value to add. | public DynamicURI | addPathInfo(ParameterParser pp) Adds a name=value pair for every entry in a ParameterParser
object to the path_info string.
Parameters: pp - A ParameterParser. | public DynamicURI | addQueryData(String name, Object value) Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - An Object with the value to add. | public DynamicURI | addQueryData(String name, String value) Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A String with the value to add. | public DynamicURI | addQueryData(String name, double value) Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A double with the value to add. | public DynamicURI | addQueryData(String name, int value) Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - An int with the value to add. | public DynamicURI | addQueryData(String name, long value) Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A long with the value to add. | public DynamicURI | addQueryData(ParameterParser pp) Adds a name=value pair for every entry in a ParameterParser
object to the query string.
Parameters: pp - A ParameterParser. | protected void | assertInitialized() | public String | getA(String name) Create an anchor object. | public String | getContextPath() | public String | getReference() Gets the reference (#ref). | public String | getScriptName() Gets the script name (/servlets/Turbine). | public ServerData | getServerData() Returns the ServerData used to initialize this DynamicURI. | public String | getServerName() Gets the server name. | public int | getServerPort() Gets the server port. | public String | getServerScheme() Gets the server scheme (HTTP or HTTPS). | public void | init(RunData data) | public void | init(ServerData serverData) Initialize with a ServerData object. | protected void | remove(int type, String name) If the type is
DynamicURI.PATH_INFO , then remove name/value from the
pathInfo. | public void | removePathInfo() Removes all the path info elements. | public void | removePathInfo(String name) Removes a name=value pair from the path info. | public void | removeQueryData() Removes all the query string elements. | public void | removeQueryData(String name) Removes a name=value pair from the query string. | protected String | renderPathInfo(List data) 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. | protected String | renderQueryString(List data) 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. | public DynamicURI | setAction(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. | public DynamicURI | setActionEvent(String actionName, String eventName) Sets the action= value for this URL and added eventSubmit_[eventName]
to the path_info. | public DynamicURI | setContextPath(String contextPath) | public DynamicURI | setReference(String reference) Sets the reference (#ref).
Parameters: reference - A String containing the reference. | public DynamicURI | setScreen(String screen) 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. | public DynamicURI | setScriptName(String name) Sets the script name (/servlets/Turbine).
Parameters: name - A String with the script name. | public DynamicURI | setSecure() Method to specify that a URI should use SSL. | public DynamicURI | setSecure(int port) Method to specify that a URI should use SSL. | public void | setServerData(ServerData serverData) Sets the ServerData used to initialize this DynamicURI. | public DynamicURI | setServerName(String name) Sets the server name.
Parameters: name - A String with the server name. | public DynamicURI | setServerPort(int port) Sets the server port.
Parameters: port - An int with the port. | public DynamicURI | setServerScheme(String scheme) Sets the scheme (HTTP or HTTPS).
Parameters: scheme - A String with the scheme. | public String | toString() Builds the URL with all of the data URL-encoded as well as
encoded using HttpServletResponse.encodeUrl(). | public static String | toString(RunData data) Given a RunData object, get a URI for the request. |
PATH_INFO | final protected static int PATH_INFO(Code) | | P = 0 for path info.
|
QUERY_DATA | final protected static int QUERY_DATA(Code) | | Q = 1 for query data.
|
hasPathInfo | protected boolean hasPathInfo(Code) | | Fast shortcut to determine if there is any data in the path info.
|
hasQueryData | protected boolean hasQueryData(Code) | | Fast shortcut to determine if there is any data in the query data.
|
pathInfo | protected List pathInfo(Code) | | A List that contains all the path info if any.
|
queryData | protected List queryData(Code) | | A List that contains all the query data if any.
|
redirect | protected boolean redirect(Code) | | Whether we want to redirect or not.
|
DynamicURI | public DynamicURI(RunData data)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. |
DynamicURI | public DynamicURI()(Code) | | Default constructor - one of the init methods must be called
before use.
|
DynamicURI | public DynamicURI(RunData data, String screen)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. Parameters: screen - A String with the name of a screen. |
DynamicURI | public DynamicURI(RunData data, String screen, String action)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. Parameters: screen - A String with the name of a screen. Parameters: action - A String with the name of an action. |
DynamicURI | public DynamicURI(RunData data, String screen, String action, boolean redirect)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. Parameters: screen - A String with the name of a screen. Parameters: action - A String with the name of an action. Parameters: redirect - True if it should redirect. |
DynamicURI | public DynamicURI(RunData data, String screen, boolean redirect)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. Parameters: screen - A String with the name of a screen. Parameters: redirect - True if it should redirect. |
DynamicURI | public DynamicURI(RunData data, boolean redirect)(Code) | | Constructor sets up some variables.
Parameters: data - A Turbine RunData object. Parameters: redirect - True if it should redirect. |
DynamicURI | public DynamicURI(ServerData sd)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: sd - A ServerData. |
DynamicURI | public DynamicURI(ServerData sd, String screen)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: sd - A ServerData. Parameters: screen - A String with the name of a screen. |
DynamicURI | public DynamicURI(ServerData sd, String screen, String action)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: sd - A ServerData. Parameters: screen - A String with the name of a screen. Parameters: action - A String with the name of an action. |
DynamicURI | public DynamicURI(ServerData sd, String screen, String action, boolean redirect)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: sd - A ServerData. Parameters: screen - A String with the name of a screen. Parameters: action - A String with the name of an action. Parameters: redirect - True if it should redirect. |
DynamicURI | public DynamicURI(ServerData serverData, String screen, boolean redirect)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: serverData - A ServerData. Parameters: screen - A String with the name of a screen. Parameters: redirect - True if it should redirect. |
DynamicURI | public DynamicURI(ServerData serverData, boolean redirect)(Code) | | Main constructor for DynamicURI. Uses ServerData.
Parameters: serverData - A ServerData. Parameters: redirect - True if it should redirect. |
add | protected void add(int type, String name, String value)(Code) | | If the type is
DynamicURI.PATH_INFO , then add name/value to the
pathInfo.
If the type is
DynamicURI.QUERY_DATA , then add name/value to the
queryData.
Parameters: type - Type of insertion. Parameters: name - A String with the name to add. Parameters: value - A String with the value to add. |
add | protected void add(int type, ParameterParser pp)(Code) | | Method for a quick way to add all the parameters in a
ParameterParser.
If the type is
DynamicURI.PATH_INFO , then add name/value to the
pathInfo.
If the type is
DynamicURI.QUERY_DATA , then add name/value to the
queryData.
Parameters: type - Type of insertion. Parameters: pp - A ParameterParser. |
addPathInfo | public DynamicURI addPathInfo(String name, Object value)(Code) | | Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - An Object with the value to add. A DynamicURI (self). |
addPathInfo | public DynamicURI addPathInfo(String name, String value)(Code) | | Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A String with the value to add. A DynamicURI (self). |
addPathInfo | public DynamicURI addPathInfo(String name, double value)(Code) | | Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A double with the value to add. A DynamicURI (self). |
addPathInfo | public DynamicURI addPathInfo(String name, int value)(Code) | | Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - An int with the value to add. A DynamicURI (self). |
addPathInfo | public DynamicURI addPathInfo(String name, long value)(Code) | | Adds a name=value pair to the path_info string.
Parameters: name - A String with the name to add. Parameters: value - A long with the value to add. A DynamicURI (self). |
addPathInfo | public DynamicURI addPathInfo(ParameterParser pp)(Code) | | Adds a name=value pair for every entry in a ParameterParser
object to the path_info string.
Parameters: pp - A ParameterParser. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(String name, Object value)(Code) | | Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - An Object with the value to add. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(String name, String value)(Code) | | Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A String with the value to add. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(String name, double value)(Code) | | Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A double with the value to add. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(String name, int value)(Code) | | Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - An int with the value to add. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(String name, long value)(Code) | | Adds a name=value pair to the query string.
Parameters: name - A String with the name to add. Parameters: value - A long with the value to add. A DynamicURI (self). |
addQueryData | public DynamicURI addQueryData(ParameterParser pp)(Code) | | Adds a name=value pair for every entry in a ParameterParser
object to the query string.
Parameters: pp - A ParameterParser. A DynamicURI (self). |
assertInitialized | protected void assertInitialized()(Code) | | Verifies that one of the init() methods has been called
|
getA | public String getA(String name)(Code) | | 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&user=jon">Click Here</A>
Parameters: name - A String with the name for the anchor. The anchor as a <A HREF="">name</A>. |
getContextPath | public String getContextPath()(Code) | | Gets the context path
A String with the servlet context path |
getReference | public String getReference()(Code) | | Gets the reference (#ref).
A String containing the reference. |
getScriptName | public String getScriptName()(Code) | | Gets the script name (/servlets/Turbine).
A String with the script name. |
getServerData | public ServerData getServerData()(Code) | | Returns the ServerData used to initialize this DynamicURI.
A ServerData used to initialize this DynamicURI. |
getServerName | public String getServerName()(Code) | | Gets the server name.
A String with the server name. |
getServerPort | public int getServerPort()(Code) | | Gets the server port.
A String with the server port. |
getServerScheme | public String getServerScheme()(Code) | | Gets the server scheme (HTTP or HTTPS).
A String with the server scheme. |
init | public void init(RunData data)(Code) | | Initialize with a RunData object
Parameters: data - RunData instance |
init | public void init(ServerData serverData)(Code) | | Initialize with a ServerData object.
Parameters: serverData - |
remove | protected void remove(int type, String name)(Code) | | If the type is
DynamicURI.PATH_INFO , then remove name/value from the
pathInfo.
If the type is
DynamicURI.QUERY_DATA , then remove name/value from the
queryData.
Parameters: type - Type of removal. Parameters: name - A String with the name to be removed. |
removePathInfo | public void removePathInfo()(Code) | | Removes all the path info elements.
|
removePathInfo | public void removePathInfo(String name)(Code) | | Removes a name=value pair from the path info.
Parameters: name - A String with the name to be removed. |
removeQueryData | public void removeQueryData()(Code) | | Removes all the query string elements.
|
removeQueryData | public void removeQueryData(String name)(Code) | | Removes a name=value pair from the query string.
Parameters: name - A String with the name to be removed. |
renderPathInfo | protected String renderPathInfo(List data)(Code) | | 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. A String with the URL encoded data. |
renderQueryString | protected String renderQueryString(List data)(Code) | | 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. A String with the URL encoded data. |
setAction | public DynamicURI setAction(String action)(Code) | | 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. A DynamicURI (self). |
setActionEvent | public DynamicURI setActionEvent(String actionName, String eventName)(Code) | | 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 Parameters: eventName - name of the event. A DynamicURI (self). |
setContextPath | public DynamicURI setContextPath(String contextPath)(Code) | | Sets the context path
Parameters: contextPath - A String with the servlet context path A DynamicURI (self). |
setReference | public DynamicURI setReference(String reference)(Code) | | Sets the reference (#ref).
Parameters: reference - A String containing the reference. A DynamicURI (self). |
setScreen | public DynamicURI setScreen(String screen)(Code) | | 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. A DynamicURI (self). |
setScriptName | public DynamicURI setScriptName(String name)(Code) | | Sets the script name (/servlets/Turbine).
Parameters: name - A String with the script name. A DynamicURI (self). |
setSecure | public DynamicURI setSecure()(Code) | | Method to specify that a URI should use SSL. Whether or not it
does is determined from TurbineResources.properties. Port
number is 443.
A DynamicURI (self). |
setSecure | public DynamicURI setSecure(int port)(Code) | | 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. A DynamicURI (self). |
setServerData | public void setServerData(ServerData serverData)(Code) | | Sets the ServerData used to initialize this DynamicURI.
Parameters: serverData - A ServerData used to initialize this DynamicURI. |
setServerName | public DynamicURI setServerName(String name)(Code) | | Sets the server name.
Parameters: name - A String with the server name. A DynamicURI (self). |
setServerPort | public DynamicURI setServerPort(int port)(Code) | | Sets the server port.
Parameters: port - An int with the port. A DynamicURI (self). |
setServerScheme | public DynamicURI setServerScheme(String scheme)(Code) | | Sets the scheme (HTTP or HTTPS).
Parameters: scheme - A String with the scheme. A DynamicURI (self). |
toString | public String toString()(Code) | | 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
A String with the built URL. |
toString | public static String toString(RunData data)(Code) | | 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. A String with the URL representing the RunData. |
|
|