644 * Write the specified class descriptor to the ObjectOutputStream. Class |
644 * Write the specified class descriptor to the ObjectOutputStream. Class |
645 * descriptors are used to identify the classes of objects written to the |
645 * descriptors are used to identify the classes of objects written to the |
646 * stream. Subclasses of ObjectOutputStream may override this method to |
646 * stream. Subclasses of ObjectOutputStream may override this method to |
647 * customize the way in which class descriptors are written to the |
647 * customize the way in which class descriptors are written to the |
648 * serialization stream. The corresponding method in ObjectInputStream, |
648 * serialization stream. The corresponding method in ObjectInputStream, |
649 * <code>readClassDescriptor</code>, should then be overridden to |
649 * {@code readClassDescriptor}, should then be overridden to |
650 * reconstitute the class descriptor from its custom stream representation. |
650 * reconstitute the class descriptor from its custom stream representation. |
651 * By default, this method writes class descriptors according to the format |
651 * By default, this method writes class descriptors according to the format |
652 * defined in the Object Serialization specification. |
652 * defined in the Object Serialization specification. |
653 * |
653 * |
654 * <p>Note that this method will only be called if the ObjectOutputStream |
654 * <p>Note that this method will only be called if the ObjectOutputStream |
655 * is not using the old serialization stream format (set by calling |
655 * is not using the old serialization stream format (set by calling |
656 * ObjectOutputStream's <code>useProtocolVersion</code> method). If this |
656 * ObjectOutputStream's {@code useProtocolVersion} method). If this |
657 * serialization stream is using the old format |
657 * serialization stream is using the old format |
658 * (<code>PROTOCOL_VERSION_1</code>), the class descriptor will be written |
658 * ({@code PROTOCOL_VERSION_1}), the class descriptor will be written |
659 * internally in a manner that cannot be overridden or customized. |
659 * internally in a manner that cannot be overridden or customized. |
660 * |
660 * |
661 * @param desc class descriptor to write to the stream |
661 * @param desc class descriptor to write to the stream |
662 * @throws IOException If an I/O error has occurred. |
662 * @throws IOException If an I/O error has occurred. |
663 * @see java.io.ObjectInputStream#readClassDescriptor() |
663 * @see java.io.ObjectInputStream#readClassDescriptor() |
887 /** |
887 /** |
888 * Put the value of the named boolean field into the persistent field. |
888 * Put the value of the named boolean field into the persistent field. |
889 * |
889 * |
890 * @param name the name of the serializable field |
890 * @param name the name of the serializable field |
891 * @param val the value to assign to the field |
891 * @param val the value to assign to the field |
892 * @throws IllegalArgumentException if <code>name</code> does not |
892 * @throws IllegalArgumentException if {@code name} does not |
893 * match the name of a serializable field for the class whose fields |
893 * match the name of a serializable field for the class whose fields |
894 * are being written, or if the type of the named field is not |
894 * are being written, or if the type of the named field is not |
895 * <code>boolean</code> |
895 * {@code boolean} |
896 */ |
896 */ |
897 public abstract void put(String name, boolean val); |
897 public abstract void put(String name, boolean val); |
898 |
898 |
899 /** |
899 /** |
900 * Put the value of the named byte field into the persistent field. |
900 * Put the value of the named byte field into the persistent field. |
901 * |
901 * |
902 * @param name the name of the serializable field |
902 * @param name the name of the serializable field |
903 * @param val the value to assign to the field |
903 * @param val the value to assign to the field |
904 * @throws IllegalArgumentException if <code>name</code> does not |
904 * @throws IllegalArgumentException if {@code name} does not |
905 * match the name of a serializable field for the class whose fields |
905 * match the name of a serializable field for the class whose fields |
906 * are being written, or if the type of the named field is not |
906 * are being written, or if the type of the named field is not |
907 * <code>byte</code> |
907 * {@code byte} |
908 */ |
908 */ |
909 public abstract void put(String name, byte val); |
909 public abstract void put(String name, byte val); |
910 |
910 |
911 /** |
911 /** |
912 * Put the value of the named char field into the persistent field. |
912 * Put the value of the named char field into the persistent field. |
913 * |
913 * |
914 * @param name the name of the serializable field |
914 * @param name the name of the serializable field |
915 * @param val the value to assign to the field |
915 * @param val the value to assign to the field |
916 * @throws IllegalArgumentException if <code>name</code> does not |
916 * @throws IllegalArgumentException if {@code name} does not |
917 * match the name of a serializable field for the class whose fields |
917 * match the name of a serializable field for the class whose fields |
918 * are being written, or if the type of the named field is not |
918 * are being written, or if the type of the named field is not |
919 * <code>char</code> |
919 * {@code char} |
920 */ |
920 */ |
921 public abstract void put(String name, char val); |
921 public abstract void put(String name, char val); |
922 |
922 |
923 /** |
923 /** |
924 * Put the value of the named short field into the persistent field. |
924 * Put the value of the named short field into the persistent field. |
925 * |
925 * |
926 * @param name the name of the serializable field |
926 * @param name the name of the serializable field |
927 * @param val the value to assign to the field |
927 * @param val the value to assign to the field |
928 * @throws IllegalArgumentException if <code>name</code> does not |
928 * @throws IllegalArgumentException if {@code name} does not |
929 * match the name of a serializable field for the class whose fields |
929 * match the name of a serializable field for the class whose fields |
930 * are being written, or if the type of the named field is not |
930 * are being written, or if the type of the named field is not |
931 * <code>short</code> |
931 * {@code short} |
932 */ |
932 */ |
933 public abstract void put(String name, short val); |
933 public abstract void put(String name, short val); |
934 |
934 |
935 /** |
935 /** |
936 * Put the value of the named int field into the persistent field. |
936 * Put the value of the named int field into the persistent field. |
937 * |
937 * |
938 * @param name the name of the serializable field |
938 * @param name the name of the serializable field |
939 * @param val the value to assign to the field |
939 * @param val the value to assign to the field |
940 * @throws IllegalArgumentException if <code>name</code> does not |
940 * @throws IllegalArgumentException if {@code name} does not |
941 * match the name of a serializable field for the class whose fields |
941 * match the name of a serializable field for the class whose fields |
942 * are being written, or if the type of the named field is not |
942 * are being written, or if the type of the named field is not |
943 * <code>int</code> |
943 * {@code int} |
944 */ |
944 */ |
945 public abstract void put(String name, int val); |
945 public abstract void put(String name, int val); |
946 |
946 |
947 /** |
947 /** |
948 * Put the value of the named long field into the persistent field. |
948 * Put the value of the named long field into the persistent field. |
949 * |
949 * |
950 * @param name the name of the serializable field |
950 * @param name the name of the serializable field |
951 * @param val the value to assign to the field |
951 * @param val the value to assign to the field |
952 * @throws IllegalArgumentException if <code>name</code> does not |
952 * @throws IllegalArgumentException if {@code name} does not |
953 * match the name of a serializable field for the class whose fields |
953 * match the name of a serializable field for the class whose fields |
954 * are being written, or if the type of the named field is not |
954 * are being written, or if the type of the named field is not |
955 * <code>long</code> |
955 * {@code long} |
956 */ |
956 */ |
957 public abstract void put(String name, long val); |
957 public abstract void put(String name, long val); |
958 |
958 |
959 /** |
959 /** |
960 * Put the value of the named float field into the persistent field. |
960 * Put the value of the named float field into the persistent field. |
961 * |
961 * |
962 * @param name the name of the serializable field |
962 * @param name the name of the serializable field |
963 * @param val the value to assign to the field |
963 * @param val the value to assign to the field |
964 * @throws IllegalArgumentException if <code>name</code> does not |
964 * @throws IllegalArgumentException if {@code name} does not |
965 * match the name of a serializable field for the class whose fields |
965 * match the name of a serializable field for the class whose fields |
966 * are being written, or if the type of the named field is not |
966 * are being written, or if the type of the named field is not |
967 * <code>float</code> |
967 * {@code float} |
968 */ |
968 */ |
969 public abstract void put(String name, float val); |
969 public abstract void put(String name, float val); |
970 |
970 |
971 /** |
971 /** |
972 * Put the value of the named double field into the persistent field. |
972 * Put the value of the named double field into the persistent field. |
973 * |
973 * |
974 * @param name the name of the serializable field |
974 * @param name the name of the serializable field |
975 * @param val the value to assign to the field |
975 * @param val the value to assign to the field |
976 * @throws IllegalArgumentException if <code>name</code> does not |
976 * @throws IllegalArgumentException if {@code name} does not |
977 * match the name of a serializable field for the class whose fields |
977 * match the name of a serializable field for the class whose fields |
978 * are being written, or if the type of the named field is not |
978 * are being written, or if the type of the named field is not |
979 * <code>double</code> |
979 * {@code double} |
980 */ |
980 */ |
981 public abstract void put(String name, double val); |
981 public abstract void put(String name, double val); |
982 |
982 |
983 /** |
983 /** |
984 * Put the value of the named Object field into the persistent field. |
984 * Put the value of the named Object field into the persistent field. |
985 * |
985 * |
986 * @param name the name of the serializable field |
986 * @param name the name of the serializable field |
987 * @param val the value to assign to the field |
987 * @param val the value to assign to the field |
988 * (which may be <code>null</code>) |
988 * (which may be {@code null}) |
989 * @throws IllegalArgumentException if <code>name</code> does not |
989 * @throws IllegalArgumentException if {@code name} does not |
990 * match the name of a serializable field for the class whose fields |
990 * match the name of a serializable field for the class whose fields |
991 * are being written, or if the type of the named field is not a |
991 * are being written, or if the type of the named field is not a |
992 * reference type |
992 * reference type |
993 */ |
993 */ |
994 public abstract void put(String name, Object val); |
994 public abstract void put(String name, Object val); |
995 |
995 |
996 /** |
996 /** |
997 * Write the data and fields to the specified ObjectOutput stream, |
997 * Write the data and fields to the specified ObjectOutput stream, |
998 * which must be the same stream that produced this |
998 * which must be the same stream that produced this |
999 * <code>PutField</code> object. |
999 * {@code PutField} object. |
1000 * |
1000 * |
1001 * @param out the stream to write the data and fields to |
1001 * @param out the stream to write the data and fields to |
1002 * @throws IOException if I/O errors occur while writing to the |
1002 * @throws IOException if I/O errors occur while writing to the |
1003 * underlying stream |
1003 * underlying stream |
1004 * @throws IllegalArgumentException if the specified stream is not |
1004 * @throws IllegalArgumentException if the specified stream is not |
1005 * the same stream that produced this <code>PutField</code> |
1005 * the same stream that produced this {@code PutField} |
1006 * object |
1006 * object |
1007 * @deprecated This method does not write the values contained by this |
1007 * @deprecated This method does not write the values contained by this |
1008 * <code>PutField</code> object in a proper format, and may |
1008 * {@code PutField} object in a proper format, and may |
1009 * result in corruption of the serialization stream. The |
1009 * result in corruption of the serialization stream. The |
1010 * correct way to write <code>PutField</code> data is by |
1010 * correct way to write {@code PutField} data is by |
1011 * calling the {@link java.io.ObjectOutputStream#writeFields()} |
1011 * calling the {@link java.io.ObjectOutputStream#writeFields()} |
1012 * method. |
1012 * method. |
1013 */ |
1013 */ |
1014 @Deprecated |
1014 @Deprecated |
1015 public abstract void write(ObjectOutput out) throws IOException; |
1015 public abstract void write(ObjectOutput out) throws IOException; |