Sha256: 9906070a86d1163a72bc75ddc909519a69f9b225fe2533db2e3668b288542ca9
Contents?: true
Size: 1.97 KB
Versions: 39
Compression:
Stored size: 1.97 KB
Contents
package org.embulk.spi.util; import java.util.Iterator; import java.util.NoSuchElementException; import org.embulk.spi.Exec; import org.embulk.spi.FileInput; import org.embulk.spi.Buffer; import org.embulk.spi.time.Timestamp; import org.embulk.spi.time.TimestampFormatter; import org.joda.time.DateTimeZone; public class Inputs { private static abstract class AbstractPollIterator <E> implements Iterator<E> { private E next; protected abstract E poll(); @Override public boolean hasNext() { if (next != null) { return true; } else { next = poll(); return next != null; } } @Override public E next() { if (!hasNext()) { throw new NoSuchElementException(); } E l = next; next = null; return l; } @Override public void remove() { throw new UnsupportedOperationException(); } } public static Iterable<Buffer> each(final FileInput input) { return new Iterable<Buffer>() { public Iterator<Buffer> iterator() { return new AbstractPollIterator<Buffer>() { public Buffer poll() { return input.poll(); } }; } }; } public static String formatPath(String pathFormat) { Timestamp timestamp = Exec.session().getTransactionTime(); DateTimeZone timezone = Exec.session().getTransactionTimeZone(); // newTimestampFormatter (eventually calls org.jruby.util.RubyDateFormat.<init> doesn't throw exceptions TimestampFormatter formatter = Exec.session().newTimestampFormatter(pathFormat, timezone); return formatter.format(timestamp); // TimestampFormatter.format doesn't throw exceptions } }
Version data entries
39 entries across 39 versions & 1 rubygems