1. /*
  2. * @(#)SerialDatalink.java 1.5 04/05/29
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sql.rowset.serial;
  8. import java.sql.*;
  9. import java.io.*;
  10. import java.net.URL;
  11. /**
  12. * A serialized mapping in the Java programming language of an SQL
  13. * <code>DATALINK</code> value. A <code>DATALINK</code> value
  14. * references a file outside of the underlying data source that the
  15. * data source manages.
  16. * <P>
  17. * <code>RowSet</code> implementations can use the method <code>RowSet.getURL</code>
  18. * to retrieve a <code>java.net.URL</code> object, which can be used
  19. * to manipulate the external data.
  20. * <pre>
  21. * java.net.URL url = rowset.getURL(1);
  22. * </pre>
  23. */
  24. public class SerialDatalink implements Serializable, Cloneable {
  25. /**
  26. * The extracted URL field retrieved from the DATALINK field.
  27. * @serial
  28. */
  29. private URL url;
  30. /**
  31. * The SQL type of the elements in this <code>SerialDatalink</code>
  32. * object. The type is expressed as one of the contants from the
  33. * class <code>java.sql.Types</code>.
  34. * @serial
  35. */
  36. private int baseType;
  37. /**
  38. * The type name used by the DBMS for the elements in the SQL
  39. * <code>DATALINK</code> value that this SerialDatalink object
  40. * represents.
  41. * @serial
  42. */
  43. private String baseTypeName;
  44. /**
  45. * Constructs a new <code>SerialDatalink</code> object from the given
  46. * <code>java.net.URL</code> object.
  47. * <P>
  48. * @throws SerialException if url parameter is a null
  49. */
  50. public SerialDatalink(URL url) throws SerialException {
  51. if (url == null) {
  52. throw new SerialException("Cannot serialize empty URL instance");
  53. }
  54. this.url = url;
  55. }
  56. /**
  57. * Returns a new URL that is a copy of this <code>SerialDatalink</code>
  58. * object.
  59. *
  60. * @return a copy of this <code>SerialDatalink</code> object as a
  61. * <code>URL</code> object in the Java programming language.
  62. * @throws SerialException if the <code>URL</code> object cannot be de-serialized
  63. */
  64. public URL getDatalink() throws SerialException {
  65. URL aURL = null;
  66. try {
  67. aURL = new URL((this.url).toString());
  68. } catch (java.net.MalformedURLException e) {
  69. throw new SerialException("MalformedURLException: " + e.getMessage());
  70. }
  71. return aURL;
  72. }
  73. /**
  74. * The identifier that assists in the serialization of this <code>SerialDatalink</code>
  75. * object.
  76. */
  77. static final long serialVersionUID = 2826907821828733626L;
  78. }