Interface Scheme

All Superinterfaces:
org.wiremock.stringparser.ParsedString

public interface Scheme extends org.wiremock.stringparser.ParsedString
Represents a valid URI scheme.

An implementation must be immutable (and hence threadsafe)

Implementations must enforce that the scheme is valid

Implementations should be equal to any other Scheme implementation with the same text representation. Implementations are NOT equal to a scheme with different casing - so Scheme.parse("http").equals(Scheme.parse("HTTP")) == false. However, their canonical representations are equal, so Scheme.parse("http").canonical().equals(Scheme.parse("HTTP").canonical()) == true .

An implementation's toString should return the String used when it was created.

  • Method Details

    • normalise

      Scheme normalise()
    • getDefaultPort

      @Nullable Port getDefaultPort()
    • isNormalForm

      default boolean isNormalForm()
    • resolve

      default AbsoluteUri resolve(Uri other)
    • resolve

      default AbsoluteUrl resolve(UrlWithAuthority other)
    • parse

      static Scheme parse(String scheme) throws IllegalScheme
      Parses & registers a scheme

      Unlike register, returns a scheme with the same casing as the scheme param, but canonical() will return the canonical (lower case) version, which may already have been registered.

      If the scheme parameter is canonical (lower case), and a matching Scheme with a default port has already been registered, that Scheme will be returned.

      Parameters:
      scheme - - the raw scheme
      Returns:
      a Scheme object representing the scheme
      Throws:
      IllegalScheme - if the raw scheme is not a legal Scheme, matching [a-zA-Z][a-zA-Z0-9+\-.]{0,255}
    • register

      static Scheme register(String schemeString) throws IllegalScheme
      Registers a canonical scheme with no default port.

      The registered and returned scheme will be canonical (i.e. lower case) regardless of the case of the input.

      If the scheme is already registered, returns the existing instance with the existing instances default port (or none).

      Parameters:
      schemeString - - the raw scheme
      Returns:
      a canonical Scheme object representing the scheme
      Throws:
      IllegalScheme - if the raw scheme is not a legal Scheme, matching [a-zA-Z][a-zA-Z0-9+\-.]{0,255}
    • register

      static Scheme register(String schemeString, @Nullable Port defaultPort) throws IllegalScheme
      Registers a scheme with an optional default port.

      The registered and returned scheme will be canonical (i.e. lower case) regardless of input.

      If the scheme is already registered, returns the existing instance and ignores the provided default port.

      The returned scheme will be canonical (i.e. lower case)

      Parameters:
      schemeString - - the raw scheme
      Returns:
      a canonical Scheme object representing the scheme
      Throws:
      IllegalScheme - if the raw scheme is not a legal Scheme, matching [a-zA-Z][a-zA-Z0-9+\-.]{0,255}