SerialJavaObjectpublic class SerialJavaObject extends Object implements Serializable, CloneableA serializable mapping in the Java programming language of an SQL
JAVA_OBJECT value. Assuming the Java object
implements the Serializable interface, this class simply wraps the
serialization process.
If however, the serialization is not possible because
the Java object is not immediately serializable, this class will
attempt to serialize all non-static members to permit the object
state to be serialized.
Static or transient fields cannot be serialized; an attempt to serialize
them will result in a SerialException object being thrown. |
Fields Summary |
---|
private Object | objPlaceholder for object to be serialized. | private transient Field[] | fieldsPlaceholder for all fields in the JavaObject being serialized. | static final long | serialVersionUIDThe identifier that assists in the serialization of this
SerialJavaObject object. | Vector | chainA container for the warnings issued on this SerialJavaObject
object. When there are multiple warnings, each warning is chained to the
previous warning. |
Constructors Summary |
---|
public SerialJavaObject(Object obj)Constructor for SerialJavaObject helper class.
// if any static fields are found, an exception
// should be thrown
// get Class. Object instance should always be available
Class c = obj.getClass();
// determine if object implements Serializable i/f
boolean serializableImpl = false;
Class[] theIf = c.getInterfaces();
for (int i = 0; i < theIf.length; i++) {
String ifName = theIf[i].getName();
if (ifName == "java.io.Serializable") {
serializableImpl = true;
}
}
// can only determine public fields (obviously). If
// any of these are static, this should invalidate
// the action of attempting to persist these fields
// in a serialized form
boolean anyStaticFields = false;
fields = c.getFields();
//fields = new Object[field.length];
for (int i = 0; i < fields.length; i++ ) {
if ( fields[i].getModifiers() == Modifier.STATIC ) {
anyStaticFields = true;
}
//fields[i] = field[i].get(obj);
}
try {
if (!(serializableImpl)) {
throw new RowSetWarning("Test");
}
} catch (RowSetWarning w) {
setWarning(w);
}
if (anyStaticFields) {
throw new SerialException("Located static fields in " +
"object instance. Cannot serialize");
}
this.obj = obj;
|
Methods Summary |
---|
public java.lang.reflect.Field[] | getFields()Returns an array of Field objects that contains each
field of the object that this helper class is serializing.
if (fields != null) {
Class c = this.obj.getClass();
return c.getFields();
} else {
throw new SerialException("SerialJavaObject does not contain" +
" a serialized object instance");
}
| public java.lang.Object | getObject()Returns an Object that is a copy of this SerialJavaObject
object.
return this.obj;
| private void | setWarning(javax.sql.rowset.RowSetWarning e)Registers the given warning.
if (chain == null) {
chain = new java.util.Vector();
}
chain.add(e);
|
|