本文整理汇总了Java中org.springframework.batch.item.file.transform.FieldSet类的典型用法代码示例。如果您正苦于以下问题:Java FieldSet类的具体用法?Java FieldSet怎么用?Java FieldSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldSet类属于org.springframework.batch.item.file.transform包,在下文中一共展示了FieldSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapFieldSet
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
@Override
public LHHuntingClubCSVRow mapFieldSet(FieldSet fieldSet) {
if (fieldSet.getFieldCount() <= 1) {
LOG.debug("Ignoring invalid row: {}", formatRow(fieldSet));
return null;
}
if (fieldSet.getFieldCount() != EXPECTED_FIELD_COUNT) {
LOG.error("Invalid field set with field count {}, expexcted {}",
fieldSet.getFieldCount(), EXPECTED_FIELD_COUNT);
LOG.debug("Invalid row was: {}", formatRow(fieldSet));
throw new IllegalStateException(
MessageFormat.format("Invalid field set with field count {0}, expected {1}",
fieldSet.getFieldCount(), EXPECTED_FIELD_COUNT));
}
return csvToRow(fieldSet);
}
示例2: setUp
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的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());
}
示例3: mapFieldSet
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
@Override
public CompetitiveIntelligenceReports mapFieldSet(final FieldSet fieldSet) throws BindException {
final String year = fieldSet.readString(YEAR);
if (Strings.isNotBlank(year)) {
final String[] yearSplit = year.split(" ");
Assertions.assertThat(yearSplit).hasSize(2);
curYear = Integer.parseInt(yearSplit[1]);
}
final String title = fieldSet.readString(TITLE);
if (Strings.isBlank(title)) {
return INVALID_ROW;
}
final String categoryStr = fieldSet.readString(CATEGORY);
if (Strings.isNotBlank(categoryStr)) {
curCategory = CompetitiveIntelligenceReportParserCategory.valueOfTitle(categoryStr);
}
parseCompanyLetters(fieldSet, title);
parseAvg(fieldSet, title);
return reports;
}
示例4: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if ("N.A. Market----------------".equals(category1)) {
curRegion = CompanyRegion.NorthAmerica;
} else if ("E-A Market----------------".equals(category1)) {
curRegion = CompanyRegion.EuropeAfrica;
} else if ("A-P Market----------------".equals(category1)) {
curRegion = CompanyRegion.AsiaPacific;
//
} else if ("L.A. Market----------------".equals(category1)) {
curRegion = CompanyRegion.LatinAmerica;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例5: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if (Strings.isNotBlank(category1)) {
curCategory1 = category1;
curCategory2 = null;
curTitle1 = null;
curTitle2 = null;
}
final String category2 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY2);
if (Strings.isNotBlank(category2)) {
curCategory2 = category2;
curTitle1 = null;
curTitle2 = null;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
//
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例6: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if (Strings.isNotBlank(category1)) {
curCategory1 = category1;
curCategory2 = null;
curTitle1 = null;
curTitle2 = null;
//
}
final String category2 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY2);
if (Strings.isNotBlank(category2)) {
curCategory2 = category2;
curTitle1 = null;
curTitle2 = null;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例7: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if (Strings.isNotBlank(category1)) {
curCategory1 = category1;
curCategory2 = null;
curTitle2 = null;
}
final String category2 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY2);
if (Strings.isNotBlank(category2)) {
curCategory2 = category2;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例8: mapFieldSet
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
@Override
public CompanyOperatingReports mapFieldSet(final FieldSet fieldSet) throws BindException {
final String subReport = fieldSet.readString(SUB_REPORT);
if (Strings.isNotBlank(subReport)) {
final CompanyOperatingReportParserSubReport newSubReport = CompanyOperatingReportParserSubReport
.valueOfTitle(curSubReport, subReport);
if (newSubReport != curSubReport) {
curSubReport = newSubReport;
curSubReportParser = curSubReport.newSubReportParser();
}
}
if (Strings.isBlank(fieldSet.readString(SUB_REPORT)) && Strings.isBlank(fieldSet.readString(CATEGORY1))
&& Strings.isBlank(fieldSet.readString(CATEGORY2)) && Strings.isBlank(fieldSet.readString(TITLE1))
&& Strings.isBlank(fieldSet.readString(TITLE2)) || Strings.isBlank(fieldSet.readString(VALUE))) {
return INVALID_ROW;
}
if (curSubReportParser != null) {
curSubReportParser.parse(fieldSet, reports);
return reports;
} else {
return INVALID_ROW;
}
}
示例9: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if (Strings.isNotBlank(category1)) {
curCategory1 = category1;
curCategory2 = null;
curTitle1 = null;
curTitle2 = null;
}
final String category2 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY2);
if (Strings.isNotBlank(category2)) {
curCategory2 = category2;
curTitle1 = null;
curTitle2 = null;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例10: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if (Strings.isNotBlank(category1)) {
curCategory1 = category1;
curTitle1 = null;
curTitle2 = null;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例11: updateCategoryAndTitle
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void updateCategoryAndTitle(final FieldSet fieldSet) {
final String category1 = fieldSet.readString(CompanyOperatingReportParserMapper.CATEGORY1);
if ("N.A. Market----------------".equals(category1)) {
curRegion = CompanyRegion.NorthAmerica;
} else if ("E-A Market----------------".equals(category1)) {
curRegion = CompanyRegion.EuropeAfrica;
} else if ("A-P Market----------------".equals(category1)) {
curRegion = CompanyRegion.AsiaPacific;
} else if ("L.A. Market----------------".equals(category1)) {
curRegion = CompanyRegion.LatinAmerica;
}
final String title1 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE1);
if (Strings.isNotBlank(title1)) {
curTitle1 = title1;
curTitle2 = null;
}
final String title2 = fieldSet.readString(CompanyOperatingReportParserMapper.TITLE2);
if (Strings.isNotBlank(title2)) {
curTitle2 = title2;
}
}
示例12: fillPreviewLines
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
protected void fillPreviewLines(MultipartFile file) {
try {
Resource resource = new InputStreamResource(new ByteArrayInputStream(file.getBytes()));
DefaultLineMapper<String[]> lineMapper = new DefaultLineMapper<>();
lineMapper.setLineTokenizer(new DelimitedLineTokenizer());
lineMapper.setFieldSetMapper(FieldSet::getValues);
FlatFileItemReader<String[]> itemReader = new FlatFileItemReader<>();
itemReader.setResource(resource);
itemReader.setLineMapper(lineMapper);
itemReader.open(new ExecutionContext());
for (int i = 0; i < 10; i++) {
String[] row = itemReader.read();
if (row == null) {
break;
}
firstRows.add(row);
columnCount = Math.max(columnCount, row.length);
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例13: mapFieldSet
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
@Override
public T mapFieldSet(FieldSet fieldSet) throws BindException {
T entity = null;
Integer indexColumn = fileOption.getKeyColumn();
String indexColumnName = fieldSet.getNames()[indexColumn];
Function<String, T> finder = getEntityFinder(indexColumnName);
if (finder == null) {
throw new BindException(entityType, "finder '" + indexColumnName + "' not found.");
}
String indexColumnValue = fieldSet.readString(indexColumn);
entity = finder.apply(indexColumnValue);
if (entity == null) {
entity = newEntitySupplier.get();
}
bindData(entity, fieldSet.getProperties());
return entity;
}
示例14: setUp
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的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());
}
示例15: read
import org.springframework.batch.item.file.transform.FieldSet; //导入依赖的package包/类
@Override
public synchronized T read() {
List<FieldSet> aTmpResult = new ArrayList<FieldSet>();
boolean aConditionResult = false;
FieldSet line = readNextFieldSet();
while (!aConditionResult && (line != null)) {
aTmpResult.add(line);
if (nextItem != null) {
updateContext(currentVariableName, (line.hasNames()) ? line.getProperties() : line.getValues(), getEvaluationContext());
updateContext(nextVariableName, (nextItem.hasNames()) ? nextItem.getProperties() : nextItem.getValues(), getEvaluationContext());
aConditionResult = getExpressionResolver().evaluate(newRecordCondition, getEvaluationContext(), Boolean.class);
}
if (!aConditionResult) {
line = readNextFieldSet();
}
}
return (aTmpResult.isEmpty() ? null : mapFieldSets(aTmpResult));
}