Class URL

java.lang.Object
de.uplanet.lucy.server.util.URL

@Scriptable public final class URL extends Object
  • Constructor Details

  • Method Details

    • cloneUrl

      public URL cloneUrl()
    • hasScheme

      public boolean hasScheme()
      Check if this URL has a scheme.
      Returns:
      true if this URL has a scheme, or false otherwise.
    • getScheme

      public String getScheme()
      Get the scheme.
      Returns:
      The scheme.
    • setScheme

      public void setScheme(String p_strScheme)
      Set the scheme, e.g. https.
      Parameters:
      p_strScheme - The scheme.
      Throws:
      IllegalArgumentException - If the given scheme is null, or does not conform to the syntax specified in RFC 3986, 3.1.
      See Also:
    • removeScheme

      public void removeScheme()
      Remove the scheme from this URL.

      This can be usefull to create schema-less URLs.

    • hasAuthority

      public boolean hasAuthority()
      Check if this URL has an authority.
      Returns:
      true if this URL has an authority, or false otherwise.
    • getAuthority

      public String getAuthority()
      Get the authority.
      Returns:
      The authority.
    • setAuthority

      public void setAuthority(String p_strAuthority)
      Set the authority.
      Parameters:
      p_strAuthority - The authority.
      Throws:
      IllegalArgumentException - If the given authority is null.
      See Also:
    • hasPath

      public boolean hasPath()
      Check if this URL has a path component.
      Returns:
      true if this URL has a path component, or false otherwise.
    • getPath

      public String getPath()
      Get the path.
      Returns:
      The path.
    • setPath

      public void setPath(String p_strPath)
      Set the path.
      Parameters:
      p_strPath - The path.
    • isAbsolute

      public boolean isAbsolute()
      Check if this URL is absolute, i.e. if it has both a scheme and an authority.

      This method does not check for the presence of a fragment identifier. Also note that a schema-less URL is considered to be a relative URL.

      Returns:
      true if this URL is absolute, or false otherwise.
    • makeRelative

      public void makeRelative()
      Make this URL relative by discarding its scheme and authority part.
    • hasParams

      public boolean hasParams()
      Check if this URL has a parameters.
      Returns:
      true if this URL has one or more parameters, or false otherwise.
    • 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.
    • 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 string representation of this URL without percent encoding to the specified java.io.Writer, e.g. $Response.

      This method is mainly used to display human-readable URLs.

      Parameters:
      p_out - The output stream.
      Throws:
      IOException - If an I/O error occurred or the character encoding could not be determined.
      See Also:
    • asString

      public String asString()
      Convert this URL in its string representation without percent encoding.

      This method is mainly used to display human-readable URLs.

      Returns:
      The URL as a string.
    • asPercentEncodedString

      public String asPercentEncodedString()
      Convert this URL in its string representation with proper percent encoding using the UTF-8 charset.

      The resulting string will contain ASCII characters only.

      Returns:
      The percent-encoded URL.
    • asParamsEncodedString

      @Deprecated public String asParamsEncodedString()
      Deprecated.
      See Also:
    • 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.
      See Also:
    • asEntityEncodedString

      public String asEntityEncodedString()
      Encode this URL to the percent-encoding format using the UTF-8 charset, and the replace ampersand characters with the &amp; HTML character entity.
      Returns:
      The percent- and entity-encoded URL.
    • asUrlEncodedString

      public String asUrlEncodedString()
      Encode the complete URL to the percent-encoding format using the UTF-8 charset.
      Returns:
      The URL-encoded string.
    • asUrlEncodedString

      @Deprecated public String asUrlEncodedString(String p_strCharset)
      Deprecated.
      Encode the complete URL to the percent-encoding format using the UTF-8 charset.

      Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites. So we ignore the charset parameter.

      Parameters:
      p_strCharset - Unused.
      Returns:
      The URL-encoded string.
    • getQueryAsPercentEncodedString

      public String getQueryAsPercentEncodedString()
      Convert this URL's query to its string representation with proper percent encoding using the UTF-8 charset.

      The returned string does not start with the question mark delimiter.

      The resulting string will contain ASCII characters only.

      Returns:
      The percent-encoded query string.