Class Parser<T> (0.7.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

NameDescription
T

Static Fields

PG_EPOCH_DAYS

public static final long PG_EPOCH_DAYS
Field Value
TypeDescription
long

PG_EPOCH_SECONDS

public static final long PG_EPOCH_SECONDS
Field Value
TypeDescription
long

UTF8

protected static final Charset UTF8
Field Value
TypeDescription
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.

Parameters
NameDescription
itembyte[]

The data to be parsed

oidTypeint

The type of the designated data

formatCodeParser.FormatCode

The format of the data to be parsed

Returns
TypeDescription
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.

Parameters
NameDescription
resultcom.google.cloud.spanner.ResultSet

The result set object containing all data retrieved.

typecom.google.cloud.spanner.Type

The type of the data to be parsed.

columnarPositionint

Column from the result to be parsed.

Returns
TypeDescription
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.

Parameters
NameDescription
resultObject

The generic object to parse.

typeCodecom.google.cloud.spanner.Type.Code

The type of the object to be parsed.

Returns
TypeDescription
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
NameDescription
typecom.google.cloud.spanner.Type

the type to translate

Returns
TypeDescription
int

The OID constant value for the type

Constructors

Parser()

public Parser()

Fields

item

protected T item
Field Value
TypeDescription
T

Methods

binaryParse()

protected abstract byte[] binaryParse()

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

Returns
TypeDescription
byte[]

bind(Statement.Builder statementBuilder, String name)

public abstract void bind(Statement.Builder statementBuilder, String name)
Parameters
NameDescription
statementBuildercom.google.cloud.spanner.Statement.Builder
nameString

getItem()

public T getItem()

Returns the item helder by this parser.

Returns
TypeDescription
T

parse(ProxyServer.DataFormat format)

public byte[] parse(ProxyServer.DataFormat format)

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

Parameter
NameDescription
formatProxyServer.DataFormat

One of possible DataFormat types to parse data.

Returns
TypeDescription
byte[]

Byte format version of the input object.

spannerBinaryParse()

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

Spanner string representation of data.

stringBinaryParse()

protected byte[] stringBinaryParse()
Returns
TypeDescription
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
TypeDescription
String

String representation of data.