org.polypheny.jdbc.types.TypedValue wraps a Prism value. You get it from PolyRow.getValue or a field of a PolyDocument. Its conversion methods follow the driver’s type conversion rules. Use a conversion that matches the data type you expect.
Inspecting and reading values
getValueCase()exposes the value’s Prism type.isNull()distinguishes a Prism null from a non-null value. CheckisNull()before converting to a primitive. A primitive conversion can return a default such as zero for a null.asObject()returns the driver’s natural Java type, such asInteger,Long,String,byte[],java.sql.Array,PolyDocument,PolyInterval, ornull. TheCalendaroverload uses the calendar for temporal values. TheClass<T>and type map overloads are specific to user-defined type prototypes and are unavailable for ordinary values.getLength()returns a string’s length or the number of binary bytes, and returns zero for other types.getTrimmed(int)is a driver utility for taking a prefix of a materialized string or binary value.isUdt()currently returns false.toString()delegates toasString()and wraps a conversion failure inRuntimeException. For database values, call the typed method directly to handle conversion errors as SQL exceptions.
Conversions and factories
| Value | Read with | Construct with |
|---|---|---|
| Boolean | asBoolean |
fromBoolean |
| Integers | asByte, asShort, asInt, asLong |
fromByte, fromShort, fromInteger, fromLong |
| Floating-point and decimal | asFloat, asDouble, asBigDecimal, asBigDecimal(int scale) |
fromFloat, fromDouble, fromBigDecimal |
| Text | asString, asNString, asCharacterStream, asNCharacterStream |
fromString, fromNString, fromCharacterStream, fromNCharacterStream |
| Binary and streams | asBytes, asAsciiStream, asBinaryStream, asUnicodeStream |
fromBytes, fromAsciiStream, fromBinaryStream, fromUnicodeStream |
| Large objects | asBlob, asClob, asNClob |
fromBlob, fromClob, fromNClob |
| Date and time | asDate, asTime, asTimestamp, with optional Calendar |
fromDate, fromTime, fromTimestamp, with optional Calendar |
| Collection and document | asArray, asDocument |
fromArray, fromDocument |
| Interval | asInterval |
fromInterval |
| Generic or null | asObject, isNull |
fromObject(Object), fromObject(Object, int targetSqlType), fromNull |
The stream and large-object factories have overloads for streams or readers and optional lengths. They can buffer their inputs in memory. Use the length-free overloads unless an API requires a length.
fromRef, fromUrl, fromRowId, fromSQLXML, fromStruct, and fromObject(Object, int, int) are unsupported. The matching asRef, asUrl, asSQLXML, and asStruct readers fail with a type mismatch. asRowId can return null for a Prism null but the driver does not map a result value to a row ID.
Protocol types
TypedValue(ProtoValue) wraps a value from the driver’s bundled Prism classes and serialize() builds a Prism ProtoValue. See the in-memory document example for a round trip.
To represent an interval, PolyInterval(long months, long milliseconds) stores the calendar and elapsed-time components separately. getMonths() and getMilliseconds() return those components, equals(Object) compares both, and toString() formats them for display.
The full signatures and implementation are available in the v3.1 TypedValue source.