// Path: src/main/java/com/google/cloud/spanner/pgadapter/ProxyServer.java
// public enum DataFormat {
//   /**
//    * Data is returned to the client in binary form. This is the most compact format, but it is not
//    * supported by all clients for all data types. Only when the client specifically requests that
//    * the data should be returned in binary format, will the server do so.
//    */
//   POSTGRESQL_BINARY((short) 1),
//   /**
//    * The default format. Data is returned to the client in a format that PostgreSQL clients should
//    * be able to understand and stringParse. Use this format if you are using the {@link Server}
//    * with a client that tries to interpret the data that is returned by the server, such as for
//    * example the PostgreSQL JDBC driver.
//    */
//   POSTGRESQL_TEXT((short) 0),
//   /**
//    * Data is returned to the client in Cloud Spanner format. Use this format if you are using the
//    * server with a text-only client, such as psql, that does not try to interpret and stringParse
//    * the data that is returned.
//    */
//   SPANNER((short) 0);
// 
//   /**
//    * The internal code used by the PostgreSQL wire protocol to determine whether the data should
//    * be interpreted as text or binary.
//    */
//   private final short code;
// 
//   DataFormat(short code) {
//     this.code = code;
//   }
// 
//   public static DataFormat getDataFormat(int index,
//       IntermediateStatement statement,
//       QueryMode mode,
//       OptionsMetadata options) {
//     if (options.isBinaryFormat()) {
//       return DataFormat.POSTGRESQL_BINARY;
//     }
//     if (mode == QueryMode.SIMPLE) {
//       // Simple query mode is always text.
//       return DataFormat.fromTextFormat(options.getTextFormat());
//     } else {
//       return DataFormat.byCode(statement.getResultFormatCode(index), options.getTextFormat());
//     }
//   }
// 
//   public static DataFormat fromTextFormat(TextFormat textFormat) {
//     switch (textFormat) {
//       case POSTGRESQL:
//         return POSTGRESQL_TEXT;
//       case SPANNER:
//         return DataFormat.SPANNER;
//       default:
//         throw new IllegalArgumentException();
//     }
//   }
// 
//   public static DataFormat byCode(short code, TextFormat textFormat) {
//     return code == 0 ? fromTextFormat(textFormat) : POSTGRESQL_BINARY;
//   }
// 
//   public short getCode() {
//     return code;
//   }
// }


import com.google.cloud.spanner.pgadapter.ProxyServer.DataFormat;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import org.postgresql.core.Oid;
import org.postgresql.util.ByteConverter;
        result = new byte[1];
        ByteConverter.bool(result, 0, (Boolean) candidate);
        return result;
      case Types.INTEGER:
        result = new byte[4];
        ByteConverter.int4(result, 0, (Integer) candidate);
        return result;
      case Types.DOUBLE:
        result = new byte[8];
        ByteConverter.float8(result, 0, (Double) candidate);
        return result;
      case Types.BIGINT:
        result = new byte[8];
        ByteConverter.int8(result, 0, (Long) candidate);
        return result;
      default:
        throw new IllegalArgumentException("Type " + type + " is not valid!");
    }
  }

  public T getItem() {
    return this.item;
  }

  /**
   * Parses data based on specified data format (Spanner, text, or binary)
   *
   * @param format One of possible {@link DataFormat} types to parse data.
   * @return Byte format version of the input object.
   */
// Path: src/main/java/com/google/cloud/spanner/pgadapter/ProxyServer.java
// public enum DataFormat {
//   /**
//    * Data is returned to the client in binary form. This is the most compact format, but it is not
//    * supported by all clients for all data types. Only when the client specifically requests that
//    * the data should be returned in binary format, will the server do so.
//    */
//   POSTGRESQL_BINARY((short) 1),
//   /**
//    * The default format. Data is returned to the client in a format that PostgreSQL clients should
//    * be able to understand and stringParse. Use this format if you are using the {@link Server}
//    * with a client that tries to interpret the data that is returned by the server, such as for
//    * example the PostgreSQL JDBC driver.
//    */
//   POSTGRESQL_TEXT((short) 0),
//   /**
//    * Data is returned to the client in Cloud Spanner format. Use this format if you are using the
//    * server with a text-only client, such as psql, that does not try to interpret and stringParse
//    * the data that is returned.
//    */
//   SPANNER((short) 0);
// 
//   /**
//    * The internal code used by the PostgreSQL wire protocol to determine whether the data should
//    * be interpreted as text or binary.
//    */
//   private final short code;
// 
//   DataFormat(short code) {
//     this.code = code;
//   }
// 
//   public static DataFormat getDataFormat(int index,
//       IntermediateStatement statement,
//       QueryMode mode,
//       OptionsMetadata options) {
//     if (options.isBinaryFormat()) {
//       return DataFormat.POSTGRESQL_BINARY;
//     }
//     if (mode == QueryMode.SIMPLE) {
//       // Simple query mode is always text.
//       return DataFormat.fromTextFormat(options.getTextFormat());
//     } else {
//       return DataFormat.byCode(statement.getResultFormatCode(index), options.getTextFormat());
//     }
//   }
// 
//   public static DataFormat fromTextFormat(TextFormat textFormat) {
//     switch (textFormat) {
//       case POSTGRESQL:
//         return POSTGRESQL_TEXT;
//       case SPANNER:
//         return DataFormat.SPANNER;
//       default:
//         throw new IllegalArgumentException();
//     }
//   }
// 
//   public static DataFormat byCode(short code, TextFormat textFormat) {
//     return code == 0 ? fromTextFormat(textFormat) : POSTGRESQL_BINARY;
//   }
// 
//   public short getCode() {
//     return code;
//   }
// }


// Path: src/main/java/com/google/cloud/spanner/pgadapter/parsers/Parser.java
import com.google.cloud.spanner.pgadapter.ProxyServer.DataFormat;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import org.postgresql.core.Oid;
import org.postgresql.util.ByteConverter;

        result = new byte[1];
        ByteConverter.bool(result, 0, (Boolean) candidate);
        return result;
      case Types.INTEGER:
        result = new byte[4];
        ByteConverter.int4(result, 0, (Integer) candidate);
        return result;
      case Types.DOUBLE:
        result = new byte[8];
        ByteConverter.float8(result, 0, (Double) candidate);
        return result;
      case Types.BIGINT:
        result = new byte[8];
        ByteConverter.int8(result, 0, (Long) candidate);
        return result;
      default:
        throw new IllegalArgumentException("Type " + type + " is not valid!");
    }
  }

  public T getItem() {
    return this.item;
  }

  /**
   * Parses data based on specified data format (Spanner, text, or binary)
   *
   * @param format One of possible {@link DataFormat} types to parse data.
   * @return Byte format version of the input object.
   */
  public byte[] parse(DataFormat format) {