| 658 | /// |
| 659 | /// - `IOException`: thrown by the stream |
| 660 | public static void writeObject(Object o, DataOutputStream out) throws IOException { |
| 661 | if (o == null) { |
| 662 | out.writeBoolean(false); |
| 663 | return; |
| 664 | } |
| 665 | out.writeBoolean(true); |
| 666 | if (o instanceof Externalizable) { |
| 667 | Externalizable e = (Externalizable) o; |
| 668 | out.writeUTF(e.getObjectId()); |
| 669 | out.writeInt(e.getVersion()); |
| 670 | e.externalize(out); |
| 671 | return; |
| 672 | } |
| 673 | if (o instanceof PropertyBusinessObject) { |
| 674 | Externalizable e = ((PropertyBusinessObject) o).getPropertyIndex().asExternalizable(); |
| 675 | out.writeUTF(e.getObjectId()); |
| 676 | out.writeInt(e.getVersion()); |
| 677 | e.externalize(out); |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | if (o instanceof Vector) { |
| 682 | Vector v = (Vector) o; |
| 683 | out.writeUTF("java.util.Vector"); |
| 684 | int size = v.size(); |
| 685 | out.writeInt(size); |
| 686 | for (int iter = 0; iter < size; iter++) { |
| 687 | writeObject(v.elementAt(iter), out); |
| 688 | } |
| 689 | return; |
| 690 | } |
| 691 | |
| 692 | if (o instanceof Set) { |
| 693 | Collection v = (Collection) o; |
| 694 | out.writeUTF("java.util.Set"); |
| 695 | int size = v.size(); |
| 696 | out.writeInt(size); |
| 697 | for (Object cur : v) { |
| 698 | writeObject(cur, out); |
| 699 | } |
| 700 | return; |
| 701 | } |
| 702 | |
| 703 | if (o instanceof Collection) { |
| 704 | Collection v = (Collection) o; |
| 705 | out.writeUTF("java.util.Collection"); |
| 706 | int size = v.size(); |
| 707 | out.writeInt(size); |
| 708 | for (Object cur : v) { |
| 709 | writeObject(cur, out); |
| 710 | } |
| 711 | return; |
| 712 | } |
| 713 | |
| 714 | if (o instanceof Hashtable) { |
| 715 | Hashtable v = (Hashtable) o; |
| 716 | out.writeUTF("java.util.Hashtable"); |
| 717 | out.writeInt(v.size()); |