1
2
3
4
5
6
7
8 package it.imolinfo.jbi4cics.messageformat.jdbc;
9
10 import it.imolinfo.jbi4cics.Logger;
11 import it.imolinfo.jbi4cics.LoggerFactory;
12 import it.imolinfo.jbi4cics.exception.FormatException;
13 import it.imolinfo.jbi4cics.jbi.Messages;
14 import it.imolinfo.jbi4cics.messageformat.FieldDescriptor;
15 import it.imolinfo.jbi4cics.messageformat.MappingDescriptor;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 public class JdbcStatementDescriptor implements MappingDescriptor{
21
22 public static final int PREPARED_STATEMENT=0;
23 public static final int CALLABLE_STATEMENT=1;
24
25 public static final int UPDATE_SQL=0;
26 public static final int SELECT_SQL=1;
27
28
29
30
31 private static final Logger LOG
32 = LoggerFactory.getLogger(JdbcStatementDescriptor.class);
33
34
35
36
37 private static final Messages MESSAGES
38 = Messages.getMessages(JdbcStatementDescriptor.class);
39
40
41 private String sql;
42 private int statementType;
43 private int sqlType;
44 private Map<Integer, FieldDescriptor> parameterList=new HashMap<Integer, FieldDescriptor>();
45 private Map<String, Integer> propertyNameParameterIndexMap=new HashMap<String, Integer>();
46 private Class beanClass;
47
48
49 public JdbcStatementDescriptor() {
50 super();
51
52 }
53
54 public JdbcParameterDescriptor getParameter(int paramterIndex){
55 return (JdbcParameterDescriptor)parameterList.get(new Integer(paramterIndex));
56 }
57
58
59
60
61 public String getSql() {
62 return sql;
63 }
64
65
66
67
68 public void setSql(String sql) {
69 this.sql = sql;
70 }
71
72
73
74
75 public int getSqlType() {
76 return sqlType;
77 }
78
79
80
81
82 public void setSqlType(int sqlType) {
83 this.sqlType = sqlType;
84 }
85
86
87
88
89 public int getStatementType() {
90 return statementType;
91 }
92
93
94
95
96 public void setStatementType(int statementType) {
97 this.statementType = statementType;
98 }
99
100 public void addFieldMapping(String propertyName, String fieldName, FieldDescriptor fieldDescriptor) throws FormatException {
101
102
103 }
104
105 public void addFieldMapping(String propertyName, Integer fieldIndex, FieldDescriptor fieldDescriptor) throws FormatException {
106 if (!(fieldDescriptor instanceof JdbcParameterDescriptor)){
107 LOG.error("CIC001805_Jdbc_parameter_descriptor_not_found", fieldDescriptor.getClass());
108 throw new FormatException(MESSAGES.getString("CIC001805_Jdbc_parameter_descriptor_not_found", fieldDescriptor.getClass()));
109 }
110 parameterList.put(fieldIndex,fieldDescriptor);
111 propertyNameParameterIndexMap.put(propertyName,fieldIndex);
112 }
113
114
115
116
117 public Map<String, Integer> getPropertyNameParameterIndexMap() {
118 return propertyNameParameterIndexMap;
119 }
120
121 public Map<String, FieldDescriptor> getFieldMap() throws FormatException {
122
123 throw new FormatException(MESSAGES.getString("CIC001800_Not_implemented"));
124 }
125
126
127
128
129 public Class getBeanClass() {
130 return beanClass;
131 }
132
133
134
135
136 public void setBeanClass(Class beanClass) {
137 this.beanClass = beanClass;
138 }
139
140 public void setCodePage(String codePage) {
141
142
143 }
144
145 }