Class Parser<T> (0.24.0)

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.

Inheritance

Object > Parser<T>

Type Parameter

Name Description
T

Static Fields

PG_EPOCH_DAYS

public static final long PG_EPOCH_DAYS
Field Value
Type Description
long

PG_EPOCH_SECONDS

public static final long PG_EPOCH_SECONDS
Field Value
Type Description
long

UTF8

protected static final Charset UTF8
Field Value
Type Description
Charset

Static Methods

create(ResultSet result, Type type, int columnarPosition, SessionState sessionState)

public static Parser<?> create(ResultSet result, Type type, int columnarPosition, SessionState sessionState)

Factory method for parsing given a result set, for the specified column.

Parameters
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.

sessionState SessionState
Returns
Type Description
Parser<?>

The parser object for the designated data type.

create(SessionState sessionState, byte[] item, int oidType, Parser.FormatCode formatCode)

public static Parser<?> create(SessionState sessionState, byte[] item, int oidType, Parser.FormatCode formatCode)

Factory method to create a Parser subtype with a designated type from a byte array.

Parameters
Name Description
sessionState SessionState

The session state to use when parsing and converting

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

Returns
Type Description
Parser<?>

The parser object for the designated data type.

create(Object result, Type.Code typeCode, SessionState sessionState)

protected static Parser<?> create(Object result, Type.Code typeCode, SessionState sessionState)

Factory method for parsing generic data given a specified type.

Parameters
Name Description
result Object

The generic object to parse.

typeCode com.google.cloud.spanner.Type.Code

The type of the object to be parsed.

sessionState SessionState
Returns
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.

Parameter
Name Description
type com.google.cloud.spanner.Type

the type to translate

Returns
Type Description
int

The OID constant value for the type

toOid(Type type)

public static int toOid(Type type)

Translates the given Cloud Spanner Type to a PostgreSQL OID constant.

Parameter
Name Description
type com.google.spanner.v1.Type

the type to translate

Returns
Type Description
int

The OID constant value for the type

toType(int oid)

public static Type toType(int oid)
Parameter
Name Description
oid int
Returns
Type Description
com.google.cloud.spanner.Type

Constructors

Parser()

public Parser()

Fields

item

protected T item
Field Value
Type Description
T

Methods

binaryParse()

protected abstract byte[] binaryParse()

Used to parse data type onto binary. Override this to change binary representation.

Returns
Type Description
byte[]

bind(Statement.Builder statementBuilder, String name)

public abstract void bind(Statement.Builder statementBuilder, String name)
Parameters
Name Description
statementBuilder com.google.cloud.spanner.Statement.Builder
name String

getItem()

public T getItem()

Returns the item helder by this parser.

Returns
Type Description
T

parse(ProxyServer.DataFormat format)

public byte[] parse(ProxyServer.DataFormat format)

Parses data based on specified data format (Spanner, text, or binary)

Parameter
Name Description
format ProxyServer.DataFormat

One of possible DataFormat types to parse data.

Returns
Type Description
byte[]

Byte format version of the input object.

spannerBinaryParse()

protected byte[] spannerBinaryParse()
Returns
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.

Returns
Type Description
String

Spanner string representation of data.

stringBinaryParse()

protected byte[] stringBinaryParse()
Returns
Type Description
byte[]

Binary representation of string data.

stringParse()

public abstract String stringParse()

Used to parse data type into string. Override this to change the string representation.

Returns
Type Description
String

String representation of data.