# Class WireOutput (0.27.1)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [0.27.1 (latest)](https://docs.cloud.google.com/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.27.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.27.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.26.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.26.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.25.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.25.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.24.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.24.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.23.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.23.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.22.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.22.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.21.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.21.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.20.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.20.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.19.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.19.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.18.4](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.18.4/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.17.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.17.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.16.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.16.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.15.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.15.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.14.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.14.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.9.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.9.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.8.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.8.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.7.0](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.7.0/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.6.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.6.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)
- [0.5.1](https://docs.cloud.google.com/java/docs/reference/pgadapter/0.5.1/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput)

    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](https://docs.cloud.google.com/java/docs/reference/pgadapter/latest/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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> WireOutput

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### UTF8

    protected static final Charset UTF8

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html` |   |

## Constructors

### WireOutput(DataOutputStream output, int length)

    public WireOutput(DataOutputStream output, int length)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/io/DataOutputStream.html` |
| `length` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

## Fields

### length

    protected int length

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### outputStream

    protected DataOutputStream outputStream

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/DataOutputStream.html` |   |

## 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** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getMessageName()

    protected abstract String getMessageName()

Used for logging.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The official name of the wire message. |

### getPayloadString()

    protected abstract String getPayloadString()

Used for logging.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | 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](https://docs.cloud.google.com/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.wireoutput.DeclineSSLResponse)) send only one byte back. Override with false if that is the case.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | 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** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html` |   |

### send(boolean flush)

    public void send(boolean flush)

Same as [#send()](https://docs.cloud.google.com/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.wireoutput.WireOutput#com_google_cloud_spanner_pgadapter_wireoutput_WireOutput_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** ||
|---|---|
| **Name** | **Description** |
| `flush` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html` |   |

### sendPayload()

    protected abstract void sendPayload()

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

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html` |   |

### toString()

    public String toString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)