All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.skjolber.stcsv.builder.CsvMappingBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.25
Show newest version
package com.github.skjolber.stcsv.builder;

import java.util.List;

import com.github.skjolber.stcsv.AbstractColumn;
import com.github.skjolber.stcsv.CsvMapper;
import com.github.skjolber.stcsv.column.bi.BooleanCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.CsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.DoubleCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.IntCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.LongCsvFieldMapperBuilder;
import com.github.skjolber.stcsv.column.bi.StringCsvFieldMapperBuilder;

public class CsvMappingBuilder extends AbstractCsvMappingBuilder> {

	public CsvMappingBuilder(Class cls) {
		super(cls);
	}

	public CsvMapper build() throws CsvBuilderException {
		List columns = toColumns();
		
		ClassLoader classLoader = this.classLoader;
		if(classLoader == null) {
			classLoader = getDefaultClassLoader();
		}
		
		if(bufferLength <= 0) {
			throw new CsvBuilderException("Expected positive buffer length");
		}
		
		return new CsvMapper(target, divider, quoteCharacter, escapeCharacter, columns, skipEmptyLines, skipComments, skippableFieldsWithoutLinebreaks, classLoader, bufferLength);
	}
	
	public CsvFieldMapperBuilder> field(String name) {
		return new CsvFieldMapperBuilder>(this, name);
	}

	public StringCsvFieldMapperBuilder> stringField(String name) {
		return new StringCsvFieldMapperBuilder>(this, name);
	}

	public DoubleCsvFieldMapperBuilder> doubleField(String name) {
		return new DoubleCsvFieldMapperBuilder>(this, name);
	}

	public LongCsvFieldMapperBuilder> longField(String name) {
		return new LongCsvFieldMapperBuilder>(this, name);
	}

	public IntCsvFieldMapperBuilder> integerField(String name) {
		return new IntCsvFieldMapperBuilder>(this, name);
	}

	public BooleanCsvFieldMapperBuilder> booleanField(String name) {
		return new BooleanCsvFieldMapperBuilder>(this, name);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy