public class IOUtils
extends java.lang.Object
This class contains optimized methods for:
All methods in this class are static and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
(package private) static int |
ALSE |
(package private) static long |
ALSE_64 |
static int[] |
DIGITS_K_32 |
static long[] |
DIGITS_K_64 |
static long |
DOT_X0 |
(package private) static short |
DOT_ZERO_16 |
(package private) static int |
DOT_ZERO_32 |
private static byte[] |
MIN_LONG_BYTES |
private static char[] |
MIN_LONG_CHARS |
(package private) static int |
NULL_32 |
(package private) static long |
NULL_64 |
static short[] |
PACKED_DIGITS |
static int[] |
PACKED_DIGITS_UTF16 |
(package private) static long[] |
POWER_TEN |
(package private) static int[] |
sizeTable |
(package private) static int |
TRUE |
(package private) static long |
TRUE_64 |
(package private) static short |
ZERO_DOT_16 |
(package private) static int |
ZERO_DOT_32 |
private static short |
ZERO_DOT_LATIN1 |
(package private) static short |
ZERO_ZERO_16 |
(package private) static int |
ZERO_ZERO_32 |
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(java.io.Closeable x)
Safely closes a Closeable resource, ignoring any exceptions that may occur.
|
static int |
convEndian(boolean big,
int n)
Converts an integer value between big-endian and little-endian byte orders.
|
static long |
convEndian(boolean big,
long n)
Converts a long value between big-endian and little-endian byte orders.
|
(package private) static short |
convEndian(boolean big,
short n) |
static int |
decodeUTF8(byte[] src,
int off,
int len,
byte[] dst)
Decodes UTF-8 encoded byte array to a UTF-16 byte array.
|
static int |
decodeUTF8(byte[] src,
int off,
int len,
char[] dst)
Decodes UTF-8 encoded byte array to a character array.
|
static int |
digit(int d)
Validates if the specified integer value represents a single digit (0-9).
|
static int |
digit1(byte[] buf,
int off)
Extracts a single digit from a byte array at the specified offset.
|
static int |
digit1(char[] buf,
int off)
Extracts a single digit from a character array at the specified offset.
|
static int |
digit2(byte[] buf,
int off)
Extracts a 2-digit number from a byte array at the specified offset.
|
static int |
digit2(char[] buf,
int off)
Extracts a 2-digit number from a character array at the specified offset.
|
static int |
digit3(byte[] buf,
int off)
Extracts a 3-digit number from a byte array at the specified offset.
|
static int |
digit3(char[] buf,
int off)
Extracts a 3-digit number from a character array at the specified offset.
|
private static int |
digit3(int x)
Extracts a 3-digit number from an integer value.
|
static int |
digit4(byte[] buf,
int off)
Extracts a 4-digit number from a byte array at the specified offset.
|
static int |
digit4(char[] buf,
int off)
Extracts a 4-digit number from a character array at the specified offset.
|
private static int |
digit4(int x)
Extracts a 4-digit number from an integer value.
|
private static short |
digitPair(int value) |
static int |
encodeUTF8(byte[] src,
int offset,
int len,
byte[] dst,
int dp)
Encodes a UTF-16 byte array to UTF-8 byte array.
|
static int |
encodeUTF8(char[] src,
int offset,
int len,
byte[] dst,
int dp)
Encodes a UTF-16 character array to UTF-8 byte array.
|
static byte |
getByte(byte[] buf,
int pos)
Gets a byte value from a byte array at the specified position.
|
static char |
getChar(byte[] buf,
int pos)
Gets a character value from a byte array at the specified position.
|
static char |
getChar(char[] buf,
int pos)
Gets a character value from a character array at the specified position.
|
static void |
getChars(int i,
int index,
byte[] buf)
Converts an integer to its character representation and writes it to a byte array.
|
static void |
getChars(int i,
int index,
char[] buf)
Converts an integer to its character representation and writes it to a character array.
|
static void |
getChars(long i,
int index,
byte[] buf)
Converts a long integer to its character representation and writes it to a byte array.
|
static void |
getChars(long i,
int index,
char[] buf)
Converts a long integer to its character representation and writes it to a character array.
|
static int |
getIntBE(byte[] buf,
int offset)
Gets an int value from a byte array at the specified offset in big-endian byte order.
|
static int |
getIntLE(byte[] buf,
int offset)
Gets an int value from a byte array at the specified offset in little-endian byte order.
|
static int |
getIntLE(char[] buf,
int offset)
Gets an int value from a character array at the specified offset in little-endian byte order.
|
static int |
getIntUnaligned(byte[] buf,
int offset)
Gets an int value from a byte array at the specified offset without alignment considerations.
|
static int |
getIntUnaligned(char[] buf,
int offset)
Gets an int value from a character array at the specified offset without alignment considerations.
|
static long |
getLongBE(byte[] buf,
int offset)
Gets a long value from a byte array at the specified offset in big-endian byte order.
|
static long |
getLongLE(byte[] buf,
int offset)
Gets a long value from a byte array at the specified offset in little-endian byte order.
|
static long |
getLongLE(char[] buf,
int offset)
Gets a long value from a character array at the specified offset in little-endian byte order.
|
static long |
getLongUnaligned(byte[] buf,
int offset)
Gets a long value from a byte array at the specified offset without alignment considerations.
|
static long |
getLongUnaligned(char[] buf,
int offset)
Gets a long value from a character array at the specified offset without alignment considerations.
|
static short |
getShortBE(byte[] buf,
int offset)
Gets a short value from a byte array at the specified offset in big-endian byte order.
|
static short |
getShortLE(byte[] buf,
int offset)
Gets a short value from a byte array at the specified offset in little-endian byte order.
|
static short |
getShortUnaligned(byte[] buf,
int offset)
Gets a short value from a byte array at the specified offset without alignment considerations.
|
static short |
hex2(int i)
Converts a 2-digit hexadecimal value to its character representation.
|
static short |
hex2U(int i)
Converts a 2-digit hexadecimal value to its uppercase character representation.
|
static int |
hex4U(int i)
Converts a 4-digit hexadecimal value to its uppercase character representation.
|
static int |
hexDigit4(byte[] buf,
int offset)
Extracts a 4-digit hexadecimal number from a byte array at the specified offset.
|
static int |
hexDigit4(byte[] buf,
int offset,
int end) |
static int |
hexDigit4(char[] buf,
int offset)
Extracts a 4-digit hexadecimal number from a character array at the specified offset.
|
static int |
hexDigit4(char[] buf,
int offset,
int end) |
static int |
indexOfChar(byte[] buf,
int ch,
int fromIndex,
int max)
Finds the index of a character in a byte array.
|
static int |
indexOfChar(char[] buf,
int ch,
int fromIndex,
int max)
Finds the index of a character in a character array.
|
static int |
indexOfDoubleQuote(byte[] buf,
int fromIndex,
int max)
Finds the index of a double quote character in a byte array.
|
static int |
indexOfDoubleQuoteV(byte[] buf,
int fromIndex,
int max)
Finds the index of a double quote character in a byte array using vectorized operations.
|
static int |
indexOfLineSeparator(byte[] buf,
int fromIndex,
int max)
Finds the index of a line separator character in a byte array.
|
static int |
indexOfLineSeparatorV(byte[] buf,
int fromIndex,
int max)
Finds the index of a line separator character in a byte array using vectorized operations.
|
static int |
indexOfQuote(byte[] buf,
int quote,
int fromIndex,
int max)
Finds the index of a quote character in a byte array.
|
static int |
indexOfQuoteV(byte[] buf,
int quote,
int fromIndex,
int max)
Finds the index of a quote character in a byte array using vectorized operations.
|
static int |
indexOfSlash(byte[] buf,
int fromIndex,
int max)
Finds the index of a slash character in a byte array.
|
static int |
indexOfSlashV(byte[] buf,
int fromIndex,
int max)
Finds the index of a slash character in a byte array using vectorized operations.
|
static boolean |
isALSE(byte[] buf,
int pos)
Checks if the specified position in a byte array contains the string "alse".
|
static boolean |
isALSE(char[] buf,
int pos)
Checks if the specified position in a character array contains the string "alse".
|
static boolean |
isASCII(byte[] buf)
Checks if a byte array contains only ASCII characters.
|
static boolean |
isASCII(byte[] buf,
int off,
int len)
Checks if a byte array segment contains only ASCII characters.
|
static boolean |
isASCII(java.lang.String str)
Checks if a string contains only ASCII characters.
|
static boolean |
isDigit(int ch)
Checks if the specified character is a digit (0-9).
|
static boolean |
isDigit2(char[] buf,
int off)
Checks if the 2 characters at the specified offset in a character array represent valid digits.
|
private static boolean |
isDigitLatin1(int c) |
static boolean |
isLatin1(char[] buf,
int off,
int len)
Checks if a character array segment contains only Latin-1 characters.
|
static boolean |
isNonSlashASCII(byte[] buf,
int off,
int len)
Checks if a byte array segment contains only ASCII characters and no backslash characters.
|
static boolean |
isNULL(byte[] buf,
int pos)
Checks if the specified position in a byte array contains the string "null".
|
static boolean |
isNULL(char[] buf,
int pos)
Checks if the specified position in a character array contains the string "null".
|
static boolean |
isNumber(byte[] buf,
int off,
int len)
Checks if the byte array segment represents a valid number.
|
static boolean |
isNumber(char[] buf,
int off,
int len)
Checks if the character array segment represents a valid number.
|
static boolean |
isNumber(java.lang.String str)
Checks if the given string represents a valid number.
|
static boolean |
isUTF8BOM(byte[] buf,
int off)
Checks if the specified position in a byte array contains a UTF-8 Byte Order Mark (BOM).
|
static long |
lines(java.io.File file)
Counts the number of lines in a file.
|
static long |
lines(java.io.InputStream in)
Counts the number of lines in an InputStream.
|
private static long |
mergeInt64(int v1,
int v2) |
static boolean |
notALSE(byte[] buf,
int pos)
Checks if the specified position in a byte array does not contain the string "alse".
|
static boolean |
notALSE(char[] buf,
int pos)
Checks if the specified position in a character array does not contain the string "alse".
|
private static boolean |
notContains(long value,
long vector) |
static boolean |
notNULL(byte[] buf,
int pos)
Checks if the specified position in a byte array does not contain the string "null".
|
static boolean |
notNULL(char[] buf,
int pos)
Checks if the specified position in a character array does not contain the string "null".
|
static boolean |
notTRUE(byte[] buf,
int pos)
Checks if the specified position in a byte array does not contain the string "true".
|
static boolean |
notTRUE(char[] buf,
int pos)
Checks if the specified position in a character array does not contain the string "true".
|
(package private) static JSONException |
outOfBoundsCheckFromToIndex(int offset,
int end) |
static int |
parseInt(byte[] buf,
int off,
int len)
Parses an integer value from a byte array segment.
|
static int |
putBoolean(byte[] buf,
int off,
boolean v)
Writes a boolean value to a byte array as a string representation.
|
static int |
putBoolean(char[] buf,
int off,
boolean v)
Writes a boolean value to a character array as a string representation.
|
private static void |
putByte(byte[] buf,
int pos,
byte v) |
private static void |
putChar(char[] buf,
int pos,
char v) |
static void |
putIntBE(byte[] buf,
int pos,
int v)
Writes an int value to a byte array in big-endian byte order.
|
static void |
putIntLE(byte[] buf,
int pos,
int v)
Writes an int value to a byte array in little-endian byte order.
|
static void |
putIntLE(char[] buf,
int pos,
int v)
Writes an int value to a character array in little-endian byte order.
|
static void |
putIntUnaligned(byte[] buf,
int pos,
int v)
Writes an int value to a byte array without alignment considerations.
|
static void |
putIntUnaligned(char[] buf,
int pos,
int v)
Writes an int value to a character array without alignment considerations.
|
static void |
putLongBE(byte[] buf,
int pos,
long v)
Writes a long value to a byte array in big-endian byte order.
|
static void |
putLongLE(byte[] buf,
int pos,
long v)
Writes a long value to a byte array in little-endian byte order.
|
static void |
putLongLE(char[] buf,
int pos,
long v)
Writes a long value to a character array in little-endian byte order.
|
static void |
putLongUnaligned(byte[] buf,
int pos,
long v)
Writes a long value to a byte array without alignment considerations.
|
static void |
putLongUnaligned(char[] buf,
int pos,
long v)
Writes a long value to a character array without alignment considerations.
|
static void |
putNULL(byte[] buf,
int pos)
Writes the string "null" to a byte array at the specified position.
|
static void |
putNULL(char[] buf,
int pos)
Writes the string "null" to a character array at the specified position.
|
static void |
putShortBE(byte[] buf,
int pos,
short v)
Writes a short value to a byte array in big-endian byte order.
|
static void |
putShortLE(byte[] buf,
int pos,
short v)
Writes a short value to a byte array in little-endian byte order.
|
static void |
putShortUnaligned(byte[] buf,
int pos,
short v)
Writes a short value to a byte array without alignment considerations.
|
static boolean |
regionMatches(byte[] bytes,
int off,
java.lang.String prefix)
Checks if a byte array region matches a prefix string.
|
private static int |
reverseBytesExpand(int i) |
static int |
stringSize(int x)
Calculates the string size (number of digits) needed to represent an integer value.
|
static int |
stringSize(long x)
Calculates the string size (number of digits) needed to represent a long value.
|
static int |
utf16Hex2(int i)
Converts a 2-digit hexadecimal value to its UTF-16 character representation.
|
static long |
utf16Hex4U(long i)
Converts a 4-digit hexadecimal value to its uppercase UTF-16 character representation.
|
private static long |
utf16ReverseBytesExpand(long i) |
private static void |
utf8_char2(byte[] src,
int offset,
int sl,
char c,
byte[] dst,
int dp) |
private static void |
utf8_char2(char[] src,
int offset,
int sl,
char c,
byte[] dst,
int dp) |
static int |
writeDecimal(byte[] buf,
int off,
long unscaledVal,
int scale)
Writes a decimal number to a byte array buffer
|
static int |
writeDecimal(char[] buf,
int off,
long unscaledVal,
int scale)
Writes a decimal number to a character array buffer
|
static void |
writeDigitPair(byte[] buf,
int charPos,
int value)
Writes a pair of digits to a byte array at the specified position.
|
static void |
writeDigitPair(char[] buf,
int charPos,
int value)
Writes a pair of digits to a character array at the specified position.
|
static int |
writeInt16(byte[] buf,
int pos,
short value)
Writes a 16-bit short value as an integer to a byte array.
|
static int |
writeInt16(char[] buf,
int pos,
short value)
Writes a 16-bit short value as an integer to a character array.
|
private static int |
writeInt3(byte[] buf,
int off,
int val) |
private static int |
writeInt3(char[] buf,
int off,
int val) |
static int |
writeInt32(byte[] buf,
int off,
long val)
Writes a 32-bit integer value to a byte array.
|
static int |
writeInt32(char[] buf,
int off,
long val)
Writes a 32-bit integer value to a character array.
|
private static int |
writeInt4(byte[] buf,
int off,
int v) |
private static int |
writeInt4(char[] buf,
int off,
int v) |
static int |
writeInt64(byte[] buf,
int off,
long val)
Writes a 64-bit long integer value to a byte array.
|
static int |
writeInt64(char[] buf,
int off,
long val)
Writes a 64-bit long integer value to a character array.
|
static int |
writeInt8(byte[] buf,
int pos,
byte value)
Writes an 8-bit byte value as an integer to a byte array.
|
private static int |
writeInt8(byte[] buf,
int off,
int v1,
int v2) |
static int |
writeInt8(char[] buf,
int pos,
byte value)
Writes an 8-bit byte value as an integer to a character array.
|
private static int |
writeInt8(char[] buf,
int off,
int v1,
int v2) |
static int |
writeLocalDate(byte[] buf,
int off,
int year,
int month,
int dayOfMonth)
Writes a LocalDate value to a byte array in ISO8601 format (yyyy-MM-dd).
|
static int |
writeLocalDate(char[] buf,
int off,
int year,
int month,
int dayOfMonth)
Writes a LocalDate value to a character array in ISO8601 format (yyyy-MM-dd).
|
static void |
writeLocalTime(byte[] buf,
int off,
int hour,
int minute,
int second)
Writes a LocalTime value to a byte array in ISO8601 format (HH:mm:ss).
|
static int |
writeLocalTime(byte[] buf,
int off,
java.time.LocalTime time)
Writes a LocalTime value to a byte array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]).
|
static void |
writeLocalTime(char[] buf,
int off,
int hour,
int minute,
int second)
Writes a LocalTime value to a character array in ISO8601 format (HH:mm:ss).
|
static int |
writeLocalTime(char[] buf,
int off,
java.time.LocalTime time)
Writes a LocalTime value to a character array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]).
|
static int |
writeNano(byte[] buf,
int off,
int nano)
Writes nanosecond values to a byte array.
|
static int |
writeNano(char[] buf,
int off,
int nano)
Writes nanosecond values to a character array.
|
static final short DOT_ZERO_16
static final int DOT_ZERO_32
static final short ZERO_DOT_16
static final int ZERO_DOT_32
static final short ZERO_ZERO_16
static final int ZERO_ZERO_32
static final int NULL_32
static final long NULL_64
static final int TRUE
static final long TRUE_64
static final int ALSE
static final long ALSE_64
public static final long DOT_X0
static final int[] sizeTable
public static final int[] DIGITS_K_32
public static final long[] DIGITS_K_64
private static final byte[] MIN_LONG_BYTES
private static final char[] MIN_LONG_CHARS
public static final short[] PACKED_DIGITS
public static final int[] PACKED_DIGITS_UTF16
static final long[] POWER_TEN
private static final short ZERO_DOT_LATIN1
private static short digitPair(int value)
public static void writeDigitPair(byte[] buf,
int charPos,
int value)
buf - the byte array buffer to write tocharPos - the position in the buffer where to write the digit pairvalue - the value (0-99) to write as a digit pairpublic static void writeDigitPair(char[] buf,
int charPos,
int value)
buf - the character array buffer to write tocharPos - the position in the buffer where to write the digit pairvalue - the value (0-99) to write as a digit pairpublic static int stringSize(int x)
x - the integer value to calculate the string size forpublic static int stringSize(long x)
x - the long value to calculate the string size forpublic static void getChars(int i,
int index,
byte[] buf)
i - the integer value to convertindex - the starting index in the buffer where to write the charactersbuf - the byte array buffer to write the characters topublic static void getChars(int i,
int index,
char[] buf)
i - the integer value to convertindex - the starting index in the buffer where to write the charactersbuf - the character array buffer to write the characters topublic static void getChars(long i,
int index,
byte[] buf)
i - the long integer value to convertindex - the starting index in the buffer where to write the charactersbuf - the byte array buffer to write the characters topublic static void getChars(long i,
int index,
char[] buf)
i - the long integer value to convertindex - the starting index in the buffer where to write the charactersbuf - the character array buffer to write the characters topublic static int writeDecimal(byte[] buf,
int off,
long unscaledVal,
int scale)
buf - byte array bufferoff - buffer starting offsetunscaledVal - unscaled value (precision part of BigDecimal)scale - number of digits after the decimal point, caller must ensure scale >= 0public static int writeDecimal(char[] buf,
int off,
long unscaledVal,
int scale)
buf - character array bufferoff - buffer starting offsetunscaledVal - unscaled value (precision part of BigDecimal)scale - number of digits after the decimal point, caller must ensure scale >= 0public static int encodeUTF8(byte[] src,
int offset,
int len,
byte[] dst,
int dp)
src - the source byte array containing UTF-16 encoded dataoffset - the starting offset in the source arraylen - the number of bytes to encode from the source arraydst - the destination byte array to write UTF-8 encoded data todp - the starting position in the destination arraypublic static int encodeUTF8(char[] src,
int offset,
int len,
byte[] dst,
int dp)
src - the source character arrayoffset - the starting offset in the source arraylen - the number of characters to encode from the source arraydst - the destination byte array to write UTF-8 encoded data todp - the starting position in the destination arrayprivate static void utf8_char2(byte[] src,
int offset,
int sl,
char c,
byte[] dst,
int dp)
private static void utf8_char2(char[] src,
int offset,
int sl,
char c,
byte[] dst,
int dp)
public static boolean isNumber(java.lang.String str)
str - the string to checkpublic static boolean isNumber(char[] buf,
int off,
int len)
buf - the character array to checkoff - the starting offset in the arraylen - the number of characters to checkpublic static boolean isNumber(byte[] buf,
int off,
int len)
buf - the byte array to checkoff - the starting offset in the arraylen - the number of bytes to checkpublic static void close(java.io.Closeable x)
x - the Closeable resource to close, can be nullpublic static int decodeUTF8(byte[] src,
int off,
int len,
byte[] dst)
src - the source byte array containing UTF-8 encoded dataoff - the starting offset in the source arraylen - the number of bytes to decode from the source arraydst - the destination byte array to write UTF-16 encoded data topublic static int decodeUTF8(byte[] src,
int off,
int len,
char[] dst)
src - the source byte array containing UTF-8 encoded dataoff - the starting offset in the source arraylen - the number of bytes to decode from the source arraydst - the destination character array to write decoded characters topublic static long lines(java.io.File file)
throws java.lang.Exception
file - the File to count lines injava.lang.Exception - if an I/O error occurs while reading the filepublic static long lines(java.io.InputStream in)
throws java.lang.Exception
in - the InputStream to count lines injava.lang.Exception - if an I/O error occurs while reading the streampublic static int writeLocalDate(byte[] buf,
int off,
int year,
int month,
int dayOfMonth)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingyear - the year component of the datemonth - the month component of the date (1-12)dayOfMonth - the day component of the date (1-31)public static int writeLocalDate(char[] buf,
int off,
int year,
int month,
int dayOfMonth)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingyear - the year component of the datemonth - the month component of the date (1-12)dayOfMonth - the day component of the date (1-31)public static void writeLocalTime(byte[] buf,
int off,
int hour,
int minute,
int second)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writinghour - the hour component of the time (0-23)minute - the minute component of the time (0-59)second - the second component of the time (0-59)public static int writeLocalTime(byte[] buf,
int off,
java.time.LocalTime time)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingtime - the LocalTime object to writepublic static int writeNano(byte[] buf,
int off,
int nano)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingnano - the nanosecond value to write (0-999,999,999)public static int writeNano(char[] buf,
int off,
int nano)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingnano - the nanosecond value to write (0-999,999,999)public static void writeLocalTime(char[] buf,
int off,
int hour,
int minute,
int second)
buf - the character array buffer to write tooff - the offset in the buffer where to start writinghour - the hour component of the time (0-23)minute - the minute component of the time (0-59)second - the second component of the time (0-59)public static int writeLocalTime(char[] buf,
int off,
java.time.LocalTime time)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingtime - the LocalTime object to writeprivate static int writeInt4(byte[] buf,
int off,
int v)
private static int writeInt4(char[] buf,
int off,
int v)
private static long mergeInt64(int v1,
int v2)
private static int writeInt3(byte[] buf,
int off,
int val)
private static int writeInt3(char[] buf,
int off,
int val)
private static int writeInt8(byte[] buf,
int off,
int v1,
int v2)
private static int writeInt8(char[] buf,
int off,
int v1,
int v2)
public static int writeInt64(byte[] buf,
int off,
long val)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingval - the long integer value to writepublic static int writeInt64(char[] buf,
int off,
long val)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingval - the long integer value to writepublic static int writeInt8(byte[] buf,
int pos,
byte value)
buf - the byte array buffer to write topos - the position in the buffer where to start writingvalue - the byte value to write as an integerpublic static int writeInt8(char[] buf,
int pos,
byte value)
buf - the character array buffer to write topos - the position in the buffer where to start writingvalue - the byte value to write as an integerpublic static int writeInt16(byte[] buf,
int pos,
short value)
buf - the byte array buffer to write topos - the position in the buffer where to start writingvalue - the short value to write as an integerpublic static int writeInt16(char[] buf,
int pos,
short value)
buf - the character array buffer to write topos - the position in the buffer where to start writingvalue - the short value to write as an integerpublic static int writeInt32(byte[] buf,
int off,
long val)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingval - the long value to write as an integerpublic static int writeInt32(char[] buf,
int off,
long val)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingval - the long value to write as an integerpublic static byte getByte(byte[] buf,
int pos)
buf - the byte array buffer to read frompos - the position in the buffer where to read the byte valuepublic static char getChar(char[] buf,
int pos)
buf - the character array buffer to read frompos - the position in the buffer where to read the character valuepublic static char getChar(byte[] buf,
int pos)
buf - the byte array buffer to read frompos - the position in the buffer where to read the character valueprivate static void putByte(byte[] buf,
int pos,
byte v)
private static void putChar(char[] buf,
int pos,
char v)
public static void putShortBE(byte[] buf,
int pos,
short v)
buf - the byte array buffer to write topos - the position in the buffer where to write the short valuev - the short value to writepublic static void putShortLE(byte[] buf,
int pos,
short v)
buf - the byte array buffer to write topos - the position in the buffer where to write the short valuev - the short value to writepublic static void putIntBE(byte[] buf,
int pos,
int v)
buf - the byte array buffer to write topos - the position in the buffer where to write the int valuev - the int value to writepublic static void putIntLE(byte[] buf,
int pos,
int v)
buf - the byte array buffer to write topos - the position in the buffer where to write the int valuev - the int value to writepublic static void putIntLE(char[] buf,
int pos,
int v)
buf - the character array buffer to write topos - the position in the buffer where to write the int valuev - the int value to writepublic static void putShortUnaligned(byte[] buf,
int pos,
short v)
buf - the byte array buffer to write topos - the position in the buffer where to write the short valuev - the short value to writepublic static void putIntUnaligned(char[] buf,
int pos,
int v)
buf - the character array buffer to write topos - the position in the buffer where to write the int valuev - the int value to writepublic static void putIntUnaligned(byte[] buf,
int pos,
int v)
buf - the byte array buffer to write topos - the position in the buffer where to write the int valuev - the int value to writepublic static void putLongLE(char[] buf,
int pos,
long v)
buf - the character array buffer to write topos - the position in the buffer where to write the long valuev - the long value to writepublic static void putLongUnaligned(char[] buf,
int pos,
long v)
buf - the character array buffer to write topos - the position in the buffer where to write the long valuev - the long value to writepublic static void putLongUnaligned(byte[] buf,
int pos,
long v)
buf - the byte array buffer to write topos - the position in the buffer where to write the long valuev - the long value to writepublic static void putLongBE(byte[] buf,
int pos,
long v)
buf - the byte array buffer to write topos - the position in the buffer where to write the long valuev - the long value to writepublic static void putLongLE(byte[] buf,
int pos,
long v)
buf - the byte array buffer to write topos - the position in the buffer where to write the long valuev - the long value to writepublic static int putBoolean(byte[] buf,
int off,
boolean v)
buf - the byte array buffer to write tooff - the offset in the buffer where to start writingv - the boolean value to writepublic static int putBoolean(char[] buf,
int off,
boolean v)
buf - the character array buffer to write tooff - the offset in the buffer where to start writingv - the boolean value to writepublic static boolean isALSE(byte[] buf,
int pos)
buf - the byte array buffer to checkpos - the position in the buffer to checkpublic static boolean notALSE(byte[] buf,
int pos)
buf - the byte array buffer to checkpos - the position in the buffer to checkpublic static boolean isALSE(char[] buf,
int pos)
buf - the character array buffer to checkpos - the position in the buffer to checkpublic static boolean notALSE(char[] buf,
int pos)
buf - the character array buffer to checkpos - the position in the buffer to checkpublic static boolean isNULL(byte[] buf,
int pos)
buf - the byte array buffer to checkpos - the position in the buffer to checkpublic static boolean notNULL(byte[] buf,
int pos)
buf - the byte array buffer to checkpos - the position in the buffer to checkpublic static boolean notTRUE(byte[] buf,
int pos)
buf - the byte array buffer to checkpos - the position in the buffer to checkpublic static boolean notTRUE(char[] buf,
int pos)
buf - the character array buffer to checkpos - the position in the buffer to checkpublic static boolean isNULL(char[] buf,
int pos)
buf - the character array buffer to checkpos - the position in the buffer to checkpublic static boolean notNULL(char[] buf,
int pos)
buf - the character array buffer to checkpos - the position in the buffer to checkpublic static void putNULL(byte[] buf,
int pos)
buf - the byte array buffer to write topos - the position in the buffer where to write "null"public static void putNULL(char[] buf,
int pos)
buf - the character array buffer to write topos - the position in the buffer where to write "null"public static int digit4(char[] buf,
int off)
buf - the character array to extract digits fromoff - the offset in the array where to start extractingpublic static int digit4(byte[] buf,
int off)
buf - the byte array to extract digits fromoff - the offset in the array where to start extractingprivate static int digit4(int x)
x - the integer containing packed digit informationpublic static int digit3(char[] buf,
int off)
buf - the character array to extract digits fromoff - the offset in the array where to start extractingpublic static int digit3(byte[] buf,
int off)
buf - the byte array to extract digits fromoff - the offset in the array where to start extractingprivate static int digit3(int x)
x - the integer containing packed digit informationpublic static int digit2(char[] buf,
int off)
buf - the character array to extract digits fromoff - the offset in the array where to start extractingpublic static int digit2(byte[] buf,
int off)
buf - the byte array to extract digits fromoff - the offset in the array where to start extractingpublic static boolean isDigit2(char[] buf,
int off)
buf - the character array to checkoff - the offset in the array where to start checkingpublic static int digit(int d)
d - the integer value to checkpublic static int digit1(char[] buf,
int off)
buf - the character array to extract the digit fromoff - the offset in the array where to extract the digitpublic static int digit1(byte[] buf,
int off)
buf - the byte array to extract the digit fromoff - the offset in the array where to extract the digitpublic static int indexOfQuote(byte[] buf,
int quote,
int fromIndex,
int max)
buf - the byte array to search inquote - the quote character to search for (either '\'' or '"')fromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfQuoteV(byte[] buf,
int quote,
int fromIndex,
int max)
buf - the byte array to search inquote - the quote character to search for (either '\'' or '"')fromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfDoubleQuote(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfDoubleQuoteV(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfLineSeparator(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfLineSeparatorV(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfSlash(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfSlashV(byte[] buf,
int fromIndex,
int max)
buf - the byte array to search infromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static boolean regionMatches(byte[] bytes,
int off,
java.lang.String prefix)
bytes - the byte array to checkoff - the offset in the byte array where to start checkingprefix - the string prefix to match againstpublic static int indexOfChar(byte[] buf,
int ch,
int fromIndex,
int max)
buf - the byte array to search inch - the character to search forfromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)public static int indexOfChar(char[] buf,
int ch,
int fromIndex,
int max)
buf - the character array to search inch - the character to search forfromIndex - the index to start searching frommax - the maximum index to search up to (exclusive)private static boolean notContains(long value,
long vector)
public static int hexDigit4(byte[] buf,
int offset,
int end)
static JSONException outOfBoundsCheckFromToIndex(int offset, int end)
public static int hexDigit4(byte[] buf,
int offset)
buf - the byte array to extract hexadecimal digits fromoffset - the offset in the array where to start extractingpublic static int hexDigit4(char[] buf,
int offset,
int end)
public static int hexDigit4(char[] buf,
int offset)
buf - the character array to extract hexadecimal digits fromoffset - the offset in the array where to start extractingpublic static boolean isDigit(int ch)
ch - the character to checkpublic static short getShortUnaligned(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the short valuepublic static short getShortBE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the short valuepublic static short getShortLE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the short valuepublic static boolean isUTF8BOM(byte[] buf,
int off)
buf - the byte array to checkoff - the offset in the array where to check for the BOMpublic static int getIntBE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the int valuepublic static int getIntLE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the int valuepublic static int getIntLE(char[] buf,
int offset)
buf - the character array to read fromoffset - the offset in the array where to read the int valuepublic static int getIntUnaligned(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the int valuepublic static int getIntUnaligned(char[] buf,
int offset)
buf - the character array to read fromoffset - the offset in the array where to read the int valuepublic static long getLongBE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the long valuepublic static long getLongUnaligned(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the long valuepublic static long getLongUnaligned(char[] buf,
int offset)
buf - the character array to read fromoffset - the offset in the array where to read the long valuepublic static long getLongLE(byte[] buf,
int offset)
buf - the byte array to read fromoffset - the offset in the array where to read the long valuepublic static long getLongLE(char[] buf,
int offset)
buf - the character array to read fromoffset - the offset in the array where to read the long valuepublic static short hex2(int i)
i - the packed 2-digit hexadecimal value to convertpublic static short hex2U(int i)
i - the packed 2-digit hexadecimal value to convertpublic static int utf16Hex2(int i)
i - the packed 2-digit hexadecimal value to convertpublic static int hex4U(int i)
i - the packed 4-digit hexadecimal value to convertpublic static long utf16Hex4U(long i)
i - the packed 4-digit hexadecimal value to convertprivate static int reverseBytesExpand(int i)
private static long utf16ReverseBytesExpand(long i)
public static int convEndian(boolean big,
int n)
big - true to convert to big-endian, false to convert to little-endiann - the integer value to convertpublic static long convEndian(boolean big,
long n)
big - true to convert to big-endian, false to convert to little-endiann - the long value to convertstatic short convEndian(boolean big,
short n)
public static boolean isLatin1(char[] buf,
int off,
int len)
buf - the character array to checkoff - the starting offset in the arraylen - the number of characters to checkpublic static boolean isASCII(java.lang.String str)
str - the string to checkpublic static boolean isASCII(byte[] buf)
buf - the byte array to checkpublic static boolean isASCII(byte[] buf,
int off,
int len)
buf - the byte array to checkoff - the starting offset in the arraylen - the number of bytes to checkpublic static boolean isNonSlashASCII(byte[] buf,
int off,
int len)
buf - the byte array to checkoff - the starting offset in the arraylen - the number of bytes to checkprivate static boolean isDigitLatin1(int c)
public static int parseInt(byte[] buf,
int off,
int len)
buf - the byte array containing the digit charactersoff - the starting offset in the arraylen - the number of bytes to parsejava.lang.NumberFormatException - if the byte array segment does not contain a valid integer representation