Sha256: 3f4ff6000552a3b02e36879e717f42808e2df16bb737720c27c0eb50dd1d6911

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

package org.embulk.input.jdbc.getter;

import java.sql.ResultSet;
import java.sql.SQLException;
import org.embulk.spi.Column;
import org.embulk.spi.PageBuilder;
import org.embulk.spi.type.Type;
import org.embulk.spi.type.Types;

public class StringColumnGetter
        extends AbstractColumnGetter
{
    private String value;

    public StringColumnGetter(PageBuilder to, Type toType)
    {
        super(to, toType);
    }

    @Override
    protected void fetch(ResultSet from, int fromIndex) throws SQLException
    {
        value = from.getString(fromIndex);
    }

    @Override
    protected Type getDefaultToType()
    {
        return Types.STRING;
    }

    @Override
    public void longColumn(Column column)
    {
        long l;
        try {
            l = Long.parseLong(value);
        } catch (NumberFormatException e) {
            super.longColumn(column);
            return;
        }
        to.setLong(column, l);
    }

    @Override
    public void doubleColumn(Column column)
    {
        double d;
        try {
            d = Double.parseDouble(value);
        } catch (NumberFormatException e) {
            super.doubleColumn(column);
            return;
        }
        to.setDouble(column, d);
    }

    @Override
    public void stringColumn(Column column)
    {
        to.setString(column, value);
    }

}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
embulk-input-jdbc-0.6.4 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
embulk-input-jdbc-0.6.3 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
embulk-input-jdbc-0.6.2 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
embulk-input-jdbc-0.6.1 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
embulk-input-jdbc-0.6.0 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
embulk-input-jdbc-0.5.0 src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java