Module bus.http

Class UnoUrl.Builder

java.lang.Object
org.miaixz.bus.http.UnoUrl.Builder
Enclosing class:
UnoUrl

public static class UnoUrl.Builder extends Object
URL 构建器
  • Constructor Details

    • Builder

      public Builder()
      默认构造函数
  • Method Details

    • scheme

      public UnoUrl.Builder scheme(String scheme)
      设置协议
      Parameters:
      scheme - 协议(http 或 https)
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 scheme 为 null
      IllegalArgumentException - 如果协议无效
    • username

      public UnoUrl.Builder username(String username)
      设置用户名
      Parameters:
      username - 用户名
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 username 为 null
    • encodedUsername

      public UnoUrl.Builder encodedUsername(String encodedUsername)
      设置编码后的用户名
      Parameters:
      encodedUsername - 编码后的用户名
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedUsername 为 null
    • password

      public UnoUrl.Builder password(String password)
      设置密码
      Parameters:
      password - 密码
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 password 为 null
    • encodedPassword

      public UnoUrl.Builder encodedPassword(String encodedPassword)
      设置编码后的密码
      Parameters:
      encodedPassword - 编码后的密码
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedPassword 为 null
    • host

      public UnoUrl.Builder host(String host)
      设置主机名
      Parameters:
      host - 主机名(普通主机名、IPv4、IPv6 或编码的 IDN)
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 host 为 null
      IllegalArgumentException - 如果主机名无效
    • port

      public UnoUrl.Builder port(int port)
      设置端口号
      Parameters:
      port - 端口号
      Returns:
      当前 Builder 实例
      Throws:
      IllegalArgumentException - 如果端口号无效
    • addPathSegment

      public UnoUrl.Builder addPathSegment(String pathSegment)
      添加路径段
      Parameters:
      pathSegment - 路径段
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 pathSegment 为 null
    • addPathSegments

      public UnoUrl.Builder addPathSegments(String pathSegments)
      添加路径段列表
      Parameters:
      pathSegments - 路径段字符串
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 pathSegments 为 null
    • addEncodedPathSegment

      public UnoUrl.Builder addEncodedPathSegment(String encodedPathSegment)
      添加编码后的路径段
      Parameters:
      encodedPathSegment - 编码后的路径段
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedPathSegment 为 null
    • addEncodedPathSegments

      public UnoUrl.Builder addEncodedPathSegments(String encodedPathSegments)
      添加编码后的路径段列表
      Parameters:
      encodedPathSegments - 编码后的路径段字符串
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedPathSegments 为 null
    • setPathSegment

      public UnoUrl.Builder setPathSegment(int index, String pathSegment)
      设置路径段
      Parameters:
      index - 索引
      pathSegment - 路径段
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 pathSegment 为 null
      IllegalArgumentException - 如果路径段无效
    • setEncodedPathSegment

      public UnoUrl.Builder setEncodedPathSegment(int index, String encodedPathSegment)
      设置编码后的路径段
      Parameters:
      index - 索引
      encodedPathSegment - 编码后的路径段
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedPathSegment 为 null
      IllegalArgumentException - 如果路径段无效
    • removePathSegment

      public UnoUrl.Builder removePathSegment(int index)
      移除路径段
      Parameters:
      index - 索引
      Returns:
      当前 Builder 实例
    • encodedPath

      public UnoUrl.Builder encodedPath(String encodedPath)
      设置编码后的路径
      Parameters:
      encodedPath - 编码后的路径
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedPath 为 null
      IllegalArgumentException - 如果路径无效
    • query

      public UnoUrl.Builder query(String query)
      设置查询字符串
      Parameters:
      query - 查询字符串
      Returns:
      当前 Builder 实例
    • encodedQuery

      public UnoUrl.Builder encodedQuery(String encodedQuery)
      设置编码后的查询字符串
      Parameters:
      encodedQuery - 编码后的查询字符串
      Returns:
      当前 Builder 实例
    • addQueryParameter

      public UnoUrl.Builder addQueryParameter(String name, String value)
      添加查询参数
      Parameters:
      name - 参数名称
      value - 参数值
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 name 为 null
    • addEncodedQueryParameter

      public UnoUrl.Builder addEncodedQueryParameter(String encodedName, String encodedValue)
      添加编码后的查询参数
      Parameters:
      encodedName - 编码后的参数名称
      encodedValue - 编码后的参数值
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedName 为 null
    • setQueryParameter

      public UnoUrl.Builder setQueryParameter(String name, String value)
      设置查询参数(替换现有参数)
      Parameters:
      name - 参数名称
      value - 参数值
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 name 为 null
    • setEncodedQueryParameter

      public UnoUrl.Builder setEncodedQueryParameter(String encodedName, String encodedValue)
      设置编码后的查询参数(替换现有参数)
      Parameters:
      encodedName - 编码后的参数名称
      encodedValue - 编码后的参数值
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedName 为 null
    • removeAllQueryParameters

      public UnoUrl.Builder removeAllQueryParameters(String name)
      移除指定名称的所有查询参数
      Parameters:
      name - 参数名称
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 name 为 null
    • removeAllEncodedQueryParameters

      public UnoUrl.Builder removeAllEncodedQueryParameters(String encodedName)
      移除编码后的所有查询参数
      Parameters:
      encodedName - 编码后的参数名称
      Returns:
      当前 Builder 实例
      Throws:
      NullPointerException - 如果 encodedName 为 null
    • fragment

      public UnoUrl.Builder fragment(String fragment)
      设置片段
      Parameters:
      fragment - 片段
      Returns:
      当前 Builder 实例
    • encodedFragment

      public UnoUrl.Builder encodedFragment(String encodedFragment)
      设置编码后的片段
      Parameters:
      encodedFragment - 编码后的片段
      Returns:
      当前 Builder 实例
    • build

      public UnoUrl build()
      构建 UnoUrl 实例
      Returns:
      UnoUrl 实例
      Throws:
      IllegalStateException - 如果 scheme 或 host 未设置
    • toString

      public String toString()
      返回 URL 的字符串表示
      Overrides:
      toString in class Object
      Returns:
      URL 字符串