Package oracle.kv.table
Class FieldValueFactory
java.lang.Object
oracle.kv.table.FieldValueFactory
Factory class to create FieldValue instance objects.
- Since:
- 4.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic BinaryValuecreateBinary(byte[] v) Creates a BinaryValue instance from its java representation.static BooleanValuecreateBoolean(boolean v) Creates a BooleanValue instance from its java representation.static DoubleValuecreateDouble(double v) Creates a DoubleValue instance from its java representation.static FloatValuecreateFloat(float v) Creates a FloatValue instance from its java representation.static IntegerValuecreateInteger(int v) Creates a IntegerValue instance from its java representation.static FieldValueCreates a special FieldValue instance representing a JSON null value, which returns true fromFieldValue.isJsonNull().static LongValuecreateLong(long v) Creates a LongValue instance from its java representation.static NumberValuecreateNumber(double v) Creates a NumberValue instance from a double value.static NumberValuecreateNumber(float v) Creates a NumberValue instance from a float value.static NumberValuecreateNumber(int v) Creates a NumberValue instance from a int value.static NumberValuecreateNumber(long v) Creates a NumberValue instance from a long value.static NumberValueCreates a NumberValue instance from a BigDecimal value.static StringValueCreates a StringValue instance from its java representation.static TimestampValuecreateTimestamp(int year, int month, int day, int hour, int minute, int second, int fracSeconds, int precision) Creates a TimestampValue instance from date time components.static TimestampValuecreateTimestamp(String s, int precision) Creates a TimestampValue instance from a string in format ofTimestampDef.DEFAULT_PATTERN.static TimestampValuecreateTimestamp(Timestamp v, int precision) Creates a TimestampValue instance from its java representation.static FieldValuecreateValueFromJson(Reader jsonReader) Creates a FieldValue instance from JSON input where the type is not known.static FieldValuecreateValueFromJson(String jsonString) Creates a FieldValue instance from JSON input where the type is not known.static FieldValuecreateValueFromJson(FieldDef type, InputStream jsonStream) Creates a new value from a JSON doc (which is given as an InputStream).static FieldValuecreateValueFromJson(FieldDef type, Reader jsonReader) Creates a new value from a JSON doc (which is given as a Reader).static FieldValuecreateValueFromJson(FieldDef type, String jsonString) Creates a new value from a JSON doc (which is given as a String).
- 
Constructor Details- 
FieldValueFactorypublic FieldValueFactory()
 
- 
- 
Method Details- 
createValueFromJsonCreates a FieldValue instance from JSON input where the type is not known. This method maps the JSON into a map (object) or array where the element type is JSON or one of the scalar types supporting JSON: INTEGER, LONG, FLOAT, DOUBLE, STRING, and BOOLEAN.- Parameters:
- jsonString- the JSON representation
- Returns:
- a FieldValue
- Throws:
- IllegalArgumentException- if the input is not valid JSON or the input cannot be parsed, or it cannot be mapped into supported data types.
- Since:
- 4.2
 
- 
createValueFromJsonCreates a FieldValue instance from JSON input where the type is not known. This method maps the JSON into a map (object) or array where the element type is JSON or one of the scalar types supporting JSON: INTEGER, LONG, FLOAT, DOUBLE, STRING, and BOOLEAN.- Parameters:
- jsonReader- a Reader over JSON
- Returns:
- a FieldValue
- Throws:
- IllegalArgumentException- if the input is not valid JSON or the input cannot be parsed, or it cannot be mapped into supported data types.
- IOException- if the input is not valid JSON or the input cannot be parse, or it cannot be mapped into supported data types.
- Since:
- 4.2
 
- 
createValueFromJsonCreates a new value from a JSON doc (which is given as a String). If type is RecordDef then:
 (a) the JSON doc may have fields that do not appear in the record schema. Such fields are simply skipped.
 (b) the JSON doc may be missing fields that appear in the record's schema. Such fields will remain unset in the record value. This meansRecordValue.get(String)will return null andFieldValue.toJsonString(boolean)will skip unset fields.
 If type is BINARY then the value must be a base64 encoded value. Note: This methods doesn't handle arbitrary JSON, it has to comply to the given type. Also, top level null is not supported. - Parameters:
- type- the type definition of the instance.
- jsonString- the JSON representation
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- for invalid documents
 
- 
createValueFromJsonCreates a new value from a JSON doc (which is given as a Reader). If type is RecordDef then: (a) the JSON doc may have fields that do not appear in the record schema. Such fields are simply skipped. (b) the JSON doc may be missing fields that appear in the record's schema. Such fields will remain unset in the record value. If type is BINARY then the value must be a base64 encoded value. Note: This methods doesn't handle arbitrary JSON, it has to comply to the given type. Also, top level null is not supported.- Parameters:
- type- the type definition of the instance.
- jsonReader- the JSON representation
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- for invalid documents
- IOException- for an invalid Reader
 
- 
createValueFromJsonpublic static FieldValue createValueFromJson(FieldDef type, InputStream jsonStream) throws IOException Creates a new value from a JSON doc (which is given as an InputStream). If type is RecordDef then: (a) the JSON doc may have fields that do not appear in the record schema. Such fields are simply skipped. (b) the JSON doc may be missing fields that appear in the record's schema. Such fields will remain unset in the record value. If type is BINARY then the value must be a base64 encoded value. Note: This methods doesn't handle arbitrary JSON, it has to comply to the given type. Also, top level null is not supported.- Parameters:
- type- the type definition of the instance.
- jsonStream- the JSON representation
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- for invalid documents
- IOException- for an invalid InputStream
 
- 
createBinaryCreates a BinaryValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createBooleanCreates a BooleanValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createDoubleCreates a DoubleValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createFloatCreates a FloatValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createIntegerCreates a IntegerValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createLongCreates a LongValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createNumberCreates a NumberValue instance from a int value.- Parameters:
- v- the java value
- Returns:
- the newly created instance
- Since:
- 4.4
 
- 
createNumberCreates a NumberValue instance from a long value.- Parameters:
- v- the java value
- Returns:
- the newly created instance
- Since:
- 4.4
 
- 
createNumberCreates a NumberValue instance from a float value.- Parameters:
- v- the java value
- Returns:
- the newly created instance
- Since:
- 4.4
 
- 
createNumberCreates a NumberValue instance from a double value.- Parameters:
- v- the java value
- Returns:
- the newly created instance
- Since:
- 4.4
 
- 
createNumberCreates a NumberValue instance from a BigDecimal value.- Parameters:
- v- the java value
- Returns:
- the newly created instance
- Since:
- 4.4
 
- 
createJsonNullCreates a special FieldValue instance representing a JSON null value, which returns true fromFieldValue.isJsonNull().- Returns:
- the newly created instance
- Since:
- 4.3
 
- 
createStringCreates a StringValue instance from its java representation.- Parameters:
- v- the java value
- Returns:
- the newly created instance
 
- 
createTimestampCreates a TimestampValue instance from its java representation.- Parameters:
- v- the java value
- precision- the precision of Timestamp value
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- if precision is invalid.
 
- 
createTimestampCreates a TimestampValue instance from a string in format ofTimestampDef.DEFAULT_PATTERN.- Parameters:
- s- the string value
- precision- the precision of Timestamp value
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- if precision is invalid or the string is not in the format of- TimestampDef.DEFAULT_PATTERN.
 
- 
createTimestamppublic static TimestampValue createTimestamp(int year, int month, int day, int hour, int minute, int second, int fracSeconds, int precision) Creates a TimestampValue instance from date time components.- Parameters:
- year- the year, from -6383 to 9999.
- month- the month of year, from 1 to 12
- day- the day of month, from 1 to 31
- hour- the hour of day, from 0 to 23
- minute- the minute of hour, from 0 to 59
- second- the second of minute, from 0 to 59
- fracSeconds- the number of fractional seconds in the specified precision. e.g. if precision is 3, then fractional seconds can be a value within the range 0 ~ 999.
- precision- the precision of Timestamp value
- Returns:
- the newly created instance
- Throws:
- IllegalArgumentException- if precision is invalid or any component is invalid.
 
 
-