public final class Numbers
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
static double |
bytesToDouble(byte[] arr) |
Converts a byte array to double.
|
static double |
bytesToDouble(org.apache.lucene.util.BytesRef bytes) |
|
static float |
bytesToFloat(byte[] arr) |
Converts a byte array to float.
|
static float |
bytesToFloat(org.apache.lucene.util.BytesRef bytes) |
|
static int |
bytesToInt(byte[] arr) |
Converts a byte array to an int.
|
static int |
bytesToInt(org.apache.lucene.util.BytesRef bytes) |
|
static long |
bytesToLong(byte[] arr) |
Converts a byte array to a long.
|
static long |
bytesToLong(org.apache.lucene.util.BytesRef bytes) |
|
static short |
bytesToShort(byte[] arr) |
Converts a byte array to an short.
|
static short |
bytesToShort(org.apache.lucene.util.BytesRef bytes) |
|
static byte[] |
doubleToBytes(double val) |
Converts a double to a byte array.
|
static byte[] |
floatToBytes(float val) |
Converts a float to a byte array.
|
static byte[] |
intToBytes(int val) |
Converts an int to a byte array.
|
static boolean |
isValidDouble(double value) |
Returns true if value is neither NaN nor infinite.
|
static byte[] |
longToBytes(long val) |
Converts a long to a byte array.
|
static byte[] |
shortToBytes(int val) |
Converts an int to a byte array.
|
static byte |
toByteExact(java.lang.Number n) |
Return the byte that
n stores, or throws an exception if the
stored value cannot be converted to a byte that stores the exact same
value. |
static int |
toIntExact(java.lang.Number n) |
Return the int that
n stores, or throws an exception if the
stored value cannot be converted to an int that stores the exact same
value. |
static long |
toLong(java.lang.String stringValue,
boolean coerce) |
Return the long that
stringValue stores or throws an exception if the
stored value cannot be converted to a long that stores the exact same
value and coerce is false. |
static long |
toLongExact(java.lang.Number n) |
Return the long that
n stores, or throws an exception if the
stored value cannot be converted to a long that stores the exact same
value. |
static short |
toShortExact(java.lang.Number n) |
Return the short that
n stores, or throws an exception if the
stored value cannot be converted to a short that stores the exact same
value. |
public static short bytesToShort(byte[] arr)
arr
- The byte array to convert to an shortpublic static short bytesToShort(org.apache.lucene.util.BytesRef bytes)
public static int bytesToInt(byte[] arr)
arr
- The byte array to convert to an intpublic static int bytesToInt(org.apache.lucene.util.BytesRef bytes)
public static long bytesToLong(byte[] arr)
arr
- The byte array to convert to a longpublic static long bytesToLong(org.apache.lucene.util.BytesRef bytes)
public static float bytesToFloat(byte[] arr)
arr
- The byte array to convert to a floatpublic static float bytesToFloat(org.apache.lucene.util.BytesRef bytes)
public static double bytesToDouble(byte[] arr)
arr
- The byte array to convert to a doublepublic static double bytesToDouble(org.apache.lucene.util.BytesRef bytes)
public static byte[] intToBytes(int val)
val
- The int to convert to a byte arraypublic static byte[] shortToBytes(int val)
val
- The int to convert to a byte arraypublic static byte[] longToBytes(long val)
val
- The long to convert to a byte arraypublic static byte[] floatToBytes(float val)
val
- The float to convert to a byte arraypublic static byte[] doubleToBytes(double val)
val
- The double to convert to a byte arraypublic static boolean isValidDouble(double value)
public static long toLongExact(java.lang.Number n)
n
stores, or throws an exception if the
stored value cannot be converted to a long that stores the exact same
value.public static long toLong(java.lang.String stringValue, boolean coerce)
stringValue
stores or throws an exception if the
stored value cannot be converted to a long that stores the exact same
value and coerce
is false.public static int toIntExact(java.lang.Number n)
n
stores, or throws an exception if the
stored value cannot be converted to an int that stores the exact same
value.public static short toShortExact(java.lang.Number n)
n
stores, or throws an exception if the
stored value cannot be converted to a short that stores the exact same
value.public static byte toByteExact(java.lang.Number n)
n
stores, or throws an exception if the
stored value cannot be converted to a byte that stores the exact same
value.