public abstract class Parser<T>
Parser is the parsing superclass, used to take wire format data types and convert them specifically to desired byte types. Each subclass is assigned with a specific type.
Type Parameter
Name | Description |
T |
Static Fields
PG_EPOCH_DAYS
public static final long PG_EPOCH_DAYS
Type | Description |
long |
PG_EPOCH_SECONDS
public static final long PG_EPOCH_SECONDS
Type | Description |
long |
UTF8
protected static final Charset UTF8
Type | Description |
Charset |
Static Methods
create(byte[] item, int oidType, Parser.FormatCode formatCode)
public static Parser<?> create(byte[] item, int oidType, Parser.FormatCode formatCode)
Factory method to create a Parser subtype with a designated type from a byte array.
Name | Description |
item | byte[] The data to be parsed |
oidType | int The type of the designated data |
formatCode | Parser.FormatCode The format of the data to be parsed |
Type | Description |
Parser<?> | The parser object for the designated data type. |
create(ResultSet result, Type type, int columnarPosition)
public static Parser<?> create(ResultSet result, Type type, int columnarPosition)
Factory method for parsing given a result set, for the specified column.
Name | Description |
result | com.google.cloud.spanner.ResultSet The result set object containing all data retrieved. |
type | com.google.cloud.spanner.Type The type of the data to be parsed. |
columnarPosition | int Column from the result to be parsed. |
Type | Description |
Parser<?> | The parser object for the designated data type. |
create(Object result, Type.Code typeCode)
protected static Parser<?> create(Object result, Type.Code typeCode)
Factory method for parsing generic data given a specified type.
Name | Description |
result | Object The generic object to parse. |
typeCode | com.google.cloud.spanner.Type.Code The type of the object to be parsed. |
Type | Description |
Parser<?> | The parser object for the designated data type. |
toOid(Type type)
public static int toOid(Type type)
Translates the given Cloud Spanner Type to a PostgreSQL OID constant.
Name | Description |
type | com.google.cloud.spanner.Type the type to translate |
Type | Description |
int | The OID constant value for the type |
Constructors
Parser()
public Parser()
Fields
item
protected T item
Type | Description |
T |
Methods
binaryParse()
protected abstract byte[] binaryParse()
Used to parse data type onto binary. Override this to change binary representation.
Type | Description |
byte[] |
bind(Statement.Builder statementBuilder, String name)
public abstract void bind(Statement.Builder statementBuilder, String name)
Name | Description |
statementBuilder | com.google.cloud.spanner.Statement.Builder |
name | String |
parse(ProxyServer.DataFormat format)
public byte[] parse(ProxyServer.DataFormat format)
Parses data based on specified data format (Spanner, text, or binary)
Name | Description |
format | ProxyServer.DataFormat One of possible DataFormat types to parse data. |
Type | Description |
byte[] | Byte format version of the input object. |
spannerBinaryParse()
protected byte[] spannerBinaryParse()
Type | Description |
byte[] | Binary representation of spanner string data. |
spannerParse()
protected String spannerParse()
Used to parse data type onto spanner format. Override this to change spanner representation.
Type | Description |
String | Spanner string representation of data. |
stringBinaryParse()
protected byte[] stringBinaryParse()
Type | Description |
byte[] | Binary representation of string data. |
stringParse()
protected abstract String stringParse()
Used to parse data type into string. Override this to change the string representation.
Type | Description |
String | String representation of data. |