Class Builder

java.lang.Object
org.miaixz.bus.http.Builder

public class Builder extends Object
实用方法工具
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addSuppressedIfPossible

      public static void addSuppressedIfPossible(Throwable e, Throwable suppressed)
    • checkOffsetAndCount

      public static void checkOffsetAndCount(long arrayLength, long offset, long count)
    • discard

      public static boolean discard(org.miaixz.bus.core.io.source.Source source, int timeout, TimeUnit timeUnit)
      Attempts to exhaust source, returning true if successful. This is useful when reading a complete source is helpful, such as when doing so completes a cache body or frees a socket connection for reuse.
    • skipAll

      public static boolean skipAll(org.miaixz.bus.core.io.source.Source source, int duration, TimeUnit timeUnit) throws IOException
      Reads until in is exhausted or the deadline has been reached. This is careful to not extend the deadline if one exists already.
      Throws:
      IOException
    • immutableList

      public static <T> List<T> immutableList(List<T> list)
      Returns an immutable copy of list.
    • immutableMap

      public static <K, V> Map<K,V> immutableMap(Map<K,V> map)
      Returns an immutable copy of map.
    • immutableList

      public static <T> List<T> immutableList(T... elements)
      Returns an immutable list containing elements.
    • threadFactory

      public static ThreadFactory threadFactory(String name, boolean daemon)
    • intersect

      public static String[] intersect(Comparator<? super String> comparator, String[] first, String[] second)
      Returns an array containing only elements found in first and also in second. The returned elements are in the same order as in first.
    • nonEmptyIntersection

      public static boolean nonEmptyIntersection(Comparator<String> comparator, String[] first, String[] second)
      Returns true if there is an element in first that is also in second. This method terminates if any intersection is found. The sizes of both arguments are assumed to be so small, and the likelihood of an intersection so great, that it is not worth the CPU cost of sorting or the memory cost of hashing.
    • hostHeader

      public static String hostHeader(UnoUrl url, boolean includeDefaultPort)
    • indexOf

      public static int indexOf(Comparator<String> comparator, String[] array, String value)
    • concat

      public static String[] concat(String[] array, String value)
    • skipLeadingAsciiWhitespace

      public static int skipLeadingAsciiWhitespace(String input, int pos, int limit)
      Increments pos until input[pos] is not ASCII whitespace. Stops at limit.
    • skipTrailingAsciiWhitespace

      public static int skipTrailingAsciiWhitespace(String input, int pos, int limit)
      Decrements limit until input[limit - 1] is not ASCII whitespace. Stops at pos.
    • trimSubstring

      public static String trimSubstring(String string, int pos, int limit)
      Equivalent to string.substring(pos, limit).trim().
    • delimiterOffset

      public static int delimiterOffset(String input, int pos, int limit, String delimiters)
      Returns the index of the first character in input that contains a character in delimiters. Returns limit if there is no such character.
    • delimiterOffset

      public static int delimiterOffset(String input, int pos, int limit, char delimiter)
      Returns the index of the first character in input that is delimiter. Returns limit if there is no such character.
    • canonicalizeHost

      public static String canonicalizeHost(String host)
      If host is an IP address, this returns the IP address in canonical form.

      Otherwise this performs IDN ToASCII encoding and canonicalize the result to lowercase. For example this converts ☃.net to xn--n3h.net, and WwW.GoOgLe.cOm to www.google.com. null will be returned if the host cannot be ToASCII encoded or if the result contains unsupported ASCII characters.

    • indexOfControlOrNonAscii

      public static int indexOfControlOrNonAscii(String input)
      Returns the index of the first character in input that is either a control character (like or \n) or a non-ASCII character. Returns -1 if input has no such characters.
    • verifyAsIpAddress

      public static boolean verifyAsIpAddress(String host)
      Returns true if host is not a host name and might be an IP address.
    • bomAwareCharset

      public static Charset bomAwareCharset(org.miaixz.bus.core.io.source.BufferSource source, Charset charset) throws IOException
      Throws:
      IOException
    • checkDuration

      public static int checkDuration(String name, long duration, TimeUnit unit)
    • decodeHexDigit

      public static int decodeHexDigit(char c)
    • toHeaders

      public static Headers toHeaders(List<Http2Header> headerBlock)
    • toHeaderBlock

      public static List<Http2Header> toHeaderBlock(Headers headers)
    • sameConnection

      public static boolean sameConnection(UnoUrl a, UnoUrl b)
      Returns true if an HTTP request for a and b can reuse a connection.
    • parse

      public static Date parse(String value)
      Returns the date for value. Returns null if the value couldn't be parsed.
    • format

      public static String format(Date value)
      Returns the string for value.