public class Converter extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
double2str(byte[] buffer,
double value,
int precision)
Converts a double value to its string representation with the specified precision
and places it into a byte buffer at the default offset of 0.
|
static int |
double2str(byte[] buffer,
int offset,
double value,
int precision)
Converts a double value to its string representation with a specified precision
and writes it to the provided byte buffer starting at the specified offset.
|
static String |
double2str(double value)
Converts a double value to its string representation with default precision.
|
static String |
double2str(double value,
int precision)
Converts a double value to its string representation with the specified precision.
|
static int |
i2str(byte[] buffer,
int value)
Converts an integer value to a string representation and stores it in the provided byte array.
|
static int |
i2str(byte[] buffer,
int offset,
int value)
Converts an integer value to its string representation and writes it to a byte buffer
starting at the specified offset.
|
static String |
i2str(int value)
Converts an integer to its string representation.
|
static int |
long2str(byte[] buffer,
int offset,
long value)
Converts a long value to its string representation and writes it into the provided byte array buffer.
|
static int |
long2str(byte[] buffer,
long value)
Converts a long value into a string representation and writes it into the specified byte array buffer.
|
static void |
long2str(DynamicByteBuffer buffer,
long value)
Converts a long value to its string representation and writes the result
into the specified
DynamicByteBuffer. |
static double |
str2double(byte[] buffer,
int offset,
int length,
boolean strict)
Converts a sequence of bytes in the provided buffer into a double-precision
floating-point number, starting at the specified offset and using the
specified length.
|
static double |
str2double(String s,
boolean strict)
Converts a given string to a double value.
|
static int |
str2int(byte[] buffer,
int offset,
int length,
boolean strict)
Converts a sequence of bytes within a buffer to an integer value.
|
static int |
str2int(String s,
boolean strict)
Converts a string representation of a number to its integer value.
|
static long |
str2long(byte[] buffer,
int offset,
int length,
boolean strict)
Converts a portion of a byte array into a long value.
|
static long |
str2long(String s,
boolean strict)
Converts a string to a long value.
|
public static String double2str(double value)
value - the double value to convertpublic static String double2str(double value, int precision)
value - the double value to be convertedprecision - the number of digits after the decimal point in the resulting stringpublic static int double2str(byte[] buffer,
double value,
int precision)
buffer - the target buffer where the string representation of the double value will be writtenvalue - the double value to convertprecision - the number of digits after the decimal point in the resulting stringNullPointerException - if buffer == nullIllegalArgumentException - if precision < 0 or precision > 10public static int double2str(byte[] buffer,
int offset,
double value,
int precision)
buffer - The byte array where the string representation of the double value will be written.
Must not be null and must have sufficient space for the resulting string.offset - The starting position in the buffer where the string representation will be written.
Must be within the bounds of the buffer.value - The double value to convert to a string representation.precision - The number of digits to include after the decimal point. Must be between 0 and 10 inclusive.NullPointerException - If the buffer is null.IllegalArgumentException - If the offset is out of bounds of the buffer or
if the precision is outside the allowed range (0-10).public static double str2double(byte[] buffer,
int offset,
int length,
boolean strict)
buffer - the byte array containing the sequence of characters to convert.offset - the starting position within the buffer where the number begins.length - the number of bytes to parse from the buffer.strict - if true, enforces strict parsing, ensuring that only valid number formats
and trailing spaces are allowed.NullPointerException - if the input buffer is null.IllegalArgumentException - if the offset is negative, the length is negative,
or if the offset and length exceed the buffer bounds.NumberFormatException - if the input does not contain a valid numeric value.public static double str2double(String s, boolean strict)
s - the string to be converted to a double; must not be nullstrict - whether to enforce strict parsing rulesNullPointerException - if the input string is nullpublic static int i2str(byte[] buffer,
int offset,
int value)
buffer - the byte array to which the string representation of the integer will be writtenoffset - the position in the byte array where the string representation should startvalue - the integer value to be converted to a string representationpublic static String i2str(int value)
value - the integer value to convert to a stringpublic static int long2str(byte[] buffer,
long value)
buffer - the byte array where the string representation of the long value will be writtenvalue - the long value to be converted into a stringpublic static int long2str(byte[] buffer,
int offset,
long value)
buffer - the byte array to write the string representation of the long value into; must not be nulloffset - the starting position in the buffer where the string representation will begin writing;
must be non-negative and less than the length of the buffervalue - the long value to be converted to its string representationNullPointerException - if the buffer is nullIllegalArgumentException - if the offset is negative or greater than or equal to the buffer lengthpublic static void long2str(DynamicByteBuffer buffer, long value)
DynamicByteBuffer.
The method handles negative values by prefixing the result with a '-' sign. Digits are written in reverse order into the buffer and then reversed back to the correct order.
buffer - the DynamicByteBuffer where the string representation
of the long value will be writtenvalue - the long value to be converted to a string representationNullPointerException - if the provided buffer is nullpublic static int i2str(byte[] buffer,
int value)
buffer - the byte array to store the string representation of the integervalue - the integer value to be converted to a stringpublic static int str2int(byte[] buffer,
int offset,
int length,
boolean strict)
buffer - the byte array containing the numeric string representationoffset - the starting position in the buffer to read fromlength - the number of bytes to read from the bufferstrict - a flag indicating whether to enforce strict parsing rulespublic static int str2int(String s, boolean strict)
s - the string to be converted must not be nullstrict - if true, enforces strict interpretation of the string;
if false, allows more lenient handling of the conversionNullPointerException - if the input string is nullpublic static long str2long(byte[] buffer,
int offset,
int length,
boolean strict)
buffer - the byte array containing the characters to convertoffset - the starting position in the arraylength - the number of characters to read from the arraystrict - a flag indicating whether to enforce strict parsing rulespublic static long str2long(String s, boolean strict)
s - the string to be converted; must not be nullstrict - a flag indicating whether strict parsing should be enforcedNullPointerException - if the provided string is nullCopyright © 2005–2025 Onix Solutions. All rights reserved.