public class Converter extends Object
Modifier and Type | Method and Description |
---|---|
static int |
double2str(byte[] buffer,
double value,
int precision)
Converts double to string and places it into a byte buffer.
|
static int |
double2str(byte[] buffer,
int offset,
double value,
int precision)
Converts double to string and places it into a byte buffer.
|
static String |
double2str(double value)
Converts double value to string.
|
static String |
double2str(double value,
int precision)
Converts double value to string.
|
static int |
i2str(byte[] buffer,
int value)
Converts integer to string and places it into a byte buffer.
|
static int |
i2str(byte[] buffer,
int offset,
int value)
Converts integer to string and places it into a byte buffer.
|
static String |
i2str(int value)
Converts integer to string.
|
static int |
long2str(byte[] buffer,
int offset,
long value)
Converts long to string and places it into a byte buffer.
|
static int |
long2str(byte[] buffer,
long value)
Converts long to string and places it into a byte buffer.
|
static void |
long2str(DynamicByteBuffer buffer,
long value)
Converts long to string and places it into a
ByteBuffer . |
static double |
str2double(byte[] buffer,
int offset,
int length,
boolean strict)
Converts string in the byte buffer to double.
|
static double |
str2double(String s,
boolean strict)
Converts string to double.
|
static int |
str2int(byte[] buffer,
int offset,
int length,
boolean strict)
Converts string in the byte buffer to int.
|
static int |
str2int(String s,
boolean strict)
Converts string to int.
|
static long |
str2long(byte[] buffer,
int offset,
int length,
boolean strict)
Converts string in the byte buffer to long.
|
static long |
str2long(String s,
boolean strict)
Converts string to long.
|
public static String double2str(double value)
value
- double value to convertpublic static String double2str(double value, int precision)
value
- double value to convertprecision
- precision of the double in the stringpublic static int double2str(byte[] buffer, double value, int precision)
buffer
- target buffervalue
- value to convertprecision
- precision of the double in the stringNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static int double2str(byte[] buffer, int offset, double value, int precision)
buffer
- target bufferoffset
- buffer offsetvalue
- value to convertprecision
- precision of the double in the stringNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
IllegalArgumentException
- if (precision < 0) || (precision > 10)
public static double str2double(byte[] buffer, int offset, int length, boolean strict)
Please note that byte buffer should not contain exponent (e.g. 'e' or 'E' symbol).
buffer
- source bufferoffset
- value offsetlength
- value lengthstrict
- whether to throw exception if not all bytes can be convertedNullPointerException
- if (buffer == null)
IllegalArgumentException
- if ((offset < 0) || (offset + length > buffer.length))
or (length <= 0)
or (valueLimit <= 0)
NumberFormatException
- if strict is true
and not all bytes can be convertedpublic static double str2double(String s, boolean strict)
s
- string to be convertedstrict
- whether to throw exception if not all chars can be convertedNullPointerException
- if (s == null)
NumberFormatException
- if strict is true
and not all chars can be convertedpublic static int i2str(byte[] buffer, int offset, int value)
buffer
- target bufferoffset
- buffer offsetvalue
- value to convertNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static String i2str(int value)
value
- value to convertNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static int long2str(byte[] buffer, long value)
buffer
- target buffervalue
- value to convertNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static int long2str(byte[] buffer, int offset, long value)
buffer
- target bufferoffset
- buffer offsetvalue
- value to convertNullPointerException
- if null == buffer
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static void long2str(DynamicByteBuffer buffer, long value)
ByteBuffer
.buffer
- target buffervalue
- value to convertNullPointerException
- if null == buffer
public static int i2str(byte[] buffer, int value)
buffer
- target buffervalue
- value to convertNullPointerException
- if buffer == null
IllegalArgumentException
- if (offset < 0) || (offset >= buffer.length)
public static int str2int(byte[] buffer, int offset, int length, boolean strict)
buffer
- source bufferoffset
- value offsetlength
- value lengthstrict
- whether to throw exception if not all bytes can be convertedNullPointerException
- if (buffer == null)
IllegalArgumentException
- if ((offset < 0) || (offset + length > buffer.length))
or (length <= 0)
NumberFormatException
- if strict is true
and not all bytes can be convertedpublic static int str2int(String s, boolean strict)
s
- string to be convertedstrict
- whether to throw exception if not all chars can be convertedNullPointerException
- if (s == null)
NumberFormatException
- if strict is true
and not all chars can be convertedpublic static long str2long(byte[] buffer, int offset, int length, boolean strict)
buffer
- source bufferoffset
- value offsetlength
- value lengthstrict
- whether to throw exception if not all bytes can be convertedNullPointerException
- if (buffer == null)
IllegalArgumentException
- if ((offset < 0) || (offset + length > buffer.length))
or (length <= 0)
NumberFormatException
- if strict is true
and not all bytes can be convertedpublic static long str2long(String s, boolean strict)
s
- string to be convertedstrict
- whether to throw exception if not all chars can be convertedNullPointerException
- if (s == null)
NumberFormatException
- if strict is true
and not all chars can be convertedCopyright © 2005–2024 Onix Solutions. All rights reserved.