1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @modules java.sql.rowset/com.sun.rowset 27 * java.sql.rowset/com.sun.rowset.internal 28 * java.sql.rowset/com.sun.rowset.providers 29 */ 30 31 package util; 32 33 import java.sql.Array; 34 import java.sql.JDBCType; 35 import java.sql.ResultSet; 36 import java.sql.SQLException; 37 import java.util.Arrays; 38 import java.util.Map; 39 40 public class StubArray implements Array { 41 42 private String typeName; 43 Object[] elements; 44 45 public StubArray(String name, Object[] values) { 46 typeName = name; 47 elements = Arrays.copyOf(values, values.length); 48 49 } 50 51 @Override 52 public String getBaseTypeName() throws SQLException { 53 return typeName; 54 } 55 56 @Override 57 public int getBaseType() throws SQLException { 58 return JDBCType.valueOf(typeName).getVendorTypeNumber(); 59 } 60 61 @Override 62 public Object getArray() throws SQLException { 63 return Arrays.copyOf(elements, elements.length); 64 } 65 66 @Override 67 public Object getArray(Map<String, Class<?>> map) throws SQLException { 68 return getArray(); 69 } 70 71 @Override 72 public Object getArray(long index, int count) throws SQLException { 73 return getArray(); 74 } 75 76 @Override 77 public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException { 78 return getArray(); 79 } 80 81 @Override 82 public ResultSet getResultSet() throws SQLException { 83 throw new UnsupportedOperationException("Not supported yet."); 84 } 85 86 @Override 87 public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException { 88 throw new UnsupportedOperationException("Not supported yet."); 89 } 90 91 @Override 92 public ResultSet getResultSet(long index, int count) throws SQLException { 93 throw new UnsupportedOperationException("Not supported yet."); 94 } 95 96 @Override 97 public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException { 98 throw new UnsupportedOperationException("Not supported yet."); 99 } 100 101 @Override 102 public void free() throws SQLException { 103 elements = null; 104 typeName = null; 105 } 106 107 }