1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/FakeSqlArray.java Wed Jan 15 21:06:12 2014 +0100
1.3 @@ -0,0 +1,96 @@
1.4 +/**
1.5 + * SQL-DK
1.6 + * Copyright © 2014 František Kučera (frantovo.cz)
1.7 + *
1.8 + * This program is free software: you can redistribute it and/or modify
1.9 + * it under the terms of the GNU General Public License as published by
1.10 + * the Free Software Foundation, either version 3 of the License, or
1.11 + * (at your option) any later version.
1.12 + *
1.13 + * This program is distributed in the hope that it will be useful,
1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.16 + * GNU General Public License for more details.
1.17 + *
1.18 + * You should have received a copy of the GNU General Public License
1.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.20 + */
1.21 +package info.globalcode.sql.dk.formatting;
1.22 +
1.23 +import info.globalcode.sql.dk.SQLType;
1.24 +import java.sql.Array;
1.25 +import java.sql.ResultSet;
1.26 +import java.sql.SQLException;
1.27 +import java.util.Map;
1.28 +
1.29 +/**
1.30 + * Fake SQL array, for formatting purposes only
1.31 + *
1.32 + * @author Ing. František Kučera (frantovo.cz)
1.33 + */
1.34 +public class FakeSqlArray implements Array {
1.35 +
1.36 + private static final UnsupportedOperationException exception = new UnsupportedOperationException("This is just a fake SQL array.");
1.37 + private final Object[] data;
1.38 + private final SQLType baseType;
1.39 +
1.40 + public FakeSqlArray(Object[] data, SQLType baseType) {
1.41 + this.data = data;
1.42 + this.baseType = baseType;
1.43 + }
1.44 +
1.45 + @Override
1.46 + public String getBaseTypeName() throws SQLException {
1.47 + return baseType.name();
1.48 + }
1.49 +
1.50 + @Override
1.51 + public int getBaseType() throws SQLException {
1.52 + return baseType.getCode();
1.53 + }
1.54 +
1.55 + @Override
1.56 + public Object getArray() throws SQLException {
1.57 + return data;
1.58 + }
1.59 +
1.60 + @Override
1.61 + public Object getArray(Map<String, Class<?>> map) throws SQLException {
1.62 + throw exception;
1.63 + }
1.64 +
1.65 + @Override
1.66 + public Object getArray(long index, int count) throws SQLException {
1.67 + throw exception;
1.68 + }
1.69 +
1.70 + @Override
1.71 + public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
1.72 + throw exception;
1.73 + }
1.74 +
1.75 + @Override
1.76 + public ResultSet getResultSet() throws SQLException {
1.77 + throw exception;
1.78 + }
1.79 +
1.80 + @Override
1.81 + public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
1.82 + throw exception;
1.83 + }
1.84 +
1.85 + @Override
1.86 + public ResultSet getResultSet(long index, int count) throws SQLException {
1.87 + throw exception;
1.88 + }
1.89 +
1.90 + @Override
1.91 + public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
1.92 + throw exception;
1.93 + }
1.94 +
1.95 + @Override
1.96 + public void free() throws SQLException {
1.97 + throw exception;
1.98 + }
1.99 +}