RowSet.java代表行的集合,代码如下:
1
package com.bat.afp.DAOComm;
2
3 import java.util.Iterator;
4 import java.util.Vector;
5
6 /**/ /**
7 * @author liuyf
8 */
9 public class RowSet {
10
11 private Vector<Row> vector = new Vector<Row>();
12
13 public RowSet() {
14 }
15
16 public void add(Row row) {
17 vector.addElement(row);
18 }
19
20 public int length() {
21 return vector.size();
22 }
23
24 public Row get(int which) {
25 return (Row) vector.elementAt(which);
26 }
27
28 public Iterator getIterator(){
29 return vector.iterator();
30 }
31
32 public void dump() {
33 Iterator<Row> itr = vector.iterator();
34 for (;itr.hasNext();) {
35 itr.next().dump();
36 }
37 }
38}
39
2
3 import java.util.Iterator;
4 import java.util.Vector;
5
6 /**/ /**
7 * @author liuyf
8 */
9 public class RowSet {
10
11 private Vector<Row> vector = new Vector<Row>();
12
13 public RowSet() {
14 }
15
16 public void add(Row row) {
17 vector.addElement(row);
18 }
19
20 public int length() {
21 return vector.size();
22 }
23
24 public Row get(int which) {
25 return (Row) vector.elementAt(which);
26 }
27
28 public Iterator getIterator(){
29 return vector.iterator();
30 }
31
32 public void dump() {
33 Iterator<Row> itr = vector.iterator();
34 for (;itr.hasNext();) {
35 itr.next().dump();
36 }
37 }
38}
39
Row.java代表数据库中的一行数据,代码如下:
1
package com.bat.afp.DAOComm;
2
3 import java.util.Hashtable;
4 import java.util.Iterator;
5 import java.util.Vector;
6
7 /**/ /**
8 * @author liuyf
9 */
10 public class Row {
11
12 private Vector<String> ordering = new Vector<String>();
13
14 private Hashtable<String, String> hashtable = new Hashtable<String, String>();
15
16 public Row() {
17 }
18
19 public void put(String name, String value) {
20 if (!hashtable.containsKey(name))
21 ordering.addElement(name);
22 hashtable.put(name, value);
23 }
24
25 public int length() {
26 return hashtable.size();
27 }
28
29 public String get(String name) {
30 if(hashtable.get(name)!=null){
31 return hashtable.get(name);
32 }else if(hashtable.get(name.toLowerCase())!=null){
33 return hashtable.get(name.toLowerCase());
34 }else if(hashtable.get(name.toUpperCase())!=null){
35 return hashtable.get(name.toUpperCase());
36 }
37
38 return null;
39 }
40
41 public String get(int which) {
42 String key = ordering.elementAt(which-1);
43 return hashtable.get(key);
44 }
45
46 public String getKey(int which) {
47 String key = ordering.elementAt(which-1);
48 return key;
49 }
50
51 public void dump() {
52 Iterator<String> itr = hashtable.keySet().iterator();
53 for (; itr.hasNext();) {
54 String name = itr.next();
55 String value = hashtable.get(name);
56 System.out.print(name + "=" + value + ", ");
57 }
58 }
59}
60
2
3 import java.util.Hashtable;
4 import java.util.Iterator;
5 import java.util.Vector;
6
7 /**/ /**
8 * @author liuyf
9 */
10 public class Row {
11
12 private Vector<String> ordering = new Vector<String>();
13
14 private Hashtable<String, String> hashtable = new Hashtable<String, String>();
15
16 public Row() {
17 }
18
19 public void put(String name, String value) {
20 if (!hashtable.containsKey(name))
21 ordering.addElement(name);
22 hashtable.put(name, value);
23 }
24
25 public int length() {
26 return hashtable.size();
27 }
28
29 public String get(String name) {
30 if(hashtable.get(name)!=null){
31 return hashtable.get(name);
32 }else if(hashtable.get(name.toLowerCase())!=null){
33 return hashtable.get(name.toLowerCase());
34 }else if(hashtable.get(name.toUpperCase())!=null){
35 return hashtable.get(name.toUpperCase());
36 }
37
38 return null;
39 }
40
41 public String get(int which) {
42 String key = ordering.elementAt(which-1);
43 return hashtable.get(key);
44 }
45
46 public String getKey(int which) {
47 String key = ordering.elementAt(which-1);
48 return key;
49 }
50
51 public void dump() {
52 Iterator<String> itr = hashtable.keySet().iterator();
53 for (; itr.hasNext();) {
54 String name = itr.next();
55 String value = hashtable.get(name);
56 System.out.print(name + "=" + value + ", ");
57 }
58 }
59}
60
<o:p></o:p>
</o:p>