本文整理汇总了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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例6: BeanIOIterator
import org.beanio.BeanReader; //导入依赖的package包/类
public BeanIOIterator(BeanReader reader) {
this.reader = reader;
this.next = next();
}