1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.tools.ij.ijResultImpl |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.tools.ij; |
22 | |
23 | import org.apache.derby.iapi.tools.i18n.LocalizedResource; |
24 | import java.sql.Connection; |
25 | import java.sql.ResultSet; |
26 | import java.sql.Statement; |
27 | import java.sql.SQLException; |
28 | import java.sql.SQLWarning; |
29 | import java.util.Vector; |
30 | |
31 | /** |
32 | * This is an empty impl for reuse of code. |
33 | * |
34 | * @author ames |
35 | */ |
36 | abstract class ijResultImpl implements ijResult { |
37 | public boolean isConnection() { return false; } |
38 | public boolean isStatement() { return false; } |
39 | public boolean isResultSet() throws SQLException { return false; } |
40 | public boolean isUpdateCount() throws SQLException { return false; } |
41 | public boolean isNextRowOfResultSet() { return false; } |
42 | public boolean isVector() { return false; } |
43 | public boolean isMulti() { return false; } |
44 | public boolean isException() { return false; } |
45 | public boolean hasWarnings() throws SQLException { return getSQLWarnings()!=null; } |
46 | |
47 | public Connection getConnection() { return null; } |
48 | public Statement getStatement() { return null; } |
49 | public int getUpdateCount() throws SQLException { return -1; } |
50 | public ResultSet getResultSet() throws SQLException { return null; } |
51 | public ResultSet getNextRowOfResultSet() { return null; } |
52 | public Vector getVector() { return null; } |
53 | public SQLException getException() { return null; } |
54 | |
55 | public void closeStatement() throws SQLException { } |
56 | |
57 | public abstract SQLWarning getSQLWarnings() throws SQLException; |
58 | public abstract void clearSQLWarnings() throws SQLException; |
59 | |
60 | |
61 | public String toString() { |
62 | if (isConnection()) return LocalizedResource.getMessage("IJ_Con0",getConnection().toString()); |
63 | if (isStatement()) return LocalizedResource.getMessage("IJ_Stm0",getStatement().toString()); |
64 | if (isNextRowOfResultSet()) return LocalizedResource.getMessage("IJ_Row0",getNextRowOfResultSet().toString()); |
65 | if (isVector()) return LocalizedResource.getMessage("IJ_Vec0",getVector().toString()); |
66 | if (isMulti()) return LocalizedResource.getMessage("IJ_Mul0",getVector().toString()); |
67 | if (isException()) return LocalizedResource.getMessage("IJ_Exc0",getException().toString()); |
68 | return LocalizedResource.getMessage("IJ_Unkn0",this.getClass().getName()); |
69 | } |
70 | } |