Class JsonRecordUtil
public class JsonRecordUtil extends Object
Provides methods and classes for retrieving typed values from a JsonRecord
. The embedded classes
are used to connect set methods of RowSetter
objects so they can be called without boxing
primitive types as they are read.
If allowMissingKeys is false in the JsonRecord being used and a requested key does not exist in the record, an IllegalArgumentException will be thrown. If missing keys are allowed, then the type-appropriate null value will be returned for get requests of missing keys.
If allowNullValues is false in the JsonRecord being used and a requested key has a null value in the record, an IllegalArgumentException will be thrown. If null values are allowed, then the type-appropriate null value will be returned for get requests of a key whose value is null.
If caseInsensitiveSearch is true in the JsonRecord being searched and a requested key does not exist in the record, then the record will be searched to find a key that matches in a case-insensitive manner.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonRecordUtil.JsonBigDecimalSetter
Provides a BigDecimal-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonBigIntegerSetter
Provides a BigInteger-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonBooleanSetter
Provides a Boolean-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonDateTimeSetter
Provides a DeephavenDBDateTime
-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonDoubleSetter
Provides a Deephaven double-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonFloatSetter
Provides a Deephaven float-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonIntSetter
Provides a Deephaven int-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonLongSetter
Provides a Deephaven long-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonSetter
Provides a generic Object set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonShortSetter
Provides a Deephaven short-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
.static class
JsonRecordUtil.JsonStringSetter
Provides a String-typed set method to call aRowSetter
set method and populate it with a value from aJsonRecord
. -
Constructor Summary
Constructors Constructor Description JsonRecordUtil()
-
Method Summary
Modifier and Type Method Description static BigDecimal
getBigDecimal(JsonRecord record, String key)
Returns a BigDecimal from aJsonRecord
.static BigDecimal
getBigDecimal(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a BigDecimal from aJsonNode
.static BigInteger
getBigInteger(JsonRecord record, String key)
Returns a BigInteger from aJsonRecord
.static BigInteger
getBigInteger(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a BigInteger from aJsonRecord
.static Boolean
getBoolean(JsonRecord record, String key)
Returns a Boolean from aJsonRecord
.static Boolean
getBoolean(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Boolean from aJsonNode
.static Byte
getBoxedByte(JsonRecord record, String key)
Returns a Byte from aJsonRecord
.static Byte
getBoxedByte(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Byte from aJsonNode
.static Character
getBoxedChar(JsonRecord record, String key)
Returns a Character from aJsonRecord
.static Character
getBoxedChar(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode tmpNode)
static Double
getBoxedDouble(JsonRecord record, String key)
Returns a Double from aJsonRecord
.static Double
getBoxedDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Double from aJsonNode
.static Float
getBoxedFloat(JsonRecord record, String key)
Returns a Float from aJsonRecord
.static Float
getBoxedFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Float from aJsonNode
.static Integer
getBoxedInt(JsonRecord record, String key)
Returns an Integer from aJsonRecord
.static Integer
getBoxedInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns an Integer from aJsonNode
.static Long
getBoxedLong(JsonRecord record, String key)
Returns a Long from aJsonRecord
.static Long
getBoxedLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Long from aJsonNode
.static Short
getBoxedShort(JsonRecord record, String key)
Returns a Short from aJsonRecord
.static Short
getBoxedShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
static byte
getByte(JsonRecord record, String key)
Returns a Deephaven byte (primitive byte with a reserved value for Null) from aJsonRecord
.static byte
getByte(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven byte (primitive byte with a reserved value for Null) from aJsonNode
.static char
getChar(JsonRecord record, String key)
Returns a Deephaven char (primitive char with a reserved value for Null) from aJsonRecord
.static char
getChar(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven char (primitive char with a reserved value for Null) from aJsonNode
.static DBDateTime
getDBDateTime(JsonRecord record, String key)
Returns aDBDateTime
from aJsonRecord
.static DBDateTime
getDBDateTime(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns aDBDateTime
from aJsonNode
.static double
getDouble(JsonRecord record, String key)
Returns a Deephaven double (primitive double with reserved values for null) from aJsonRecord
.static double
getDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven double (primitive double with reserved values for null) from aJsonNode
.static float
getFloat(JsonRecord record, String key)
Returns a Deephaven float (primitive float with reserved values for Null) from aJsonRecord
.static float
getFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven float (primitive float with reserved values for Null) from aJsonNode
.static int
getInt(JsonRecord record, String key)
Returns a Deephaven int (primitive int with reserved values for null) from aJsonRecord
.static int
getInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven int (primitive int with reserved values for null) from aJsonNode
.static long
getLong(JsonRecord record, String key)
Returns a Deephaven long (primitive long with reserved values for Null) from aJsonRecord
.static long
getLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven long (primitive long with reserved values for null) from aJsonNode
.static JsonRecordSetter
getSetter(Class columnClass)
Gets the appropriateJsonRecordSetter
for the type of the Deephaven column to be populated.static short
getShort(JsonRecord record, String key)
Returns a Deephaven short (primitive short with reserved values for Null) from aJsonRecord
.static short
getShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a Deephaven short (primitive short with reserved values for Null) from aJsonNode
.static String
getString(JsonRecord record, String key)
Returns a String from aJsonRecord
.static String
getString(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a String from aJsonNode
.static Object
getValue(JsonRecord record, String key)
Returns a generic Object from aJsonRecord
.static Object
getValue(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)
Returns a generic Object from aJsonNode
.
-
Constructor Details
-
JsonRecordUtil
public JsonRecordUtil()
-
-
Method Details
-
getSetter
Gets the appropriateJsonRecordSetter
for the type of the Deephaven column to be populated.- Parameters:
columnClass
- Class of the column to be populated.- Returns:
- A
JsonRecordSetter
-
getInt
Returns a Deephaven int (primitive int with reserved values for null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven int (primitive int with reserved values for null)
-
getInt
public static int getInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven int (primitive int with reserved values for null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven int (primitive int with reserved values for null)
-
getBoxedInt
Returns an Integer from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- An Integer
-
getBoxedInt
@Nullable public static Integer getBoxedInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns an Integer from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- An Integer
-
getShort
Returns a Deephaven short (primitive short with reserved values for Null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven short (primitive short with reserved values for Null)
-
getShort
public static short getShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven short (primitive short with reserved values for Null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven short (primitive short with reserved values for Null)
-
getBoxedShort
Returns a Short from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Short
-
getBoxedShort
@Nullable public static Short getBoxedShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node) -
getLong
Returns a Deephaven long (primitive long with reserved values for Null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven long (primitive long with reserved values for Null)
-
getLong
public static long getLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven long (primitive long with reserved values for null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven long (primitive long with reserved values for null)
-
getBoxedLong
Returns a Long from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Long
-
getBoxedLong
@Nullable public static Long getBoxedLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Long from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Long
-
getDouble
Returns a Deephaven double (primitive double with reserved values for null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven double (primitive double with reserved values for null)
-
getDouble
public static double getDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven double (primitive double with reserved values for null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven double (primitive double with reserved values for null)
-
getBoxedDouble
Returns a Double from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Double
-
getBoxedDouble
@Nullable public static Double getBoxedDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Double from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Double
-
getFloat
Returns a Deephaven float (primitive float with reserved values for Null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven float (primitive float with reserved values for Null)
-
getFloat
public static float getFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven float (primitive float with reserved values for Null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven float (primitive float with reserved values for Null)
-
getBoxedFloat
Returns a Float from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Float
-
getBoxedFloat
@Nullable public static Float getBoxedFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Float from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Float
-
getByte
Returns a Deephaven byte (primitive byte with a reserved value for Null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven byte (primitive byte with a reserved value for Null)
-
getByte
public static byte getByte(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven byte (primitive byte with a reserved value for Null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven byte (primitive byte with a reserved value for Null)
-
getBoxedByte
Returns a Byte from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Byte
-
getBoxedByte
@Nullable public static Byte getBoxedByte(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Byte from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Byte
-
getChar
Returns a Deephaven char (primitive char with a reserved value for Null) from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Deephaven char (primitive char with a reserved value for Null)
-
getChar
public static char getChar(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven char (primitive char with a reserved value for Null) from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Deephaven char (primitive char with a reserved value for Null)
-
getBoxedChar
Returns a Character from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Character
-
getBoxedChar
@Nullable public static Character getBoxedChar(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode tmpNode) -
getString
Returns a String from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A String
-
getString
@Nullable public static String getString(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a String from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A String
-
getBoolean
Returns a Boolean from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A Boolean
-
getBoolean
@Nullable public static Boolean getBoolean(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Boolean from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A Boolean
-
getBigInteger
Returns a BigInteger from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A BigInteger
-
getBigInteger
@Nullable public static BigInteger getBigInteger(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a BigInteger from aJsonRecord
.- Parameters:
node
- TheJsonRecord
from which to retrieve the value.- Returns:
- A BigInteger
-
getBigDecimal
Returns a BigDecimal from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A BigDecimal
-
getBigDecimal
@Nullable public static BigDecimal getBigDecimal(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a BigDecimal from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A BigDecimal
-
getValue
Returns a generic Object from aJsonRecord
.- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- An Object
-
getValue
@Nullable public static Object getValue(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a generic Object from aJsonNode
.- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- An Object
-
getDBDateTime
Returns aDBDateTime
from aJsonRecord
. Will try to infer precision of a long value to be parsed usingDBTimeUtils
autoEpochToTime. If the value in the JSON record is not numeric, this method will attempt to parse it as a Deephaven DBDateTime string (yyyy-MM-ddThh:mm:ss[.nnnnnnnnn] TZ).- Parameters:
record
- TheJsonRecord
from which to retrieve the value.key
- The String key of the value to retrieve.- Returns:
- A
DBDateTime
-
getDBDateTime
@Nullable public static DBDateTime getDBDateTime(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns aDBDateTime
from aJsonNode
. Will try to infer precision of a long value to be parsed usingDBTimeUtils
autoEpochToTime. If the value in the JSON record is not numeric, this method will attempt to parse it as a Deephaven DBDateTime string (yyyy-MM-ddThh:mm:ss[.nnnnnnnnn] TZ).- Parameters:
node
- TheJsonNode
from which to retrieve the value.- Returns:
- A
DBDateTime
-