Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/package-info.java
40948 views
1
/*
2
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
/**
27
* Provides utility classes to allow serializable mappings between SQL types
28
* and data types in the Java programming language.
29
* <p> Standard JDBC {@code RowSet} implementations may use these utility
30
* classes to
31
* assist in the serialization of disconnected {@code RowSet} objects.
32
* This is useful
33
* when transmitting a disconnected {@code RowSet} object over the wire to
34
* a different VM or across layers within an application.<br>
35
* </p>
36
*
37
* <h2>1.0 SerialArray</h2>
38
* A serializable mapping in the Java programming language of an SQL ARRAY
39
* value. <br>
40
* <br>
41
* The {@code SerialArray} class provides a constructor for creating a {@code SerialArray}
42
* instance from an Array object, methods for getting the base type and
43
* the SQL name for the base type, and methods for copying all or part of a
44
* {@code SerialArray} object. <br>
45
*
46
* <h2>2.0 SerialBlob</h2>
47
* A serializable mapping in the Java programming language of an SQL BLOB
48
* value. <br>
49
* <br>
50
* The {@code SerialBlob} class provides a constructor for creating an instance
51
* from a Blob object. Note that the Blob object should have brought the SQL
52
* BLOB value's data over to the client before a {@code SerialBlob} object
53
* is constructed from it. The data of an SQL BLOB value can be materialized
54
* on the client as an array of bytes (using the method {@code Blob.getBytes})
55
* or as a stream of uninterpreted bytes (using the method {@code Blob.getBinaryStream}).
56
* <br>
57
* <br>
58
* {@code SerialBlob} methods make it possible to make a copy of a {@code SerialBlob}
59
* object as an array of bytes or as a stream. They also make it possible
60
* to locate a given pattern of bytes or a {@code Blob} object within a {@code SerialBlob}
61
* object. <br>
62
*
63
* <h2>3.0 SerialClob</h2>
64
* A serializable mapping in the Java programming language of an SQL CLOB
65
* value. <br>
66
* <br>
67
* The {@code SerialClob} class provides a constructor for creating an instance
68
* from a {@code Clob} object. Note that the {@code Clob} object should have
69
* brought the SQL CLOB value's data over to the client before a {@code SerialClob}
70
* object is constructed from it. The data of an SQL CLOB value can be
71
* materialized on the client as a stream of Unicode characters. <br>
72
* <br>
73
* {@code SerialClob} methods make it possible to get a substring from a
74
* {@code SerialClob} object or to locate the start of a pattern of characters.
75
* <br>
76
*
77
* <h2>5.0 SerialDatalink</h2>
78
* A serializable mapping in the Java programming language of an SQL DATALINK
79
* value. A DATALINK value references a file outside of the underlying data source
80
* that the originating data source manages. <br>
81
* <br>
82
* {@code RowSet} implementations can use the method {@code RowSet.getURL()} to retrieve
83
* a {@code java.net.URL} object, which can be used to manipulate the external data.
84
* <br>
85
* <PRE>
86
* java.net.URL url = rowset.getURL(1);
87
* </PRE>
88
*
89
* <h2>6.0 SerialJavaObject</h2>
90
* A serializable mapping in the Java programming language of an SQL JAVA_OBJECT
91
* value. Assuming the Java object instance implements the Serializable interface,
92
* this simply wraps the serialization process. <br>
93
* <br>
94
* If however, the serialization is not possible in the case where the Java
95
* object is not immediately serializable, this class will attempt to serialize
96
* all non static members to permit the object instance state to be serialized.
97
* Static or transient fields cannot be serialized and attempting to do so
98
* will result in a {@code SerialException} being thrown. <br>
99
*
100
* <h2>7.0 SerialRef</h2>
101
* A serializable mapping between the SQL REF type and the Java programming
102
* language. <br>
103
* <br>
104
* The {@code SerialRef} class provides a constructor for creating a {@code SerialRef}
105
* instance from a {@code Ref} type and provides methods for getting
106
* and setting the {@code Ref} object type. <br>
107
*
108
* <h2>8.0 SerialStruct</h2>
109
* A serializable mapping in the Java programming language of an SQL structured
110
* type. Each attribute that is not already serializable is mapped to a serializable
111
* form, and if an attribute is itself a structured type, each of its attributes
112
* that is not already serializable is mapped to a serializable form. <br>
113
* <br>
114
* In addition, if a {@code Map} object is passed to one of the constructors or
115
* to the method {@code getAttributes}, the structured type is custom mapped
116
* according to the mapping specified in the {@code Map} object.
117
* <br>
118
* The {@code SerialStruct} class provides a constructor for creating an
119
* instance from a {@code Struct} object, a method for retrieving the SQL
120
* type name of the SQL structured type in the database, and methods for retrieving
121
* its attribute values. <br>
122
*
123
* <h2>9.0 SQLInputImpl</h2>
124
* An input stream used for custom mapping user-defined types (UDTs). An
125
* {@code SQLInputImpl} object is an input stream that contains a stream of
126
* values that are
127
* the attributes of a UDT. This class is used by the driver behind the scenes
128
* when the method {@code getObject} is called on an SQL structured or distinct
129
* type that has a custom mapping; a programmer never invokes {@code SQLInputImpl}
130
* methods directly. <br>
131
* <br>
132
* The {@code SQLInputImpl} class provides a set of reader methods
133
* analogous to the {@code ResultSet} getter methods. These methods make it
134
* possible to read the values in an {@code SQLInputImpl} object. The method
135
* {@code wasNull} is used to determine whether the last value read was SQL NULL.
136
* <br>
137
* <br>
138
* When a constructor or getter method that takes a {@code Map} object is called,
139
* the JDBC driver calls the method
140
* {@code SQLData.getSQLType} to determine the SQL type of the UDT being custom
141
* mapped. The driver creates an instance of {@code SQLInputImpl}, populating it with
142
* the attributes of the UDT. The driver then passes the input stream to the
143
* method {@code SQLData.readSQL}, which in turn calls the {@code SQLInputImpl}
144
* methods to read the attributes from the input stream. <br>
145
*
146
* <h2>10.0 SQLOutputImpl</h2>
147
* The output stream for writing the attributes of a custom mapped user-defined
148
* type (UDT) back to the database. The driver uses this interface internally,
149
* and its methods are never directly invoked by an application programmer.
150
* <br>
151
* <br>
152
* When an application calls the method {@code PreparedStatement.setObject}, the
153
* driver checks to see whether the value to be written is a UDT with a custom
154
* mapping. If it is, there will be an entry in a type map containing the Class
155
* object for the class that implements {@code SQLData} for this UDT. If the
156
* value to be written is an instance of {@code SQLData}, the driver will
157
* create an instance of {@code SQLOutputImpl} and pass it to the method
158
* {@code SQLData.writeSQL}.
159
* The method {@code writeSQL} in turn calls the appropriate {@code SQLOutputImpl}
160
* writer methods to write data from the {@code SQLData} object to the
161
* {@code SQLOutputImpl}
162
* output stream as the representation of an SQL user-defined type.
163
*
164
* <h2>Custom Mapping</h2>
165
* The JDBC API provides mechanisms for mapping an SQL structured type or DISTINCT
166
* type to the Java programming language. Typically, a structured type is mapped
167
* to a class, and its attributes are mapped to fields in the class.
168
* (A DISTINCT type can thought of as having one attribute.) However, there are
169
* many other possibilities, and there may be any number of different mappings.
170
* <P>
171
* A programmer defines the mapping by implementing the interface {@code SQLData}.
172
* For example, if an SQL structured type named AUTHORS has the attributes NAME,
173
* TITLE, and PUBLISHER, it could be mapped to a Java class named Authors. The
174
* Authors class could have the fields name, title, and publisher, to which the
175
* attributes of AUTHORS are mapped. In such a case, the implementation of
176
* {@code SQLData} could look like the following:
177
* <PRE>
178
* public class Authors implements SQLData {
179
* public String name;
180
* public String title;
181
* public String publisher;
182
*
183
* private String sql_type;
184
* public String getSQLTypeName() {
185
* return sql_type;
186
* }
187
*
188
* public void readSQL(SQLInput stream, String type)
189
* throws SQLException {
190
* sql_type = type;
191
* name = stream.readString();
192
* title = stream.readString();
193
* publisher = stream.readString();
194
* }
195
*
196
* public void writeSQL(SQLOutput stream) throws SQLException {
197
* stream.writeString(name);
198
* stream.writeString(title);
199
* stream.writeString(publisher);
200
* }
201
* }
202
* </PRE>
203
*
204
* A {@code java.util.Map} object is used to associate the SQL structured
205
* type with its mapping to the class {@code Authors}. The following code fragment shows
206
* how a {@code Map} object might be created and given an entry associating
207
* {@code AUTHORS} and {@code Authors}.
208
* <PRE>
209
* java.util.Map map = new java.util.HashMap();
210
* map.put("SCHEMA_NAME.AUTHORS", Class.forName("Authors");
211
* </PRE>
212
*
213
* The {@code Map} object <i>map</i> now contains an entry with the
214
* fully qualified name of the SQL structured type and the {@code Class}
215
* object for the class {@code Authors}. It can be passed to a method
216
* to tell the driver how to map {@code AUTHORS} to {@code Authors}.
217
* <P>
218
* For a disconnected {@code RowSet} object, custom mapping can be done
219
* only when a {@code Map} object is passed to the method or constructor
220
* that will be doing the custom mapping. The situation is different for
221
* connected {@code RowSet} objects because they maintain a connection
222
* with the data source. A method that does custom mapping and is called by
223
* a disconnected {@code RowSet} object may use the {@code Map}
224
* object that is associated with the {@code Connection} object being
225
* used. So, in other words, if no map is specified, the connection's type
226
* map can be used by default.
227
*/
228
package javax.sql.rowset.serial;
229
230