/luni/src/main/java/java/sql/SQLOutput.java

https://bitbucket.org/aways/android_libcore · Java · 334 lines · 34 code · 30 blank · 270 comment · 0 complexity · d5ad4d95b85c1f65a38be3ea8af99a77 MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package java.sql;
  18. import java.io.InputStream;
  19. import java.io.Reader;
  20. import java.math.BigDecimal;
  21. import java.net.URL;
  22. /**
  23. * The interface for an output stream used to write attributes of an SQL <i>User
  24. * Defined Type</i> (UDT) to the database. This interface is used for custom
  25. * mapping of types and is called by the JDBC driver. It is not intended to be
  26. * used by applications.
  27. * <p>
  28. * When an object which implements the {@code SQLData} interface is used as an
  29. * argument to an SQL statement, the JDBC driver calls the method {@code
  30. * SQLData.getSQLType} to establish the type of the SQL UDT that is being
  31. * passed. The driver then creates an {@code SQLOutput} stream and passes it to
  32. * the {@code SQLData.writeSQL} method, which in turn uses the appropriate
  33. * {@code SQLOutput} writer methods to write the data from the {@code SQLData}
  34. * object into the stream according to the defined mapping.
  35. *
  36. * @see SQLData
  37. */
  38. public interface SQLOutput {
  39. /**
  40. * Write a {@code String} value into the output stream.
  41. *
  42. * @param theString
  43. * the {@code String} to write.
  44. * @throws SQLException
  45. * if a database error occurs.
  46. */
  47. public void writeString(String theString) throws SQLException;
  48. /**
  49. * Write a {@code boolean} value into the output stream.
  50. *
  51. * @param theFlag
  52. * the {@code boolean} value to write.
  53. * @throws SQLException
  54. * if a database error occurs.
  55. */
  56. public void writeBoolean(boolean theFlag) throws SQLException;
  57. /**
  58. * Write a {@code byte} value into the output stream.
  59. *
  60. * @param theByte
  61. * the {@code byte} value to write.
  62. * @throws SQLException
  63. * if a database error occurs.
  64. */
  65. public void writeByte(byte theByte) throws SQLException;
  66. /**
  67. * Write a {@code short} value into the output stream.
  68. *
  69. * @param theShort
  70. * the {@code short} value to write.
  71. * @throws SQLException
  72. * if a database error occurs.
  73. */
  74. public void writeShort(short theShort) throws SQLException;
  75. /**
  76. * Write an {@code int} value into the output stream.
  77. *
  78. * @param theInt
  79. * the {@code int} value to write.
  80. * @throws SQLException
  81. * if a database error occurs.
  82. */
  83. public void writeInt(int theInt) throws SQLException;
  84. /**
  85. * Write a {@code long} value into the output stream.
  86. *
  87. * @param theLong
  88. * the {@code long} value to write.
  89. * @throws SQLException
  90. * if a database error occurs.
  91. */
  92. public void writeLong(long theLong) throws SQLException;
  93. /**
  94. * Write a {@code float} value into the output stream.
  95. *
  96. * @param theFloat
  97. * the {@code float} value to write.
  98. * @throws SQLException
  99. * if a database error occurs.
  100. */
  101. public void writeFloat(float theFloat) throws SQLException;
  102. /**
  103. * Write a {@code double} value into the output stream.
  104. *
  105. * @param theDouble
  106. * the {@code double} value to write.
  107. * @throws SQLException
  108. * if a database error occurs.
  109. */
  110. public void writeDouble(double theDouble) throws SQLException;
  111. /**
  112. * Write a {@code java.math.BigDecimal} value into the output stream.
  113. *
  114. * @param theBigDecimal
  115. * the {@code BigDecimal} value to write.
  116. * @throws SQLException
  117. * if a database error occurs.
  118. */
  119. public void writeBigDecimal(BigDecimal theBigDecimal) throws SQLException;
  120. /**
  121. * Write an array of bytes into the output stream.
  122. *
  123. * @param theBytes
  124. * the array of bytes to write.
  125. * @throws SQLException
  126. * if a database error occurs.
  127. */
  128. public void writeBytes(byte[] theBytes) throws SQLException;
  129. /**
  130. * Write a {@code java.sql.Date} value into the output stream.
  131. *
  132. * @param theDate
  133. * the {@code Date} value to write.
  134. * @throws SQLException
  135. * if a database error occurs.
  136. * @see Date
  137. */
  138. public void writeDate(Date theDate) throws SQLException;
  139. /**
  140. * Write a {@code java.sql.Time} value into the output stream.
  141. *
  142. * @param theTime
  143. * the {@code Time} value to write.
  144. * @throws SQLException
  145. * if a database error occurs.
  146. * @see Time
  147. */
  148. public void writeTime(Time theTime) throws SQLException;
  149. /**
  150. * Write a {@code java.sql.Timestamp} value into the output stream.
  151. *
  152. * @param theTimestamp
  153. * the {@code Timestamp} value to write.
  154. * @throws SQLException
  155. * if a database error occurs.
  156. * @see Timestamp
  157. */
  158. public void writeTimestamp(Timestamp theTimestamp) throws SQLException;
  159. /**
  160. * Write a stream of unicode characters into the output stream.
  161. *
  162. * @param theStream
  163. * the stream of unicode characters to write, as a {@code
  164. * java.io.Reader} object.
  165. * @throws SQLException
  166. * if a database error occurs.
  167. */
  168. public void writeCharacterStream(Reader theStream) throws SQLException;
  169. /**
  170. * Write a stream of ASCII characters into the output stream.
  171. *
  172. * @param theStream
  173. * the stream of ASCII characters to write, as a {@code
  174. * java.io.InputStream} object
  175. * @throws SQLException
  176. * if a database error occurs.
  177. */
  178. public void writeAsciiStream(InputStream theStream) throws SQLException;
  179. /**
  180. * Write a stream of uninterpreted bytes into the output stream.
  181. *
  182. * @param theStream
  183. * the stream of bytes to write, as a {@code java.io.InputStream}
  184. * object
  185. * @throws SQLException
  186. * if a database error occurs.
  187. */
  188. public void writeBinaryStream(InputStream theStream) throws SQLException;
  189. /**
  190. * Write an {@code SQLData} object into the output stream.
  191. * <p>
  192. * If the {@code SQLData} object is null, writes {@code NULL} to the stream.
  193. * <p>
  194. * Otherwise, calls the {@code SQLData.writeSQL} method of the object, which
  195. * writes the object's attributes to the stream by calling the appropriate
  196. * SQLOutput writer methods for each attribute, in order. The order of the
  197. * attributes is the order they are listed in the SQL definition of the User
  198. * Defined Type.
  199. *
  200. * @param theObject
  201. * the {@code SQLData} object to write.
  202. * @throws SQLException
  203. * if a database error occurs.
  204. * @see SQLData
  205. */
  206. public void writeObject(SQLData theObject) throws SQLException;
  207. /**
  208. * Write an SQL {@code Ref} value into the output stream.
  209. *
  210. * @param theRef
  211. * the {@code java.sql.Ref} object to write.
  212. * @throws SQLException
  213. * if a database error occurs.
  214. * @see Ref
  215. */
  216. public void writeRef(Ref theRef) throws SQLException;
  217. /**
  218. * Write an SQL {@code Blob} value into the output stream.
  219. *
  220. * @param theBlob
  221. * the {@code java.sql.Blob} object to write.
  222. * @throws SQLException
  223. * if a database error occurs.
  224. * @see Blob
  225. */
  226. public void writeBlob(Blob theBlob) throws SQLException;
  227. /**
  228. * Write an SQL {@code Clob} value into the output stream.
  229. *
  230. * @param theClob
  231. * the {@code java.sql.Clob} object to write.
  232. * @throws SQLException
  233. * if a database error occurs.
  234. * @see Clob
  235. */
  236. public void writeClob(Clob theClob) throws SQLException;
  237. /**
  238. * Write an SQL {@code Struct} value into the output stream.
  239. *
  240. * @param theStruct
  241. * the {@code java.sql.Struct} object to write.
  242. * @throws SQLException
  243. * if a database error occurs.
  244. * @see Struct
  245. */
  246. public void writeStruct(Struct theStruct) throws SQLException;
  247. /**
  248. * Write an SQL {@code Array} value into the output stream.
  249. *
  250. * @param theArray
  251. * the {@code java.sql.Array} object to write.
  252. * @throws SQLException
  253. * if a database error occurs.
  254. * @see Array
  255. */
  256. public void writeArray(Array theArray) throws SQLException;
  257. /**
  258. * Write a {@code URL} into the output stream as an SQL DATALINK.
  259. *
  260. * @param theURL
  261. * the datalink value as a {@code java.net.URL} to write.
  262. * @throws SQLException
  263. * if a database error occurs.
  264. * @see java.net.URL
  265. */
  266. public void writeURL(URL theURL) throws SQLException;
  267. /**
  268. * Write a {@code String} into the output stream as an SQL NCHAR, NVARCHAR,
  269. * or LONGNVARCHAR.
  270. *
  271. * @param theString
  272. * the {@code String} to write.
  273. * @throws SQLException
  274. * if a database error occurs.
  275. */
  276. public void writeNString(String theString) throws SQLException;
  277. /**
  278. * Write a {@code Clob} into the output stream as an SQL NCLOB.
  279. *
  280. * @param theNClob
  281. * the {@code java.sql.Clob} object to write.
  282. * @throws SQLException
  283. * if a database error occurs.
  284. */
  285. public void writeNClob(NClob theNClob) throws SQLException;
  286. /**
  287. * Write a {@code RowId} into the output stream as an SQL ROWID.
  288. *
  289. * @param theRowId
  290. * the {@code java.sql.RowId} object to write.
  291. * @throws SQLException
  292. * if a database error occurs.
  293. */
  294. public void writeRowId(RowId theRowId) throws SQLException;
  295. /**
  296. * Write a {@code SQLXML} into the output stream as an SQL XML.
  297. *
  298. * @param theXml
  299. * the {@code java.sql.SQLXML} object to write.
  300. * @throws SQLException
  301. * if a database error occurs.
  302. */
  303. public void writeSQLXML(SQLXML theXml) throws SQLException;
  304. }