public class FieldValueFactory
extends java.lang.Object
| Constructor | Description |
|---|---|
FieldValueFactory() |
| Modifier and Type | Method | Description |
|---|---|---|
static BinaryValue |
createBinary(byte[] v) |
Creates a BinaryValue instance from its java representation.
|
static BooleanValue |
createBoolean(boolean v) |
Creates a BooleanValue instance from its java representation.
|
static DoubleValue |
createDouble(double v) |
Creates a DoubleValue instance from its java representation.
|
static FloatValue |
createFloat(float v) |
Creates a FloatValue instance from its java representation.
|
static IntegerValue |
createInteger(int v) |
Creates a IntegerValue instance from its java representation.
|
static FieldValue |
createJsonNull() |
Creates a special FieldValue instance representing a JSON null
value, which returns true from
FieldValue.isJsonNull(). |
static LongValue |
createLong(long v) |
Creates a LongValue instance from its java representation.
|
static NumberValue |
createNumber(double v) |
Creates a NumberValue instance from a double value.
|
static NumberValue |
createNumber(float v) |
Creates a NumberValue instance from a float value.
|
static NumberValue |
createNumber(int v) |
Creates a NumberValue instance from a int value.
|
static NumberValue |
createNumber(long v) |
Creates a NumberValue instance from a long value.
|
static NumberValue |
createNumber(java.math.BigDecimal v) |
Creates a NumberValue instance from a BigDecimal value.
|
static StringValue |
createString(java.lang.String v) |
Creates a StringValue instance from its java representation.
|
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.
|
static TimestampValue |
createTimestamp(java.lang.String s,
int precision) |
Creates a TimestampValue instance from a string in format of
TimestampDef.DEFAULT_PATTERN. |
static TimestampValue |
createTimestamp(java.sql.Timestamp v,
int precision) |
Creates a TimestampValue instance from its java representation.
|
static FieldValue |
createValueFromJson(java.io.Reader jsonReader) |
Creates a FieldValue instance from JSON input where the type is not
known.
|
static FieldValue |
createValueFromJson(java.lang.String jsonString) |
Creates a FieldValue instance from JSON input where the type is not
known.
|
static FieldValue |
createValueFromJson(FieldDef type,
java.io.InputStream jsonStream) |
Creates a new value from a JSON doc (which is given as an InputStream).
|
static FieldValue |
createValueFromJson(FieldDef type,
java.io.Reader jsonReader) |
Creates a new value from a JSON doc (which is given as a Reader).
|
static FieldValue |
createValueFromJson(FieldDef type,
java.lang.String jsonString) |
Creates a new value from a JSON doc (which is given as a String).
|
public static FieldValue createValueFromJson(java.lang.String jsonString)
jsonString - the JSON representationjava.lang.IllegalArgumentException - if the input is not valid JSON or the
input cannot be parsed, or it cannot be mapped into supported data types.public static FieldValue createValueFromJson(java.io.Reader jsonReader) throws java.io.IOException
jsonReader - a Reader over JSONjava.lang.IllegalArgumentException - if the input is not valid JSON or the
input cannot be parsed, or it cannot be mapped into supported data types.java.io.IOException - if the input is not valid JSON or the input cannot
be parse, or it cannot be mapped into supported data types.public static FieldValue createValueFromJson(FieldDef type, java.lang.String jsonString)
Creates a new value from a JSON doc (which is given as a String).
If type is RecordDef then:RecordValue.get(String) will return null and FieldValue.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.
type - the type definition of the instance.jsonString - the JSON representationjava.lang.IllegalArgumentException - for invalid documentspublic static FieldValue createValueFromJson(FieldDef type, java.io.Reader jsonReader) throws java.io.IOException
type - the type definition of the instance.jsonReader - the JSON representationjava.lang.IllegalArgumentException - for invalid documentsjava.io.IOException - for an invalid Readerpublic static FieldValue createValueFromJson(FieldDef type, java.io.InputStream jsonStream) throws java.io.IOException
type - the type definition of the instance.jsonStream - the JSON representationjava.lang.IllegalArgumentException - for invalid documentsjava.io.IOException - for an invalid InputStreampublic static BinaryValue createBinary(byte[] v)
v - the java valuepublic static BooleanValue createBoolean(boolean v)
v - the java valuepublic static DoubleValue createDouble(double v)
v - the java valuepublic static FloatValue createFloat(float v)
v - the java valuepublic static IntegerValue createInteger(int v)
v - the java valuepublic static LongValue createLong(long v)
v - the java valuepublic static NumberValue createNumber(int v)
v - the java valuepublic static NumberValue createNumber(long v)
v - the java valuepublic static NumberValue createNumber(float v)
v - the java valuepublic static NumberValue createNumber(double v)
v - the java valuepublic static NumberValue createNumber(java.math.BigDecimal v)
v - the java valuepublic static FieldValue createJsonNull()
FieldValue.isJsonNull().public static StringValue createString(java.lang.String v)
v - the java valuepublic static TimestampValue createTimestamp(java.sql.Timestamp v, int precision)
v - the java valueprecision - the precision of Timestamp valuejava.lang.IllegalArgumentException - if precision is invalid.public static TimestampValue createTimestamp(java.lang.String s, int precision)
TimestampDef.DEFAULT_PATTERN.s - the string valueprecision - the precision of Timestamp valuejava.lang.IllegalArgumentException - if precision is invalid or the string
is not in the format of TimestampDef.DEFAULT_PATTERN.public static TimestampValue createTimestamp(int year, int month, int day, int hour, int minute, int second, int fracSeconds, int precision)
year - the year, from -6383 to 9999.month - the month of year, from 1 to 12day - the day of month, from 1 to 31hour - the hour of day, from 0 to 23minute - the minute of hour, from 0 to 59second - the second of minute, from 0 to 59fracSeconds - 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 valuejava.lang.IllegalArgumentException - if precision is invalid or any component
is invalid.Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.