class PostgreSQLDataRowPacket implements PostgreSQLPacket {

    @Override
    public void write(final PostgreSQLPacketPayload payload) {
        payload.writeInt2(data.size());
        for (Object each : data) {
            if (null == each) {
                payload.writeInt4(0xFFFFFFFF);
            } else {
                if (each instanceof byte[]) {
                    payload.writeInt4(((byte[]) each).length);
                    payload.writeBytes((byte[]) each);
                } else if (each instanceof SQLXML) {
                    writeSQLXMLData(payload, each);
                } else {
                    String columnData = each.toString();
                    payload.writeInt4(columnData.getBytes().length);
                    payload.writeStringEOF(columnData);
                }
            }
        }
    }

}