/projects/derby-10.9.1.0/db-derby-10.9.1.0-src/java/stubs/jsr169/java/sql/Blob.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 160 lines · 15 code · 12 blank · 133 comment · 0 complexity · eda03094fe30807d14d12ac067b0aeb1 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.OutputStream;
  19. import java.io.InputStream;
  20. /**
  21. * A Java interface mapping for the SQL BLOB type.
  22. * <p>
  23. * An SQL CLOB type stores a large array of bytes (binary data) as the value in
  24. * a column of a database.
  25. * <p>
  26. * The java.sql.Blob interface provides methods for setting and retrieving data
  27. * in the Blob, for querying Clob data length, for searching for data within the
  28. * Blob.
  29. */
  30. public interface Blob {
  31. /**
  32. * Retrieves this Blob object as a binary stream.
  33. *
  34. * @return a binary InputStream giving access to the Blob data
  35. * @throws SQLException
  36. * if an error occurs accessing the Blob
  37. */
  38. public InputStream getBinaryStream() throws SQLException;
  39. /**
  40. * Gets a portion of the value of this Blob as an array of bytes.
  41. *
  42. * @param pos
  43. * the position of the first byte in the Blob to get, where the
  44. * first byte in the Blob has position = 1
  45. * @param length
  46. * the number of bytes to get
  47. * @return a byte array containing the data from the Blob, starting at pos
  48. * and of length up to <code>length</code> bytes long
  49. * @throws SQLException
  50. * if an error occurs accessing the Blob
  51. */
  52. public byte[] getBytes(long pos, int length) throws SQLException;
  53. /**
  54. * Gets the number of bytes in this Blob object.
  55. *
  56. * @return an long value with the length of the Blob in bytes
  57. * @throws SQLException
  58. * if an error occurs accessing the Blob
  59. */
  60. public long length() throws SQLException;
  61. /**
  62. * Search for the position in this Blob at which a specified pattern begins,
  63. * starting at a specified position within the Blob.
  64. *
  65. * @param pattern
  66. * a Blob containing the pattern of data to search for in this
  67. * Blob
  68. * @param start
  69. * the position within this Blob to start the search, where the
  70. * first position in the Blob is 1
  71. * @return a long value with the position at which the pattern begins. -1 if
  72. * the pattern is not found in this Blob.
  73. * @throws SQLException
  74. * if an error occurs accessing the Blob
  75. */
  76. public long position(Blob pattern, long start) throws SQLException;
  77. /**
  78. * Search for the position in this Blob at which the specified pattern
  79. * begins, starting at a specified position within the Blob.
  80. *
  81. * @param pattern
  82. * a byte array containing the pattern of data to search for in
  83. * this Blob
  84. * @param start
  85. * the position within this Blob to start the search, where the
  86. * first position in the Blob is 1
  87. * @return a long value with the position at which the pattern begins. -1 if
  88. * the pattern is not found in this Blob.
  89. * @throws SQLException
  90. * if an error occurs accessing the Blob
  91. */
  92. public long position(byte[] pattern, long start) throws SQLException;
  93. /**
  94. * Gets a stream that can be used to write binary data to this Blob.
  95. *
  96. * @param pos
  97. * the position within this Blob at which to start writing, where
  98. * the first position in the Blob is 1
  99. * @return a binary InputStream which can be used to write data into the
  100. * Blob starting at the specified position.
  101. * @throws SQLException
  102. * if an error occurs accessing the Blob
  103. */
  104. public OutputStream setBinaryStream(long pos) throws SQLException;
  105. /**
  106. * Writes a specified array of bytes to this Blob. object, starting at a
  107. * specified position. Returns the number of bytes written.
  108. *
  109. * @param pos
  110. * the position within this Blob at which to start writing, where
  111. * the first position in the Blob is 1
  112. * @param theBytes
  113. * an array of bytes to write into the Blob
  114. * @return an integer containing the number of bytes written to the Blob
  115. * @throws SQLException
  116. * if an error occurs accessing the Blob
  117. */
  118. public int setBytes(long pos, byte[] theBytes) throws SQLException;
  119. /**
  120. * Writes a portion of a specified byte array to this Blob. Returns the
  121. * number of bytes written.
  122. *
  123. * @param pos
  124. * the position within this Blob at which to start writing, where
  125. * the first position in the Blob is 1
  126. * @param theBytes
  127. * an array of bytes to write into the Blob
  128. * @param offset
  129. * the offset into the byte array from which to start writing
  130. * data - the first byte in the array has offset 0.
  131. * @param len
  132. * the length of data to write, as the number of bytes
  133. * @return an integer containing the number of bytes written to the Blob
  134. * @throws SQLException
  135. * if an error occurs accessing the Blob
  136. */
  137. public int setBytes(long pos, byte[] theBytes, int offset, int len)
  138. throws SQLException;
  139. /**
  140. * Truncate the value of this Blob object to a specified length in bytes.
  141. *
  142. * @param len
  143. * the length of data in bytes to truncate the value of this Blob
  144. * @throws SQLException
  145. * if an error occurs accessing the Blob
  146. */
  147. public void truncate(long len) throws SQLException;
  148. }