Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 193 |  | Methods: | 18
| NCLOC: | 109 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
SqlLoadableConnection.java | 0% | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * Joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      */
5 |  |
     /*
6 |  |
      * Created on 2003/12/16
7 |  |
      */
8 |  |
     package org.asyrinx.brownie.jdbc;
9 |  |
10 |  |
     import java.io.IOException;
11 |  |
     import java.sql.CallableStatement;
12 |  |
     import java.sql.Connection;
13 |  |
     import java.sql.PreparedStatement;
14 |  |
     import java.sql.SQLException;
15 |  |
16 |  |
     import org.asyrinx.brownie.core.io.sf.RelativeClassResourceStreamFactory;
17 |  |
     import org.asyrinx.brownie.core.io.sf.StreamFactory;
18 |  |
     import org.asyrinx.brownie.core.io.sf.StreamFactoryFacade;
19 |  |
     import org.asyrinx.brownie.core.io.sf.StringLoader;
20 |  |
     import org.asyrinx.brownie.core.lang.StringUtils;
21 |  |
     import org.asyrinx.brownie.jdbc.wrapper.ConnectionWrapper;
22 |  |
23 |  |
     /**
24 |  |
      * @author akima
25 |  |
      */
26 |  |
     public final class SqlLoadableConnection extends ConnectionWrapper {
27 |  |
28 |  |
         /**
29 |  |
          * @param source
30 |  |
          */
31 | 0 |
         public SqlLoadableConnection(Connection source) {
32 | 0 |
             this(source, (String) null);
33 |  |
         }
34 |  |
35 |  |
         /**
36 |  |
          * @param source
37 |  |
          */
38 | 0 |
         public SqlLoadableConnection(Connection source, String classToBeCalled) {
39 | 0 |
             this(source, classToBeCalled, (String) null);
40 |  |
         }
41 |  |
42 |  |
         /**
43 |  |
          * @param source
44 |  |
          */
45 | 0 |
         public SqlLoadableConnection(Connection source, String classToBeCalled,
46 |  |
                 String sqlResources) {
47 | 0 |
             super(source);
48 | 0 |
             this.baseFactoryFacade = newBaseFactoryFacade(sqlResources);
49 | 0 |
             this.streamFactory = newFactory(classToBeCalled, baseFactoryFacade);
50 | 0 |
             this.loader = new StringLoader(streamFactory);
51 |  |
         }
52 |  |
53 |  |
         private final StreamFactory streamFactory;
54 |  |
55 |  |
         private final StreamFactoryFacade baseFactoryFacade;
56 |  |
57 |  |
         private final StringLoader loader;
58 |  |
59 | 0 |
         protected final String load(String key) throws SQLException {
60 | 0 |
             try {
61 | 0 |
                 return loader.load(key);
62 |  |
             } catch (IOException e) {
63 | 0 |
                 throw new SQLException(e.getMessage());
64 |  |
             }
65 |  |
         }
66 |  |
67 | 0 |
         static StreamFactoryFacade newBaseFactoryFacade(String sqlResources) {
68 | 0 |
             final StreamFactoryFacade result = StreamFactoryFacade
69 |  |
                     .newFacade(sqlResources);
70 | 0 |
             return result;
71 |  |
         }
72 |  |
73 | 0 |
         static StreamFactory newFactory(String classToBeCalled,
74 |  |
                 StreamFactoryFacade baseFactoryFacade) {
75 | 0 |
             final StreamFactoryFacade result = baseFactoryFacade.copy();
76 | 0 |
             classToBeCalled = StringUtils.isEmpty(classToBeCalled) ? SqlLoadableConnection.class
77 |  |
                     .getName()
78 |  |
                     : classToBeCalled;
79 | 0 |
             result.add(1, new RelativeClassResourceStreamFactory(classToBeCalled));
80 | 0 |
             return result;
81 |  |
         }
82 |  |
83 |  |
         /**
84 |  |
          * @see org.asyrinx.jdbc.wrapper.ConnectionWrapper#createStatement()
85 |  |
          */
86 | 0 |
         public SqlLoadableStatement createSqlLoadableStatement()
87 |  |
                 throws SQLException {
88 | 0 |
             return new SqlLoadableStatement(super.createStatement(),
89 |  |
                     this.baseFactoryFacade);
90 |  |
         }
91 |  |
92 |  |
         /**
93 |  |
          * @see org.asyrinx.jdbc.wrapper.ConnectionWrapper#createStatement(int, int)
94 |  |
          */
95 | 0 |
         public SqlLoadableStatement createSqlLoadableStatement(int resultSetType,
96 |  |
                 int resultSetConcurrency) throws SQLException {
97 | 0 |
             return new SqlLoadableStatement(super.createStatement(resultSetType,
98 |  |
                     resultSetConcurrency), this.baseFactoryFacade);
99 |  |
         }
100 |  |
101 |  |
         /**
102 |  |
          * @see org.asyrinx.jdbc.wrapper.ConnectionWrapper#createStatement(int, int,
103 |  |
          *        int)
104 |  |
          */
105 | 0 |
         public SqlLoadableStatement createSqlLoadableStatement(int resultSetType,
106 |  |
                 int resultSetConcurrency, int resultSetHoldability)
107 |  |
                 throws SQLException {
108 | 0 |
             return new SqlLoadableStatement(super.createStatement(resultSetType,
109 |  |
                     resultSetConcurrency, resultSetHoldability),
110 |  |
                     this.baseFactoryFacade);
111 |  |
         }
112 |  |
113 |  |
         /**
114 |  |
          * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)
115 |  |
          */
116 | 0 |
         public CallableStatement prepareCallFromFile(String sqlKey,
117 |  |
                 int resultSetType, int resultSetConcurrency,
118 |  |
                 int resultSetHoldability) throws SQLException {
119 | 0 |
             return super.prepareCall(load(sqlKey), resultSetType,
120 |  |
                     resultSetConcurrency, resultSetHoldability);
121 |  |
         }
122 |  |
123 |  |
         /**
124 |  |
          * @see java.sql.Connection#prepareCall(java.lang.String, int, int)
125 |  |
          */
126 | 0 |
         public CallableStatement prepareCallFromFile(String sqlKey,
127 |  |
                 int resultSetType, int resultSetConcurrency) throws SQLException {
128 | 0 |
             return super.prepareCall(load(sqlKey), resultSetType,
129 |  |
                     resultSetConcurrency);
130 |  |
         }
131 |  |
132 |  |
         /**
133 |  |
          * @see java.sql.Connection#prepareCall(java.lang.String)
134 |  |
          */
135 | 0 |
         public CallableStatement prepareCallFromFile(String sqlKey)
136 |  |
                 throws SQLException {
137 | 0 |
             return super.prepareCall(load(sqlKey));
138 |  |
         }
139 |  |
140 |  |
         /**
141 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String, int, int,
142 |  |
          *        int)
143 |  |
          */
144 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey,
145 |  |
                 int resultSetType, int resultSetConcurrency,
146 |  |
                 int resultSetHoldability) throws SQLException {
147 | 0 |
             return super.prepareStatement(load(sqlKey), resultSetType,
148 |  |
                     resultSetConcurrency, resultSetHoldability);
149 |  |
         }
150 |  |
151 |  |
         /**
152 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)
153 |  |
          */
154 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey,
155 |  |
                 int resultSetType, int resultSetConcurrency) throws SQLException {
156 | 0 |
             return super.prepareStatement(load(sqlKey), resultSetType,
157 |  |
                     resultSetConcurrency);
158 |  |
         }
159 |  |
160 |  |
         /**
161 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String, int)
162 |  |
          */
163 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey,
164 |  |
                 int autoGeneratedKeys) throws SQLException {
165 | 0 |
             return super.prepareStatement(load(sqlKey), autoGeneratedKeys);
166 |  |
         }
167 |  |
168 |  |
         /**
169 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String, int[])
170 |  |
          */
171 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey,
172 |  |
                 int[] columnIndexes) throws SQLException {
173 | 0 |
             return super.prepareStatement(load(sqlKey), columnIndexes);
174 |  |
         }
175 |  |
176 |  |
         /**
177 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String,
178 |  |
          *        java.lang.String[])
179 |  |
          */
180 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey,
181 |  |
                 String[] columnNames) throws SQLException {
182 | 0 |
             return super.prepareStatement(load(sqlKey), columnNames);
183 |  |
         }
184 |  |
185 |  |
         /**
186 |  |
          * @see java.sql.Connection#prepareStatement(java.lang.String)
187 |  |
          */
188 | 0 |
         public PreparedStatement prepareStatementFromFile(String sqlKey)
189 |  |
                 throws SQLException {
190 | 0 |
             return super.prepareStatement(load(sqlKey));
191 |  |
         }
192 |  |
193 |  |
     }