Class VelrValue
VelrValue preserves both the public Velr value kind and the underlying storage kind
used for exact reconstruction. Vector embedding callbacks receive values through VectorEmbeddingField.velrValue() so embedders can choose between Java scalar accessors, canonical
JSON, display text, and raw storage bytes.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn this value as a boolean.byte[]asBytes()Return this value as bytes.Return this date value as canonical text.doubleasDouble()Return this value as a double.Return this duration value as canonical text.Return this geography value as canonical GeoJSON.Return this geometry value as canonical GeoJSON.Return this list value as canonical JSON.Return this local-datetime value as canonical text.Return this local-time value as canonical text.longasLong()Return this value as a 64-bit integer.asObject()Return the Java-native value for simple kinds.Return this point value as canonical GeoJSON.asString()Return this value as a string.Return this vector value as canonical JSON.Return this zoned-datetime value as canonical text.Return this zoned-time value as canonical text.static VelrValuebool(boolean value) Create a Velr boolean value.static VelrValueCreate a Velr bytes value.static VelrValuecanonical(VelrValueType type, VelrStorageType storageType, String valueJson, String display, byte[] storageBytes) Create a non-scalar Velr value from canonical renderings.display()Return the display rendering suitable for text embedders and logs.static VelrValuedoubleValue(double value) Create a Velr double value.static VelrValueint64(long value) Create a Velr 64-bit integer value.booleanisNull()Return whether this value is the Velrnullvalue.booleanReturn whether this value is one of Velr's spatial types.booleanReturn whether this value is one of Velr's temporal types.static VelrValueCreate the Velrnullvalue.byte[]Return the raw TEXT or BLOB storage payload when the native storage representation has one.Return the underlying storage kind used for exact reconstruction.static VelrValueCreate a Velr string value.toString()Return the display rendering of this value.type()Return the public Velr value kind.Return the canonical JSON rendering of the Velr value.
-
Method Details
-
nullValue
Create the Velrnullvalue.- Returns:
- a null Velr value
-
bool
Create a Velr boolean value.- Parameters:
value- boolean value- Returns:
- a Velr boolean value
-
int64
Create a Velr 64-bit integer value.- Parameters:
value- integer value- Returns:
- a Velr integer value
-
doubleValue
Create a Velr double value.- Parameters:
value- finite double value- Returns:
- a Velr double value
-
string
Create a Velr string value.- Parameters:
value- string value- Returns:
- a Velr string value
-
bytes
Create a Velr bytes value.valueJsonis the canonical JSON rendering anddisplayis the human-readable rendering used bydisplay()andtoString().- Parameters:
value- raw bytesvalueJson- canonical JSON renderingdisplay- display rendering- Returns:
- a Velr bytes value
-
canonical
public static VelrValue canonical(VelrValueType type, VelrStorageType storageType, String valueJson, String display, byte[] storageBytes) Create a non-scalar Velr value from canonical renderings.Use the dedicated scalar factories for null, boolean, integer, double, string, and bytes values. This factory is intended for temporal, spatial, list, and vector values when the canonical JSON/display/storage representation is already available.
- Parameters:
type- Velr value kindstorageType- underlying storage kindvalueJson- canonical JSON renderingdisplay- display renderingstorageBytes- raw TEXT or BLOB storage payload when available- Returns:
- a Velr value
-
type
Return the public Velr value kind.- Returns:
- value kind
-
storageType
Return the underlying storage kind used for exact reconstruction.- Returns:
- storage kind
-
asObject
Return the Java-native value for simple kinds.Scalars return
null,Boolean,Long,Double,String, orbyte[]. Temporal, spatial, list, and vector values return their canonical JSON text.- Returns:
- Java-native value or canonical JSON text
-
isNull
public boolean isNull()Return whether this value is the Velrnullvalue.- Returns:
trueforVelrValueType.NULL
-
isTemporal
public boolean isTemporal()Return whether this value is one of Velr's temporal types.- Returns:
truefor date, time, datetime, and duration values
-
isSpatial
public boolean isSpatial()Return whether this value is one of Velr's spatial types.- Returns:
truefor point, geometry, and geography values
-
asBoolean
public boolean asBoolean()Return this value as a boolean.- Returns:
- boolean value
-
asLong
public long asLong()Return this value as a 64-bit integer.- Returns:
- integer value
-
asDouble
public double asDouble()Return this value as a double.- Returns:
- double value
-
asString
Return this value as a string.- Returns:
- string value
-
asBytes
public byte[] asBytes()Return this value as bytes.- Returns:
- a defensive copy of the byte value
-
valueJson
Return the canonical JSON rendering of the Velr value.- Returns:
- canonical JSON text
-
display
Return the display rendering suitable for text embedders and logs.- Returns:
- display text
-
storageBytes
public byte[] storageBytes()Return the raw TEXT or BLOB storage payload when the native storage representation has one.- Returns:
- storage bytes, or an empty array when no byte-backed payload is available
-
asDateText
Return this date value as canonical text.- Returns:
- date text
-
asLocalTimeText
Return this local-time value as canonical text.- Returns:
- local-time text
-
asZonedTimeText
Return this zoned-time value as canonical text.- Returns:
- zoned-time text
-
asLocalDateTimeText
Return this local-datetime value as canonical text.- Returns:
- local-datetime text
-
asZonedDateTimeText
Return this zoned-datetime value as canonical text.- Returns:
- zoned-datetime text
-
asDurationText
Return this duration value as canonical text.- Returns:
- duration text
-
asPointGeoJson
Return this point value as canonical GeoJSON.- Returns:
- point GeoJSON
-
asGeometryGeoJson
Return this geometry value as canonical GeoJSON.- Returns:
- geometry GeoJSON
-
asGeographyGeoJson
Return this geography value as canonical GeoJSON.- Returns:
- geography GeoJSON
-
asListJson
Return this list value as canonical JSON.- Returns:
- list JSON
-
asVectorJson
Return this vector value as canonical JSON.- Returns:
- vector JSON
-
toString
Return the display rendering of this value.
-