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 classJsonRecordUtil.JsonBigDecimalSetterProvides a BigDecimal-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonBigIntegerSetterProvides a BigInteger-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonBooleanSetterProvides a Boolean-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonDateTimeSetterProvides a DeephavenDBDateTime-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonDoubleSetterProvides a Deephaven double-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonFloatSetterProvides a Deephaven float-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonIntSetterProvides a Deephaven int-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonLongSetterProvides a Deephaven long-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonSetterProvides a generic Object set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonShortSetterProvides a Deephaven short-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord.static classJsonRecordUtil.JsonStringSetterProvides a String-typed set method to call aRowSetterset method and populate it with a value from aJsonRecord. -
Constructor Summary
Constructors Constructor Description JsonRecordUtil() -
Method Summary
Modifier and Type Method Description static BigDecimalgetBigDecimal(JsonRecord record, String key)Returns a BigDecimal from aJsonRecord.static BigDecimalgetBigDecimal(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a BigDecimal from aJsonNode.static BigIntegergetBigInteger(JsonRecord record, String key)Returns a BigInteger from aJsonRecord.static BigIntegergetBigInteger(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a BigInteger from aJsonRecord.static BooleangetBoolean(JsonRecord record, String key)Returns a Boolean from aJsonRecord.static BooleangetBoolean(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Boolean from aJsonNode.static BytegetBoxedByte(JsonRecord record, String key)Returns a Byte from aJsonRecord.static BytegetBoxedByte(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Byte from aJsonNode.static CharactergetBoxedChar(JsonRecord record, String key)Returns a Character from aJsonRecord.static CharactergetBoxedChar(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode tmpNode)static DoublegetBoxedDouble(JsonRecord record, String key)Returns a Double from aJsonRecord.static DoublegetBoxedDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Double from aJsonNode.static FloatgetBoxedFloat(JsonRecord record, String key)Returns a Float from aJsonRecord.static FloatgetBoxedFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Float from aJsonNode.static IntegergetBoxedInt(JsonRecord record, String key)Returns an Integer from aJsonRecord.static IntegergetBoxedInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns an Integer from aJsonNode.static LonggetBoxedLong(JsonRecord record, String key)Returns a Long from aJsonRecord.static LonggetBoxedLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Long from aJsonNode.static ShortgetBoxedShort(JsonRecord record, String key)Returns a Short from aJsonRecord.static ShortgetBoxedShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)static bytegetByte(JsonRecord record, String key)Returns a Deephaven byte (primitive byte with a reserved value for Null) from aJsonRecord.static bytegetByte(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 chargetChar(JsonRecord record, String key)Returns a Deephaven char (primitive char with a reserved value for Null) from aJsonRecord.static chargetChar(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 DBDateTimegetDBDateTime(JsonRecord record, String key)Returns aDBDateTimefrom aJsonRecord.static DBDateTimegetDBDateTime(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns aDBDateTimefrom aJsonNode.static doublegetDouble(JsonRecord record, String key)Returns a Deephaven double (primitive double with reserved values for null) from aJsonRecord.static doublegetDouble(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven double (primitive double with reserved values for null) from aJsonNode.static floatgetFloat(JsonRecord record, String key)Returns a Deephaven float (primitive float with reserved values for Null) from aJsonRecord.static floatgetFloat(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven float (primitive float with reserved values for Null) from aJsonNode.static intgetInt(JsonRecord record, String key)Returns a Deephaven int (primitive int with reserved values for null) from aJsonRecord.static intgetInt(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven int (primitive int with reserved values for null) from aJsonNode.static longgetLong(JsonRecord record, String key)Returns a Deephaven long (primitive long with reserved values for Null) from aJsonRecord.static longgetLong(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven long (primitive long with reserved values for null) from aJsonNode.static JsonRecordSettergetSetter(Class columnClass)Gets the appropriateJsonRecordSetterfor the type of the Deephaven column to be populated.static shortgetShort(JsonRecord record, String key)Returns a Deephaven short (primitive short with reserved values for Null) from aJsonRecord.static shortgetShort(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a Deephaven short (primitive short with reserved values for Null) from aJsonNode.static StringgetString(JsonRecord record, String key)Returns a String from aJsonRecord.static StringgetString(io.deephaven.shadow.jackson.com.fasterxml.jackson.databind.JsonNode node)Returns a String from aJsonNode.static ObjectgetValue(JsonRecord record, String key)Returns a generic Object from aJsonRecord.static ObjectgetValue(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 appropriateJsonRecordSetterfor 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- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Deephaven int (primitive int with reserved values for null)
-
getBoxedInt
Returns an Integer from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- An Integer
-
getShort
Returns a Deephaven short (primitive short with reserved values for Null) from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Deephaven short (primitive short with reserved values for Null)
-
getBoxedShort
Returns a Short from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Deephaven long (primitive long with reserved values for null)
-
getBoxedLong
Returns a Long from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Long
-
getDouble
Returns a Deephaven double (primitive double with reserved values for null) from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Deephaven double (primitive double with reserved values for null)
-
getBoxedDouble
Returns a Double from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Double
-
getFloat
Returns a Deephaven float (primitive float with reserved values for Null) from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Deephaven float (primitive float with reserved values for Null)
-
getBoxedFloat
Returns a Float from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom 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- TheJsonRecordfrom 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- TheJsonNodefrom 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- TheJsonRecordfrom 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- TheJsonNodefrom 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- TheJsonRecordfrom 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- TheJsonNodefrom 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- TheJsonRecordfrom 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- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A String
-
getBoolean
Returns a Boolean from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A Boolean
-
getBigInteger
Returns a BigInteger from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonRecordfrom which to retrieve the value.- Returns:
- A BigInteger
-
getBigDecimal
Returns a BigDecimal from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A BigDecimal
-
getValue
Returns a generic Object from aJsonRecord.- Parameters:
record- TheJsonRecordfrom 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- TheJsonNodefrom which to retrieve the value.- Returns:
- An Object
-
getDBDateTime
Returns aDBDateTimefrom aJsonRecord. Will try to infer precision of a long value to be parsed usingDBTimeUtilsautoEpochToTime. 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- TheJsonRecordfrom 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 aDBDateTimefrom aJsonNode. Will try to infer precision of a long value to be parsed usingDBTimeUtilsautoEpochToTime. 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- TheJsonNodefrom which to retrieve the value.- Returns:
- A
DBDateTime
-