1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
package ca.spaz.sql; |
10 |
|
|
11 |
|
import java.util.*; |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
public class SQLColumnSet { |
19 |
|
|
20 |
|
private List terms; |
21 |
|
|
22 |
|
private List names; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
public SQLColumnSet() { |
28 |
0 |
super(); |
29 |
0 |
names = new ArrayList(); |
30 |
0 |
terms = new ArrayList(); |
31 |
0 |
} |
32 |
|
|
33 |
|
public void add(String name, String str) { |
34 |
0 |
names.add(name); |
35 |
0 |
terms.add(str); |
36 |
0 |
} |
37 |
|
|
38 |
|
public void add(String name, Object o) { |
39 |
0 |
names.add(name); |
40 |
0 |
terms.add(SQLStatement.fixClass(o)); |
41 |
0 |
} |
42 |
|
|
43 |
|
public void add(String name, int i) { |
44 |
0 |
names.add(name); |
45 |
0 |
terms.add(new Integer(i)); |
46 |
0 |
} |
47 |
|
|
48 |
|
public void add(String name, boolean b) { |
49 |
0 |
names.add(name); |
50 |
0 |
terms.add(new Boolean(b)); |
51 |
0 |
} |
52 |
|
|
53 |
|
public void add(String name, double d) { |
54 |
0 |
names.add(name); |
55 |
0 |
terms.add(new Double(d)); |
56 |
0 |
} |
57 |
|
|
58 |
|
public void add(String name, float f) { |
59 |
0 |
names.add(name); |
60 |
0 |
terms.add(new Double(f)); |
61 |
0 |
} |
62 |
|
|
63 |
|
public void add(String name, char c) { |
64 |
0 |
names.add(name); |
65 |
0 |
terms.add(new Character(c)); |
66 |
0 |
} |
67 |
|
|
68 |
|
public String getNameString() { |
69 |
0 |
StringBuffer sb = new StringBuffer(); |
70 |
0 |
sb.append(" ( "); |
71 |
0 |
for (int i = 0; i < names.size(); i++) { |
72 |
0 |
Object name = names.get(i); |
73 |
0 |
sb.append(name.toString()); |
74 |
0 |
if (i < names.size() - 1) { |
75 |
0 |
sb.append(", "); |
76 |
|
} |
77 |
|
} |
78 |
0 |
sb.append(" ) "); |
79 |
0 |
return sb.toString(); |
80 |
|
} |
81 |
|
|
82 |
|
public String getValueString() { |
83 |
0 |
StringBuffer sb = new StringBuffer(); |
84 |
0 |
sb.append(" ("); |
85 |
0 |
for (int i = 0; i < terms.size(); i++) { |
86 |
0 |
Object term = terms.get(i); |
87 |
0 |
if (term != null) { |
88 |
0 |
sb.append(" '"); |
89 |
0 |
sb.append(SQLStatement.escape(term.toString())); |
90 |
0 |
sb.append("' "); |
91 |
0 |
} else { |
92 |
0 |
sb.append(" NULL"); |
93 |
|
} |
94 |
0 |
if (i < terms.size() - 1) { |
95 |
0 |
sb.append(", "); |
96 |
|
} |
97 |
|
} |
98 |
0 |
sb.append(") "); |
99 |
0 |
return sb.toString(); |
100 |
|
} |
101 |
|
|
102 |
|
public List getNames() { |
103 |
0 |
return Collections.unmodifiableList(names); |
104 |
|
} |
105 |
|
|
106 |
|
public List getValues() { |
107 |
0 |
return Collections.unmodifiableList(terms); |
108 |
|
} |
109 |
|
|
110 |
|
} |