Array.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* Array.java -- Interface for accessing SQL array object
  2. Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.sql;
  32. import java.util.Map;
  33. /**
  34. * This interface provides methods for accessing SQL array types.
  35. *
  36. * @author Aaron M. Renn (arenn@urbanophile.com)
  37. */
  38. public interface Array
  39. {
  40. /**
  41. * Returns the name of the SQL type of the elements in this
  42. * array. This name is database specific.
  43. *
  44. * @return The name of the SQL type of the elements in this array.
  45. * @exception SQLException If an error occurs.
  46. */
  47. String getBaseTypeName() throws SQLException;
  48. /**
  49. * Returns the JDBC type identifier of the elements in this
  50. * array. This will be one of the values defined in the
  51. * <code>Types</code> class.
  52. *
  53. * @return The JDBC type of the elements in this array.
  54. * @exception SQLException If an error occurs.
  55. * @see Types
  56. */
  57. int getBaseType() throws SQLException;
  58. /**
  59. * Returns the contents of this array. This object returned
  60. * will be an array of Java objects of the appropriate types.
  61. *
  62. * @return The contents of the array as an array of Java objects.
  63. * @exception SQLException If an error occurs.
  64. */
  65. Object getArray() throws SQLException;
  66. /**
  67. * Returns the contents of this array. The specified
  68. * <code>Map</code> will be used to override selected mappings
  69. * between SQL types and Java classes.
  70. *
  71. * @param map A mapping of SQL types to Java classes.
  72. * @return The contents of the array as an array of Java objects.
  73. * @exception SQLException If an error occurs.
  74. */
  75. Object getArray(Map<String, Class<?>> map) throws SQLException;
  76. /**
  77. * Returns a portion of this array starting at <code>start</code>
  78. * into the array and continuing for <code>count</code>
  79. * elements. Fewer than the requested number of elements will be
  80. * returned if the array does not contain the requested number of elements.
  81. * The object returned will be an array of Java objects of
  82. * the appropriate types.
  83. *
  84. * @param start The offset into this array to start returning elements from.
  85. * @param count The requested number of elements to return.
  86. * @return The requested portion of the array.
  87. * @exception SQLException If an error occurs.
  88. */
  89. Object getArray(long start, int count) throws SQLException;
  90. /**
  91. * This method returns a portion of this array starting at <code>start</code>
  92. * into the array and continuing for <code>count</code>
  93. * elements. Fewer than the requested number of elements will be
  94. * returned if the array does not contain the requested number of elements.
  95. * The object returned will be an array of Java objects. The specified
  96. * <code>Map</code> will be used for overriding selected SQL type to
  97. * Java class mappings.
  98. *
  99. * @param start The offset into this array to start returning elements from.
  100. * @param count The requested number of elements to return.
  101. * @param map A mapping of SQL types to Java classes.
  102. * @return The requested portion of the array.
  103. * @exception SQLException If an error occurs.
  104. */
  105. Object getArray(long start, int count, Map<String, Class<?>> map)
  106. throws SQLException;
  107. /**
  108. * Returns the elements in the array as a <code>ResultSet</code>.
  109. * Each row of the result set will have two columns. The first will be
  110. * the index into the array of that row's contents. The second will be
  111. * the actual value of that array element.
  112. *
  113. * @return The elements of this array as a <code>ResultSet</code>.
  114. * @exception SQLException If an error occurs.
  115. * @see ResultSet
  116. */
  117. ResultSet getResultSet() throws SQLException;
  118. /**
  119. * This method returns the elements in the array as a <code>ResultSet</code>.
  120. * Each row of the result set will have two columns. The first will be
  121. * the index into the array of that row's contents. The second will be
  122. * the actual value of that array element. The specified <code>Map</code>
  123. * will be used to override selected default mappings of SQL types to
  124. * Java classes.
  125. *
  126. * @param map A mapping of SQL types to Java classes.
  127. * @return The elements of this array as a <code>ResultSet</code>.
  128. * @exception SQLException If an error occurs.
  129. * @see ResultSet
  130. */
  131. ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException;
  132. /**
  133. * This method returns a portion of the array as a <code>ResultSet</code>.
  134. * The returned portion will start at <code>start</code> into the
  135. * array and up to <code>count</code> elements will be returned.
  136. * <p>
  137. * Each row of the result set will have two columns. The first will be
  138. * the index into the array of that row's contents. The second will be
  139. * the actual value of that array element.
  140. *
  141. * @param start The index into the array to start returning elements from.
  142. * @param count The requested number of elements to return.
  143. * @return The requested elements of this array as a <code>ResultSet</code>.
  144. * @exception SQLException If an error occurs.
  145. * @see ResultSet
  146. */
  147. ResultSet getResultSet(long start, int count) throws SQLException;
  148. /**
  149. * This method returns a portion of the array as a <code>ResultSet</code>.
  150. * The returned portion will start at <code>start</code> into the
  151. * array and up to <code>count</code> elements will be returned.
  152. *
  153. * <p> Each row of the result set will have two columns. The first will be
  154. * the index into the array of that row's contents. The second will be
  155. * the actual value of that array element. The specified <code>Map</code>
  156. * will be used to override selected default mappings of SQL types to
  157. * Java classes.</p>
  158. *
  159. * @param start The index into the array to start returning elements from.
  160. * @param count The requested number of elements to return.
  161. * @param map A mapping of SQL types to Java classes.
  162. * @return The requested elements of this array as a <code>ResultSet</code>.
  163. * @exception SQLException If an error occurs.
  164. * @see ResultSet
  165. */
  166. ResultSet getResultSet(long start, int count, Map<String, Class<?>> map)
  167. throws SQLException;
  168. }