001    /* Array.java -- Interface for accessing SQL array object
002       Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    package java.sql;
039    
040    import java.util.Map;
041    
042    /**
043     * This interface provides methods for accessing SQL array types.
044     *
045     * @author Aaron M. Renn (arenn@urbanophile.com)
046     */
047    public interface Array
048    {
049      /**
050       * Returns the name of the SQL type of the elements in this
051       * array.  This name is database specific.
052       *
053       * @return The name of the SQL type of the elements in this array.
054       * @exception SQLException If an error occurs.
055       */
056      String getBaseTypeName() throws SQLException;
057    
058      /**
059       * Returns the JDBC type identifier of the elements in this
060       * array.  This will be one of the values defined in the
061       * <code>Types</code> class.
062       *
063       * @return The JDBC type of the elements in this array.
064       * @exception SQLException If an error occurs.
065       * @see Types
066       */
067      int getBaseType() throws SQLException;
068    
069      /**
070       * Returns the contents of this array.  This object returned
071       * will be an array of Java objects of the appropriate types.
072       *
073       * @return The contents of the array as an array of Java objects.
074       * @exception SQLException If an error occurs.
075       */
076      Object getArray() throws SQLException;
077    
078      /**
079       * Returns the contents of this array.  The specified
080       * <code>Map</code> will be used to override selected mappings
081       * between SQL types and Java classes.
082       *
083       * @param map A mapping of SQL types to Java classes.
084       * @return The contents of the array as an array of Java objects.
085       * @exception SQLException If an error occurs.
086       */
087      Object getArray(Map<String, Class<?>> map) throws SQLException;
088    
089      /**
090       * Returns a portion of this array starting at <code>start</code>
091       * into the array and continuing for <code>count</code>
092       * elements.  Fewer than the requested number of elements will be
093       * returned if the array does not contain the requested number of elements.
094       * The object returned will be an array of Java objects of
095       * the appropriate types.
096       *
097       * @param start The offset into this array to start returning elements from.
098       * @param count The requested number of elements to return.
099       * @return The requested portion of the array.
100       * @exception SQLException If an error occurs.
101       */
102      Object getArray(long start, int count) throws SQLException;
103    
104      /**
105       * This method returns a portion of this array starting at <code>start</code>
106       * into the array and continuing for <code>count</code>
107       * elements.  Fewer than the requested number of elements will be
108       * returned if the array does not contain the requested number of elements.
109       * The object returned will be an array of Java objects.  The specified
110       * <code>Map</code> will be used for overriding selected SQL type to
111       * Java class mappings.
112       *
113       * @param start The offset into this array to start returning elements from.
114       * @param count The requested number of elements to return.
115       * @param map A mapping of SQL types to Java classes.
116       * @return The requested portion of the array.
117       * @exception SQLException If an error occurs.
118       */
119      Object getArray(long start, int count, Map<String, Class<?>> map)
120        throws SQLException;
121    
122      /**
123       * Returns the elements in the array as a <code>ResultSet</code>.
124       * Each row of the result set will have two columns.  The first will be
125       * the index into the array of that row's contents.  The second will be
126       * the actual value of that array element.
127       *
128       * @return The elements of this array as a <code>ResultSet</code>.
129       * @exception SQLException If an error occurs.
130       * @see ResultSet
131       */
132      ResultSet getResultSet() throws SQLException;
133    
134      /**
135       * This method returns the elements in the array as a <code>ResultSet</code>.
136       * Each row of the result set will have two columns.  The first will be
137       * the index into the array of that row's contents.  The second will be
138       * the actual value of that array element.  The specified <code>Map</code>
139       * will be used to override selected default mappings of SQL types to
140       * Java classes.
141       *
142       * @param map A mapping of SQL types to Java classes.
143       * @return The elements of this array as a <code>ResultSet</code>.
144       * @exception SQLException If an error occurs.
145       * @see ResultSet
146       */
147      ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException;
148    
149      /**
150       * This method returns a portion of the array as a <code>ResultSet</code>.
151       * The returned portion will start at <code>start</code> into the
152       * array and up to <code>count</code> elements will be returned.
153       * <p>
154       * Each row of the result set will have two columns.  The first will be
155       * the index into the array of that row's contents.  The second will be
156       * the actual value of that array element.
157       *
158       * @param start The index into the array to start returning elements from.
159       * @param count The requested number of elements to return.
160       * @return The requested elements of this array as a <code>ResultSet</code>.
161       * @exception SQLException If an error occurs.
162       * @see ResultSet
163       */
164      ResultSet getResultSet(long start, int count) throws SQLException;
165    
166      /**
167       * This method returns a portion of the array as a <code>ResultSet</code>.
168       * The returned portion will start at <code>start</code> into the
169       * array and up to <code>count</code> elements will be returned.
170       *
171       * <p> Each row of the result set will have two columns.  The first will be
172       * the index into the array of that row's contents.  The second will be
173       * the actual value of that array element.  The specified <code>Map</code>
174       * will be used to override selected default mappings of SQL types to
175       * Java classes.</p>
176       *
177       * @param start The index into the array to start returning elements from.
178       * @param count The requested number of elements to return.
179       * @param map A mapping of SQL types to Java classes.
180       * @return The requested elements of this array as a <code>ResultSet</code>.
181       * @exception SQLException If an error occurs.
182       * @see ResultSet
183       */
184      ResultSet getResultSet(long start, int count, Map<String, Class<?>> map)
185        throws SQLException;
186    }