Package org.apache.turbine.util.uri
Class BaseURI
- java.lang.Object
-
- org.apache.turbine.util.uri.BaseURI
-
- All Implemented Interfaces:
URI,URIConstants
- Direct Known Subclasses:
DataURI,TurbineURI
public abstract class BaseURI extends Object implements URI, URIConstants
This is the base class for all dynamic URIs in the Turbine System. All of the classes used for generating URIs are derived from this.- Version:
- $Id$
- Author:
- Jon S. Stevens, Jason van Zyl, Henning P. Schmiedehausen, Quinton McCombs
-
-
Field Summary
-
Fields inherited from interface org.apache.turbine.util.uri.URIConstants
CGI_ACTION_PARAM, CGI_SCREEN_PARAM, CGI_TEMPLATE_PARAM, EVENT_PREFIX, FTP_PORT, HTTP, HTTP_PORT, HTTPS, HTTPS_PORT, PATH_INFO, QUERY_DATA, URI_SCHEME_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description BaseURI()Empty C'tor.BaseURI(RunData runData)Constructor with a RunData objectBaseURI(RunData runData, boolean redirect)Constructor, set explicit redirectionBaseURI(ServerData serverData)Constructor with a ServerData objectBaseURI(ServerData serverData, boolean redirect)Constructor, set explicit redirection
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringencodeResponse(String uri)Encodes a Response Uri according to the Servlet Container.protected voidgetContextAndScript(StringBuilder sb)Append the Context Path and Script Name to the passed String Buffer.StringgetContextPath()Gets the context path.StringgetReference()Returns the current reference anchor.protected HttpServletResponsegetResponse()Returns the Response Object from the Servlet Container.protected voidgetSchemeAndPort(StringBuilder sb)Appends Scheme, Server and optionally the port to the supplied String Buffer.StringgetScriptName()Gets the script name (/servlets/Turbine).StringgetServerName()Gets the server name.intgetServerPort()Gets the server port.StringgetServerScheme()Returns the current Server SchemebooleanhasReference()Does this URI contain an anchor? (#ref)booleanisRedirect()Returns the current value of the Redirect flagvoidsetContextPath(String contextPath)Sets the context path.voidsetRedirect(boolean redirect)Set the redirect FlagvoidsetReference(String reference)Sets a reference anchor (#ref).protected voidsetResponse(HttpServletResponse response)Set a Response Object to use when creating the response string.voidsetScriptName(String scriptName)Sets the script name (/servlets/Turbine).voidsetSecure()Method to specify that a URI should use SSL.voidsetSecure(int port)Method to specify that a URI should use SSL.voidsetServerName(String serverName)Sets the server name.voidsetServerPort(int serverPort)Sets the server port.voidsetServerScheme(String serverScheme)Sets the scheme (HTTP or HTTPS).
-
-
-
Constructor Detail
-
BaseURI
public BaseURI()
Empty C'tor. Uses Turbine.getDefaultServerData().
-
BaseURI
public BaseURI(RunData runData)
Constructor with a RunData object- Parameters:
runData- A RunData object
-
BaseURI
public BaseURI(RunData runData, boolean redirect)
Constructor, set explicit redirection- Parameters:
runData- A RunData objectredirect- True if redirection allowed.
-
BaseURI
public BaseURI(ServerData serverData)
Constructor with a ServerData object- Parameters:
serverData- A ServerData object
-
BaseURI
public BaseURI(ServerData serverData, boolean redirect)
Constructor, set explicit redirection- Parameters:
serverData- A ServerData objectredirect- True if redirection allowed.
-
-
Method Detail
-
setRedirect
public void setRedirect(boolean redirect)
Set the redirect Flag- Parameters:
redirect- The new value of the redirect flag.
-
isRedirect
public boolean isRedirect()
Returns the current value of the Redirect flag- Returns:
- True if Redirect is allowed
-
getScriptName
public String getScriptName()
Gets the script name (/servlets/Turbine).- Specified by:
getScriptNamein interfaceURI- Returns:
- A String with the script name.
-
setScriptName
public void setScriptName(String scriptName)
Sets the script name (/servlets/Turbine).- Parameters:
scriptName- A String with the script name.
-
getContextPath
public String getContextPath()
Gets the context path.- Specified by:
getContextPathin interfaceURI- Returns:
- A String with the context path.
-
setContextPath
public void setContextPath(String contextPath)
Sets the context path.- Parameters:
contextPath- A String with the context path
-
getServerName
public String getServerName()
Gets the server name.- Specified by:
getServerNamein interfaceURI- Returns:
- A String with the server name.
-
setServerName
public void setServerName(String serverName)
Sets the server name.- Parameters:
serverName- A String with the server name.
-
getServerPort
public int getServerPort()
Gets the server port.- Specified by:
getServerPortin interfaceURI- Returns:
- A String with the server port.
-
setServerPort
public void setServerPort(int serverPort)
Sets the server port.- Parameters:
serverPort- An int with the port.
-
setSecure
public void setSecure()
Method to specify that a URI should use SSL. The default port is used.
-
setSecure
public void setSecure(int port)
Method to specify that a URI should use SSL. Whether or not it does is determined from Turbine.properties. If use.ssl in the Turbine.properties is set to false, then http is used in any case. (Default of use.ssl is true).- Parameters:
port- An int with the port number.
-
setServerScheme
public void setServerScheme(String serverScheme)
Sets the scheme (HTTP or HTTPS).- Parameters:
serverScheme- A String with the scheme.
-
getServerScheme
public String getServerScheme()
Returns the current Server Scheme- Specified by:
getServerSchemein interfaceURI- Returns:
- The current Server scheme
-
setReference
public void setReference(String reference)
Sets a reference anchor (#ref).- Parameters:
reference- A String containing the reference.
-
getReference
public String getReference()
Returns the current reference anchor.- Specified by:
getReferencein interfaceURI- Returns:
- A String containing the reference.
-
hasReference
public boolean hasReference()
Does this URI contain an anchor? (#ref)- Returns:
- True if this URI contains an anchor.
-
setResponse
protected void setResponse(HttpServletResponse response)
Set a Response Object to use when creating the response string.- Parameters:
response- the servlet response
-
getResponse
protected HttpServletResponse getResponse()
Returns the Response Object from the Servlet Container.- Returns:
- The Servlet Response object or null
-
getContextAndScript
protected void getContextAndScript(StringBuilder sb)
Append the Context Path and Script Name to the passed String Buffer.This is a convenience method to be used in the Link output routines of derived classes to easily append the correct path.
- Parameters:
sb- The StringBuilder to store context path and script name.
-
getSchemeAndPort
protected void getSchemeAndPort(StringBuilder sb)
Appends Scheme, Server and optionally the port to the supplied String Buffer.This is a convenience method to be used in the Link output routines of derived classes to easily append the correct server scheme.
- Parameters:
sb- The StringBuilder to store the scheme and port information.
-
encodeResponse
protected String encodeResponse(String uri)
Encodes a Response Uri according to the Servlet Container. This might add a Java session identifier or do redirection. The resulting String can be used in a page or template.- Parameters:
uri- The Uri to encode- Returns:
- An Uri encoded by the container.
-
-