当前位置: 首页>>代码示例>>Java>>正文


Java DelimitedLineTokenizer.setStrict方法代码示例

本文整理汇总了Java中org.springframework.batch.item.file.transform.DelimitedLineTokenizer.setStrict方法的典型用法代码示例。如果您正苦于以下问题:Java DelimitedLineTokenizer.setStrict方法的具体用法?Java DelimitedLineTokenizer.setStrict怎么用?Java DelimitedLineTokenizer.setStrict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.batch.item.file.transform.DelimitedLineTokenizer的用法示例。


在下文中一共展示了DelimitedLineTokenizer.setStrict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
	lineTokenizer.setDelimiter('\t');
	lineTokenizer.setNames(new String[] {"foo","bar"});
	lineTokenizer.setStrict(false);

	DefaultLineMapper<FieldSet> lineMapper = new DefaultLineMapper<FieldSet>();
	lineMapper.setLineTokenizer(lineTokenizer);
	lineMapper.setFieldSetMapper(new PassThroughFieldSetMapper());

	flatFileItemReader = new FlatFileItemReader<FieldSet>();
	flatFileItemReader.setEncoding("UTF-8");
	flatFileItemReader.setLinesToSkip(0);
	flatFileItemReader.setLineMapper(lineMapper);
	flatFileItemReader.setResource(new ClassPathResource("org/emonocot/bom.txt"));
	flatFileItemReader.setBufferedReaderFactory(new BOMIgnoringBufferedReaderFactory());

	flatFileItemReader.afterPropertiesSet();
	flatFileItemReader.open(new ExecutionContext());
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:22,代码来源:BOMIgnoringFlatFileItemReaderTest.java

示例2: newDefaultLineMapper

import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; //导入方法依赖的package包/类
private DefaultLineMapper<T> newDefaultLineMapper() {
    final DefaultLineMapper<T> lineMapper = new DefaultLineMapper<T>();
    final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    if (delimiter != null) {
        tokenizer.setDelimiter(delimiter);
    }
    if (names != null) {
        tokenizer.setNames(names);
    }
    if (strict != null) {
        tokenizer.setStrict(strict);
    }
    if (fieldSetFactory != null) {
        tokenizer.setFieldSetFactory(fieldSetFactory);
    }
    lineMapper.setLineTokenizer(tokenizer);
    if (fieldSetMapper != null) {
        lineMapper.setFieldSetMapper(fieldSetMapper);
    }
    lineMapper.afterPropertiesSet();
    return lineMapper;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:23,代码来源:CsvItemReaderBuilder.java

示例3: setUp

import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
	lineTokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_TAB);
	lineTokenizer.setNames(new String[] {"foo","bar"});
	lineTokenizer.setStrict(false);

	DefaultLineMapper<FieldSet> lineMapper = new DefaultLineMapper<FieldSet>();
	lineMapper.setLineTokenizer(lineTokenizer);
	lineMapper.setFieldSetMapper(new PassThroughFieldSetMapper());

	flatFileItemReader = new FlatFileItemReader<FieldSet>();
	flatFileItemReader.setEncoding("UTF-8");
	flatFileItemReader.setLinesToSkip(0);
	flatFileItemReader.setLineMapper(lineMapper);
	flatFileItemReader.setResource(new ClassPathResource("org/emonocot/bom.txt"));
	flatFileItemReader.setBufferedReaderFactory(new BOMIgnoringBufferedReaderFactory());

	flatFileItemReader.afterPropertiesSet();
	flatFileItemReader.open(new ExecutionContext());
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:22,代码来源:BOMIgnoringFlatFileItemReaderTest.java

示例4: readStores

import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; //导入方法依赖的package包/类
/**
 * Reads a file {@code starbucks.csv} from the class path and parses it into {@link Store} instances about to
 * persisted.
 * 
 * @return
 * @throws Exception
 */
public static List<Store> readStores() throws Exception {

	ClassPathResource resource = new ClassPathResource("starbucks.csv");
	Scanner scanner = new Scanner(resource.getInputStream());
	String line = scanner.nextLine();
	scanner.close();

	FlatFileItemReader<Store> itemReader = new FlatFileItemReader<Store>();
	itemReader.setResource(resource);

	// DelimitedLineTokenizer defaults to comma as its delimiter
	DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
	tokenizer.setNames(line.split(","));
	tokenizer.setStrict(false);

	DefaultLineMapper<Store> lineMapper = new DefaultLineMapper<Store>();
	lineMapper.setFieldSetMapper(fields -> {

		Point location = new Point(fields.readDouble("Longitude"), fields.readDouble("Latitude"));
		Address address = new Address(fields.readString("Street Address"), fields.readString("City"),
				fields.readString("Zip"), location);

		return new Store(fields.readString("Name"), address);
	});

	lineMapper.setLineTokenizer(tokenizer);
	itemReader.setLineMapper(lineMapper);
	itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
	itemReader.setLinesToSkip(1);
	itemReader.open(new ExecutionContext());

	List<Store> stores = new ArrayList<>();
	Store store = null;

	do {

		store = itemReader.read();

		if (store != null) {
			stores.add(store);
		}

	} while (store != null);

	return stores;
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:54,代码来源:StoreInitializer.java


注:本文中的org.springframework.batch.item.file.transform.DelimitedLineTokenizer.setStrict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。