Interface ISimpleURL

All Known Implementing Classes:
SimpleURL, URLData

public interface ISimpleURL
Interface for a simple URL that works around the usability issues with the Java default java.net.URL.
Author:
Philip Helger
  • Method Details

    • getProtocol

      @Nullable default IURLProtocol getProtocol()
      Returns:
      The protocol used. May be null for an unknown protocol.
    • hasKnownProtocol

      default boolean hasKnownProtocol()
      Returns:
      true if the URL has a known protocol
    • getPath

      @Nonnull String getPath()
      Returns:
      The path part of the URL (everything before the "?" and the "#", incl. the protocol). Never null but maybe empty (e.g. for "?x=y").
    • params

      Returns:
      A map of all query string parameters. May be null.
    • getAnchor

      @Nullable String getAnchor()
      Returns:
      The name of the anchor (everything after the "#") or null if none is defined.
    • hasAnchor

      default boolean hasAnchor()
      Returns:
      true if an anchor is present, false otherwise.
    • hasAnchor

      default boolean hasAnchor(@Nullable String sAnchor)
      Check if this URL has an anchor with the passed name.
      Parameters:
      sAnchor - The anchor name to check.
      Returns:
      true if the passed anchor is present.
    • getAsStringWithoutEncodedParameters

      @Nonnull default String getAsStringWithoutEncodedParameters()
      Returns:
      The final string representation of this URL not encoding the request parameters.
    • getAsStringWithEncodedParameters

      @Nonnull default String getAsStringWithEncodedParameters()
      Returns:
      The final string representation of this URL with encoded URL parameter keys and values. Using the default URL charset as determined by URLHelper.CHARSET_URL_OBJ.
    • getAsStringWithEncodedParameters

      @Nonnull default String getAsStringWithEncodedParameters(@Nonnull Charset aCharset)
      Parameters:
      aCharset - The charset used for encoding the parameters. May not be null.
      Returns:
      The final string representation of this URL with encoded URL parameter keys and values.
    • getAsURL

      @Nullable default URL getAsURL()
    • getAsURI

      @Nullable default URI getAsURI()