@API.Public public class Values extends Object
Value
.Constructor and Description |
---|
Values() |
Modifier and Type | Method and Description |
---|---|
static boolean |
asBoolean(Value value) |
static byte |
asByte(Value value) |
static BigDecimal |
asDecimal(Value value) |
static double |
asDouble(Value value) |
static float |
asFloat(Value value) |
static int |
asInt(Value value) |
static String |
asJsonString(Value value)
Converts a
Value to its extended JSON representation.The 7 intrinsic types, null, boolean, string, long,
double, array, and map , are represented in regular JSON. |
static long |
asLong(Value value) |
static Number |
asNumber(Value value) |
static short |
asShort(Value value) |
static String |
asString(Value value) |
static BigDecimal |
parseBigDecimal(String s)
Converts a string to BigDecimal object.
|
static ByteBuffer |
parseBinary(String s)
Converts a base-64 encoded string to ByteBuffer.
|
public static byte asByte(@API.NonNullable Value value)
byte
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static short asShort(@API.NonNullable Value value)
short
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static int asInt(@API.NonNullable Value value)
int
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static long asLong(Value value)
long
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static float asFloat(Value value)
float
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static double asDouble(Value value)
double
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number typespublic static BigDecimal asDecimal(Value value)
BigDecimal
.
This may involve rounding or truncation.IllegalArgumentException
- uf the specified value is
not one of the number typespublic static Number asNumber(@API.NonNullable Value value)
Number
.
This may involve rounding or truncation.IllegalArgumentException
- if the specified value is
not one of the number types or a string that can not be converted to a number.public static boolean asBoolean(@API.NonNullable Value value)
boolean
.IllegalArgumentException
- if the specified value is
not can not be converted to a boolean.public static String asString(@API.NonNullable Value value)
String
.public static BigDecimal parseBigDecimal(@API.NonNullable String s)
public static ByteBuffer parseBinary(@API.NonNullable String s)
public static String asJsonString(@API.NonNullable Value value)
Value
to its extended JSON representation.null, boolean, string, long,
double, array, and map
, are represented in regular JSON. The
extended types are converted to a singleton map with the type tag name
as the key and the value of the given Value
as its value.
The following sample illustrates the string representation of the
various types.
{ "map": { "null": null, "boolean" : true, "string": "eureka", "byte" : {"$numberLong": 127}, "short": {"$numberLong": 32767}, "int": {"$numberLong": 2147483647}, "long": {"$numberLong":9223372036854775807}, "float" : 3.4028235E38, "double" : 1.7976931348623157e308, "decimal": {"$decimal": "12345678901234567890189012345678901.23456789"}, "date": {"$dateDay": "<yyyy-mm-dd>"}, "time" : {"$time" : "<HH:mm:ss[.sss]>"}, "timestamp" : {"$date" : "<yyyy-MM-ddTHH:mm:ss.SSSXXX>"}, "interval" : {"$interval" : <number_of_millisecods>}, "binary" : {"$binary" : "<base64_encoded_binary_value>"}, "array" : [42, "open sesame", 3.14, {"$dateDay": "2015-01-21"}] } }
value
- a Value
that should be converted to JSON stringCopyright © 2015–2018 MapR Technologies, Inc.. All rights reserved.