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 Boolean
asBool()
Decodes a Spanner Value into a boolean.byte[]
asBytes()
Decodes a Spanner Value into a byte array.Double
asDouble()
Decodes a Spanner Value into a double.Float
asFloat()
Decodes a Spanner Value into a float.Integer
asInt()
Decodes a Spanner Value into an integer.Object
asInterface()
Converts the Spanner Value into a Java object.Long
asLong()
Decodes a Spanner Value into a long.Boolean
asNull()
Checks if the Spanner Value is null.String
asString()
Decodes a Spanner Value into a string.void
decodeList(ListDecoderCallback callback)
Decodes a list of Spanner Values using the provided callback.void
decodeMap(MapDecoderCallback callback)
Decodes a map of Spanner Values using the provided callback.int
listLen()
Gets the length of the list in the Spanner Value.void
setValue(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:
decodeList
in 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:
asInterface
in 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
-
-