Class SpannerDecoder
- java.lang.Object
-
- com.salesforce.multicloudj.docstore.gcp.SpannerDecoder
-
- All Implemented Interfaces:
Decoder
public class SpannerDecoder extends Object implements 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
Constructors Constructor Description SpannerDecoder(com.google.cloud.spanner.Struct struct)Creates a new SpannerDecoder with the specified Struct.SpannerDecoder(com.google.cloud.spanner.Value value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanasBool()Decodes a Spanner Value into a boolean.byte[]asBytes()Decodes a Spanner Value into a byte array.DoubleasDouble()Decodes a Spanner Value into a double.FloatasFloat()Decodes a Spanner Value into a float.IntegerasInt()Decodes a Spanner Value into an integer.ObjectasInterface()Converts the Spanner Value into a Java object.LongasLong()Decodes a Spanner Value into a long.BooleanasNull()Checks if the Spanner Value is null.StringasString()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.
-
-
-
Method Detail
-
asString
public String asString()
Decodes a Spanner Value into a string.
-
asInt
public Integer asInt()
Decodes a Spanner Value into an integer.
-
asLong
public Long asLong()
Decodes a Spanner Value into a long.
-
asFloat
public Float asFloat()
Decodes a Spanner Value into a float.
-
asDouble
public Double asDouble()
Decodes a Spanner Value into a double.
-
asBytes
public byte[] asBytes()
Decodes a Spanner Value into a byte array.
-
asBool
public Boolean asBool()
Decodes a Spanner Value into a boolean.
-
asNull
public Boolean asNull()
Checks if the Spanner Value is null.
-
decodeList
public void decodeList(ListDecoderCallback callback)
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
public void decodeMap(MapDecoderCallback callback)
Decodes a map of Spanner Values using the provided callback.
-
asInterface
public Object 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
-
-