Sha256: eaed73c97573e46f1ff1331a4602a6b6e12e37493906f1dd54c81ebefa81b973

Contents?: true

Size: 1.9 KB

Versions: 115

Compression:

Stored size: 1.9 KB

Contents

package org.embulk.spi.util;

import java.util.Map;
import com.google.common.base.Optional;
import org.embulk.config.Task;
import org.embulk.spi.Column;
import org.embulk.spi.Schema;
import org.embulk.spi.ColumnConfig;
import org.embulk.spi.SchemaConfig;
import org.embulk.spi.time.TimestampFormatter;
import org.embulk.spi.type.TimestampType;
import org.embulk.spi.time.TimestampParser;
import org.embulk.spi.SchemaConfig;

public class Timestamps
{
    private Timestamps() { }

    private interface TimestampColumnOption
            extends Task, TimestampParser.TimestampColumnOption
    { }

    public static TimestampParser[] newTimestampColumnParsers(
            TimestampParser.Task parserTask, SchemaConfig schema)
    {
        TimestampParser[] parsers = new TimestampParser[schema.getColumnCount()];
        int i = 0;
        for (ColumnConfig column : schema.getColumns()) {
            if (column.getType() instanceof TimestampType) {
                TimestampColumnOption option = column.getOption().loadConfig(TimestampColumnOption.class);
                parsers[i] = new TimestampParser(parserTask, option);
            }
            i++;
        }
        return parsers;
    }

    public static TimestampFormatter[] newTimestampColumnFormatters(
            TimestampFormatter.Task formatterTask, Schema schema,
            Map<String, ? extends TimestampFormatter.TimestampColumnOption> columnOptions)
    {
        TimestampFormatter[] formatters = new TimestampFormatter[schema.getColumnCount()];
        int i = 0;
        for (Column column : schema.getColumns()) {
            if (column.getType() instanceof TimestampType) {
                Optional<TimestampFormatter.TimestampColumnOption> option = Optional.fromNullable(columnOptions.get(column.getName()));
                formatters[i] = new TimestampFormatter(formatterTask, option);
            }
            i++;
        }
        return formatters;
    }
}

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.39-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.38 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.38-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.37 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.37-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.36 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.36-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.35 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.35-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.34 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.34-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.33 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.33-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.32 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.32-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.31 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.31-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.30 embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java
embulk-0.8.30-java embulk-core/src/main/java/org/embulk/spi/util/Timestamps.java