612 throws IOException, ClassNotFoundException {
613
614 ObjectInputStream.GetField fields = s.readFields();
615 Object[] tmp = (Object[])fields.get("elements", null);
616 if (tmp == null)
617 throw new InvalidObjectException("elements is null and should not be!");
618 elements = tmp.clone();
619 len = fields.get("len", 0);
620 if(elements.length != len)
621 throw new InvalidObjectException("elements is not the expected size");
622
623 baseType = fields.get("baseType", 0);
624 baseTypeName = (String)fields.get("baseTypeName", null);
625 }
626
627 /**
628 * writeObject is called to save the state of the {@code SerialArray}
629 * to a stream.
630 */
631 private void writeObject(ObjectOutputStream s)
632 throws IOException, ClassNotFoundException {
633
634 ObjectOutputStream.PutField fields = s.putFields();
635 fields.put("elements", elements);
636 fields.put("len", len);
637 fields.put("baseType", baseType);
638 fields.put("baseTypeName", baseTypeName);
639 s.writeFields();
640 }
641
642 /**
643 * Check to see if this object had previously had its {@code free} method
644 * called
645 *
646 * @throws SerialException
647 */
648 private void isValid() throws SerialException {
649 if (elements == null) {
650 throw new SerialException("Error: You cannot call a method on a "
651 + "SerialArray instance once free() has been called.");
652 }
|
612 throws IOException, ClassNotFoundException {
613
614 ObjectInputStream.GetField fields = s.readFields();
615 Object[] tmp = (Object[])fields.get("elements", null);
616 if (tmp == null)
617 throw new InvalidObjectException("elements is null and should not be!");
618 elements = tmp.clone();
619 len = fields.get("len", 0);
620 if(elements.length != len)
621 throw new InvalidObjectException("elements is not the expected size");
622
623 baseType = fields.get("baseType", 0);
624 baseTypeName = (String)fields.get("baseTypeName", null);
625 }
626
627 /**
628 * writeObject is called to save the state of the {@code SerialArray}
629 * to a stream.
630 */
631 private void writeObject(ObjectOutputStream s)
632 throws IOException {
633
634 ObjectOutputStream.PutField fields = s.putFields();
635 fields.put("elements", elements);
636 fields.put("len", len);
637 fields.put("baseType", baseType);
638 fields.put("baseTypeName", baseTypeName);
639 s.writeFields();
640 }
641
642 /**
643 * Check to see if this object had previously had its {@code free} method
644 * called
645 *
646 * @throws SerialException
647 */
648 private void isValid() throws SerialException {
649 if (elements == null) {
650 throw new SerialException("Error: You cannot call a method on a "
651 + "SerialArray instance once free() has been called.");
652 }
|