Class WireOutput (0.19.1)

public abstract class WireOutput

Classes inheriting WireOutput concern themselves with sending data back to the client using PG wire protocol. These classes function similarly to com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage in that they use the constructor to instantiate items, but require send to be called to actually send data. Here, you must override postSend with data you wish to send. Note that this subclass will handle sending the identifier and length (provided you initialize them correctly through getIdentifier and he constructor respectively) via send, so you just have to implement payload sending.

Inheritance

java.lang.Object > WireOutput

Static Fields

UTF8

protected static final Charset UTF8
Field Value
TypeDescription
Charset

Constructors

WireOutput(DataOutputStream output, int length)

public WireOutput(DataOutputStream output, int length)
Parameters
NameDescription
outputDataOutputStream
lengthint

Fields

length

protected int length
Field Value
TypeDescription
int

outputStream

protected DataOutputStream outputStream
Field Value
TypeDescription
DataOutputStream

Methods

getIdentifier()

public abstract byte getIdentifier()

Override this to specify the byte which represents the protocol for the specific message. Used for logging and by send.

Returns
TypeDescription
byte

getMessageName()

protected abstract String getMessageName()

Used for logging.

Returns
TypeDescription
String

The official name of the wire message.

getPayloadString()

protected abstract String getPayloadString()

Used for logging.

Returns
TypeDescription
String

Payload metadata.

isCompoundResponse()

protected boolean isCompoundResponse()

Whether this response sends more data than just the identifier (i.e.: length). WireOutput items are convoluted in that some do send a large payload, and other (such as DeclineSSLResponse) send only one byte back. Override with false if that is the case.

Returns
TypeDescription
boolean

True if compound, false otherwise.

send()

public void send()

This is the method which must be called to actually send data. Here we log information, send the protocol identifier and length automatically (provided those items were instantiated correctly). For most WireOutput subclasses this should be unchanged; there are however exceptions (such as where length) need not be sent for very specific protocols: for those, override this and you will need to send the identifier and log yourself.

Exceptions
TypeDescription
Exception

send(boolean flush)

public void send(boolean flush)

Same as #send(), but with the option to skip the flush at the end. This is more efficient for responses that contain multiple parts, such as query results.

Parameter
NameDescription
flushboolean
Exceptions
TypeDescription
Exception

sendPayload()

protected abstract void sendPayload()

Override this method to include post-processing and metadata in the sending process. Template method for send.

Exceptions
TypeDescription
Exception

toString()

public String toString()
Returns
TypeDescription
String
Overrides