Package com.alibaba.fastjson2.util
Class IOUtils
java.lang.Object
com.alibaba.fastjson2.util.IOUtils
IOUtils is a utility class that provides various I/O operations and helper methods
for working with byte arrays, character arrays, and other data structures used in
FASTJSON2 for serialization and deserialization.
This class contains optimized methods for:
- Writing and reading primitive values to/from byte and character arrays
- Handling UTF-8 and UTF-16 encoding/decoding
- Working with date/time values
- Performing low-level memory operations
- Managing resource cleanup
All methods in this class are static and thread-safe.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int[]static final long[]static final longstatic final short[]static final int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidSafely closes a Closeable resource, ignoring any exceptions that may occur.static intconvEndian(boolean big, int n) Converts an integer value between big-endian and little-endian byte orders.static longconvEndian(boolean big, long n) Converts a long value between big-endian and little-endian byte orders.static intdecodeUTF8(byte[] src, int off, int len, byte[] dst) Decodes UTF-8 encoded byte array to a UTF-16 byte array.static intdecodeUTF8(byte[] src, int off, int len, char[] dst) Decodes UTF-8 encoded byte array to a character array.static intdigit(int d) Validates if the specified integer value represents a single digit (0-9).static intdigit1(byte[] buf, int off) Extracts a single digit from a byte array at the specified offset.static intdigit1(char[] buf, int off) Extracts a single digit from a character array at the specified offset.static intdigit2(byte[] buf, int off) Extracts a 2-digit number from a byte array at the specified offset.static intdigit2(char[] buf, int off) Extracts a 2-digit number from a character array at the specified offset.static intdigit3(byte[] buf, int off) Extracts a 3-digit number from a byte array at the specified offset.static intdigit3(char[] buf, int off) Extracts a 3-digit number from a character array at the specified offset.static intdigit4(byte[] buf, int off) Extracts a 4-digit number from a byte array at the specified offset.static intdigit4(char[] buf, int off) Extracts a 4-digit number from a character array at the specified offset.static intencodeUTF8(byte[] src, int offset, int len, byte[] dst, int dp) Encodes a UTF-16 byte array to UTF-8 byte array.static intencodeUTF8(char[] src, int offset, int len, byte[] dst, int dp) Encodes a UTF-16 character array to UTF-8 byte array.static bytegetByte(byte[] buf, int pos) Gets a byte value from a byte array at the specified position.static chargetChar(byte[] buf, int pos) Gets a character value from a byte array at the specified position.static chargetChar(char[] buf, int pos) Gets a character value from a character array at the specified position.static voidgetChars(int i, int index, byte[] buf) Converts an integer to its character representation and writes it to a byte array.static voidgetChars(int i, int index, char[] buf) Converts an integer to its character representation and writes it to a character array.static voidgetChars(long i, int index, byte[] buf) Converts a long integer to its character representation and writes it to a byte array.static voidgetChars(long i, int index, char[] buf) Converts a long integer to its character representation and writes it to a character array.static intgetIntBE(byte[] buf, int offset) Gets an int value from a byte array at the specified offset in big-endian byte order.static intgetIntLE(byte[] buf, int offset) Gets an int value from a byte array at the specified offset in little-endian byte order.static intgetIntLE(char[] buf, int offset) Gets an int value from a character array at the specified offset in little-endian byte order.static intgetIntUnaligned(byte[] buf, int offset) Gets an int value from a byte array at the specified offset without alignment considerations.static intgetIntUnaligned(char[] buf, int offset) Gets an int value from a character array at the specified offset without alignment considerations.static longgetLongBE(byte[] buf, int offset) Gets a long value from a byte array at the specified offset in big-endian byte order.static longgetLongLE(byte[] buf, int offset) Gets a long value from a byte array at the specified offset in little-endian byte order.static longgetLongLE(char[] buf, int offset) Gets a long value from a character array at the specified offset in little-endian byte order.static longgetLongUnaligned(byte[] buf, int offset) Gets a long value from a byte array at the specified offset without alignment considerations.static longgetLongUnaligned(char[] buf, int offset) Gets a long value from a character array at the specified offset without alignment considerations.static shortgetShortBE(byte[] buf, int offset) Gets a short value from a byte array at the specified offset in big-endian byte order.static shortgetShortLE(byte[] buf, int offset) Gets a short value from a byte array at the specified offset in little-endian byte order.static shortgetShortUnaligned(byte[] buf, int offset) Gets a short value from a byte array at the specified offset without alignment considerations.static shorthex2(int i) Converts a 2-digit hexadecimal value to its character representation.static shorthex2U(int i) Converts a 2-digit hexadecimal value to its uppercase character representation.static inthex4U(int i) Converts a 4-digit hexadecimal value to its uppercase character representation.static inthexDigit4(byte[] buf, int offset) Extracts a 4-digit hexadecimal number from a byte array at the specified offset.static inthexDigit4(char[] buf, int offset) Extracts a 4-digit hexadecimal number from a character array at the specified offset.static intindexOfChar(byte[] buf, int ch, int fromIndex, int max) Finds the index of a character in a byte array.static intindexOfChar(char[] buf, int ch, int fromIndex, int max) Finds the index of a character in a character array.static intindexOfDoubleQuote(byte[] buf, int fromIndex, int max) Finds the index of a double quote character in a byte array.static intindexOfDoubleQuoteV(byte[] buf, int fromIndex, int max) Finds the index of a double quote character in a byte array using vectorized operations.static intindexOfLineSeparator(byte[] buf, int fromIndex, int max) Finds the index of a line separator character in a byte array.static intindexOfLineSeparatorV(byte[] buf, int fromIndex, int max) Finds the index of a line separator character in a byte array using vectorized operations.static intindexOfQuote(byte[] buf, int quote, int fromIndex, int max) Finds the index of a quote character in a byte array.static intindexOfQuoteV(byte[] buf, int quote, int fromIndex, int max) Finds the index of a quote character in a byte array using vectorized operations.static intindexOfSlash(byte[] buf, int fromIndex, int max) Finds the index of a slash character in a byte array.static intindexOfSlashV(byte[] buf, int fromIndex, int max) Finds the index of a slash character in a byte array using vectorized operations.static booleanisALSE(byte[] buf, int pos) Checks if the specified position in a byte array contains the string "alse".static booleanisALSE(char[] buf, int pos) Checks if the specified position in a character array contains the string "alse".static booleanisASCII(byte[] buf) Checks if a byte array contains only ASCII characters.static booleanisASCII(byte[] buf, int off, int len) Checks if a byte array segment contains only ASCII characters.static booleanChecks if a string contains only ASCII characters.static booleanisDigit(int ch) Checks if the specified character is a digit (0-9).static booleanisDigit2(char[] buf, int off) Checks if the 2 characters at the specified offset in a character array represent valid digits.static booleanisLatin1(char[] buf, int off, int len) Checks if a character array segment contains only Latin-1 characters.static booleanisNonSlashASCII(byte[] buf, int off, int len) Checks if a byte array segment contains only ASCII characters and no backslash characters.static booleanisNULL(byte[] buf, int pos) Checks if the specified position in a byte array contains the string "null".static booleanisNULL(char[] buf, int pos) Checks if the specified position in a character array contains the string "null".static booleanisNumber(byte[] buf, int off, int len) Checks if the byte array segment represents a valid number.static booleanisNumber(char[] buf, int off, int len) Checks if the character array segment represents a valid number.static booleanChecks if the given string represents a valid number.static booleanisUTF8BOM(byte[] buf, int off) Checks if the specified position in a byte array contains a UTF-8 Byte Order Mark (BOM).static longCounts the number of lines in a file.static longlines(InputStream in) Counts the number of lines in an InputStream.static booleannotALSE(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "alse".static booleannotALSE(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "alse".static booleannotNULL(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "null".static booleannotNULL(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "null".static booleannotTRUE(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "true".static booleannotTRUE(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "true".static intparseInt(byte[] buf, int off, int len) Parses an integer value from a byte array segment.static intputBoolean(byte[] buf, int off, boolean v) Writes a boolean value to a byte array as a string representation.static intputBoolean(char[] buf, int off, boolean v) Writes a boolean value to a character array as a string representation.static voidputIntBE(byte[] buf, int pos, int v) Writes an int value to a byte array in big-endian byte order.static voidputIntLE(byte[] buf, int pos, int v) Writes an int value to a byte array in little-endian byte order.static voidputIntLE(char[] buf, int pos, int v) Writes an int value to a character array in little-endian byte order.static voidputIntUnaligned(byte[] buf, int pos, int v) Writes an int value to a byte array without alignment considerations.static voidputIntUnaligned(char[] buf, int pos, int v) Writes an int value to a character array without alignment considerations.static voidputLongBE(byte[] buf, int pos, long v) Writes a long value to a byte array in big-endian byte order.static voidputLongLE(byte[] buf, int pos, long v) Writes a long value to a byte array in little-endian byte order.static voidputLongLE(char[] buf, int pos, long v) Writes a long value to a character array in little-endian byte order.static voidputLongUnaligned(byte[] buf, int pos, long v) Writes a long value to a byte array without alignment considerations.static voidputLongUnaligned(char[] buf, int pos, long v) Writes a long value to a character array without alignment considerations.static voidputNULL(byte[] buf, int pos) Writes the string "null" to a byte array at the specified position.static voidputNULL(char[] buf, int pos) Writes the string "null" to a character array at the specified position.static voidputShortBE(byte[] buf, int pos, short v) Writes a short value to a byte array in big-endian byte order.static voidputShortLE(byte[] buf, int pos, short v) Writes a short value to a byte array in little-endian byte order.static voidputShortUnaligned(byte[] buf, int pos, short v) Writes a short value to a byte array without alignment considerations.static booleanregionMatches(byte[] bytes, int off, String prefix) Checks if a byte array region matches a prefix string.static intstringSize(int x) Calculates the string size (number of digits) needed to represent an integer value.static intstringSize(long x) Calculates the string size (number of digits) needed to represent a long value.static intutf16Hex2(int i) Converts a 2-digit hexadecimal value to its UTF-16 character representation.static longutf16Hex4U(long i) Converts a 4-digit hexadecimal value to its uppercase UTF-16 character representation.static intwriteDecimal(byte[] buf, int off, long unscaledVal, int scale) Writes a decimal number to a byte array bufferstatic intwriteDecimal(char[] buf, int off, long unscaledVal, int scale) Writes a decimal number to a character array bufferstatic voidwriteDigitPair(byte[] buf, int charPos, int value) Writes a pair of digits to a byte array at the specified position.static voidwriteDigitPair(char[] buf, int charPos, int value) Writes a pair of digits to a character array at the specified position.static intwriteInt16(byte[] buf, int pos, short value) Writes a 16-bit short value as an integer to a byte array.static intwriteInt16(char[] buf, int pos, short value) Writes a 16-bit short value as an integer to a character array.static intwriteInt32(byte[] buf, int off, long val) Writes a 32-bit integer value to a byte array.static intwriteInt32(char[] buf, int off, long val) Writes a 32-bit integer value to a character array.static intwriteInt64(byte[] buf, int off, long val) Writes a 64-bit long integer value to a byte array.static intwriteInt64(char[] buf, int off, long val) Writes a 64-bit long integer value to a character array.static intwriteInt8(byte[] buf, int pos, byte value) Writes an 8-bit byte value as an integer to a byte array.static intwriteInt8(char[] buf, int pos, byte value) Writes an 8-bit byte value as an integer to a character array.static intwriteLocalDate(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 intwriteLocalDate(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 voidwriteLocalTime(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 intwriteLocalTime(byte[] buf, int off, LocalTime time) Writes a LocalTime value to a byte array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]).static voidwriteLocalTime(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 intwriteLocalTime(char[] buf, int off, LocalTime time) Writes a LocalTime value to a character array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]).static intwriteNano(byte[] buf, int off, int nano) Writes nanosecond values to a byte array.static intwriteNano(char[] buf, int off, int nano) Writes nanosecond values to a character array.
-
Field Details
-
DOT_X0
public static final long DOT_X0 -
DIGITS_K_32
public static final int[] DIGITS_K_32 -
DIGITS_K_64
public static final long[] DIGITS_K_64 -
PACKED_DIGITS
public static final short[] PACKED_DIGITS -
PACKED_DIGITS_UTF16
public static final int[] PACKED_DIGITS_UTF16
-
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
writeDigitPair
public static void writeDigitPair(byte[] buf, int charPos, int value) Writes a pair of digits to a byte array at the specified position. This method is used for efficient digit pair writing during number formatting.- Parameters:
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 pair
-
writeDigitPair
public static void writeDigitPair(char[] buf, int charPos, int value) Writes a pair of digits to a character array at the specified position. This method is used for efficient digit pair writing during number formatting.- Parameters:
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 pair
-
stringSize
public static int stringSize(int x) Calculates the string size (number of digits) needed to represent an integer value. This method is used to determine the buffer size needed for number formatting.- Parameters:
x- the integer value to calculate the string size for- Returns:
- the number of digits needed to represent the integer value
-
stringSize
public static int stringSize(long x) Calculates the string size (number of digits) needed to represent a long value. This method is used to determine the buffer size needed for number formatting.- Parameters:
x- the long value to calculate the string size for- Returns:
- the number of digits needed to represent the long value
-
getChars
public static void getChars(int i, int index, byte[] buf) Converts an integer to its character representation and writes it to a byte array. This method handles negative numbers and optimizes digit conversion by processing two digits at a time when possible.- Parameters:
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 to
-
getChars
public static void getChars(int i, int index, char[] buf) Converts an integer to its character representation and writes it to a character array. This method handles negative numbers and optimizes digit conversion by processing two digits at a time when possible.- Parameters:
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 to
-
getChars
public static void getChars(long i, int index, byte[] buf) Converts a long integer to its character representation and writes it to a byte array. This method handles negative numbers and optimizes digit conversion by processing two digits at a time when possible, switching to int-based processing when the value fits in an integer.- Parameters:
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 to
-
getChars
public static void getChars(long i, int index, char[] buf) Converts a long integer to its character representation and writes it to a character array. This method handles negative numbers and optimizes digit conversion by processing two digits at a time when possible, switching to int-based processing when the value fits in an integer.- Parameters:
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 to
-
writeDecimal
public static int writeDecimal(byte[] buf, int off, long unscaledVal, int scale) Writes a decimal number to a byte array buffer- Parameters:
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 >= 0- Returns:
- offset after writing Note: This method trusts that the caller has ensured scale >= 0
-
writeDecimal
public static int writeDecimal(char[] buf, int off, long unscaledVal, int scale) Writes a decimal number to a character array buffer- Parameters:
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 >= 0- Returns:
- offset after writing Note: This method trusts that the caller has ensured scale >= 0
-
encodeUTF8
public static int encodeUTF8(byte[] src, int offset, int len, byte[] dst, int dp) Encodes a UTF-16 byte array to UTF-8 byte array. This method converts characters from a source byte array (containing UTF-16 encoded data) to a destination byte array in UTF-8 encoding format.- Parameters:
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 array- Returns:
- the updated position in the destination array after encoding
-
encodeUTF8
public static int encodeUTF8(char[] src, int offset, int len, byte[] dst, int dp) Encodes a UTF-16 character array to UTF-8 byte array. This method converts characters from a source character array to a destination byte array in UTF-8 encoding format, with optimized handling for ASCII characters.- Parameters:
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 array- Returns:
- the updated position in the destination array after encoding
-
isNumber
Checks if the given string represents a valid number. A valid number may have an optional leading '+' or '-' sign, followed by one or more digits.- Parameters:
str- the string to check- Returns:
- true if the string represents a valid number, false otherwise
-
isNumber
public static boolean isNumber(char[] buf, int off, int len) Checks if the character array segment represents a valid number. A valid number may have an optional leading '+' or '-' sign, followed by one or more digits.- Parameters:
buf- the character array to checkoff- the starting offset in the arraylen- the number of characters to check- Returns:
- true if the character array segment represents a valid number, false otherwise
-
isNumber
public static boolean isNumber(byte[] buf, int off, int len) Checks if the byte array segment represents a valid number. A valid number may have an optional leading '+' or '-' sign, followed by one or more digits.- Parameters:
buf- the byte array to checkoff- the starting offset in the arraylen- the number of bytes to check- Returns:
- true if the byte array segment represents a valid number, false otherwise
-
close
Safely closes a Closeable resource, ignoring any exceptions that may occur. This method is a utility to close resources without having to handle IOException or other exceptions.- Parameters:
x- the Closeable resource to close, can be null
-
decodeUTF8
public static int decodeUTF8(byte[] src, int off, int len, byte[] dst) Decodes UTF-8 encoded byte array to a UTF-16 byte array. This method converts UTF-8 encoded data from a source byte array to UTF-16 encoded data in a destination byte array. Each UTF-16 character is stored as two consecutive bytes.- Parameters:
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 to- Returns:
- the number of bytes written to the destination array, or -1 if decoding fails
-
decodeUTF8
public static int decodeUTF8(byte[] src, int off, int len, char[] dst) Decodes UTF-8 encoded byte array to a character array. This method converts UTF-8 encoded data from a source byte array to Unicode characters in a destination character array, with optimized handling for ASCII characters.- Parameters:
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 to- Returns:
- the number of characters written to the destination array, or -1 if decoding fails
-
lines
Counts the number of lines in a file. This method reads the specified file and counts the number of newline characters ('\ ') to determine the total number of lines in the file.- Parameters:
file- the File to count lines in- Returns:
- the number of lines in the file
- Throws:
Exception- if an I/O error occurs while reading the file
-
lines
Counts the number of lines in an InputStream. This method reads data from the specified InputStream and counts the number of newline characters ('\ ') to determine the total number of lines in the stream.- Parameters:
in- the InputStream to count lines in- Returns:
- the number of lines in the stream
- Throws:
Exception- if an I/O error occurs while reading the stream
-
writeLocalDate
public 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). This method formats a date with year, month, and day components and writes it to the specified byte array buffer at the given offset.- Parameters:
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)- Returns:
- the updated offset after writing the date
-
writeLocalDate
public 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). This method formats a date with year, month, and day components and writes it to the specified character array buffer at the given offset.- Parameters:
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)- Returns:
- the updated offset after writing the date
-
writeLocalTime
public 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). This method formats a time with hour, minute, and second components and writes it to the specified byte array buffer at the given offset.- Parameters:
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)
-
writeLocalTime
Writes a LocalTime value to a byte array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]). This method formats a time with hour, minute, second, and nanosecond components and writes it to the specified byte array buffer at the given offset.- Parameters:
buf- the byte array buffer to write tooff- the offset in the buffer where to start writingtime- the LocalTime object to write- Returns:
- the updated offset after writing the time (including nanoseconds if present)
-
writeNano
public static int writeNano(byte[] buf, int off, int nano) Writes nanosecond values to a byte array. This method formats nanosecond values and writes them to the specified byte array buffer at the given offset, typically used for writing fractional seconds in time values.- Parameters:
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)- Returns:
- the updated offset after writing the nanoseconds
-
writeNano
public static int writeNano(char[] buf, int off, int nano) Writes nanosecond values to a character array. This method formats nanosecond values and writes them to the specified character array buffer at the given offset, typically used for writing fractional seconds in time values.- Parameters:
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)- Returns:
- the updated offset after writing the nanoseconds
-
writeLocalTime
public 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). This method formats a time with hour, minute, and second components and writes it to the specified character array buffer at the given offset.- Parameters:
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)
-
writeLocalTime
Writes a LocalTime value to a character array in ISO8601 format (HH:mm:ss[.nnnnnnnnn]). This method formats a time with hour, minute, second, and nanosecond components and writes it to the specified character array buffer at the given offset.- Parameters:
buf- the character array buffer to write tooff- the offset in the buffer where to start writingtime- the LocalTime object to write- Returns:
- the updated offset after writing the time (including nanoseconds if present)
-
writeInt64
public static int writeInt64(byte[] buf, int off, long val) Writes a 64-bit long integer value to a byte array. This method converts a long integer to its string representation and writes it to the specified byte array buffer at the given offset, handling negative values and optimizing for different value ranges.- Parameters:
buf- the byte array buffer to write tooff- the offset in the buffer where to start writingval- the long integer value to write- Returns:
- the updated offset after writing the value
-
writeInt64
public static int writeInt64(char[] buf, int off, long val) Writes a 64-bit long integer value to a character array. This method converts a long integer to its string representation and writes it to the specified character array buffer at the given offset, handling negative values and optimizing for different value ranges.- Parameters:
buf- the character array buffer to write tooff- the offset in the buffer where to start writingval- the long integer value to write- Returns:
- the updated offset after writing the value
-
writeInt8
public static int writeInt8(byte[] buf, int pos, byte value) Writes an 8-bit byte value as an integer to a byte array. This method converts a byte value to its string representation and writes it to the specified byte array buffer at the given position, handling negative values and optimizing for different value ranges.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to start writingvalue- the byte value to write as an integer- Returns:
- the updated position after writing the value
-
writeInt8
public static int writeInt8(char[] buf, int pos, byte value) Writes an 8-bit byte value as an integer to a character array. This method converts a byte value to its string representation and writes it to the specified character array buffer at the given position, handling negative values and optimizing for different value ranges.- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to start writingvalue- the byte value to write as an integer- Returns:
- the updated position after writing the value
-
writeInt16
public static int writeInt16(byte[] buf, int pos, short value) Writes a 16-bit short value as an integer to a byte array. This method converts a short value to its string representation and writes it to the specified byte array buffer at the given position, handling negative values and optimizing for different value ranges.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to start writingvalue- the short value to write as an integer- Returns:
- the updated position after writing the value
-
writeInt16
public static int writeInt16(char[] buf, int pos, short value) Writes a 16-bit short value as an integer to a character array. This method converts a short value to its string representation and writes it to the specified character array buffer at the given position, handling negative values and optimizing for different value ranges.- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to start writingvalue- the short value to write as an integer- Returns:
- the updated position after writing the value
-
writeInt32
public static int writeInt32(byte[] buf, int off, long val) Writes a 32-bit integer value to a byte array. This method converts a long value to its string representation and writes it to the specified byte array buffer at the given offset, handling negative values and optimizing for different value ranges.- Parameters:
buf- the byte array buffer to write tooff- the offset in the buffer where to start writingval- the long value to write as an integer- Returns:
- the updated offset after writing the value
-
writeInt32
public static int writeInt32(char[] buf, int off, long val) Writes a 32-bit integer value to a character array. This method converts a long value to its string representation and writes it to the specified character array buffer at the given offset, handling negative values and optimizing for different value ranges.- Parameters:
buf- the character array buffer to write tooff- the offset in the buffer where to start writingval- the long value to write as an integer- Returns:
- the updated offset after writing the value
-
getByte
public static byte getByte(byte[] buf, int pos) Gets a byte value from a byte array at the specified position. This method retrieves a byte value from the specified byte array at the given position using unsafe memory operations for improved performance.- Parameters:
buf- the byte array buffer to read frompos- the position in the buffer where to read the byte value- Returns:
- the byte value at the specified position
-
getChar
public static char getChar(char[] buf, int pos) Gets a character value from a character array at the specified position. This method retrieves a character value from the specified character array at the given position using unsafe memory operations for improved performance.- Parameters:
buf- the character array buffer to read frompos- the position in the buffer where to read the character value- Returns:
- the character value at the specified position
-
getChar
public static char getChar(byte[] buf, int pos) Gets a character value from a byte array at the specified position. This method retrieves a character value from the specified byte array at the given position using unsafe memory operations for improved performance.- Parameters:
buf- the byte array buffer to read frompos- the position in the buffer where to read the character value- Returns:
- the character value at the specified position
-
putShortBE
public static void putShortBE(byte[] buf, int pos, short v) Writes a short value to a byte array in big-endian byte order. This method puts a short value into the specified byte array at the given position using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the short valuev- the short value to write
-
putShortLE
public static void putShortLE(byte[] buf, int pos, short v) Writes a short value to a byte array in little-endian byte order. This method puts a short value into the specified byte array at the given position using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the short valuev- the short value to write
-
putIntBE
public static void putIntBE(byte[] buf, int pos, int v) Writes an int value to a byte array in big-endian byte order. This method puts an int value into the specified byte array at the given position using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the int valuev- the int value to write
-
putIntLE
public static void putIntLE(byte[] buf, int pos, int v) Writes an int value to a byte array in little-endian byte order. This method puts an int value into the specified byte array at the given position using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the int valuev- the int value to write
-
putIntLE
public static void putIntLE(char[] buf, int pos, int v) Writes an int value to a character array in little-endian byte order. This method puts an int value into the specified character array at the given position using little-endian byte ordering (least significant byte first).- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to write the int valuev- the int value to write
-
putShortUnaligned
public static void putShortUnaligned(byte[] buf, int pos, short v) Writes a short value to a byte array without alignment considerations. This method puts a short value into the specified byte array at the given position without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the short valuev- the short value to write
-
putIntUnaligned
public static void putIntUnaligned(char[] buf, int pos, int v) Writes an int value to a character array without alignment considerations. This method puts an int value into the specified character array at the given position without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to write the int valuev- the int value to write
-
putIntUnaligned
public static void putIntUnaligned(byte[] buf, int pos, int v) Writes an int value to a byte array without alignment considerations. This method puts an int value into the specified byte array at the given position without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the int valuev- the int value to write
-
putLongLE
public static void putLongLE(char[] buf, int pos, long v) Writes a long value to a character array in little-endian byte order. This method puts a long value into the specified character array at the given position using little-endian byte ordering (least significant byte first).- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to write the long valuev- the long value to write
-
putLongUnaligned
public static void putLongUnaligned(char[] buf, int pos, long v) Writes a long value to a character array without alignment considerations. This method puts a long value into the specified character array at the given position without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to write the long valuev- the long value to write
-
putLongUnaligned
public static void putLongUnaligned(byte[] buf, int pos, long v) Writes a long value to a byte array without alignment considerations. This method puts a long value into the specified byte array at the given position without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the long valuev- the long value to write
-
putLongBE
public static void putLongBE(byte[] buf, int pos, long v) Writes a long value to a byte array in big-endian byte order. This method puts a long value into the specified byte array at the given position using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the long valuev- the long value to write
-
putLongLE
public static void putLongLE(byte[] buf, int pos, long v) Writes a long value to a byte array in little-endian byte order. This method puts a long value into the specified byte array at the given position using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write the long valuev- the long value to write
-
putBoolean
public static int putBoolean(byte[] buf, int off, boolean v) Writes a boolean value to a byte array as a string representation. This method writes either "true" or "false" to the specified byte array at the given offset. For true values, it writes "true" (4 bytes), and for false values, it writes "false" (5 bytes).- Parameters:
buf- the byte array buffer to write tooff- the offset in the buffer where to start writingv- the boolean value to write- Returns:
- the updated offset after writing the boolean value
-
putBoolean
public static int putBoolean(char[] buf, int off, boolean v) Writes a boolean value to a character array as a string representation. This method writes either "true" or "false" to the specified character array at the given offset. For true values, it writes "true" (4 characters), and for false values, it writes "false" (5 characters).- Parameters:
buf- the character array buffer to write tooff- the offset in the buffer where to start writingv- the boolean value to write- Returns:
- the updated offset after writing the boolean value
-
isALSE
public static boolean isALSE(byte[] buf, int pos) Checks if the specified position in a byte array contains the string "alse". This method is used to verify if a byte sequence matches the "alse" portion of "false".- Parameters:
buf- the byte array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position contains "alse", false otherwise
-
notALSE
public static boolean notALSE(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "alse". This method is used to verify if a byte sequence does not match the "alse" portion of "false".- Parameters:
buf- the byte array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "alse", false otherwise
-
isALSE
public static boolean isALSE(char[] buf, int pos) Checks if the specified position in a character array contains the string "alse". This method is used to verify if a character sequence matches the "alse" portion of "false".- Parameters:
buf- the character array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position contains "alse", false otherwise
-
notALSE
public static boolean notALSE(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "alse". This method is used to verify if a character sequence does not match the "alse" portion of "false".- Parameters:
buf- the character array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "alse", false otherwise
-
isNULL
public static boolean isNULL(byte[] buf, int pos) Checks if the specified position in a byte array contains the string "null". This method is used to verify if a byte sequence matches the string "null".- Parameters:
buf- the byte array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position contains "null", false otherwise
-
notNULL
public static boolean notNULL(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "null". This method is used to verify if a byte sequence does not match the string "null".- Parameters:
buf- the byte array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "null", false otherwise
-
notTRUE
public static boolean notTRUE(byte[] buf, int pos) Checks if the specified position in a byte array does not contain the string "true". This method is used to verify if a byte sequence does not match the string "true".- Parameters:
buf- the byte array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "true", false otherwise
-
notTRUE
public static boolean notTRUE(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "true". This method is used to verify if a character sequence does not match the string "true".- Parameters:
buf- the character array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "true", false otherwise
-
isNULL
public static boolean isNULL(char[] buf, int pos) Checks if the specified position in a character array contains the string "null". This method is used to verify if a character sequence matches the string "null".- Parameters:
buf- the character array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position contains "null", false otherwise
-
notNULL
public static boolean notNULL(char[] buf, int pos) Checks if the specified position in a character array does not contain the string "null". This method is used to verify if a character sequence does not match the string "null".- Parameters:
buf- the character array buffer to checkpos- the position in the buffer to check- Returns:
- true if the position does not contain "null", false otherwise
-
putNULL
public static void putNULL(byte[] buf, int pos) Writes the string "null" to a byte array at the specified position. This method puts the byte representation of "null" into the specified byte array at the given position.- Parameters:
buf- the byte array buffer to write topos- the position in the buffer where to write "null"
-
putNULL
public static void putNULL(char[] buf, int pos) Writes the string "null" to a character array at the specified position. This method puts the character representation of "null" into the specified character array at the given position.- Parameters:
buf- the character array buffer to write topos- the position in the buffer where to write "null"
-
digit4
public static int digit4(char[] buf, int off) Extracts a 4-digit number from a character array at the specified offset. This method performs optimized digit extraction by processing 4 characters at once using vector operations for improved performance.- Parameters:
buf- the character array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 4-digit number, or -1 if the characters are not valid digits
-
digit4
public static int digit4(byte[] buf, int off) Extracts a 4-digit number from a byte array at the specified offset. This method performs optimized digit extraction by processing 4 bytes at once using vector operations for improved performance.- Parameters:
buf- the byte array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 4-digit number, or -1 if the bytes are not valid digits
-
digit3
public static int digit3(char[] buf, int off) Extracts a 3-digit number from a character array at the specified offset. This method performs optimized digit extraction by processing 3 characters at once using vector operations for improved performance.- Parameters:
buf- the character array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 3-digit number, or -1 if the characters are not valid digits
-
digit3
public static int digit3(byte[] buf, int off) Extracts a 3-digit number from a byte array at the specified offset. This method performs optimized digit extraction by processing 3 bytes at once using vector operations for improved performance.- Parameters:
buf- the byte array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 3-digit number, or -1 if the bytes are not valid digits
-
digit2
public static int digit2(char[] buf, int off) Extracts a 2-digit number from a character array at the specified offset. This method performs optimized digit extraction by processing 2 characters at once using vector operations for improved performance.- Parameters:
buf- the character array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 2-digit number, or -1 if the characters are not valid digits
-
digit2
public static int digit2(byte[] buf, int off) Extracts a 2-digit number from a byte array at the specified offset. This method performs optimized digit extraction by processing 2 bytes at once using vector operations for improved performance.- Parameters:
buf- the byte array to extract digits fromoff- the offset in the array where to start extracting- Returns:
- the extracted 2-digit number, or -1 if the bytes are not valid digits
-
isDigit2
public static boolean isDigit2(char[] buf, int off) Checks if the 2 characters at the specified offset in a character array represent valid digits. This method performs optimized digit validation by processing 2 characters at once using vector operations for improved performance.- Parameters:
buf- the character array to checkoff- the offset in the array where to start checking- Returns:
- true if both characters represent valid digits (0-9), false otherwise
-
digit
public static int digit(int d) Validates if the specified integer value represents a single digit (0-9). This method checks if the input value is within the valid digit range.- Parameters:
d- the integer value to check- Returns:
- the input value if it's a valid digit (0-9), -1 otherwise
-
digit1
public static int digit1(char[] buf, int off) Extracts a single digit from a character array at the specified offset. This method performs optimized digit extraction for a single character.- Parameters:
buf- the character array to extract the digit fromoff- the offset in the array where to extract the digit- Returns:
- the extracted digit value (0-9), or -1 if the character is not a valid digit
-
digit1
public static int digit1(byte[] buf, int off) Extracts a single digit from a byte array at the specified offset. This method performs optimized digit extraction for a single byte.- Parameters:
buf- the byte array to extract the digit fromoff- the offset in the array where to extract the digit- Returns:
- the extracted digit value (0-9), or -1 if the byte is not a valid digit
-
indexOfQuote
public static int indexOfQuote(byte[] buf, int quote, int fromIndex, int max) Finds the index of a quote character in a byte array. This method searches for either a single quote (') or double quote (") character within the specified range of the byte array.- Parameters:
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)- Returns:
- the index of the quote character, or -1 if not found
-
indexOfQuoteV
public 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. This method searches for either a single quote (') or double quote (") character within the specified range of the byte array using optimized vector operations.- Parameters:
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)- Returns:
- the index of the quote character, or -1 if not found
-
indexOfDoubleQuote
public static int indexOfDoubleQuote(byte[] buf, int fromIndex, int max) Finds the index of a double quote character in a byte array. This method searches for a double quote (") character within the specified range of the byte array.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the double quote character, or -1 if not found
-
indexOfDoubleQuoteV
public static int indexOfDoubleQuoteV(byte[] buf, int fromIndex, int max) Finds the index of a double quote character in a byte array using vectorized operations. This method searches for a double quote (") character within the specified range of the byte array using optimized vector operations.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the double quote character, or -1 if not found
-
indexOfLineSeparator
public static int indexOfLineSeparator(byte[] buf, int fromIndex, int max) Finds the index of a line separator character in a byte array. This method searches for a newline ('\n') character within the specified range of the byte array.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the line separator character, or -1 if not found
-
indexOfLineSeparatorV
public static int indexOfLineSeparatorV(byte[] buf, int fromIndex, int max) Finds the index of a line separator character in a byte array using vectorized operations. This method searches for a newline ('\n') character within the specified range of the byte array using optimized vector operations.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the line separator character, or -1 if not found
-
indexOfSlash
public static int indexOfSlash(byte[] buf, int fromIndex, int max) Finds the index of a slash character in a byte array. This method searches for a backslash ('\') character within the specified range of the byte array.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the slash character, or -1 if not found
-
indexOfSlashV
public static int indexOfSlashV(byte[] buf, int fromIndex, int max) Finds the index of a slash character in a byte array using vectorized operations. This method searches for a backslash ('\') character within the specified range of the byte array using optimized vector operations.- Parameters:
buf- the byte array to search infromIndex- the index to start searching frommax- the maximum index to search up to (exclusive)- Returns:
- the index of the slash character, or -1 if not found
-
regionMatches
Checks if a byte array region matches a prefix string. This method compares a segment of a byte array with a string prefix to see if they match exactly.- Parameters:
bytes- the byte array to checkoff- the offset in the byte array where to start checkingprefix- the string prefix to match against- Returns:
- true if the byte array region matches the prefix, false otherwise
-
indexOfChar
public static int indexOfChar(byte[] buf, int ch, int fromIndex, int max) Finds the index of a character in a byte array. This method searches for a specific character within the specified range of the byte array.- Parameters:
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)- Returns:
- the index of the character, or -1 if not found
-
indexOfChar
public static int indexOfChar(char[] buf, int ch, int fromIndex, int max) Finds the index of a character in a character array. This method searches for a specific character within the specified range of the character array.- Parameters:
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)- Returns:
- the index of the character, or -1 if not found
-
hexDigit4
public static int hexDigit4(byte[] buf, int offset) Extracts a 4-digit hexadecimal number from a byte array at the specified offset. This method performs optimized hexadecimal digit extraction by processing 4 bytes at once using vector operations for improved performance.- Parameters:
buf- the byte array to extract hexadecimal digits fromoffset- the offset in the array where to start extracting- Returns:
- the extracted 4-digit hexadecimal number
-
hexDigit4
public static int hexDigit4(char[] buf, int offset) Extracts a 4-digit hexadecimal number from a character array at the specified offset. This method performs optimized hexadecimal digit extraction by processing 4 characters at once using vector operations for improved performance.- Parameters:
buf- the character array to extract hexadecimal digits fromoffset- the offset in the array where to start extracting- Returns:
- the extracted 4-digit hexadecimal number
-
isDigit
public static boolean isDigit(int ch) Checks if the specified character is a digit (0-9). This method determines if a character represents a valid decimal digit.- Parameters:
ch- the character to check- Returns:
- true if the character is a digit (0-9), false otherwise
-
getShortUnaligned
public static short getShortUnaligned(byte[] buf, int offset) Gets a short value from a byte array at the specified offset without alignment considerations. This method retrieves a short value from the specified byte array at the given offset without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the short value- Returns:
- the short value at the specified offset
-
getShortBE
public static short getShortBE(byte[] buf, int offset) Gets a short value from a byte array at the specified offset in big-endian byte order. This method retrieves a short value from the specified byte array at the given offset using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the short value- Returns:
- the short value at the specified offset in big-endian order
-
getShortLE
public static short getShortLE(byte[] buf, int offset) Gets a short value from a byte array at the specified offset in little-endian byte order. This method retrieves a short value from the specified byte array at the given offset using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the short value- Returns:
- the short value at the specified offset in little-endian order
-
isUTF8BOM
public static boolean isUTF8BOM(byte[] buf, int off) Checks if the specified position in a byte array contains a UTF-8 Byte Order Mark (BOM). This method verifies if the first three bytes at the specified offset match the UTF-8 BOM sequence (0xEF, 0xBB, 0xBF).- Parameters:
buf- the byte array to checkoff- the offset in the array where to check for the BOM- Returns:
- true if the position contains a UTF-8 BOM, false otherwise
-
getIntBE
public static int getIntBE(byte[] buf, int offset) Gets an int value from a byte array at the specified offset in big-endian byte order. This method retrieves an int value from the specified byte array at the given offset using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the int value- Returns:
- the int value at the specified offset in big-endian order
-
getIntLE
public static int getIntLE(byte[] buf, int offset) Gets an int value from a byte array at the specified offset in little-endian byte order. This method retrieves an int value from the specified byte array at the given offset using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the int value- Returns:
- the int value at the specified offset in little-endian order
-
getIntLE
public static int getIntLE(char[] buf, int offset) Gets an int value from a character array at the specified offset in little-endian byte order. This method retrieves an int value from the specified character array at the given offset using little-endian byte ordering (least significant byte first).- Parameters:
buf- the character array to read fromoffset- the offset in the array where to read the int value- Returns:
- the int value at the specified offset in little-endian order
-
getIntUnaligned
public static int getIntUnaligned(byte[] buf, int offset) Gets an int value from a byte array at the specified offset without alignment considerations. This method retrieves an int value from the specified byte array at the given offset without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the int value- Returns:
- the int value at the specified offset
-
getIntUnaligned
public static int getIntUnaligned(char[] buf, int offset) Gets an int value from a character array at the specified offset without alignment considerations. This method retrieves an int value from the specified character array at the given offset without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the character array to read fromoffset- the offset in the array where to read the int value- Returns:
- the int value at the specified offset
-
getLongBE
public static long getLongBE(byte[] buf, int offset) Gets a long value from a byte array at the specified offset in big-endian byte order. This method retrieves a long value from the specified byte array at the given offset using big-endian byte ordering (most significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the long value- Returns:
- the long value at the specified offset in big-endian order
-
getLongUnaligned
public static long getLongUnaligned(byte[] buf, int offset) Gets a long value from a byte array at the specified offset without alignment considerations. This method retrieves a long value from the specified byte array at the given offset without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the long value- Returns:
- the long value at the specified offset
-
getLongUnaligned
public static long getLongUnaligned(char[] buf, int offset) Gets a long value from a character array at the specified offset without alignment considerations. This method retrieves a long value from the specified character array at the given offset without performing any byte order conversion or alignment adjustments.- Parameters:
buf- the character array to read fromoffset- the offset in the array where to read the long value- Returns:
- the long value at the specified offset
-
getLongLE
public static long getLongLE(byte[] buf, int offset) Gets a long value from a byte array at the specified offset in little-endian byte order. This method retrieves a long value from the specified byte array at the given offset using little-endian byte ordering (least significant byte first).- Parameters:
buf- the byte array to read fromoffset- the offset in the array where to read the long value- Returns:
- the long value at the specified offset in little-endian order
-
getLongLE
public static long getLongLE(char[] buf, int offset) Gets a long value from a character array at the specified offset in little-endian byte order. This method retrieves a long value from the specified character array at the given offset using little-endian byte ordering (least significant byte first).- Parameters:
buf- the character array to read fromoffset- the offset in the array where to read the long value- Returns:
- the long value at the specified offset in little-endian order
-
hex2
public static short hex2(int i) Converts a 2-digit hexadecimal value to its character representation. This method transforms a packed 2-digit hexadecimal value into its ASCII character representation using optimized bit operations.- Parameters:
i- the packed 2-digit hexadecimal value to convert- Returns:
- the character representation of the hexadecimal value
-
hex2U
public static short hex2U(int i) Converts a 2-digit hexadecimal value to its uppercase character representation. This method transforms a packed 2-digit hexadecimal value into its uppercase ASCII character representation using optimized bit operations.- Parameters:
i- the packed 2-digit hexadecimal value to convert- Returns:
- the uppercase character representation of the hexadecimal value
-
utf16Hex2
public static int utf16Hex2(int i) Converts a 2-digit hexadecimal value to its UTF-16 character representation. This method transforms a packed 2-digit hexadecimal value into its UTF-16 character representation using optimized bit operations.- Parameters:
i- the packed 2-digit hexadecimal value to convert- Returns:
- the UTF-16 character representation of the hexadecimal value
-
hex4U
public static int hex4U(int i) Converts a 4-digit hexadecimal value to its uppercase character representation. This method transforms a packed 4-digit hexadecimal value into its uppercase ASCII character representation using optimized bit operations.- Parameters:
i- the packed 4-digit hexadecimal value to convert- Returns:
- the uppercase character representation of the hexadecimal value
-
utf16Hex4U
public static long utf16Hex4U(long i) Converts a 4-digit hexadecimal value to its uppercase UTF-16 character representation. This method transforms a packed 4-digit hexadecimal value into its uppercase UTF-16 character representation using optimized bit operations.- Parameters:
i- the packed 4-digit hexadecimal value to convert- Returns:
- the uppercase UTF-16 character representation of the hexadecimal value
-
convEndian
public static int convEndian(boolean big, int n) Converts an integer value between big-endian and little-endian byte orders. This method conditionally reverses the byte order of an integer value based on the specified endianness flag and the system's native endianness.- Parameters:
big- true to convert to big-endian, false to convert to little-endiann- the integer value to convert- Returns:
- the converted integer value in the specified byte order
-
convEndian
public static long convEndian(boolean big, long n) Converts a long value between big-endian and little-endian byte orders. This method conditionally reverses the byte order of a long value based on the specified endianness flag and the system's native endianness.- Parameters:
big- true to convert to big-endian, false to convert to little-endiann- the long value to convert- Returns:
- the converted long value in the specified byte order
-
isLatin1
public static boolean isLatin1(char[] buf, int off, int len) Checks if a character array segment contains only Latin-1 characters. This method verifies that all characters in the specified segment of the character array are within the Latin-1 character set (Unicode code points 0-255).- Parameters:
buf- the character array to checkoff- the starting offset in the arraylen- the number of characters to check- Returns:
- true if all characters in the segment are Latin-1, false otherwise
-
isASCII
Checks if a string contains only ASCII characters. This method verifies that all characters in the specified string are within the ASCII character set (Unicode code points 0-127).- Parameters:
str- the string to check- Returns:
- true if all characters in the string are ASCII, false otherwise
-
isASCII
public static boolean isASCII(byte[] buf) Checks if a byte array contains only ASCII characters. This method verifies that all bytes in the specified byte array are within the ASCII character set (values 0-127).- Parameters:
buf- the byte array to check- Returns:
- true if all bytes in the array are ASCII, false otherwise
-
isASCII
public static boolean isASCII(byte[] buf, int off, int len) Checks if a byte array segment contains only ASCII characters. This method verifies that all bytes in the specified segment of the byte array are within the ASCII character set (values 0-127).- Parameters:
buf- the byte array to checkoff- the starting offset in the arraylen- the number of bytes to check- Returns:
- true if all bytes in the segment are ASCII, false otherwise
-
isNonSlashASCII
public static boolean isNonSlashASCII(byte[] buf, int off, int len) Checks if a byte array segment contains only ASCII characters and no backslash characters. This method verifies that all bytes in the specified segment of the byte array are within the ASCII character set (values 0-127) and do not contain any backslash ('\\') characters.- Parameters:
buf- the byte array to checkoff- the starting offset in the arraylen- the number of bytes to check- Returns:
- true if all bytes in the segment are ASCII and not backslashes, false otherwise
-
parseInt
public static int parseInt(byte[] buf, int off, int len) Parses an integer value from a byte array segment. This method converts a sequence of ASCII digit characters in a byte array segment to an integer value, handling optional leading '+' or '-' signs.- Parameters:
buf- the byte array containing the digit charactersoff- the starting offset in the arraylen- the number of bytes to parse- Returns:
- the parsed integer value
- Throws:
NumberFormatException- if the byte array segment does not contain a valid integer representation
-