1. /*
  2. * @(#)Clob.java 1.11 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.sql;
  8. /**
  9. * JDBC 2.0
  10. * The mapping in the Java<sup><font size=-2>TM</font></sup> programming language
  11. * for the SQL <code>CLOB</code> type.
  12. * An SQL <code>CLOB</code> is a built-in type
  13. * that stores a Character Large Object as a column value in a row of
  14. * a database table.
  15. * The driver implements a <code>Clob</code> object using an SQL
  16. * <code>locator(CLOB)</code>, which means that a <code>Clob</code> object
  17. * contains a logical pointer to the SQL <code>CLOB</code> data rather than
  18. * the data itself. A <code>Clob</code> object is valid for the duration
  19. * of the transaction in which it was created.
  20. * <P>The <code>Clob</code> interface provides methods for getting the
  21. * length of an SQL <code>CLOB</code> (Character Large Object) value,
  22. * for materializing a <code>CLOB</code> value on the client, and for
  23. * searching for a substring or <code>CLOB</code> object within a
  24. * <code>CLOB</code> value.
  25. * Methods in the interfaces {@link ResultSet},
  26. * {@link CallableStatement}, and {@link PreparedStatement}, such as
  27. * <code>getClob</code> and <code>setClob</code> allow a programmer to
  28. * access the SQL <code>CLOB</code>.
  29. */
  30. public interface Clob {
  31. /**
  32. * Returns the number of characters
  33. * in the <code>CLOB</code> value
  34. * designated by this <code>Clob</code> object.
  35. * @return length of the <code>CLOB</code> in characters
  36. * @exception SQLException if there is an error accessing the
  37. * length of the <code>CLOB</code>
  38. */
  39. long length() throws SQLException;
  40. /**
  41. * Returns a copy of the specified substring
  42. * in the <code>CLOB</code> value
  43. * designated by this <code>Clob</code> object.
  44. * The substring begins at position
  45. * <code>pos</code> and has up to <code>length</code> consecutive
  46. * characters.
  47. * @param pos the first character of the substring to be extracted.
  48. * The first character is at position 1.
  49. * @param length the number of consecutive characters to be copied
  50. * @return a <code>String</code> that is the specified substring in
  51. * the <code>CLOB</code> value designated by this <code>Clob</code> object
  52. * @exception SQLException if there is an error accessing the
  53. * <code>CLOB</code>
  54. */
  55. String getSubString(long pos, int length) throws SQLException;
  56. /**
  57. * Gets the <code>Clob</code> contents as a Unicode stream.
  58. * @return a Unicode stream containing the <code>CLOB</code> data
  59. * @exception SQLException if there is an error accessing the
  60. * <code>CLOB</code>
  61. */
  62. java.io.Reader getCharacterStream() throws SQLException;
  63. /**
  64. * Gets the <code>CLOB</code> value designated by this <code>Clob</code>
  65. * object as a stream of Ascii bytes.
  66. * @return an ascii stream containing the <code>CLOB</code> data
  67. * @exception SQLException if there is an error accessing the
  68. * <code>CLOB</code> value
  69. */
  70. java.io.InputStream getAsciiStream() throws SQLException;
  71. /**
  72. * Determines the character position at which the specified substring
  73. * <code>searchstr</code> appears in the <code>CLOB</code>. The search
  74. * begins at position <code>start</code>.
  75. * @param searchstr the substring for which to search
  76. * @param start the position at which to begin searching; the first position
  77. * is 1
  78. * @return the position at which the substring appears, else -1; the first
  79. * position is 1
  80. * @exception SQLException if there is an error accessing the
  81. * <code>CLOB</code> value
  82. */
  83. long position(String searchstr, long start) throws SQLException;
  84. /**
  85. * Determines the character position at which the specified
  86. * <code>Clob</code> object <code>searchstr</code> appears in this
  87. * <code>Clob</code> object. The search begins at position
  88. * <code>start</code>.
  89. * @param searchstr the <code>Clob</code> object for which to search
  90. * @param start the position at which to begin searching; the first
  91. * position is 1
  92. * @return the position at which the <code>Clob</code> object appears,
  93. * else -1; the first position is 1
  94. * @exception SQLException if there is an error accessing the
  95. * <code>CLOB</code> value
  96. */
  97. long position(Clob searchstr, long start) throws SQLException;
  98. }