KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > RowReaderTestImpl


1 /*
2  * Created by IntelliJ IDEA.
3  * User: tom
4  * Date: Aug 7, 2001
5  * Time: 9:37:18 PM
6  * To change template for new class use
7  * Code Style | Class Templates options (Tools | IDE Options).
8  */

9 package org.apache.ojb.broker;
10
11 import java.util.Map JavaDoc;
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 {
18     public RowReaderTestImpl(ClassDescriptor cld)
19     {
20         super(cld);
21     }
22
23     /**
24      * materialize a single object of a type described by cld,
25      * from the first row of the ResultSet rs.
26      * the implementor of this class must not care for materialiing
27      * references or collection attributes, this is done later!
28      */

29     public Object JavaDoc readObjectFrom(Map JavaDoc row)
30     {
31         Object JavaDoc result = super.readObjectFrom(row);
32         if (result instanceof ArticleWithStockDetail)
33         {
34             ArticleWithStockDetail art = (ArticleWithStockDetail) result;
35             boolean sellout = art.isSelloutArticle;
36             int minimum = art.minimumStock;
37             int ordered = art.orderedUnits;
38             int stock = art.stock;
39             String JavaDoc unit = art.unit;
40             StockDetail detail = new StockDetail(sellout, minimum, ordered, stock, unit, art);
41             art.stockDetail = detail;
42             return art;
43         }
44         else
45         {
46             return result;
47         }
48     }
49 }
50
Popular Tags