public final class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static RequestBody |
EMPTY_REQUEST |
static ResponseBody |
EMPTY_RESPONSE |
static java.lang.String[] |
EMPTY_STRING_ARRAY |
static java.nio.charset.Charset |
ISO_8859_1 |
static java.util.Comparator<java.lang.String> |
NATURAL_ORDER |
static java.util.TimeZone |
UTC
GMT and UTC are equivalent for our purposes.
|
private static java.nio.charset.Charset |
UTF_16_BE |
private static okio.ByteString |
UTF_16_BE_BOM |
private static java.nio.charset.Charset |
UTF_16_LE |
private static okio.ByteString |
UTF_16_LE_BOM |
private static java.nio.charset.Charset |
UTF_32_BE |
private static okio.ByteString |
UTF_32_BE_BOM |
private static java.nio.charset.Charset |
UTF_32_LE |
private static okio.ByteString |
UTF_32_LE_BOM |
static java.nio.charset.Charset |
UTF_8 |
private static okio.ByteString |
UTF_8_BOM |
private static java.util.regex.Pattern |
VERIFY_AS_IP_ADDRESS
Quick and dirty pattern to differentiate IP addresses from hostnames.
|
Modifier | Constructor and Description |
---|---|
private |
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.AssertionError |
assertionError(java.lang.String message,
java.lang.Exception e) |
static java.nio.charset.Charset |
bomAwareCharset(okio.BufferedSource source,
java.nio.charset.Charset charset) |
static java.lang.String |
canonicalizeHost(java.lang.String host)
If
host is an IP address, this returns the IP address in canonical form. |
static int |
checkDuration(java.lang.String name,
long duration,
java.util.concurrent.TimeUnit unit) |
static void |
checkOffsetAndCount(long arrayLength,
long offset,
long count) |
static void |
closeQuietly(java.io.Closeable closeable)
Closes
closeable , ignoring any checked exceptions. |
static void |
closeQuietly(java.net.ServerSocket serverSocket)
Closes
serverSocket , ignoring any checked exceptions. |
static void |
closeQuietly(java.net.Socket socket)
Closes
socket , ignoring any checked exceptions. |
static java.lang.String[] |
concat(java.lang.String[] array,
java.lang.String value) |
private static boolean |
containsInvalidHostnameAsciiCodes(java.lang.String hostnameAscii) |
static int |
decodeHexDigit(char c) |
private static boolean |
decodeIpv4Suffix(java.lang.String input,
int pos,
int limit,
byte[] address,
int addressOffset)
Decodes an IPv4 address suffix of an IPv6 address, like 1111::5555:6666:192.168.0.1.
|
private static java.net.InetAddress |
decodeIpv6(java.lang.String input,
int pos,
int limit)
Decodes an IPv6 address like 1111:2222:3333:4444:5555:6666:7777:8888 or ::1.
|
static int |
delimiterOffset(java.lang.String input,
int pos,
int limit,
char delimiter)
Returns the index of the first character in
input that is delimiter . |
static int |
delimiterOffset(java.lang.String input,
int pos,
int limit,
java.lang.String delimiters)
Returns the index of the first character in
input that contains a character in delimiters . |
static boolean |
discard(okio.Source source,
int timeout,
java.util.concurrent.TimeUnit timeUnit)
Attempts to exhaust
source , returning true if successful. |
static boolean |
equal(java.lang.Object a,
java.lang.Object b)
Returns true if two possibly-null objects are equal.
|
static java.lang.String |
format(java.lang.String format,
java.lang.Object... args)
Returns a
Locale.US formatted String . |
static java.lang.String |
hostHeader(HttpUrl url,
boolean includeDefaultPort) |
static <T> java.util.List<T> |
immutableList(java.util.List<T> list)
Returns an immutable copy of
list . |
static <T> java.util.List<T> |
immutableList(T... elements)
Returns an immutable list containing
elements . |
static int |
indexOf(java.util.Comparator<java.lang.String> comparator,
java.lang.String[] array,
java.lang.String value) |
static int |
indexOfControlOrNonAscii(java.lang.String input)
Returns the index of the first character in input that is either a control character
(like
|