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


Java BeanReader.read方法代码示例

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


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


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