java.lang.Object
javax.sql.rowset.serial.SerialStruct
- All Implemented Interfaces:
Serializable
,Cloneable
,Struct
public class SerialStruct extends Object implements Struct, Serializable, Cloneable
A serialized mapping in the Java programming language of an SQL
structured type. Each attribute that is not already serialized
is mapped to a serialized form, and if an attribute is itself
a structured type, each of its attributes that is not already
serialized is mapped to a serialized form.
In addition, the structured type is custom mapped to a class in the Java programming language if there is such a mapping, as are its attributes, if appropriate.
The SerialStruct
class provides a constructor for creating
an instance from a Struct
object, a method for retrieving
the SQL type name of the SQL structured type in the database, and methods
for retrieving its attribute values.
Thread safety
A SerialStruct is not safe for use by multiple concurrent threads. If a SerialStruct is to be used by more than one thread then access to the SerialStruct should be controlled by appropriate synchronization.- Since:
- 1.5
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description SerialStruct(SQLData in, Map<String,Class<?>> map)
Constructs aSerialStruct
object from the givenSQLData
object, using the given type map to custom map it to a class in the Java programming language.SerialStruct(Struct in, Map<String,Class<?>> map)
Constructs aSerialStruct
object from the givenStruct
object, using the givenjava.util.Map
object for custom mapping the SQL structured type or any of its attributes that are SQL structured types. -
Method Summary
Modifier and Type Method Description Object
clone()
Returns a clone of thisSerialStruct
.boolean
equals(Object obj)
Compares this SerialStruct to the specified object.Object[]
getAttributes()
Retrieves an array ofObject
values containing the attributes of the SQL structured type that thisSerialStruct
object represents.Object[]
getAttributes(Map<String,Class<?>> map)
Retrieves the attributes for the SQL structured type that thisSerialStruct
represents as an array ofObject
values, using the given type map for custom mapping if appropriate.String
getSQLTypeName()
Retrieves the SQL type name for thisSerialStruct
object.int
hashCode()
Returns a hash code for thisSerialStruct
.
-
Constructor Details
-
SerialStruct
Constructs aSerialStruct
object from the givenStruct
object, using the givenjava.util.Map
object for custom mapping the SQL structured type or any of its attributes that are SQL structured types.- Parameters:
in
- an instance ofStruct
map
- ajava.util.Map
object in which each entry consists of 1) aString
object giving the fully qualified name of a UDT and 2) theClass
object for theSQLData
implementation that defines how the UDT is to be mapped- Throws:
SerialException
- if an error occurs- See Also:
Struct
-
SerialStruct
Constructs aSerialStruct
object from the givenSQLData
object, using the given type map to custom map it to a class in the Java programming language. The type map gives the SQL type and the class to which it is mapped. TheSQLData
object defines the class to which the SQL type will be mapped.- Parameters:
in
- an instance of theSQLData
class that defines the mapping of the SQL structured type to one or more objects in the Java programming languagemap
- ajava.util.Map
object in which each entry consists of 1) aString
object giving the fully qualified name of a UDT and 2) theClass
object for theSQLData
implementation that defines how the UDT is to be mapped- Throws:
SerialException
- if an error occurs
-
-
Method Details
-
getSQLTypeName
Retrieves the SQL type name for thisSerialStruct
object. This is the name used in the SQL definition of the structured type- Specified by:
getSQLTypeName
in interfaceStruct
- Returns:
- a
String
object representing the SQL type name for the SQL structured type that thisSerialStruct
object represents - Throws:
SerialException
- if an error occurs
-
getAttributes
Retrieves an array ofObject
values containing the attributes of the SQL structured type that thisSerialStruct
object represents.- Specified by:
getAttributes
in interfaceStruct
- Returns:
- an array of
Object
values, with each element being an attribute of the SQL structured type that thisSerialStruct
object represents - Throws:
SerialException
- if an error occurs
-
getAttributes
Retrieves the attributes for the SQL structured type that thisSerialStruct
represents as an array ofObject
values, using the given type map for custom mapping if appropriate.- Specified by:
getAttributes
in interfaceStruct
- Parameters:
map
- ajava.util.Map
object in which each entry consists of 1) aString
object giving the fully qualified name of a UDT and 2) theClass
object for theSQLData
implementation that defines how the UDT is to be mapped- Returns:
- an array of
Object
values, with each element being an attribute of the SQL structured type that thisSerialStruct
object represents - Throws:
SerialException
- if an error occurs
-
equals
Compares this SerialStruct to the specified object. The result istrue
if and only if the argument is notnull
and is aSerialStruct
object whose attributes are identical to this object's attributes- Overrides:
equals
in classObject
- Parameters:
obj
- The object to compare thisSerialStruct
against- Returns:
true
if the given object represents aSerialStruct
equivalent to this SerialStruct,false
otherwise- See Also:
Object.hashCode()
,HashMap
-
hashCode
public int hashCode()Returns a hash code for thisSerialStruct
. The hash code for aSerialStruct
object is computed using the hash codes of the attributes of theSerialStruct
object and itsSQLTypeName
- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
clone
Returns a clone of thisSerialStruct
. The copy will contain a reference to a clone of the underlying attribs array, not a reference to the original underlying attribs array of thisSerialStruct
object.
-