in src/main/protocol-impl/java/com/mysql/cj/protocol/a/BooleanValueEncoder.java [81:132]
public void encodeAsBinary(Message msg, BindValue binding) {
boolean b = ((Boolean) binding.getValue()).booleanValue();
NativePacketPayload intoPacket = (NativePacketPayload) msg;
switch (binding.getMysqlType()) {
case BIT:
case BOOLEAN:
case TINYINT:
case TINYINT_UNSIGNED:
intoPacket.writeInteger(IntegerDataType.INT1, b ? 1L : 0L);
return;
case CHAR:
case VARCHAR:
case TINYTEXT:
case TEXT:
case MEDIUMTEXT:
case LONGTEXT:
intoPacket.writeBytes(StringSelfDataType.STRING_LENENC, StringUtils.getBytes(String.valueOf(b), this.charEncoding.getValue()));
return;
case SMALLINT:
case SMALLINT_UNSIGNED:
case MEDIUMINT:
case MEDIUMINT_UNSIGNED:
intoPacket.writeInteger(IntegerDataType.INT2, b ? 1L : 0L);
return;
case INT:
case INT_UNSIGNED:
case YEAR:
intoPacket.writeInteger(IntegerDataType.INT4, ((Long) binding.getValue()).longValue());
return;
case BIGINT:
case BIGINT_UNSIGNED:
intoPacket.writeInteger(IntegerDataType.INT8, b ? 1L : 0L);
return;
case FLOAT:
case FLOAT_UNSIGNED:
intoPacket.writeInteger(IntegerDataType.INT4, Float.floatToIntBits(b ? 1f : 0f));
return;
case DOUBLE:
case DOUBLE_UNSIGNED:
intoPacket.writeInteger(IntegerDataType.INT8, Double.doubleToLongBits(b ? 1d : 0d));
return;
case DECIMAL:
case DECIMAL_UNSIGNED:
intoPacket.writeBytes(StringSelfDataType.STRING_LENENC,
StringUtils.getBytes(new BigDecimal(b ? 1d : 0d).toPlainString(), this.charEncoding.getValue()));
return;
default:
throw ExceptionFactory.createException(WrongArgumentException.class,
Messages.getString("PreparedStatement.67", new Object[] { binding.getValue().getClass().getName(), binding.getMysqlType().toString() }),
this.exceptionInterceptor);
}
}