Class HttpURI.Mutable

java.lang.Object
org.eclipse.jetty.http.HttpURI.Mutable
All Implemented Interfaces:
HttpURI
Enclosing interface:
HttpURI

public static class HttpURI.Mutable extends Object implements HttpURI
  • Method Details

    • asImmutable

      public HttpURI.Immutable asImmutable()
      Specified by:
      asImmutable in interface HttpURI
      Returns:
      An immutable copy of this HttpURI.
    • asString

      public String asString()
      Specified by:
      asString in interface HttpURI
      Returns:
      The URI as a string.
    • authority

      public HttpURI.Mutable authority(String host, int port)
      Parameters:
      host - the host
      port - the port
      Returns:
      this mutable
    • authority

      public HttpURI.Mutable authority(String hostPort)
      Parameters:
      hostPort - the host and port combined
      Returns:
      this mutable
    • clear

      public HttpURI.Mutable clear()
      Clears all URI components, resetting this mutable to an empty state.
      Returns:
      this mutable for chaining.
    • decodedPath

      public HttpURI.Mutable decodedPath(String path)
      Sets the path from a decoded (non-percent-encoded) string.
      Parameters:
      path - The decoded path to set.
      Returns:
      this mutable for chaining.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • fragment

      public HttpURI.Mutable fragment(String fragment)
      Parameters:
      fragment - The fragment to set.
      Returns:
      this mutable for chaining.
    • getAuthority

      public String getAuthority()
      Specified by:
      getAuthority in interface HttpURI
      Returns:
      The authority component of the URI in the form host:port, or just host if the port is not set, or null if no host is set.
    • getDecodedPath

      public String getDecodedPath()
      Specified by:
      getDecodedPath in interface HttpURI
      Returns:
      The decoded path with percent-encoded characters decoded, or null if no path is set.
      See Also:
    • getCanonicalPath

      public String getCanonicalPath()
      Specified by:
      getCanonicalPath in interface HttpURI
      Returns:
      The canonical path with path parameters removed and percent-encoded characters decoded, or null if no path is set.
      See Also:
    • getFragment

      public String getFragment()
      Specified by:
      getFragment in interface HttpURI
      Returns:
      The fragment component of the URI (after the # character), or null if not set.
    • getHost

      public String getHost()
      Specified by:
      getHost in interface HttpURI
      Returns:
      The host component of the URI, or null if not set.
    • getParam

      public String getParam()
      Description copied from interface: HttpURI

      Get a URI path parameter.

      Path parameters were defined in RFC 2068 and appear after a semicolon in the path, such as /path;param. This is distinct from query parameters which appear after the ? character.

      Specified by:
      getParam in interface HttpURI
      Returns:
      The last path parameter, or null if no path parameter is present. If there are multiple path parameters, only the last one is returned.
      See Also:
    • getPath

      public String getPath()
      Specified by:
      getPath in interface HttpURI
      Returns:
      The raw, undecoded, path component of the URI including path parameters, or null if not set.
      See Also:
    • getPathQuery

      public String getPathQuery()
      Specified by:
      getPathQuery in interface HttpURI
      Returns:
      The raw, undecoded, path and query components combined as path?query, or just the path if no query is present, or null if no path is set.
    • getPort

      public int getPort()
      Specified by:
      getPort in interface HttpURI
      Returns:
      The port number of the URI, or -1 if not set.
    • getQuery

      public String getQuery()
      Specified by:
      getQuery in interface HttpURI
      Returns:
      The query string component of the URI (after the ? character but before any # fragment), or null if not set.
      See Also:
    • getScheme

      public String getScheme()
      Specified by:
      getScheme in interface HttpURI
      Returns:
      The URI scheme such as http or https, or null if not set.
    • getUser

      public String getUser()
      Specified by:
      getUser in interface HttpURI
      Returns:
      The user info component of the URI authority (before the @ character), or null if not set.
    • hasAuthority

      public boolean hasAuthority()
      Specified by:
      hasAuthority in interface HttpURI
      Returns:
      true if the URI has an authority component.
    • hashCode

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

      public HttpURI.Mutable host(String host)
      Parameters:
      host - The host to set.
      Returns:
      this mutable for chaining.
      Throws:
      IllegalArgumentException - if a relative path is set with an authority.
    • isAbsolute

      public boolean isAbsolute()
      Specified by:
      isAbsolute in interface HttpURI
      Returns:
      true if the URI has a scheme component.
    • isAmbiguous

      public boolean isAmbiguous()
      Description copied from interface: HttpURI

      Checks if the URI contains any ambiguous path violations that could be interpreted differently by different URI parsers.

      Specified by:
      isAmbiguous in interface HttpURI
      Returns:
      true if the URI has any ambiguous UriCompliance.Violations.
      See Also:
    • hasViolations

      public boolean hasViolations()
      Description copied from interface: HttpURI

      Checks if the URI has any compliance violations against the URI specification or best practices.

      Specified by:
      hasViolations in interface HttpURI
      Returns:
      true if the URI has any UriCompliance.Violations.
      See Also:
    • hasViolation

      public boolean hasViolation(UriCompliance.Violation violation)
      Specified by:
      hasViolation in interface HttpURI
      Parameters:
      violation - The violation to check.
      Returns:
      true if the URI has the specified violation.
      See Also:
    • getViolations

      public Collection<UriCompliance.Violation> getViolations()
      Specified by:
      getViolations in interface HttpURI
      Returns:
      The set of UriCompliance.Violations detected in the URI, or an empty set if none.
      See Also:
    • normalize

      public HttpURI.Mutable normalize()
      Normalizes the URI by removing the default port if it matches the scheme's default port.
      Returns:
      this mutable for chaining.
    • param

      public HttpURI.Mutable param(String param)
      Sets the path parameter, appending it to the path after a semicolon.
      Parameters:
      param - The path parameter to set.
      Returns:
      this mutable for chaining.
    • path

      public HttpURI.Mutable path(String path)
      Parameters:
      path - the path
      Returns:
      this Mutable
    • pathQuery

      public HttpURI.Mutable pathQuery(String pathQuery)
      Sets the path and query from a combined string in the form path?query.
      Parameters:
      pathQuery - The path and query string to set.
      Returns:
      this mutable for chaining.
      Throws:
      IllegalArgumentException - if a relative path is set with an authority.
    • port

      public HttpURI.Mutable port(int port)
      Parameters:
      port - The port to set, or -1 to clear the port.
      Returns:
      this mutable for chaining.
    • query

      public HttpURI.Mutable query(String query)
      Parameters:
      query - The query string to set.
      Returns:
      this mutable for chaining.
    • scheme

      public HttpURI.Mutable scheme(HttpScheme scheme)
      Parameters:
      scheme - The HttpScheme to set.
      Returns:
      this mutable for chaining.
    • scheme

      public HttpURI.Mutable scheme(String scheme)
      Parameters:
      scheme - The scheme to set, which will be normalized to lower-case.
      Returns:
      this mutable for chaining.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • uri

      public HttpURI.Mutable uri(HttpURI uri)
      Sets all URI components from another HttpURI.
      Parameters:
      uri - The URI to copy components from.
      Returns:
      this mutable for chaining.
    • uri

      public HttpURI.Mutable uri(String uri)
      Parses and sets all URI components from a string.
      Parameters:
      uri - The URI string to parse.
      Returns:
      this mutable for chaining.
    • uri

      public HttpURI.Mutable uri(String method, String uri)
      Parses and sets URI components from a string, handling HTTP method-specific parsing.
      Parameters:
      method - The HTTP method, which affects parsing for CONNECT requests.
      uri - The URI string to parse.
      Returns:
      this mutable for chaining.
    • uri

      public HttpURI.Mutable uri(String uri, int offset, int length)
      Parses and sets all URI components from a substring.
      Parameters:
      uri - The string containing the URI.
      offset - The offset within the string where the URI starts.
      length - The length of the URI substring.
      Returns:
      this mutable for chaining.
    • user

      public HttpURI.Mutable user(String user)
      Sets the user info component of the URI authority.
      Parameters:
      user - The user info to set, or null to clear it.
      Returns:
      this mutable for chaining.