package ch.uzh.ddis.katts.spouts.file.source;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

import au.com.bytecode.opencsv.CSVReader;

import ch.uzh.ddis.katts.query.source.File;

public class CSVSource extends AbstractSource{
	
	private transient CSVReader csvReader;
	private File file;
	
	@Override
	public List<String> getNextTriple() throws Exception {
		String[] line = csvReader.readNext();
		if (line == null) {
			return null;
		}
		List<String> list = new ArrayList<String>();
		for (String item : line) {
			list.add(item);
		}
		return list;
	}

	@Override
	public InputStream buildInputStream(File file) throws FileNotFoundException {
		this.file = file;
		return new FileInputStream(file.getPath());
	}

	@Override
	public void setFileInputStream(InputStream inputStream) {
		Reader inputStreamReader = new InputStreamReader(inputStream);
		csvReader = new CSVReader(inputStreamReader, getDelimiter());
	}
	
	public char getDelimiter() {
		return file.getCsvFieldDelimiter().charAt(0);
	}

}

@@ -251,16 +251,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -654,118 +654,34 @@
 %7D%0A%09%09
-List%3CString%3E list = new ArrayList%3CString%3E();%0A%09%09for (String item : line) %7B%0A%09%09%09list.add(item);%0A%09%09%7D%0A%09%09return list
+return Arrays.asList(line)
 ;%0A%09%7D

use Arrays.asList() instead of copying everything