org.apache.turbine.util.uri
Class BaseURI

java.lang.Object
  extended byorg.apache.turbine.util.uri.BaseURI
All Implemented Interfaces:
URI, URIConstants
Direct Known Subclasses:
DataURI, TurbineURI

public abstract class BaseURI
extends java.lang.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: BaseURI.java 534527 2007-05-02 16:10:59Z tv $
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
BaseURI()
          Empty C'tor.
BaseURI(RunData runData)
          Constructor with a RunData object
BaseURI(RunData runData, boolean redirect)
          Constructor, set explicit redirection
BaseURI(ServerData serverData)
          Constructor with a ServerData object
BaseURI(ServerData serverData, boolean redirect)
          Constructor, set explicit redirection
 
Method Summary
protected  java.lang.String encodeResponse(java.lang.String uri)
          Encodes a Response Uri according to the Servlet Container.
protected  void getContextAndScript(java.lang.StringBuffer sb)
          Append the Context Path and Script Name to the passed String Buffer.
 java.lang.String getContextPath()
          Gets the context path.
 java.lang.String getReference()
          Returns the current reference anchor.
protected  javax.servlet.http.HttpServletResponse getResponse()
          Returns the Response Object from the Servlet Container.
protected  void getSchemeAndPort(java.lang.StringBuffer sb)
          Appends Scheme, Server and optionally the port to the supplied String Buffer.
 java.lang.String getScriptName()
          Gets the script name (/servlets/Turbine).
 java.lang.String getServerName()
          Gets the server name.
 int getServerPort()
          Gets the server port.
 java.lang.String getServerScheme()
          Returns the current Server Scheme
 boolean hasReference()
          Does this URI contain an anchor?
 boolean isRedirect()
          Returns the current value of the Redirect flag
 void setContextPath(java.lang.String contextPath)
          Sets the context path.
 void setRedirect(boolean redirect)
          Set the redirect Flag
 void setReference(java.lang.String reference)
          Sets a reference anchor (#ref).
protected  void setResponse(javax.servlet.http.HttpServletResponse response)
          Set a Response Object to use when creating the response string.
 void setScriptName(java.lang.String scriptName)
          Sets the script name (/servlets/Turbine).
 void setSecure()
          Method to specify that a URI should use SSL.
 void setSecure(int port)
          Method to specify that a URI should use SSL.
 void setServerName(java.lang.String serverName)
          Sets the server name.
 void setServerPort(int serverPort)
          Sets the server port.
 void setServerScheme(java.lang.String serverScheme)
          Sets the scheme (HTTP or HTTPS).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 object
redirect - 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 object
redirect - 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 java.lang.String getScriptName()
Gets the script name (/servlets/Turbine).

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

setScriptName

public void setScriptName(java.lang.String scriptName)
Sets the script name (/servlets/Turbine).

Parameters:
scriptName - A String with the script name.

getContextPath

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

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

setContextPath

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

Parameters:
contextPath - A String with the context path

getServerName

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

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

setServerName

public void setServerName(java.lang.String serverName)
Sets the server name.

Parameters:
serverName - A String with the server name.

getServerPort

public int getServerPort()
Gets the server port.

Specified by:
getServerPort in interface URI
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(java.lang.String serverScheme)
Sets the scheme (HTTP or HTTPS).

Parameters:
serverScheme - A String with the scheme.

getServerScheme

public java.lang.String getServerScheme()
Returns the current Server Scheme

Specified by:
getServerScheme in interface URI
Returns:
The current Server scheme

setReference

public void setReference(java.lang.String reference)
Sets a reference anchor (#ref).

Parameters:
reference - A String containing the reference.

getReference

public java.lang.String getReference()
Returns the current reference anchor.

Specified by:
getReference in interface URI
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(javax.servlet.http.HttpServletResponse response)
Set a Response Object to use when creating the response string.


getResponse

protected javax.servlet.http.HttpServletResponse getResponse()
Returns the Response Object from the Servlet Container.

Returns:
The Servlet Response object or null

getContextAndScript

protected void getContextAndScript(java.lang.StringBuffer 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 StringBuffer to store context path and script name.

getSchemeAndPort

protected void getSchemeAndPort(java.lang.StringBuffer 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 StringBuffer to store the scheme and port information.

encodeResponse

protected java.lang.String encodeResponse(java.lang.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.


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