[BIRT]-[Tutorial]-使用ScriptDataSet从POJO中获得数据(三)

RowSet.java代表行的集合,代码如下:

 1 None.gif package com.bat.afp.DAOComm;
 2 None.gif
 3 None.gifimport java.util.Iterator;
 4 None.gifimport java.util.Vector;
 5 None.gif
 6 ExpandedBlockStart.gifContractedBlock.gif /**/ /**
 7InBlock.gif * @author liuyf
 8ExpandedBlockEnd.gif */

 9 ExpandedBlockStart.gifContractedBlock.gif public   class  RowSet  dot.gif {
10InBlock.gif
11InBlock.gif    private Vector<Row>    vector    = new Vector<Row>();
12InBlock.gif
13ExpandedSubBlockStart.gifContractedSubBlock.gif    public RowSet() dot.gif{
14ExpandedSubBlockEnd.gif    }

15InBlock.gif
16ExpandedSubBlockStart.gifContractedSubBlock.gif    public void add(Row row) dot.gif{
17InBlock.gif        vector.addElement(row);
18ExpandedSubBlockEnd.gif    }

19InBlock.gif
20ExpandedSubBlockStart.gifContractedSubBlock.gif    public int length() dot.gif{
21InBlock.gif        return vector.size();
22ExpandedSubBlockEnd.gif    }

23InBlock.gif
24ExpandedSubBlockStart.gifContractedSubBlock.gif    public Row get(int which) dot.gif{
25InBlock.gif        return (Row) vector.elementAt(which);
26ExpandedSubBlockEnd.gif    }

27InBlock.gif    
28ExpandedSubBlockStart.gifContractedSubBlock.gif    public Iterator getIterator()dot.gif{
29InBlock.gif        return vector.iterator();
30ExpandedSubBlockEnd.gif    }

31InBlock.gif
32ExpandedSubBlockStart.gifContractedSubBlock.gif    public void dump() dot.gif{
33InBlock.gif        Iterator<Row> itr = vector.iterator();
34ExpandedSubBlockStart.gifContractedSubBlock.gif        for (;itr.hasNext();) dot.gif{
35InBlock.gif            itr.next().dump();
36ExpandedSubBlockEnd.gif        }

37ExpandedSubBlockEnd.gif    }

38ExpandedBlockEnd.gif}

39 None.gif
<o:p>

Row.java代表数据库中的一行数据,代码如下:

 1 None.gif package com.bat.afp.DAOComm;
 2 None.gif
 3 None.gifimport java.util.Hashtable;
 4 None.gifimport java.util.Iterator;
 5 None.gifimport java.util.Vector;
 6 None.gif
 7 ExpandedBlockStart.gifContractedBlock.gif /**/ /**
 8InBlock.gif * @author liuyf
 9ExpandedBlockEnd.gif */

10 ExpandedBlockStart.gifContractedBlock.gif public   class  Row  dot.gif {
11InBlock.gif
12InBlock.gif    private Vector<String>                ordering    = new Vector<String>();
13InBlock.gif
14InBlock.gif    private Hashtable<String, String>    hashtable    = new Hashtable<String, String>();
15InBlock.gif
16ExpandedSubBlockStart.gifContractedSubBlock.gif    public Row() dot.gif{
17ExpandedSubBlockEnd.gif    }

18InBlock.gif
19ExpandedSubBlockStart.gifContractedSubBlock.gif    public void put(String name, String value) dot.gif{
20InBlock.gif        if (!hashtable.containsKey(name))
21InBlock.gif            ordering.addElement(name);
22InBlock.gif        hashtable.put(name, value);
23ExpandedSubBlockEnd.gif    }

24InBlock.gif
25ExpandedSubBlockStart.gifContractedSubBlock.gif    public int length() dot.gif{
26InBlock.gif        return hashtable.size();
27ExpandedSubBlockEnd.gif    }

28InBlock.gif
29ExpandedSubBlockStart.gifContractedSubBlock.gif    public String get(String name) dot.gif{
30ExpandedSubBlockStart.gifContractedSubBlock.gif        if(hashtable.get(name)!=null)dot.gif{
31InBlock.gif            return hashtable.get(name);
32ExpandedSubBlockStart.gifContractedSubBlock.gif        }
else if(hashtable.get(name.toLowerCase())!=null)dot.gif{
33InBlock.gif            return hashtable.get(name.toLowerCase());
34ExpandedSubBlockStart.gifContractedSubBlock.gif        }
else if(hashtable.get(name.toUpperCase())!=null)dot.gif{
35InBlock.gif            return hashtable.get(name.toUpperCase());
36ExpandedSubBlockEnd.gif        }

37InBlock.gif        
38InBlock.gif        return null;
39ExpandedSubBlockEnd.gif    }

40InBlock.gif
41ExpandedSubBlockStart.gifContractedSubBlock.gif    public String get(int which) dot.gif{
42InBlock.gif        String key = ordering.elementAt(which-1);
43InBlock.gif        return hashtable.get(key);
44ExpandedSubBlockEnd.gif    }

45InBlock.gif
46ExpandedSubBlockStart.gifContractedSubBlock.gif    public String getKey(int which) dot.gif{
47InBlock.gif        String key = ordering.elementAt(which-1);
48InBlock.gif        return key;
49ExpandedSubBlockEnd.gif    }

50InBlock.gif
51ExpandedSubBlockStart.gifContractedSubBlock.gif    public void dump() dot.gif{
52InBlock.gif        Iterator<String> itr = hashtable.keySet().iterator();
53ExpandedSubBlockStart.gifContractedSubBlock.gif        for (; itr.hasNext();) dot.gif{
54InBlock.gif            String name = itr.next();
55InBlock.gif            String value = hashtable.get(name);
56InBlock.gif            System.out.print(name + "=" + value + "");
57ExpandedSubBlockEnd.gif        }

58ExpandedSubBlockEnd.gif    }

59ExpandedBlockEnd.gif}

60 None.gif

<o:p></o:p>

</o:p>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值