< prev index next >

src/java.base/share/classes/java/time/chrono/AbstractChronology.java

Print this page




 712      * Outputs this chronology as a {@code String}, using the chronology ID.
 713      *
 714      * @return a string representation of this chronology, not null
 715      */
 716     @Override
 717     public String toString() {
 718         return getId();
 719     }
 720 
 721     //-----------------------------------------------------------------------
 722     /**
 723      * Writes the Chronology using a
 724      * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
 725      * <pre>
 726      *  out.writeByte(1);  // identifies this as a Chronology
 727      *  out.writeUTF(getId());
 728      * </pre>
 729      *
 730      * @return the instance of {@code Ser}, not null
 731      */

 732     Object writeReplace() {
 733         return new Ser(Ser.CHRONO_TYPE, this);
 734     }
 735 
 736     /**
 737      * Defend against malicious streams.
 738      *
 739      * @param s the stream to read
 740      * @throws java.io.InvalidObjectException always
 741      */

 742     private void readObject(ObjectInputStream s) throws ObjectStreamException {
 743         throw new InvalidObjectException("Deserialization via serialization delegate");
 744     }
 745 
 746     void writeExternal(DataOutput out) throws IOException {
 747         out.writeUTF(getId());
 748     }
 749 
 750     static Chronology readExternal(DataInput in) throws IOException {
 751         String id = in.readUTF();
 752         return Chronology.of(id);
 753     }
 754 
 755 }


 712      * Outputs this chronology as a {@code String}, using the chronology ID.
 713      *
 714      * @return a string representation of this chronology, not null
 715      */
 716     @Override
 717     public String toString() {
 718         return getId();
 719     }
 720 
 721     //-----------------------------------------------------------------------
 722     /**
 723      * Writes the Chronology using a
 724      * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
 725      * <pre>
 726      *  out.writeByte(1);  // identifies this as a Chronology
 727      *  out.writeUTF(getId());
 728      * </pre>
 729      *
 730      * @return the instance of {@code Ser}, not null
 731      */
 732     @java.io.Serial
 733     Object writeReplace() {
 734         return new Ser(Ser.CHRONO_TYPE, this);
 735     }
 736 
 737     /**
 738      * Defend against malicious streams.
 739      *
 740      * @param s the stream to read
 741      * @throws java.io.InvalidObjectException always
 742      */
 743     @java.io.Serial
 744     private void readObject(ObjectInputStream s) throws ObjectStreamException {
 745         throw new InvalidObjectException("Deserialization via serialization delegate");
 746     }
 747 
 748     void writeExternal(DataOutput out) throws IOException {
 749         out.writeUTF(getId());
 750     }
 751 
 752     static Chronology readExternal(DataInput in) throws IOException {
 753         String id = in.readUTF();
 754         return Chronology.of(id);
 755     }
 756 
 757 }
< prev index next >