Class UrlImpl

java.lang.Object
org.refcodes.web.UrlImpl
All Implemented Interfaces:
org.refcodes.mixin.CredentialsAccessor, org.refcodes.mixin.Dumpable, org.refcodes.mixin.IdentityAccessor, org.refcodes.mixin.PathAccessor, org.refcodes.mixin.PortAccessor, org.refcodes.mixin.SecretAccessor, FragmentAccessor, HostAccessor, IpAddressAccessor, QueryFieldsAccessor, SchemeAccessor, Url

public class UrlImpl
extends Object
implements Url
  • Constructor Details

    • UrlImpl

      public UrlImpl()
      Default constructor. Make sure to set required attributes for a valid URL.
    • UrlImpl

      public UrlImpl​(String aUrl) throws MalformedURLException
      Constructs an Url from the provided URL String.
      Parameters:
      aUrl - The URL String to be parsed. The URL consists of the scheme (protocol), the identify and the secret (optional), the host as well as an optional port and the (optional) path.
      Throws:
      MalformedURLException - in case the provided URL is considered being malformed.
    • UrlImpl

      public UrlImpl​(String aUrl, FormFields aQueryFields) throws MalformedURLException
      Constructs an Url from the provided URL String.
      Parameters:
      aUrl - The URL String to be parsed. The URL consists of the scheme (protocol), the identify and the secret (optional), the host as well as an optional port and the (optional) path.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
      Throws:
      MalformedURLException - in case the provided URL is considered being malformed.
    • UrlImpl

      public UrlImpl​(String aUrl, FormFields aQueryFields, String aFragment) throws MalformedURLException
      Constructs an Url from the provided URL String.
      Parameters:
      aUrl - The URL String to be parsed. The URL consists of the scheme (protocol), the identify and the secret (optional), the host as well as an optional port and the (optional) path.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
      aFragment - The fragment to be set.
      Throws:
      MalformedURLException - in case the provided URL is considered being malformed.
    • UrlImpl

      public UrlImpl​(URL aURL)
      Constructs an Url from the provided URL instance.
      Parameters:
      aURL - The URL to be used.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
      aFragment - The fragment to be set.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, int aPort)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, int aPort, String aPath)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPort - The port to be used when connecting to the host.
      aPath - The path on the host to which the base destination URL is to point to.
      aFragment - The fragment to be set.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url with the common attributes.
      Parameters:
      aScheme - The Scheme (e.g. HTTP or HTTPS) to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
      aFragment - The fragment to be set.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, String aPath)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, String aPath, FormFields aQueryFields)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
    • UrlImpl

      public UrlImpl​(String aProtocol, String aHost, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url with the common attributes.
      Parameters:
      aProtocol - The protocol String (e.g. "http://" or "https://") to be used for the destination URL.
      aHost - The host to which the destination URL is to point to.
      aPath - The path on the host to which the base destination URL is to point to.
      aQueryFields - The Query-Fields to be used for the HTTP Query-String.
      aFragment - The fragment to be set.
    • UrlImpl

      public UrlImpl​(Url aUrl, Url aOtherUrl)
      Constructs a new Url from the given Url instances by adding the other Url's data to the first Url's data. E.g. a path from the other Url is append to the first Url's path, the query parameters are added or overwritten accordingly and so on.
      Parameters:
      aUrl - The Url which is to be enriched.
      aOtherUrl - The Url enriching the given Url.
    • UrlImpl

      public UrlImpl​(Url aUrl, String... aPaths)
      Some Url algebra: Adds the provided path to the given Url by prepending it to the Url's path.
      Parameters:
      aUrl - The Url to which to add the path.
      aPaths - The paths to be added to the given Url.
    • UrlImpl

      public UrlImpl​(Url aUrl)
      Creates an Url from the provided Url.
      Parameters:
      aUrl - The Url from which to construct this instance.
  • Method Details

    • getScheme

      public org.refcodes.data.Scheme getScheme()
      Retrieves the UrlScheme from the URL scheme.
      Specified by:
      getScheme in interface SchemeAccessor
      Returns:
      The UrlScheme stored by the URL scheme.
    • toProtocol

      public String toProtocol()
      Retrieves the protocol representation from the Scheme. In case of a scheme unknown by the Scheme enumeration, then SchemeAccessor.getScheme() might return null whilst SchemeAccessor.toProtocol() still retrieves the unknown scheme's protocol representation (as of SchemeAccessor.SchemeMutator.setProtocol(String)).
      Specified by:
      toProtocol in interface SchemeAccessor
      Returns:
      The protocol representation for the URL.
    • getHost

      public String getHost()
      Retrieves the host from the host property.
      Specified by:
      getHost in interface HostAccessor
      Returns:
      The host stored by the host property.
    • getIpAddress

      public int[] getIpAddress()
      Retrieves the IP-Address from the IP-Address property.
      Specified by:
      getIpAddress in interface IpAddressAccessor
      Returns:
      The IP-Address stored by the IP-Address property.
    • getPort

      public int getPort()
      Specified by:
      getPort in interface org.refcodes.mixin.PortAccessor
    • getPath

      public String getPath()
      Specified by:
      getPath in interface org.refcodes.mixin.PathAccessor
    • getQueryFields

      public FormFields getQueryFields()
      Retrieves the request Query-Fields from the request Query-Fields property.
      Specified by:
      getQueryFields in interface QueryFieldsAccessor
      Returns:
      The request Query-Fields stored by the request Query-Fields property.
    • getFragment

      public String getFragment()
      Retrieves the fragment from the fragment property.
      Specified by:
      getFragment in interface FragmentAccessor
      Returns:
      The fragment stored by the fragment property.
    • getIdentity

      public String getIdentity()
      Specified by:
      getIdentity in interface org.refcodes.mixin.IdentityAccessor
    • getSecret

      public String getSecret()
      Specified by:
      getSecret in interface org.refcodes.mixin.SecretAccessor
    • toString

      public String toString()
      Overrides:
      toString in class Object