src/main/java/org/embulk/decoder/unzip/UnzipDecoderPlugin.java in embulk-decoder-unzip-0.1.1 vs src/main/java/org/embulk/decoder/unzip/UnzipDecoderPlugin.java in embulk-decoder-unzip-0.1.2
- old
+ new
@@ -1,28 +1,36 @@
package org.embulk.decoder.unzip;
-import java.io.InputStream;
-import java.io.IOException;
-
import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.ConfigInject;
import org.embulk.config.ConfigSource;
import org.embulk.config.Task;
import org.embulk.config.TaskSource;
import org.embulk.spi.BufferAllocator;
import org.embulk.spi.DecoderPlugin;
import org.embulk.spi.FileInput;
import org.embulk.spi.util.FileInputInputStream;
-import org.embulk.spi.util.InputStreamFileInput;
public class UnzipDecoderPlugin
implements DecoderPlugin
{
public interface PluginTask
extends Task
{
+ @Config("format")
+ @ConfigDefault("\"\"")
+ public String getFormat();
+
+ @Config("decompress_concatenated")
+ @ConfigDefault("true")
+ public boolean getDecompressConcatenated();
+
+ @Config("match_name")
+ @ConfigDefault("\"\"")
+ public String getMatchName();
+
// @Config("skip_on_error")
// @ConfigDefault("true")
// public boolean skipOnError();
@ConfigInject
@@ -38,42 +46,15 @@
}
@Override
public FileInput open(TaskSource taskSource, FileInput fileInput)
{
+ String zipFileName = fileInput.hintOfCurrentInputFileNameForLogging().get();
+ System.out.println(zipFileName);
final PluginTask task = taskSource.loadTask(PluginTask.class);
final FileInputInputStream files = new FileInputInputStream(fileInput);
-
- InputStreamFileInput isfi = null;
- try {
- isfi = new InputStreamFileInput(
- task.getBufferAllocator(),
- new InputStreamFileInput.Provider() {
- public InputStream openNext() throws IOException
- {
- if (!files.nextFile()) {
- return null;
- }
- return newDecoderInputStream(task, files);
- }
-
- public void close() throws IOException
- {
- files.close();
- }
- });
- } catch (Exception e) {
-// if(task.skipOnError()) {
-// System.out.println("skip: " + isfi.hintOfCurrentInputFileNameForLogging());
-// return null;
-// } else
- throw new RuntimeException(e);
- }
- return isfi;
+ return new CommonsCompressFileInput(task.getBufferAllocator(),
+ new CommonsCompressProvider(task, files));
}
- private static InputStream newDecoderInputStream(PluginTask task, InputStream file) throws IOException
- {
- return new UnzipInputStream(file);
- }
}