Path: blob/master/test/jdk/javax/sql/testng/util/StubArray.java
41153 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package util;2324import java.sql.Array;25import java.sql.JDBCType;26import java.sql.ResultSet;27import java.sql.SQLException;28import java.util.Arrays;29import java.util.Map;3031public class StubArray implements Array {3233private String typeName;34Object[] elements;3536public StubArray(String name, Object[] values) {37typeName = name;38elements = Arrays.copyOf(values, values.length);3940}4142@Override43public String getBaseTypeName() throws SQLException {44return typeName;45}4647@Override48public int getBaseType() throws SQLException {49return JDBCType.valueOf(typeName).getVendorTypeNumber();50}5152@Override53public Object getArray() throws SQLException {54return Arrays.copyOf(elements, elements.length);55}5657@Override58public Object getArray(Map<String, Class<?>> map) throws SQLException {59return getArray();60}6162@Override63public Object getArray(long index, int count) throws SQLException {64return getArray();65}6667@Override68public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {69return getArray();70}7172@Override73public ResultSet getResultSet() throws SQLException {74throw new UnsupportedOperationException("Not supported yet.");75}7677@Override78public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {79throw new UnsupportedOperationException("Not supported yet.");80}8182@Override83public ResultSet getResultSet(long index, int count) throws SQLException {84throw new UnsupportedOperationException("Not supported yet.");85}8687@Override88public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {89throw new UnsupportedOperationException("Not supported yet.");90}9192@Override93public void free() throws SQLException {94elements = null;95typeName = null;96}9798}99100101