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


Java BeanReader类代码示例

本文整理汇总了Java中org.beanio.BeanReader的典型用法代码示例。如果您正苦于以下问题:Java BeanReader类的具体用法?Java BeanReader怎么用?Java BeanReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testIdentifyingRecords

import org.beanio.BeanReader; //导入依赖的package包/类
/**
 * Tests that we can identify record types we're interested in, without breaking
 */
@Test
public void testIdentifyingRecords() {
	StreamFactory factory = StreamFactory.newInstance();
	
	factory.load(IGC_MAPPING_FILE);

	BeanReader br = factory.createReader("igc_file", new File("src/test/resources/5c6c3ke1.igc"));;
	
	boolean found_b_records = false;
	
	try {
		Object bean = null;
		while ((bean = br.read()) != null) {
			if (bean instanceof GNSSPointData) {
				found_b_records = true;
			}
		}
		
	} finally {
		br.close();
	}
	
	assertEquals(true, found_b_records);
}
 
开发者ID:jpretori,项目名称:SoaringCoach,代码行数:28,代码来源:TestFileParsing.java

示例2: testPICNameParsing

import org.beanio.BeanReader; //导入依赖的package包/类
/**
 * Test header record parsing by checking that the pilot name comes through correctly
 */
@Test
public void testPICNameParsing() {
	StreamFactory factory = StreamFactory.newInstance();
	
	factory.load(IGC_MAPPING_FILE);

	BeanReader br = factory.createReader("igc_file", new File("src/test/resources/minimal_parsable.igc"));;

	try {
		Object bean = null;
		while (!(bean instanceof PICName)) {
			bean = br.read();
		}
		
		PICName pilot = (PICName) bean;
		
		assertEquals("Kevin Mitchell", pilot.picName);
	} finally {
		br.close();
	}
}
 
开发者ID:jpretori,项目名称:SoaringCoach,代码行数:25,代码来源:TestFileParsing.java

示例3: testFlightDateParsing

import org.beanio.BeanReader; //导入依赖的package包/类
@Test
public void testFlightDateParsing() throws ParseException {
	StreamFactory factory = StreamFactory.newInstance();
	
	factory.load(IGC_MAPPING_FILE);

	BeanReader br = factory.createReader("igc_file", new File("src/test/resources/minimal_parsable.igc"));;

	try {
		Object bean = null;
		while (!(bean instanceof FlightDate)) {
			bean = br.read();
		}
		
		FlightDate fd = (FlightDate) bean;
		
		assertEquals("2017-09-05", fd.getFlightDateString());
		
	} finally {
		br.close();
	}
}
 
开发者ID:jpretori,项目名称:SoaringCoach,代码行数:23,代码来源:TestFileParsing.java

示例4: readModels

import org.beanio.BeanReader; //导入依赖的package包/类
private List<Object> readModels(Exchange exchange, InputStream stream) {
    List<Object> results = new ArrayList<Object>();
    BufferedReader streamReader = IOHelper.buffered(new InputStreamReader(stream, getEncoding()));

    BeanReader in = factory.createReader(getStreamName(), streamReader);

    try {
        if (ObjectHelper.isNotEmpty(configuration.getBeanReaderErrorHandler())) {
            in.setErrorHandler(configuration.getBeanReaderErrorHandler());
        } else {
            in.setErrorHandler(new BeanIOErrorHandler(configuration));
        }

        Object readObject;
        while ((readObject = in.read()) != null) {
            if (readObject instanceof BeanIOHeader) {
                exchange.getOut().getHeaders().putAll(((BeanIOHeader) readObject).getHeaders());
            }
            results.add(readObject);
        }
    } finally {
        in.close();
    }

    return results;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:BeanIODataFormat.java

示例5: evaluate

import org.beanio.BeanReader; //导入依赖的package包/类
public Object evaluate(Exchange exchange) throws Exception {
    Message msg = exchange.getIn();
    Object body = msg.getBody();

    if (factory == null) {
        factory = createStreamFactory(exchange.getContext());
    }

    BeanReader beanReader = null;
    if (body instanceof WrappedFile) {
        body = ((WrappedFile) body).getFile();
    }
    if (body instanceof File) {
        File file = (File) body;
        beanReader = factory.createReader(getStreamName(), file);
    }
    if (beanReader == null) {
        Reader reader = msg.getMandatoryBody(Reader.class);
        beanReader = factory.createReader(getStreamName(), reader);
    }

    beanReader.setErrorHandler(new BeanIOErrorHandler(configuration));

    return new BeanIOIterator(beanReader);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:BeanIOSplitter.java

示例6: BeanIOIterator

import org.beanio.BeanReader; //导入依赖的package包/类
public BeanIOIterator(BeanReader reader) {
    this.reader = reader;
    this.next = next();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:BeanIOIterator.java


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