Class UriAuthority

java.lang.Object
io.helidon.common.uri.UriAuthority

public final class UriAuthority extends Object
Normalized URI authority.

URI authority is a host plus an optional port. Userinfo is not supported.

  • Field Details

    • UNDEFINED_PORT

      public static final int UNDEFINED_PORT
      Undefined port value.
      See Also:
  • Method Details

    • create

      public static UriAuthority create(UriHost host, int port)
      Create a normalized authority from a host and optional port.
      Parameters:
      host - normalized host
      port - port, or -1 when absent
      Returns:
      normalized authority
      Throws:
      NullPointerException - in case the host is null
      IllegalArgumentException - in case the port is invalid
    • create

      public static UriAuthority create(String authority)
      Parse and normalize authority text.

      DNS hosts are normalized to lower-case ASCII. IPv6 authorities must use brackets.

      Parameters:
      authority - authority text containing a host and optional port
      Returns:
      normalized authority
      Throws:
      NullPointerException - in case the authority is null
      IllegalArgumentException - in case the authority is invalid
    • host

      public UriHost host()
      Host.
      Returns:
      normalized host
    • port

      public int port()
      Port.
      Returns:
      port, or -1 when absent
    • hasPort

      public boolean hasPort()
      Whether the authority has a port.
      Returns:
      whether a port is defined
    • portOrDefault

      public int portOrDefault(int defaultPort)
      Port or a default value.
      Parameters:
      defaultPort - default port to use when the authority has no port
      Returns:
      authority port or the provided default port
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object