franta-hg@159: /** franta-hg@159: * SQL-DK franta-hg@159: * Copyright © 2014 František Kučera (frantovo.cz) franta-hg@159: * franta-hg@159: * This program is free software: you can redistribute it and/or modify franta-hg@159: * it under the terms of the GNU General Public License as published by franta-hg@159: * the Free Software Foundation, either version 3 of the License, or franta-hg@159: * (at your option) any later version. franta-hg@159: * franta-hg@159: * This program is distributed in the hope that it will be useful, franta-hg@159: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@159: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@159: * GNU General Public License for more details. franta-hg@159: * franta-hg@159: * You should have received a copy of the GNU General Public License franta-hg@159: * along with this program. If not, see . franta-hg@159: */ franta-hg@159: package info.globalcode.sql.dk.formatting; franta-hg@159: franta-hg@159: import info.globalcode.sql.dk.SQLType; franta-hg@159: import java.sql.Array; franta-hg@159: import java.sql.ResultSet; franta-hg@159: import java.sql.SQLException; franta-hg@159: import java.util.Map; franta-hg@159: franta-hg@159: /** franta-hg@159: * Fake SQL array, for formatting purposes only franta-hg@159: * franta-hg@159: * @author Ing. František Kučera (frantovo.cz) franta-hg@159: */ franta-hg@159: public class FakeSqlArray implements Array { franta-hg@159: franta-hg@159: private static final UnsupportedOperationException exception = new UnsupportedOperationException("This is just a fake SQL array."); franta-hg@159: private final Object[] data; franta-hg@159: private final SQLType baseType; franta-hg@159: franta-hg@159: public FakeSqlArray(Object[] data, SQLType baseType) { franta-hg@159: this.data = data; franta-hg@159: this.baseType = baseType; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@164: public String toString() { franta-hg@164: StringBuilder string = new StringBuilder(); franta-hg@164: for (Object o : data) { franta-hg@164: string.append(o); franta-hg@164: string.append("\n"); franta-hg@164: } franta-hg@164: return string.toString(); franta-hg@164: } franta-hg@164: franta-hg@164: @Override franta-hg@159: public String getBaseTypeName() throws SQLException { franta-hg@159: return baseType.name(); franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public int getBaseType() throws SQLException { franta-hg@159: return baseType.getCode(); franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public Object getArray() throws SQLException { franta-hg@159: return data; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public Object getArray(Map> map) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public Object getArray(long index, int count) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public Object getArray(long index, int count, Map> map) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public ResultSet getResultSet() throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public ResultSet getResultSet(Map> map) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public ResultSet getResultSet(long index, int count) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public ResultSet getResultSet(long index, int count, Map> map) throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: franta-hg@159: @Override franta-hg@159: public void free() throws SQLException { franta-hg@159: throw exception; franta-hg@159: } franta-hg@159: }