Class Parser<T> (0.26.0)
Stay organized with collections
Save and categorize content based on your preferences.
publicabstractclass 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.
Inherited Members
Type Parameter |
|
|---|---|
| Name | Description |
T |
|
Static Fields
PG_EPOCH_DAYS
publicstaticfinallongPG_EPOCH_DAYS| Field Value | |
|---|---|
| Type | Description |
long |
|
PG_EPOCH_SECONDS
publicstaticfinallongPG_EPOCH_SECONDS| Field Value | |
|---|---|
| Type | Description |
long |
|
UTF8
protectedstaticfinalCharsetUTF8| Field Value | |
|---|---|
| Type | Description |
Charset |
|
Static Methods
create(ResultSet result, Type type, int columnarPosition, SessionState sessionState)
publicstaticParser<?>create(ResultSetresult,Typetype,intcolumnarPosition,SessionStatesessionState)Factory method for parsing given a result set, for the specified column.
| Parameters | |
|---|---|
| Name | Description |
result |
com.google.cloud.spanner.ResultSetThe result set object containing all data retrieved. |
type |
com.google.cloud.spanner.TypeThe 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)
publicstaticParser<?>create(SessionStatesessionState,byte[]item,intoidType,Parser.FormatCodeformatCode)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)
protectedstaticParser<?>create(Objectresult,Type.CodetypeCode,SessionStatesessionState)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.CodeThe type of the object to be parsed. |
sessionState |
SessionState |
| Returns | |
|---|---|
| Type | Description |
Parser<?> |
The parser object for the designated data type. |
toOid(Type type)
publicstaticinttoOid(Typetype)Translates the given Cloud Spanner Type to a PostgreSQL OID constant.
| Parameter | |
|---|---|
| Name | Description |
type |
com.google.cloud.spanner.Typethe type to translate |
| Returns | |
|---|---|
| Type | Description |
int |
The OID constant value for the type |
toOid(Type type)
publicstaticinttoOid(Typetype)Translates the given Cloud Spanner Type to a PostgreSQL OID constant.
| Parameter | |
|---|---|
| Name | Description |
type |
com.google.spanner.v1.Typethe type to translate |
| Returns | |
|---|---|
| Type | Description |
int |
The OID constant value for the type |
toType(int oid)
publicstaticTypetoType(intoid)| Parameter | |
|---|---|
| Name | Description |
oid |
int |
| Returns | |
|---|---|
| Type | Description |
com.google.cloud.spanner.Type |
|
Constructors
Parser()
publicParser()Fields
item
protectedTitem| Field Value | |
|---|---|
| Type | Description |
T |
|
Methods
binaryParse()
protectedabstractbyte[]binaryParse()Used to parse data type onto binary. Override this to change binary representation.
| Returns | |
|---|---|
| Type | Description |
byte[] |
|
bind(Statement.Builder statementBuilder, String name)
publicabstractvoidbind(Statement.BuilderstatementBuilder,Stringname)| Parameters | |
|---|---|
| Name | Description |
statementBuilder |
com.google.cloud.spanner.Statement.Builder |
name |
String |
getItem()
publicTgetItem()Returns the item helder by this parser.
| Returns | |
|---|---|
| Type | Description |
T |
|
parse(ProxyServer.DataFormat format)
publicbyte[]parse(ProxyServer.DataFormatformat)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()
protectedbyte[]spannerBinaryParse()| Returns | |
|---|---|
| Type | Description |
byte[] |
Binary representation of spanner string data. |
spannerParse()
protectedStringspannerParse()Used to parse data type onto spanner format. Override this to change spanner representation.
| Returns | |
|---|---|
| Type | Description |
String |
Spanner string representation of data. |
stringBinaryParse()
protectedbyte[]stringBinaryParse()| Returns | |
|---|---|
| Type | Description |
byte[] |
Binary representation of string data. |
stringParse()
publicabstractStringstringParse()Used to parse data type into string. Override this to change the string representation.
| Returns | |
|---|---|
| Type | Description |
String |
String representation of data. |