java/sql-dk/src/info/globalcode/sql/dk/formatting/FakeSqlArray.java
author František Kučera <franta-hg@frantovo.cz>
Wed, 15 Jan 2014 21:06:12 +0100
branchv_0
changeset 159 9632b23df30c
child 164 8cc7862605a1
permissions -rw-r--r--
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
franta-hg@159
     1
/**
franta-hg@159
     2
 * SQL-DK
franta-hg@159
     3
 * Copyright © 2014 František Kučera (frantovo.cz)
franta-hg@159
     4
 *
franta-hg@159
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@159
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@159
     7
 * the Free Software Foundation, either version 3 of the License, or
franta-hg@159
     8
 * (at your option) any later version.
franta-hg@159
     9
 *
franta-hg@159
    10
 * This program is distributed in the hope that it will be useful,
franta-hg@159
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@159
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@159
    13
 * GNU General Public License for more details.
franta-hg@159
    14
 *
franta-hg@159
    15
 * You should have received a copy of the GNU General Public License
franta-hg@159
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@159
    17
 */
franta-hg@159
    18
package info.globalcode.sql.dk.formatting;
franta-hg@159
    19
franta-hg@159
    20
import info.globalcode.sql.dk.SQLType;
franta-hg@159
    21
import java.sql.Array;
franta-hg@159
    22
import java.sql.ResultSet;
franta-hg@159
    23
import java.sql.SQLException;
franta-hg@159
    24
import java.util.Map;
franta-hg@159
    25
franta-hg@159
    26
/**
franta-hg@159
    27
 * Fake SQL array, for formatting purposes only
franta-hg@159
    28
 *
franta-hg@159
    29
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@159
    30
 */
franta-hg@159
    31
public class FakeSqlArray implements Array {
franta-hg@159
    32
franta-hg@159
    33
	private static final UnsupportedOperationException exception = new UnsupportedOperationException("This is just a fake SQL array.");
franta-hg@159
    34
	private final Object[] data;
franta-hg@159
    35
	private final SQLType baseType;
franta-hg@159
    36
franta-hg@159
    37
	public FakeSqlArray(Object[] data, SQLType baseType) {
franta-hg@159
    38
		this.data = data;
franta-hg@159
    39
		this.baseType = baseType;
franta-hg@159
    40
	}
franta-hg@159
    41
franta-hg@159
    42
	@Override
franta-hg@159
    43
	public String getBaseTypeName() throws SQLException {
franta-hg@159
    44
		return baseType.name();
franta-hg@159
    45
	}
franta-hg@159
    46
franta-hg@159
    47
	@Override
franta-hg@159
    48
	public int getBaseType() throws SQLException {
franta-hg@159
    49
		return baseType.getCode();
franta-hg@159
    50
	}
franta-hg@159
    51
franta-hg@159
    52
	@Override
franta-hg@159
    53
	public Object getArray() throws SQLException {
franta-hg@159
    54
		return data;
franta-hg@159
    55
	}
franta-hg@159
    56
franta-hg@159
    57
	@Override
franta-hg@159
    58
	public Object getArray(Map<String, Class<?>> map) throws SQLException {
franta-hg@159
    59
		throw exception;
franta-hg@159
    60
	}
franta-hg@159
    61
franta-hg@159
    62
	@Override
franta-hg@159
    63
	public Object getArray(long index, int count) throws SQLException {
franta-hg@159
    64
		throw exception;
franta-hg@159
    65
	}
franta-hg@159
    66
franta-hg@159
    67
	@Override
franta-hg@159
    68
	public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
franta-hg@159
    69
		throw exception;
franta-hg@159
    70
	}
franta-hg@159
    71
franta-hg@159
    72
	@Override
franta-hg@159
    73
	public ResultSet getResultSet() throws SQLException {
franta-hg@159
    74
		throw exception;
franta-hg@159
    75
	}
franta-hg@159
    76
franta-hg@159
    77
	@Override
franta-hg@159
    78
	public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
franta-hg@159
    79
		throw exception;
franta-hg@159
    80
	}
franta-hg@159
    81
franta-hg@159
    82
	@Override
franta-hg@159
    83
	public ResultSet getResultSet(long index, int count) throws SQLException {
franta-hg@159
    84
		throw exception;
franta-hg@159
    85
	}
franta-hg@159
    86
franta-hg@159
    87
	@Override
franta-hg@159
    88
	public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
franta-hg@159
    89
		throw exception;
franta-hg@159
    90
	}
franta-hg@159
    91
franta-hg@159
    92
	@Override
franta-hg@159
    93
	public void free() throws SQLException {
franta-hg@159
    94
		throw exception;
franta-hg@159
    95
	}
franta-hg@159
    96
}