FileDocCategorySizeDatePackage
SerialRef.javaAPI DocJava SE 5 API5227Fri Aug 26 14:57:52 BST 2005javax.sql.rowset.serial

SerialRef

public class SerialRef extends Object implements Ref, Serializable, Cloneable
A serialized mapping of a Ref object, which is the mapping in the Java programming language of an SQL REF value.

The SerialRef class provides a constructor for creating a SerialRef instance from a Ref object and provides methods for getting and setting the Ref object.

Fields Summary
private String
baseTypeName
String containing the base type name.
private Object
object
This will store the type Ref as an Object.
private Ref
reference
Private copy of the Ref reference.
static final long
serialVersionUID
The identifier that assists in the serialization of this SerialRef object.
Constructors Summary
public SerialRef(Ref ref)
Constructs a SerialRef object from the given Ref object.

param
ref a Ref object; cannot be null
throws
SQLException if a database access occurs; if ref is null; or if the Ref object returns a null value base type name.
throws
SerialException if an error occurs serializing the Ref object

        
        if (ref == null) {
            throw new SQLException("Cannot instantiate a SerialRef object " +
                "with a null Ref object");
        }
        reference = ref;
        object = ref;
        if (ref.getBaseTypeName() == null) {
            throw new SQLException("Cannot instantiate a SerialRef object " +
                "that returns a null base type name");
        } else {
            baseTypeName = new String(ref.getBaseTypeName());
        }
    
Methods Summary
public java.lang.StringgetBaseTypeName()
Returns a string describing the base type name of the Ref.

return
a string of the base type name of the Ref
throws
SerialException in no Ref object has been set

        return baseTypeName;
    
public java.lang.ObjectgetObject(java.util.Map map)
Returns an Object representing the SQL structured type to which this SerialRef object refers. The attributes of the structured type are mapped according to the given type map.

param
map a java.util.Map object containing zero or more entries, with each entry consisting of 1) a String giving the fully qualified name of a UDT and 2) the Class object for the SQLData implementation that defines how the UDT is to be mapped
return
an object instance resolved from the Ref reference and mapped according to the supplied type map
throws
SerialException if an error is encountered in the reference resolution

        map = new Hashtable(map);
        if (!object.equals(null)) {
            return map.get(object);
        } else {
            throw new SerialException("The object is not set");
        }   
    
public java.lang.ObjectgetObject()
Returns an Object representing the SQL structured type to which this SerialRef object refers.

return
an object instance resolved from the Ref reference
throws
SerialException if an error is encountered in the reference resolution

        
        if (reference != null) {
            try {
                return reference.getObject();
            } catch (SQLException e) {
                throw new SerialException("SQLException: " + e.getMessage());
            }
        }
                
        if (object != null) {
            return object;
        }
    
        
        throw new SerialException("The object is not set");
        
    
public voidsetObject(java.lang.Object obj)
Sets the SQL structured type that this SerialRef object references to the given Object object.

param
obj an Object representing the SQL structured type to be referenced
throws
SerialException if an error is encountered generating the the structured type referenced by this SerialRef object

        try {
            reference.setObject(obj);
        } catch (SQLException e) {
            throw new SerialException("SQLException: " + e.getMessage());
        }
        object = obj;