1. /*
  2. * @(#)SQLData.java 1.10 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 interface used for the custom mapping of SQL user-defined types.
  11. * This interface must be implemented by a Java class that is
  12. * registered in a type mapping. It is expected that this interface
  13. * will normally be implemented by a tool. The methods in this interface
  14. * are called by the driver and are never called by a programmer
  15. * directly.
  16. */
  17. public interface SQLData {
  18. /**
  19. * Returns the fully-qualified
  20. * name of the SQL user-defined type that this object represents.
  21. * This method is called by the JDBC driver to get the name of the
  22. * UDT instance that is being mapped to this instance of SQLData.
  23. *
  24. * @returns the type name that was passed to the method <code>readSql</code>
  25. * when this object was constructed and populated
  26. */
  27. String getSQLTypeName() throws SQLException;
  28. /**
  29. * Populates this object with data read from the database.
  30. * The implementation of the method must follow this protocol:
  31. *
  32. * It must read each of the attributes or elements of the SQL
  33. * type from the given input stream. This is done
  34. * by calling a method of the input stream to read each
  35. * item, in the order that they appear in the SQL definition
  36. * of the type. The method <code>readSQL</code> then
  37. * assigns the data to appropriate fields or
  38. * elements (of this or other objects).
  39. * Specifically, it must call the appropriate <code>SQLInput.readXXX</code>
  40. * method(s) to do the following:
  41. * for a Distinct Type, read its single data element;
  42. * for a Structured Type, read a value for each attribute of the SQL type.
  43. *
  44. * The JDBC driver initializes the input stream with a type map
  45. * before calling this method, which is used by the appropriate
  46. * <code>SQLInput.readXXX</code> method on the stream.
  47. *
  48. * @param stream the input SQL data stream
  49. * @param descriptor the SQL type of the value on the data stream
  50. * @see SQLInput
  51. */
  52. void readSQL (SQLInput stream, String typeName) throws SQLException;
  53. /**
  54. * Writes this object to the given SQL data stream.
  55. * The implementation of the method must follow this protocol:
  56. *
  57. * It must write each of the attributes of the SQL type
  58. * to the given output stream. This is done by calling a
  59. * method of the output stream to write each item, in the order that
  60. * they appear in the SQL definition of the type.
  61. * Specifically, it must call the appropriate <code>SQLOutput.writeXXX</code>
  62. * method(s) to do the following:
  63. * for a Distinct Type, write its single data element;
  64. * for a Structured Type, write a value for each attribute of the SQL type.
  65. *
  66. * @param stream the output SQL data stream
  67. * @see SQLOutput
  68. */
  69. void writeSQL (SQLOutput stream) throws SQLException;
  70. }