Class SpannerDecoder
java.lang.Object
com.salesforce.multicloudj.docstore.gcp.SpannerDecoder
- All Implemented Interfaces:
Decoder
SpannerDecoder implements the Decoder interface for Google Cloud Spanner. It converts Spanner
Struct types into Java objects for retrieval from Spanner.
This decoder handles: - Primitive types (boolean, int, long, double, string) - Byte arrays - Lists and arrays - Maps and structs - Null values
-
Constructor Summary
ConstructorsConstructorDescriptionSpannerDecoder(com.google.cloud.spanner.Struct struct) Creates a new SpannerDecoder with the specified Struct.SpannerDecoder(com.google.cloud.spanner.Value value) -
Method Summary
Modifier and TypeMethodDescriptionasBool()Decodes a Spanner Value into a boolean.byte[]asBytes()Decodes a Spanner Value into a byte array.asDouble()Decodes a Spanner Value into a double.asFloat()Decodes a Spanner Value into a float.asInt()Decodes a Spanner Value into an integer.Converts the Spanner Value into a Java object.asLong()Decodes a Spanner Value into a long.asNull()Checks if the Spanner Value is null.asString()Decodes a Spanner Value into a string.voiddecodeList(ListDecoderCallback callback) Decodes a list of Spanner Values using the provided callback.voiddecodeMap(MapDecoderCallback callback) Decodes a map of Spanner Values using the provided callback.intlistLen()Gets the length of the list in the Spanner Value.voidsetValue(com.google.cloud.spanner.Value value) Sets the current value to decode.
-
Constructor Details
-
SpannerDecoder
public SpannerDecoder(com.google.cloud.spanner.Struct struct) Creates a new SpannerDecoder with the specified Struct.- Parameters:
struct- The Spanner Struct to decode
-
SpannerDecoder
public SpannerDecoder(com.google.cloud.spanner.Value value)
-
-
Method Details
-
asString
Decodes a Spanner Value into a string. -
asInt
Decodes a Spanner Value into an integer. -
asLong
Decodes a Spanner Value into a long. -
asFloat
Decodes a Spanner Value into a float. -
asDouble
Decodes a Spanner Value into a double. -
asBytes
public byte[] asBytes()Decodes a Spanner Value into a byte array. -
asBool
Decodes a Spanner Value into a boolean. -
asNull
Checks if the Spanner Value is null. -
decodeList
Decodes a list of Spanner Values using the provided callback.- Specified by:
decodeListin interfaceDecoder- Parameters:
callback- The callback to handle each list element
-
listLen
public int listLen()Gets the length of the list in the Spanner Value. -
decodeMap
Decodes a map of Spanner Values using the provided callback. -
asInterface
Converts the Spanner Value into a Java object. This method handles all supported Spanner types and converts them into their corresponding Java types.- Specified by:
asInterfacein interfaceDecoder- Returns:
- The converted Java object
-
setValue
public void setValue(com.google.cloud.spanner.Value value) Sets the current value to decode.- Parameters:
value- The value to decode
-