package org.skife.jdbi.v2;
import org.skife.jdbi.v2.tweak.Argument;
import java.io.InputStream;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
class InputStreamArgument implements Argument
{
private final InputStream value;
private final int length;
private final boolean ascii;
InputStreamArgument(InputStream value, int length, boolean ascii)
{
this.value = value;
this.length = length;
this.ascii = ascii;
}
@Override
public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException
{
if (ascii)
{
if (value != null) {
statement.setAsciiStream(position, value, length);
}
else {
statement.setNull(position, Types.LONGVARCHAR);
}
}
else
{
if (value != null) {
statement.setBinaryStream(position, value, length);
}
else {
statement.setNull(position, Types.LONGVARBINARY);
}
}
}
}