Class DataURI

  • All Implemented Interfaces:
    URI, URIConstants

    public class DataURI
    extends BaseURI
    This class can convert a simple link into a turbine relative URL. It should be used to convert references for images, style sheets and similar references. The resulting links have no query data or path info. If you need this, use TurbineURI or TemplateURI.
    Version:
    $Id$
    Author:
    Henning P. Schmiedehausen
    • Constructor Detail

      • DataURI

        public DataURI()
        Empty C'tor. Uses Turbine.getDefaultServerData().
      • DataURI

        public DataURI​(RunData runData)
        Constructor with a RunData object
        Parameters:
        runData - A RunData object
      • DataURI

        public DataURI​(RunData runData,
                       boolean redirect)
        Constructor, set explicit redirection
        Parameters:
        runData - A RunData object
        redirect - True if redirection allowed.
      • DataURI

        public DataURI​(ServerData serverData)
        Constructor with a ServerData object
        Parameters:
        serverData - A ServerData object
      • DataURI

        public DataURI​(ServerData serverData,
                       boolean redirect)
        Constructor, set explicit redirection
        Parameters:
        serverData - A ServerData object
        redirect - True if redirection allowed.
    • Method Detail

      • clearResponse

        public void clearResponse()
        Content Tool wants to be able to turn the encoding of the servlet container off. After calling this method, the encoding will not happen any longer.
      • getAbsoluteLink

        public String getAbsoluteLink()
        Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl(). The resulting URL is absolute; it starts with http/https...
         TurbineURI tui = new TurbineURI (data, "UserScreen");
         tui.addPathInfo("user","jon");
         tui.getAbsoluteLink();
         
        The above call to getAbsoluteLink() would return the String:

        http://www.server.com/servlets/Turbine/screen/UserScreen/user/jon

        Returns:
        A String with the built URL.
      • getRelativeLink

        public String getRelativeLink()
        Builds the URL with all of the data URL-encoded as well as encoded using HttpServletResponse.encodeUrl(). The resulting URL is relative to the webserver root.
         TurbineURI tui = new TurbineURI (data, "UserScreen");
         tui.addPathInfo("user","jon");
         tui.getRelativeLink();
         
        The above call to getRelativeLink() would return the String:

        /servlets/Turbine/screen/UserScreen/user/jon

        Returns:
        A String with the built URL.
      • toString

        public String toString()
        toString() simply calls getAbsoluteLink. You should not use this in your code unless you have to. Use getAbsoluteLink.
        Overrides:
        toString in class Object
        Returns:
        This URI as a String