src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java

Print this page




  53  * SerialJavaObject is to be used by more than one thread then access to the
  54  * SerialJavaObject should be controlled by appropriate synchronization.
  55  *
  56  * @author Jonathan Bruce
  57  */
  58 public class SerialJavaObject implements Serializable, Cloneable {
  59 
  60     /**
  61      * Placeholder for object to be serialized.
  62      */
  63     private Object obj;
  64 
  65 
  66    /**
  67     * Placeholder for all fields in the <code>JavaObject</code> being serialized.
  68     */
  69     private transient Field[] fields;
  70 
  71     /**
  72      * Constructor for <code>SerialJavaObject</code> helper class.
  73      * <p>
  74      *
  75      * @param obj the Java <code>Object</code> to be serialized
  76      * @throws SerialException if the object is found not to be serializable
  77      */
  78     public SerialJavaObject(Object obj) throws SerialException {
  79 
  80         // if any static fields are found, an exception
  81         // should be thrown
  82 
  83 
  84         // get Class. Object instance should always be available
  85         Class<?> c = obj.getClass();
  86 
  87         // determine if object implements Serializable i/f
  88         if (!(obj instanceof java.io.Serializable)) {
  89             setWarning(new RowSetWarning("Warning, the object passed to the constructor does not implement Serializable"));
  90         }
  91 
  92         // can only determine public fields (obviously). If
  93         // any of these are static, this should invalidate




  53  * SerialJavaObject is to be used by more than one thread then access to the
  54  * SerialJavaObject should be controlled by appropriate synchronization.
  55  *
  56  * @author Jonathan Bruce
  57  */
  58 public class SerialJavaObject implements Serializable, Cloneable {
  59 
  60     /**
  61      * Placeholder for object to be serialized.
  62      */
  63     private Object obj;
  64 
  65 
  66    /**
  67     * Placeholder for all fields in the <code>JavaObject</code> being serialized.
  68     */
  69     private transient Field[] fields;
  70 
  71     /**
  72      * Constructor for <code>SerialJavaObject</code> helper class.

  73      *
  74      * @param obj the Java <code>Object</code> to be serialized
  75      * @throws SerialException if the object is found not to be serializable
  76      */
  77     public SerialJavaObject(Object obj) throws SerialException {
  78 
  79         // if any static fields are found, an exception
  80         // should be thrown
  81 
  82 
  83         // get Class. Object instance should always be available
  84         Class<?> c = obj.getClass();
  85 
  86         // determine if object implements Serializable i/f
  87         if (!(obj instanceof java.io.Serializable)) {
  88             setWarning(new RowSetWarning("Warning, the object passed to the constructor does not implement Serializable"));
  89         }
  90 
  91         // can only determine public fields (obviously). If
  92         // any of these are static, this should invalidate