Class UrlBuilder

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

public class UrlBuilder extends Url implements SchemeAccessor.SchemeProperty, SchemeAccessor.SchemeBuilder<UrlBuilder>, HostAccessor.HostProperty, HostAccessor.HostBuilder<UrlBuilder>, org.refcodes.net.IpAddressAccessor.IpAddressProperty, org.refcodes.net.IpAddressAccessor.IpAddressBuilder<UrlBuilder>, org.refcodes.mixin.PortAccessor.PortProperty, org.refcodes.mixin.PortAccessor.PortBuilder<UrlBuilder>, org.refcodes.mixin.PathAccessor.PathProperty, org.refcodes.mixin.PathAccessor.PathBuilder<UrlBuilder>, QueryFieldsAccessor.QueryFieldsProperty, QueryFieldsAccessor.QueryFieldsBuilder<UrlBuilder>, FragmentAccessor.FragmentProperty, FragmentAccessor.FragmentBuilder<UrlBuilder>, org.refcodes.mixin.CredentialsAccessor.CredentialsProperty, org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<UrlBuilder>
The UrlBuilder extends an immutable Url with mutable functionality.
  • Constructor Details

  • Method Details

    • fromUrl

      public void fromUrl(String aUrl) throws MalformedURLException
      Uses the given String to set the Url's state.
      Overrides:
      fromUrl in class Url
      Parameters:
      aUrl - The URL from which to determine the state.
      Throws:
      MalformedURLException - in case the provided URL is considered being malformed.
    • fromURL

      public void fromURL(URL aUrl)
      Uses the given URL to set the Url's state.
      Overrides:
      fromURL in class Url
      Parameters:
      aUrl - The URL from which to determine the state.
    • withScheme

      public UrlBuilder withScheme(org.refcodes.data.Scheme aScheme)
      Sets the UrlScheme for the URL scheme.
      Specified by:
      withScheme in interface SchemeAccessor.SchemeBuilder<UrlBuilder>
      Parameters:
      aScheme - The UrlScheme to be stored by the URL scheme.
      Returns:
      The builder for applying multiple build operations.
    • withProtocol

      public UrlBuilder withProtocol(String aProtocol)
      Sets the protocol for the URL scheme.
      Specified by:
      withProtocol in interface SchemeAccessor.SchemeBuilder<UrlBuilder>
      Parameters:
      aProtocol - The protocol to be stored by the URL scheme.
      Returns:
      The builder for applying multiple build operations.
    • withHost

      public UrlBuilder withHost(String aHost)
      Sets the host to use and returns this builder as of the builder pattern.
      Specified by:
      withHost in interface HostAccessor.HostBuilder<UrlBuilder>
      Parameters:
      aHost - The host to be stored by the host property.
      Returns:
      This HostAccessor.HostBuilder instance to continue configuration.
    • withIpAddress

      public UrlBuilder withIpAddress(int[] aIpAddress)
      Specified by:
      withIpAddress in interface org.refcodes.net.IpAddressAccessor.IpAddressBuilder<UrlBuilder>
    • withCidrNotation

      public UrlBuilder withCidrNotation(String aCidrNotation)
      Specified by:
      withCidrNotation in interface org.refcodes.net.IpAddressAccessor.IpAddressBuilder<UrlBuilder>
    • withPort

      public UrlBuilder withPort(int aPort)
      Specified by:
      withPort in interface org.refcodes.mixin.PortAccessor.PortBuilder<UrlBuilder>
    • withPath

      public UrlBuilder withPath(String aPath)
      Specified by:
      withPath in interface org.refcodes.mixin.PathAccessor.PathBuilder<UrlBuilder>
    • appendToPath

      public void appendToPath(String aPathElement)
      Appends a path element to the path.
      Parameters:
      aPathElement - The path element to be appended.
    • appendToPath

      public void appendToPath(String... aPathElements)
      Appends multiple path elements to the path, automatically adding the path separator "/" as required.
      Parameters:
      aPathElements - The path elements to be appended.
    • withAppendToPath

      public UrlBuilder withAppendToPath(String aPath)
      Appends a path element to the path as of the Builder-Pattern.
      Parameters:
      aPath - The path element to be appended.
      Returns:
      This UrlBuilder instance to continue configuration.
    • withAppendToPath

      public UrlBuilder withAppendToPath(String... aPathElements)
      Appends multiple path elements to the path, automatically adding the path separator "/" as required as of the Builder-Pattern.
      Parameters:
      aPathElements - The path elements to be appended.
      Returns:
      This UrlBuilder instance to continue configuration.
    • withQueryFields

      public UrlBuilder withQueryFields(FormFields aQueryFields)
      Sets the request Query-Fields to use and returns this builder as of the Builder-Pattern.
      Specified by:
      withQueryFields in interface QueryFieldsAccessor.QueryFieldsBuilder<UrlBuilder>
      Parameters:
      aQueryFields - The request Query-Fields to be stored by the form fields property.
      Returns:
      This FormFieldsAccessor.FormFieldsBuilder instance to continue configuration.
    • addToQueryFields

      public void addToQueryFields(String aField, String aValue)
      Adds a value to the list of values associated with the given Query-Field (key).
      Parameters:
      aField - The Query-Field (key) of which's list of values a value is to be added.
      aValue - The value to be added to the list of values associated to the given Query-Field (key).
    • addToQueryFields

      public void addToQueryFields(String aField, String... aValues)
      Adds values to the list of values associated with the given Query-Field (key).
      Parameters:
      aField - The Query-Field (key) of which's list of values the values are to be added.
      aValues - The values to be added to the list of values associated to the given Query-Field (key).
    • withAddToQueryFields

      public UrlBuilder withAddToQueryFields(String aField, String aValue)
      Adds a value to the list of values associated with the given Query-Field (key) and returns this builder as of the Builder-Pattern.
      Parameters:
      aField - The Query-Field (key) of which's list of values a value is to be added.
      aValue - The value to be added to the list of values associated to the given Query-Field (key).
      Returns:
      This UrlBuilder instance to continue configuration.
    • withAddToQueryFields

      public UrlBuilder withAddToQueryFields(String aField, String... aValues)
      Adds values to the list of values associated with the given Query-Field (key) and returns this builder as of the Builder-Pattern.
      Parameters:
      aField - The Query-Field (key) of which's list of values the values are to be added.
      aValues - The values to be added to the list of values associated to the given Query-Field (key).
      Returns:
      This UrlBuilder instance to continue configuration.
    • withFragment

      public UrlBuilder withFragment(String aFragment)
      Sets the fragment to use and returns this builder as of the builder pattern.
      Specified by:
      withFragment in interface FragmentAccessor.FragmentBuilder<UrlBuilder>
      Parameters:
      aFragment - The fragment to be stored by the fragment property.
      Returns:
      This FragmentAccessor.FragmentBuilder instance to continue configuration.
    • withIdentity

      public UrlBuilder withIdentity(String aIdentity)
      Specified by:
      withIdentity in interface org.refcodes.mixin.IdentityAccessor.IdentityBuilder<UrlBuilder>
    • withSecret

      public UrlBuilder withSecret(String aSecret)
      Specified by:
      withSecret in interface org.refcodes.mixin.SecretAccessor.SecretBuilder<UrlBuilder>
    • setScheme

      public void setScheme(org.refcodes.data.Scheme aScheme)
      Sets the UrlScheme for the URL scheme.
      Specified by:
      setScheme in interface SchemeAccessor.SchemeMutator
      Overrides:
      setScheme in class Url
      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
      Overrides:
      setProtocol in class Url
      Parameters:
      aProtocol - The UrlScheme's String representation to be stored by the URL scheme.
    • setHost

      public void setHost(String aHost)
      Sets the host for the host property.
      Specified by:
      setHost in interface HostAccessor.HostMutator
      Overrides:
      setHost in class Url
      Parameters:
      aHost - The host to be stored by the host property.
    • setIpAddress

      public void setIpAddress(int[] aIpAddress)
      Specified by:
      setIpAddress in interface org.refcodes.net.IpAddressAccessor.IpAddressMutator
      Overrides:
      setIpAddress in class Url
    • setPort

      public void setPort(int aPort)
      Specified by:
      setPort in interface org.refcodes.mixin.PortAccessor.PortMutator
      Overrides:
      setPort in class Url
    • setPath

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