553 private void readObject(ObjectInputStream s)
554 throws IOException, ClassNotFoundException {
555
556 ObjectInputStream.GetField fields = s.readFields();
557 byte[] tmp = (byte[])fields.get("buf", null);
558 if (tmp == null)
559 throw new InvalidObjectException("buf is null and should not be!");
560 buf = tmp.clone();
561 len = fields.get("len", 0L);
562 if (buf.length != len)
563 throw new InvalidObjectException("buf is not the expected size");
564 origLen = fields.get("origLen", 0L);
565 blob = (Blob) fields.get("blob", null);
566 }
567
568 /**
569 * writeObject is called to save the state of the SerialBlob
570 * to a stream.
571 */
572 private void writeObject(ObjectOutputStream s)
573 throws IOException, ClassNotFoundException {
574
575 ObjectOutputStream.PutField fields = s.putFields();
576 fields.put("buf", buf);
577 fields.put("len", len);
578 fields.put("origLen", origLen);
579 // Note: this check to see if it is an instance of Serializable
580 // is for backwards compatibility
581 fields.put("blob", blob instanceof Serializable ? blob : null);
582 s.writeFields();
583 }
584
585 /**
586 * Check to see if this object had previously had its {@code free} method
587 * called
588 *
589 * @throws SerialException
590 */
591 private void isValid() throws SerialException {
592 if (buf == null) {
593 throw new SerialException("Error: You cannot call a method on a " +
|
553 private void readObject(ObjectInputStream s)
554 throws IOException, ClassNotFoundException {
555
556 ObjectInputStream.GetField fields = s.readFields();
557 byte[] tmp = (byte[])fields.get("buf", null);
558 if (tmp == null)
559 throw new InvalidObjectException("buf is null and should not be!");
560 buf = tmp.clone();
561 len = fields.get("len", 0L);
562 if (buf.length != len)
563 throw new InvalidObjectException("buf is not the expected size");
564 origLen = fields.get("origLen", 0L);
565 blob = (Blob) fields.get("blob", null);
566 }
567
568 /**
569 * writeObject is called to save the state of the SerialBlob
570 * to a stream.
571 */
572 private void writeObject(ObjectOutputStream s)
573 throws IOException {
574
575 ObjectOutputStream.PutField fields = s.putFields();
576 fields.put("buf", buf);
577 fields.put("len", len);
578 fields.put("origLen", origLen);
579 // Note: this check to see if it is an instance of Serializable
580 // is for backwards compatibility
581 fields.put("blob", blob instanceof Serializable ? blob : null);
582 s.writeFields();
583 }
584
585 /**
586 * Check to see if this object had previously had its {@code free} method
587 * called
588 *
589 * @throws SerialException
590 */
591 private void isValid() throws SerialException {
592 if (buf == null) {
593 throw new SerialException("Error: You cannot call a method on a " +
|