1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package tools.gsf.facade.sql;
18
19 import COM.FutureTense.Interfaces.IList;
20 import com.fatwire.cs.core.db.Util;
21 import org.apache.commons.lang3.StringUtils;
22
23 import java.util.Date;
24
25
26
27
28
29
30 class SingleRow implements Row {
31
32 private final IList list;
33
34
35
36
37 public SingleRow(final IList list) {
38 super();
39 this.list = list;
40 }
41
42
43
44
45
46
47 public byte[] getBytes(final String key) {
48 try {
49 return (byte[]) list.getObject(key);
50 } catch (final NoSuchFieldException e) {
51 throw new RuntimeException(e);
52 }
53 }
54
55
56
57
58
59
60 public Character getChar(final String key) {
61 try {
62 final String s = list.getValue(key);
63 if (StringUtils.isNotBlank(s)) {
64 return s.charAt(0);
65 }
66 return null;
67 } catch (final NoSuchFieldException e) {
68 throw new RuntimeException(e);
69 }
70 }
71
72
73
74
75
76
77 public Date getDate(final String key) {
78 try {
79 final String s = list.getValue(key);
80 if (StringUtils.isNotBlank(s)) {
81 return Util.parseJdbcDate(s);
82 }
83 return null;
84 } catch (final NoSuchFieldException e) {
85 throw new RuntimeException(e);
86 }
87 }
88
89
90
91
92
93
94 public Long getLong(final String key) {
95 try {
96 final String s = list.getValue(key);
97 if (StringUtils.isNotBlank(s)) {
98 return Long.parseLong(s);
99 }
100 return null;
101 } catch (final NoSuchFieldException e) {
102 throw new RuntimeException(e);
103 }
104 }
105
106
107
108
109
110
111
112 public String getString(final String key) {
113 try {
114 return list.getValue(key);
115 } catch (final NoSuchFieldException e) {
116 throw new RuntimeException(e);
117 }
118 }
119
120
121
122
123
124 public boolean isField(String key) {
125 for (int i = 0; i < list.numColumns(); i++) {
126 if (key.equalsIgnoreCase(list.getColumnName(i))) {
127 return true;
128 }
129
130 }
131 return false;
132 }
133
134 @Override
135 public Integer getInt(String key) {
136 try {
137 final String s = list.getValue(key);
138 if (StringUtils.isNotBlank(s)) {
139 return Integer.parseInt(s);
140 }
141 return null;
142 } catch (final NoSuchFieldException e) {
143 throw new RuntimeException(e);
144 }
145
146 }
147 }