01: /*
02: * Created by IntelliJ IDEA.
03: * User: tom
04: * Date: Aug 7, 2001
05: * Time: 9:37:18 PM
06: * To change template for new class use
07: * Code Style | Class Templates options (Tools | IDE Options).
08: */
09: package org.apache.ojb.broker;
10:
11: import java.util.Map;
12:
13: import org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl;
14: import org.apache.ojb.broker.metadata.ClassDescriptor;
15:
16: public class RowReaderTestImpl extends RowReaderDefaultImpl {
17: public RowReaderTestImpl(ClassDescriptor cld) {
18: super (cld);
19: }
20:
21: /**
22: * materialize a single object of a type described by cld,
23: * from the first row of the ResultSet rs.
24: * the implementor of this class must not care for materialiing
25: * references or collection attributes, this is done later!
26: */
27: public Object readObjectFrom(Map row) {
28: Object result = super .readObjectFrom(row);
29: if (result instanceof ArticleWithStockDetail) {
30: ArticleWithStockDetail art = (ArticleWithStockDetail) result;
31: boolean sellout = art.isSelloutArticle;
32: int minimum = art.minimumStock;
33: int ordered = art.orderedUnits;
34: int stock = art.stock;
35: String unit = art.unit;
36: StockDetail detail = new StockDetail(sellout, minimum,
37: ordered, stock, unit, art);
38: art.stockDetail = detail;
39: return art;
40: } else {
41: return result;
42: }
43: }
44: }
|