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