Value
The Value class is the untyped representation of any SurrealDB value. It provides methods to check the underlying type and extract the value as a native Java type or SDK class. You can also convert a Value to a Java POJO using .get(Class<T>).
Source: surrealdb.java
Type Checking Methods
Each method returns true when the Value holds the corresponding SurrealDB type.
| Method | Returns true when |
|---|---|
isNone() | Value is NONE |
isNull() | Value is NULL |
isBoolean() | Value is a boolean |
isDouble() | Value is a float/double |
isLong() | Value is an integer/long |
isBigDecimal() | Value is a decimal |
isString() | Value is a string |
isUuid() | Value is a UUID |
isArray() | Value is an array |
isObject() | Value is an object |
isGeometry() | Value is a geometry |
isDateTime() | Value is a datetime |
isDuration() | Value is a duration |
isBytes() | Value is binary data |
isRecordId() | Value is a record ID |
isFile() | Value is a file reference |
isRange() | Value is a range |
isTable() | Value is a table name |
Getter Methods
Each getter extracts the underlying value. Call the corresponding type check method first to avoid unexpected results.
| Method | Return Type |
|---|---|
getBoolean() | boolean |
getDouble() | double |
getLong() | long |
getBigDecimal() | BigDecimal |
getString() | String |
getUuid() | UUID |
getArray() | Array |
getObject() | Object |
getGeometry() | Geometry |
getDateTime() | ZonedDateTime |
getDuration() | Duration |
getBytes() | byte[] |
getRecordId() | RecordId |
getFile() | FileRef |
getRangeStart() | Optional<Value> |
getRangeEnd() | Optional<Value> |
getTable() | String |
POJO Conversion
.get(type)
Converts the value to a Java POJO. The target class must have a public no-argument constructor. Fields are matched by name between the SurrealDB object and the Java class.
| Parameter | Type | Description |
|---|---|---|
type | Class<T> | The target class to deserialize into. |
Returns: T
Array
The Array class represents a SurrealDB array value. It implements Iterable<Value> and provides both untyped and typed iteration.
Methods
.get(idx)
Returns the value at the specified index.
| Parameter | Type | Description |
|---|---|---|
idx | int | The zero-based index of the element. |
Returns: Value
.len()
Returns the number of elements in the array.
Returns: int
.iterator()
Returns an iterator over the array elements as Value instances.
Returns: Iterator<Value>
.iterator(clazz)
Returns a typed iterator that deserializes each element into the specified class.
| Parameter | Type | Description |
|---|---|---|
clazz | Class<T> | The class to deserialize each element into. |
Returns: Iterator<T>
.synchronizedIterator()
Returns a thread-safe iterator over the array elements.
Returns: Iterator<Value>
.synchronizedIterator(clazz)
Returns a thread-safe typed iterator that deserializes each element into the specified class.
| Parameter | Type | Description |
|---|---|---|
clazz | Class<T> | The class to deserialize each element into. |
Returns: Iterator<T>
Object
The Object class represents a SurrealDB object value. It implements Iterable<Entry> and provides key-based access to its fields.
Methods
.get(key)
Returns the value associated with the specified key.
| Parameter | Type | Description |
|---|---|---|
key | String | The field name to look up. |
Returns: Value
.len()
Returns the number of key-value pairs in the object.
Returns: int
.iterator()
Returns an iterator over the object's key-value pairs as Entry instances.
Returns: Iterator<Entry>
.synchronizedIterator()
Returns a thread-safe iterator over the object's key-value pairs.
Returns: Iterator<Entry>
Entry
The Entry class represents a key-value pair in a SurrealDB object.
Methods
.getKey()
Returns the field name of this entry.
Returns: String
.getValue()
Returns the value of this entry.
Returns: Value
See Also
Value types — Type mapping overview
RecordId — Record identifiers
SurrealQL data model — SurrealDB data types and structures