Class UrlBuilderImpl

java.lang.Object
org.refcodes.web.UrlBuilderImpl
All Implemented Interfaces:
org.refcodes.mixin.CredentialsAccessor, org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<Url.UrlBuilder>, org.refcodes.mixin.CredentialsAccessor.CredentialsMutator, org.refcodes.mixin.CredentialsAccessor.CredentialsProperty, org.refcodes.mixin.Dumpable, org.refcodes.mixin.IdentityAccessor, org.refcodes.mixin.IdentityAccessor.IdentityBuilder<Url.UrlBuilder>, org.refcodes.mixin.IdentityAccessor.IdentityMutator, org.refcodes.mixin.IdentityAccessor.IdentityProperty, org.refcodes.mixin.PathAccessor, org.refcodes.mixin.PathAccessor.PathBuilder<Url.UrlBuilder>, org.refcodes.mixin.PathAccessor.PathMutator, org.refcodes.mixin.PathAccessor.PathProperty, org.refcodes.mixin.PortAccessor, org.refcodes.mixin.PortAccessor.PortBuilder<Url.UrlBuilder>, org.refcodes.mixin.PortAccessor.PortMutator, org.refcodes.mixin.PortAccessor.PortProperty, org.refcodes.mixin.SecretAccessor, org.refcodes.mixin.SecretAccessor.SecretBuilder<Url.UrlBuilder>, org.refcodes.mixin.SecretAccessor.SecretMutator, org.refcodes.mixin.SecretAccessor.SecretProperty, FragmentAccessor, FragmentAccessor.FragmentBuilder<Url.UrlBuilder>, FragmentAccessor.FragmentMutator, FragmentAccessor.FragmentProperty, HostAccessor, HostAccessor.HostBuilder<Url.UrlBuilder>, HostAccessor.HostMutator, HostAccessor.HostProperty, IpAddressAccessor, IpAddressAccessor.IpAddressBuilder<Url.UrlBuilder>, IpAddressAccessor.IpAddressMutator, IpAddressAccessor.IpAddressProperty, QueryFieldsAccessor, QueryFieldsAccessor.QueryFieldsBuilder<Url.UrlBuilder>, QueryFieldsAccessor.QueryFieldsMutator, QueryFieldsAccessor.QueryFieldsProperty, SchemeAccessor, SchemeAccessor.SchemeBuilder<Url.UrlBuilder>, SchemeAccessor.SchemeMutator, SchemeAccessor.SchemeProperty, Url, Url.UrlBuilder

public class UrlBuilderImpl
extends Object
implements Url.UrlBuilder
  • Constructor Details

    • UrlBuilderImpl

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

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

      public UrlBuilderImpl​(String aUrl) throws MalformedURLException
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aUrl, FormFields aQueryFields) throws MalformedURLException
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aUrl, FormFields aQueryFields, String aFragment) throws MalformedURLException
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

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

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, int aPort)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, int aPort, String aPath)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, String aPath)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, String aPath, FormFields aQueryFields)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(Url aUrl, Url aOtherUrl)
      Constructs a new Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(String aProtocol, String aHost, String aPath, FormFields aQueryFields, String aFragment)
      Constructs an Url.UrlBuilder 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.
    • UrlBuilderImpl

      public UrlBuilderImpl​(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.
  • 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.
    • setScheme

      public void setScheme​(org.refcodes.data.Scheme aScheme)
      Sets the UrlScheme for the URL scheme.
      Specified by:
      setScheme in interface SchemeAccessor.SchemeMutator
      Parameters:
      aScheme - The UrlScheme to be stored by the URL scheme.
    • setProtocol

      public void setProtocol​(String aProtocol)
      Sets the protocol String representation for the scheme property. You must provide the scheme's specific part as well. In case of HTTP, provide "http://". In case your provided protocol is unknown by the Scheme enumeration, then the scheme property will not be set, though the SchemeAccessor.toProtocol() still returns your protocol.
      Specified by:
      setProtocol in interface SchemeAccessor.SchemeMutator
      Parameters:
      aProtocol - The UrlScheme's String representation to be stored by the URL scheme.
    • 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.
    • setHost

      public void setHost​(String aHost)
      Sets the host for the host property.
      Specified by:
      setHost in interface HostAccessor.HostMutator
      Parameters:
      aHost - The host to be 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.
    • setIpAddress

      public void setIpAddress​(int[] aIpAddress)
      Sets the IP-Address for the IP-Address property.
      Specified by:
      setIpAddress in interface IpAddressAccessor.IpAddressMutator
      Parameters:
      aIpAddress - The IP-Address to be stored by the IP-Address property.
    • getPort

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

      public void setPort​(int aPort)
      Specified by:
      setPort in interface org.refcodes.mixin.PortAccessor.PortMutator
    • getPath

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

      public void setPath​(String aPath)
      Specified by:
      setPath in interface org.refcodes.mixin.PathAccessor.PathMutator
    • 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.
    • setQueryFields

      public void setQueryFields​(FormFields aQueryFields)
      Sets the request Query-Fields for the request Query-Fields property.
      Specified by:
      setQueryFields in interface QueryFieldsAccessor.QueryFieldsMutator
      Parameters:
      aQueryFields - The request Query-Fields to be stored by the form 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.
    • setFragment

      public void setFragment​(String aFragment)
      Sets the fragment for the fragment property.
      Specified by:
      setFragment in interface FragmentAccessor.FragmentMutator
      Parameters:
      aFragment - The fragment to be 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
    • setIdentity

      public void setIdentity​(String aIdentity)
      Specified by:
      setIdentity in interface org.refcodes.mixin.IdentityAccessor.IdentityMutator
    • setSecret

      public void setSecret​(String aSecret)
      Specified by:
      setSecret in interface org.refcodes.mixin.SecretAccessor.SecretMutator
    • toString

      public String toString()
      Overrides:
      toString in class Object