|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.util.DynamicURI
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.
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>
DynamicURI dui = new DynamicURI (data, "UserScreen" );
dui.setName("Click Here").addPathInfo("user","jon");
dui.getA();
Field Summary | |
protected RunData |
data
The RunData object. |
protected boolean |
hasPathInfo
Fast shortcut to determine if there is any data in the path info. |
protected boolean |
hasQueryData
Fast shortcut to determine if there is any data in the query data. |
static java.lang.String |
HTTP
HTTP protocol. |
static java.lang.String |
HTTPS
HTTPS protocol. |
protected static int |
PATH_INFO
P = 0 for path info. |
protected java.util.Vector |
pathInfo
A Vector that contains all the path info if any. |
protected static int |
QUERY_DATA
Q = 1 for query data. |
protected java.util.Vector |
queryData
A Vectory that contains all the query data if any. |
protected boolean |
redirect
Whether we want to redirect or not. |
javax.servlet.http.HttpServletResponse |
res
Servlet response interface. |
protected java.lang.String |
scriptName
/foo/Turbine. |
protected ServerData |
sd
The ServerData object. |
protected java.lang.String |
serverName
ie: www.foo.com. |
protected int |
serverPort
ie: 80 or 443. |
protected java.lang.String |
serverScheme
ie: http or https. |
Constructor Summary | |
DynamicURI()
Default constructor - one of the init methods must be called before use. |
|
DynamicURI(RunData data)
Constructor sets up some variables. |
|
DynamicURI(RunData data,
boolean redirect)
Constructor sets up some variables. |
|
DynamicURI(RunData data,
java.lang.String screen)
Constructor sets up some variables. |
|
DynamicURI(RunData data,
java.lang.String screen,
boolean redirect)
Constructor sets up some variables. |
|
DynamicURI(RunData data,
java.lang.String screen,
java.lang.String action)
Constructor sets up some variables. |
|
DynamicURI(RunData data,
java.lang.String screen,
java.lang.String action,
boolean redirect)
Constructor sets up some variables. |
|
DynamicURI(ServerData sd)
Main constructor for DynamicURI. |
|
DynamicURI(ServerData sd,
boolean redirect)
Main constructor for DynamicURI. |
|
DynamicURI(ServerData sd,
java.lang.String screen)
Main constructor for DynamicURI. |
|
DynamicURI(ServerData sd,
java.lang.String screen,
boolean redirect)
Main constructor for DynamicURI. |
|
DynamicURI(ServerData sd,
java.lang.String screen,
java.lang.String action)
Main constructor for DynamicURI. |
|
DynamicURI(ServerData sd,
java.lang.String screen,
java.lang.String action,
boolean redirect)
Main constructor for DynamicURI. |
Method Summary | |
protected void |
add(int type,
ParameterParser pp)
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)
If the type is P (0), then add name/value to the pathInfo hashtable. |
DynamicURI |
addPathInfo(ParameterParser pp)
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)
Adds a name=value pair to the path_info string. |
DynamicURI |
addPathInfo(java.lang.String name,
int value)
Adds a name=value pair to the path_info string. |
DynamicURI |
addPathInfo(java.lang.String name,
long value)
Adds a name=value pair to the path_info string. |
DynamicURI |
addPathInfo(java.lang.String name,
java.lang.Object value)
Adds a name=value pair to the path_info string. |
DynamicURI |
addPathInfo(java.lang.String name,
java.lang.String value)
Adds a name=value pair to the path_info string. |
DynamicURI |
addQueryData(ParameterParser pp)
Adds a name=value pair for every entry in a ParameterParser object to the query string. |
DynamicURI |
addQueryData(java.lang.String name,
double value)
Adds a name=value pair to the query string. |
DynamicURI |
addQueryData(java.lang.String name,
int value)
Adds a name=value pair to the query string. |
DynamicURI |
addQueryData(java.lang.String name,
long value)
Adds a name=value pair to the query string. |
DynamicURI |
addQueryData(java.lang.String name,
java.lang.Object value)
Adds a name=value pair to the query string. |
DynamicURI |
addQueryData(java.lang.String name,
java.lang.String value)
Adds a name=value pair to the query string. |
java.lang.String |
getA(java.lang.String name)
Create an anchor object. |
java.lang.String |
getScriptName()
Gets the script name (/servlets/Turbine). |
ServerData |
getServerData()
Returns the ServerData used to initialize this DynamicURI. |
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). |
protected void |
init()
Initializes some common variables. |
void |
init(RunData data)
Initialize with a RunData object |
void |
init(ServerData sd)
Initialize with a ServerData object. |
protected void |
remove(int type,
java.lang.String name)
If the type is P (0), then remove name/value from the pathInfo hashtable. |
void |
removePathInfo()
Removes all the path info elements. |
void |
removePathInfo(java.lang.String name)
Removes a name=value pair from the path info. |
void |
removeQueryData()
Removes all the query string elements. |
void |
removeQueryData(java.lang.String name)
Removes a name=value pair from the query string. |
protected java.lang.String |
renderPathInfo(java.util.Vector data)
This method takes a Vector of key/value arrays and converts it into a URL encoded querystring format. |
protected java.lang.String |
renderQueryString(java.util.Vector data)
This method takes a Vector of key/value arrays and converts it into a URL encoded querystring format. |
DynamicURI |
setAction(java.lang.String action)
Sets the action= value for this URL. |
DynamicURI |
setScreen(java.lang.String screen)
Sets the screen= value for this URL. |
DynamicURI |
setScriptName(java.lang.String name)
Sets the script name (/servlets/Turbine). |
DynamicURI |
setSecure()
Method to specify that a URI should use SSL. |
DynamicURI |
setSecure(int port)
Method to specify that a URI should use SSL. |
void |
setServerData(ServerData sd)
Sets the ServerData used to initialize this DynamicURI. |
DynamicURI |
setServerName(java.lang.String name)
Sets the server name. |
DynamicURI |
setServerPort(int port)
Sets the server port. |
DynamicURI |
setServerScheme(java.lang.String scheme)
Sets the scheme (HTTP or HTTPS). |
java.lang.String |
toString()
Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl(). |
static java.lang.String |
toString(RunData data)
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 |
public static final java.lang.String HTTP
public static final java.lang.String HTTPS
protected ServerData sd
protected RunData data
protected java.lang.String serverScheme
protected java.lang.String serverName
protected int serverPort
protected java.lang.String scriptName
public javax.servlet.http.HttpServletResponse res
protected java.util.Vector pathInfo
protected java.util.Vector queryData
protected boolean hasPathInfo
protected boolean hasQueryData
protected boolean redirect
protected static final int PATH_INFO
protected static final int QUERY_DATA
Constructor Detail |
public DynamicURI(RunData data)
data
- A Turbine RunData object.public DynamicURI()
public DynamicURI(RunData data, java.lang.String screen)
data
- A Turbine RunData object.screen
- A String with the name of a screen.public DynamicURI(RunData data, java.lang.String screen, java.lang.String action)
data
- A Turbine RunData object.screen
- A String with the name of a screen.action
- A String with the name of an action.public DynamicURI(RunData data, java.lang.String screen, java.lang.String action, boolean redirect)
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.public DynamicURI(RunData data, java.lang.String screen, boolean redirect)
data
- A Turbine RunData object.screen
- A String with the name of a screen.redirect
- True if it should redirect.public DynamicURI(RunData data, boolean redirect)
data
- A Turbine RunData object.redirect
- True if it should redirect.public DynamicURI(ServerData sd)
sd
- A ServerData.public DynamicURI(ServerData sd, java.lang.String screen)
sd
- A ServerData.screen
- A String with the name of a screen.public DynamicURI(ServerData sd, java.lang.String screen, java.lang.String action)
sd
- A ServerData.screen
- A String with the name of a screen.action
- A String with the name of an action.public DynamicURI(ServerData sd, java.lang.String screen, java.lang.String action, boolean redirect)
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.public DynamicURI(ServerData sd, java.lang.String screen, boolean redirect)
sd
- A ServerData.screen
- A String with the name of a screen.redirect
- True if it should redirect.public DynamicURI(ServerData sd, boolean redirect)
sd
- A ServerData.redirect
- True if it should redirect.Method Detail |
public void init(RunData data)
RunData
- public void init(ServerData sd)
ServerData
- protected void add(int type, java.lang.String name, java.lang.String value)
If the type is P (0), then add name/value to the pathInfo hashtable.
If the type is Q (1), then add name/value to the queryData hashtable.
type
- Type (P or Q) of insertion.name
- A String with the name to add.value
- A String with the value to add.protected void add(int type, ParameterParser pp)
If the type is P (0), then add name/value to the pathInfo hashtable.
If the type is Q (1), then add name/value to the queryData hashtable.
type
- Type (P or Q) of insertion.pp
- A ParameterParser.public DynamicURI addPathInfo(java.lang.String name, java.lang.Object value)
name
- A String with the name to add.value
- An Object with the value to add.public DynamicURI addPathInfo(java.lang.String name, java.lang.String value)
name
- A String with the name to add.value
- A String with the value to add.public DynamicURI addPathInfo(java.lang.String name, double value)
name
- A String with the name to add.value
- A double with the value to add.public DynamicURI addPathInfo(java.lang.String name, int value)
name
- A String with the name to add.value
- An int with the value to add.public DynamicURI addPathInfo(java.lang.String name, long value)
name
- A String with the name to add.value
- A long with the value to add.public DynamicURI addPathInfo(ParameterParser pp)
pp
- A ParameterParser.public DynamicURI addQueryData(java.lang.String name, java.lang.Object value)
name
- A String with the name to add.value
- An Object with the value to add.public DynamicURI addQueryData(java.lang.String name, java.lang.String value)
name
- A String with the name to add.value
- A String with the value to add.public DynamicURI addQueryData(java.lang.String name, double value)
name
- A String with the name to add.value
- A double with the value to add.public DynamicURI addQueryData(java.lang.String name, int value)
name
- A String with the name to add.value
- An int with the value to add.public DynamicURI addQueryData(java.lang.String name, long value)
name
- A String with the name to add.value
- A long with the value to add.public DynamicURI addQueryData(ParameterParser pp)
pp
- A ParameterParser.public java.lang.String getA(java.lang.String name)
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>
name
- A String with the name for the anchor.public java.lang.String getScriptName()
public java.lang.String getServerName()
public int getServerPort()
public java.lang.String getServerScheme()
protected void init()
protected void remove(int type, java.lang.String name)
If the type is P (0), then remove name/value from the pathInfo hashtable.
If the type is Q (1), then remove name/value from the queryData hashtable.
type
- Type (P or Q) of removal.name
- A String with the name to be removed.public void removePathInfo()
public void removePathInfo(java.lang.String name)
name
- A String with the name to be removed.public void removeQueryData()
public void removeQueryData(java.lang.String name)
name
- A String with the name to be removed.protected java.lang.String renderPathInfo(java.util.Vector data)
data
- A Vector of key/value arrays.protected java.lang.String renderQueryString(java.util.Vector data)
data
- A Vector of key/value arrays.public DynamicURI setAction(java.lang.String action)
By default it adds the information to the path_info instead of the query data.
action
- A String with the action value.public DynamicURI setScreen(java.lang.String screen)
By default it adds the information to the path_info instead of the query data.
action
- A String with the screen value.public DynamicURI setScriptName(java.lang.String name)
name
- A String with the script name.public DynamicURI setServerName(java.lang.String name)
name
- A String with the server name.public DynamicURI setServerPort(int port)
port
- An int with the port.public DynamicURI setSecure()
public DynamicURI setSecure(int port)
port
- An int with the port number.public DynamicURI setServerScheme(java.lang.String scheme)
scheme
- A String with the scheme.public java.lang.String toString()
The above call to toString() would return the String:
DynamicURI dui = new DynamicURI (data, "UserScreen" );
dui.addPathInfo("user","jon");
dui.toString();
http://www.server.com/servlets/Turbine/screen/UserScreen/user/jon
toString
in class java.lang.Object
public static java.lang.String toString(RunData data)
data
- A Turbine RunData object.public ServerData getServerData()
public void setServerData(ServerData sd)
sd
- A ServerData used to initialize this DynamicURI.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |