%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.aspects.jdbc.SqlMemory |
|
|
1 | /* |
|
2 | * Copyright 2005 Tavant Technologies and Contributors |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | * |
|
16 | * |
|
17 | * |
|
18 | * Original Author: binil.thomas (Tavant Technologies) |
|
19 | * Contributor(s): prashant.nair; |
|
20 | * |
|
21 | */ |
|
22 | package net.sf.infrared.aspects.jdbc; |
|
23 | ||
24 | import java.sql.PreparedStatement; |
|
25 | import java.util.Map; |
|
26 | import java.util.WeakHashMap; |
|
27 | ||
28 | ||
29 | /** |
|
30 | * This class 'remembers' the template SQL using which a PreparedStatement or CallableStatement |
|
31 | * was prepared. (The JDBC interfaces, unfortunately, do not expose this capability). |
|
32 | * |
|
33 | * @author prashant.nair |
|
34 | * @author binil.thomas |
|
35 | */ |
|
36 | 0 | public class SqlMemory { |
37 | // map of PreparedStatement implementation -> sql string |
|
38 | 0 | private Map psToSqlMap = new WeakHashMap(); |
39 | ||
40 | public void memorizeSql(String sql, PreparedStatement ps) { |
|
41 | 0 | psToSqlMap.put(ps, sql); |
42 | 0 | } |
43 | ||
44 | // untyped version of the above api |
|
45 | public void memorizeSql(String sql, Object ps) { |
|
46 | 0 | psToSqlMap.put(ps, sql); |
47 | 0 | } |
48 | ||
49 | public String recollectSql(PreparedStatement ps) { |
|
50 | 0 | return (String) psToSqlMap.get(ps); |
51 | } |
|
52 | ||
53 | // untyped version of the above api |
|
54 | public String recollectSql(Object ps) { |
|
55 | 0 | return (String) psToSqlMap.get(ps); |
56 | } |
|
57 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |