Class URL


  • @Scriptable
    public final class URL
    extends Object
    • Method Detail

      • cloneUrl

        public URL cloneUrl()
      • putParam

        public void putParam​(String p_strParam,
                             Object p_value)
        Set a querystring parameter.

        Parameters that start with rq_ will be hex-encoded unless they are in the list of unencoded querystring parameters. All other parameters are not hex-encoded.

        Parameters:
        p_strParam - The name of the querystring parameter.
        p_value - The value of the querystring parameter.
      • putParamUnencoded

        @Deprecated
        public void putParamUnencoded​(String p_strParam,
                                      Object p_value)
        Deprecated.
        The method putParamUnencoded is error-prone and thus not supported anymore. User putParam instead.
        Throws:
        UnsupportedOperationException - Always.
      • getParam

        public Object getParam​(String p_strParam)
        Get a querystring parameter.
        Parameters:
        p_strParam - The name of the querystring parameter.
        Returns:
        The value of the given querystring parameter, or null if it does not exist.
      • getParams

        public Map<String,​Object> getParams()
        Get all query parameters.
        Returns:
        The query parameters.
      • hasParam

        public boolean hasParam​(String p_strParam)
        Test if the URL has the specified querystring parameter.
        Parameters:
        p_strParam - The querystring parameter.
        Returns:
        true if the URL has the specified, querystring parameter, or false otherwise.
      • removeParam

        public boolean removeParam​(String p_strParam)
        Remove the specified querystring parameter.
        Parameters:
        p_strParam - The The querystring parameter.
        Returns:
        true if the specified querystring parameter was was removed, or false if the URL did not contain the specified querystring parameter.
      • setParams

        public void setParams​(Map<String,​String> p_params)
        Set the querystring parameters that are contained in the given map.
        Parameters:
        p_params - The querystring parameters to set.
      • clearParams

        public void clearParams()
        Remove all querystring parameters.
      • hasFragment

        public boolean hasFragment()
        Determine if this URL has a fragment.
        Returns:
        true if the URL has a fragment, or false otherwise.
      • getFragment

        public String getFragment()
        Get the URL's fragment.
        Returns:
        The URL's fragment, not including the leading sharp sign, or null if the URL has no fragment.
      • setFragment

        public void setFragment​(String p_strFragment)
        Set the URL#s fragment.
        Parameters:
        p_strFragment - The URL#s fragment.
      • removeFragment

        public void removeFragment()
        Remove the URL's fragment.
      • writeTo

        public void writeTo​(Writer p_out)
                     throws IOException
        Write the URL to the specified java.io.Writer, e.g. $Response.
        Parameters:
        p_out - The output stream.
        Throws:
        IOException - If an I/O error occurred or the character encoding could not be determined.
      • writeEntityEncodedTo

        public void writeEntityEncodedTo​(Writer p_out)
                                  throws IOException
        Write the URL to the specified java.io.Writer, e.g. $Response.
        Parameters:
        p_out - The output stream.
        Throws:
        IOException - If an I/O error occurred or the character encoding could not be determined.
      • asString

        public String asString()
        Convert this URL in its string representation.
        Returns:
        The URL as a string.
      • asUrlEncodedString

        public String asUrlEncodedString()
        Encode this URL into application/x-www-form-urlencoded format using UTF-8 for the unsafe characters.
        Returns:
        The URL-encoded string.
      • asUrlEncodedString

        public String asUrlEncodedString​(String p_strCharset)
                                  throws UnsupportedEncodingException
        Encode this URL into application/x-www-form-urlencoded format using the given characted set.

        Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

        Parameters:
        p_strCharset - The character set to be used for encoding.
        Returns:
        The URL-encoded string.
        Throws:
        UnsupportedEncodingException - If the given charset is not supported.
      • asEntityEncodedString

        public String asEntityEncodedString()
      • asParamsEncodedString

        public String asParamsEncodedString()