KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sql > rowset > serial > SerialDatalink


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
8 package javax.sql.rowset.serial;
9
10 import java.sql.*;
11 import java.io.*;
12 import java.net.URL JavaDoc;
13
14
15 /**
16  * A serialized mapping in the Java programming language of an SQL
17  * <code>DATALINK</code> value. A <code>DATALINK</code> value
18  * references a file outside of the underlying data source that the
19  * data source manages.
20  * <P>
21  * <code>RowSet</code> implementations can use the method <code>RowSet.getURL</code>
22  * to retrieve a <code>java.net.URL</code> object, which can be used
23  * to manipulate the external data.
24  * <pre>
25  * java.net.URL url = rowset.getURL(1);
26  * </pre>
27  */

28 public class SerialDatalink implements Serializable, Cloneable JavaDoc {
29
30     /**
31      * The extracted URL field retrieved from the DATALINK field.
32      * @serial
33      */

34     private URL JavaDoc url;
35
36     /**
37      * The SQL type of the elements in this <code>SerialDatalink</code>
38      * object. The type is expressed as one of the contants from the
39      * class <code>java.sql.Types</code>.
40      * @serial
41      */

42     private int baseType;
43
44     /**
45      * The type name used by the DBMS for the elements in the SQL
46      * <code>DATALINK</code> value that this SerialDatalink object
47      * represents.
48      * @serial
49      */

50     private String JavaDoc baseTypeName;
51
52     /**
53       * Constructs a new <code>SerialDatalink</code> object from the given
54       * <code>java.net.URL</code> object.
55       * <P>
56       * @throws SerialException if url parameter is a null
57       */

58     public SerialDatalink(URL JavaDoc url) throws SerialException JavaDoc {
59     if (url == null) {
60         throw new SerialException JavaDoc("Cannot serialize empty URL instance");
61     }
62     this.url = url;
63     }
64
65     /**
66      * Returns a new URL that is a copy of this <code>SerialDatalink</code>
67      * object.
68      *
69      * @return a copy of this <code>SerialDatalink</code> object as a
70      * <code>URL</code> object in the Java programming language.
71      * @throws SerialException if the <code>URL</code> object cannot be de-serialized
72      */

73     public URL JavaDoc getDatalink() throws SerialException JavaDoc {
74
75     URL JavaDoc aURL = null;
76
77     try {
78         aURL = new URL JavaDoc((this.url).toString());
79     } catch (java.net.MalformedURLException JavaDoc e) {
80         throw new SerialException JavaDoc("MalformedURLException: " + e.getMessage());
81     }
82     return aURL;
83     }
84     
85
86     /**
87      * The identifier that assists in the serialization of this <code>SerialDatalink</code>
88      * object.
89      */

90     static final long serialVersionUID = 2826907821828733626L;
91 }
92
Popular Tags