01: package org.geotools.data.jdbc.datasource;
02:
03: import java.sql.Connection;
04: import java.sql.Statement;
05:
06: /**
07: * Generic {@link Connection} unwrapper. A user can test if the unwrapper is able to unwrap a
08: * certain connection, on positive answer he can call {@link #unwrap(Connection)} to get the native
09: * connection
10: *
11: * @author Andrea Aime - TOPP
12: *
13: */
14: public interface UnWrapper {
15: /**
16: * Returns true if this unwrapper knows how to unwrap the specified connection
17: *
18: * @param conn
19: * @return
20: */
21: boolean canUnwrap(Connection conn);
22:
23: /**
24: * Returns tru if this unwrapper knows how to unwrap the specified statement
25: * @param st
26: * @return
27: */
28: boolean canUnwrap(Statement st);
29:
30: /**
31: * Returns the unwrapped connection, of throws {@link IllegalArgumentException} if the passed
32: * {@link Connection} is not supported ({@link #canUnwrap(Connection)} returns false}.
33: *
34: * @param conn
35: * @return
36: */
37: Connection unwrap(Connection conn);
38:
39: /**
40: * Returns the unwrapped statement, of throws {@link IllegalArgumentException} if the passed
41: * {@link java.sql.Statement} is not supported ({@link #canUnwrap(Statement)} returns false}.
42: * @param statement
43: * @return
44: */
45: Statement unwrap(Statement statement);
46: }
|