FirstColumnSmartProjector.java
biz/hammurapi/sql/FirstColumnSmartProjector.java
Violations
Inspector |
Message |
Severity |
Location |
Java Inspector 048 |
Copyrights information should be present in each file. |
1 |
|
Java Inspector 089 |
Undocumented method |
2 |
41:9
|
Java Inspector 089 |
Undocumented constructor |
2 |
56:5
|
Java Inspector 051 |
It is good practice to call in any case super() in a constructor. |
3 |
56:5
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23package biz.hammurapi.sql;
24
25import java.sql.ResultSet;
26import java.sql.SQLException;
27
28import biz.hammurapi.convert.ConverterClosure;
29import biz.hammurapi.convert.ConvertingService;
30
31
32
33
34
35
36
37public class FirstColumnSmartProjector implements Projector {
38 private ConverterClosure converter;
39 private Class targetClass;
40
41 public Object project(ResultSet rs) throws SQLException {
42 Object ret;
43 if (targetClass==null) {
44 ret = rs.getObject(1);
45 } else {
46 ret=ConvertingService.convert(rs.getObject(1), targetClass);
47 }
48
49 if (converter==null) {
50 return ret;
51 }
52
53 return converter.convert(ret);
54 }
55
56 public FirstColumnSmartProjector(Class targetClass, ConverterClosure converter) {
57 this.converter=converter;
58 this.targetClass=targetClass;
59 }
60}
61