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: BaseURI.java 1709648 2015-10-20 17:08:10Z 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

    Constructors
    Constructor and Description
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `encodeResponse(String uri)` Encodes a Response Uri according to the Servlet Container.
    `protected void` | `getContextAndScript(StringBuilder sb)` Append the Context Path and Script Name to the passed String Buffer.
    `String` | `getContextPath()` Gets the context path.
    `String` | `getReference()` Returns the current reference anchor.
    `protected javax.servlet.http.HttpServletResponse` | `getResponse()` Returns the Response Object from the Servlet Container.
    `protected void` | `getSchemeAndPort(StringBuilder sb)` Appends Scheme, Server and optionally the port to the supplied String Buffer.
    `String` | `getScriptName()` Gets the script name (/servlets/Turbine).
    `String` | `getServerName()` Gets the server name.
    `int` | `getServerPort()` Gets the server port.
    `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(String contextPath)` Sets the context path.
    `void` | `setRedirect(boolean redirect)` Set the redirect Flag
    `void` | `setReference(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(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(String serverName)` Sets the server name.
    `void` | `setServerPort(int serverPort)` Sets the server port.
    `void` | `setServerScheme(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 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(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:
        `getContextPath` in interface `URI`
      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:
        `getServerName` in interface `URI`
      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:
        `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(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:
        `getServerScheme` in interface `URI`
      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:
        `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(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.

Copyright © 2000–2018 The Apache Software Foundation. All rights reserved.