Sha256: a8fda0594c7de319f94fa914a44b6dfbb6051cf8b38af7448e3a5fb7e31c386d

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 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.ColumnVisitor;
import org.embulk.spi.PageBuilder;
import org.embulk.spi.type.Type;

public abstract class AbstractColumnGetter implements ColumnGetter, ColumnVisitor
{
    protected final PageBuilder to;
    private final Type toType;

    public AbstractColumnGetter(PageBuilder to, Type toType)
    {
        this.to = to;
        this.toType = toType;
    }

    @Override
    public void getAndSet(ResultSet from, int fromIndex,
            Column toColumn) throws SQLException {

        fetch(from, fromIndex);
        if (from.wasNull()) {
            to.setNull(toColumn);
        } else {
            toColumn.visit(this);
        }
    }

    protected abstract void fetch(ResultSet from, int fromIndex) throws SQLException;

    @Override
    public void booleanColumn(Column column)
    {
        to.setNull(column);
    }

    @Override
    public void longColumn(Column column)
    {
        to.setNull(column);
    }

    @Override
    public void doubleColumn(Column column)
    {
        to.setNull(column);
    }

    @Override
    public void stringColumn(Column column)
    {
        to.setNull(column);
    }

    @Override
    public void jsonColumn(Column column) {
        throw new UnsupportedOperationException("This plugin doesn't support json type. Please try to upgrade version of the plugin using 'embulk gem update' command. If the latest version still doesn't support json type, please contact plugin developers, or change configuration of input plugin not to use json type.");
    }

    @Override
    public void timestampColumn(Column column)
    {
        to.setNull(column);
    }

    @Override
    public Type getToType()
    {
        if (toType == null) {
            return getDefaultToType();
        }
        return toType;
    }

    protected abstract Type getDefaultToType();

}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-input-jdbc-0.6.4 src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java
embulk-input-jdbc-0.6.3 src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java