jdk/src/share/classes/java/time/chrono/Chronology.java
changeset 19841 15c8e97d6a14
parent 19030 32f129cb6351
child 20519 eee7a92074fd
equal deleted inserted replaced
19822:4e10a58fa28f 19841:15c8e97d6a14
  1256 
  1256 
  1257     //-----------------------------------------------------------------------
  1257     //-----------------------------------------------------------------------
  1258     /**
  1258     /**
  1259      * Writes the Chronology using a
  1259      * Writes the Chronology using a
  1260      * <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
  1260      * <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
       
  1261      * @serialData
  1261      * <pre>
  1262      * <pre>
  1262      *  out.writeByte(1);  // identifies this as a Chronology
  1263      *  out.writeByte(1);  // identifies a Chronology
  1263      *  out.writeUTF(getId());
  1264      *  out.writeUTF(getId());
  1264      * </pre>
  1265      * </pre>
  1265      *
  1266      *
  1266      * @return the instance of {@code Ser}, not null
  1267      * @return the instance of {@code Ser}, not null
  1267      */
  1268      */
  1268     protected Object writeReplace() {
  1269     Object writeReplace() {
  1269         return new Ser(Ser.CHRONO_TYPE, this);
  1270         return new Ser(Ser.CHRONO_TYPE, this);
  1270     }
  1271     }
  1271 
  1272 
  1272     /**
  1273     /**
  1273      * Defend against malicious streams.
  1274      * Defend against malicious streams.
  1274      * @return never
  1275      * @return never
  1275      * @throws InvalidObjectException always
  1276      * @throws InvalidObjectException always
  1276      */
  1277      */
  1277     private Object readResolve() throws ObjectStreamException {
  1278     private Object readResolve() throws InvalidObjectException {
  1278         throw new InvalidObjectException("Deserialization via serialization delegate");
  1279         throw new InvalidObjectException("Deserialization via serialization delegate");
  1279     }
  1280     }
  1280 
  1281 
       
  1282     /**
       
  1283      * Write the Chronology id to the stream.
       
  1284      * @param out the output stream
       
  1285      * @throws IOException on any error during the write
       
  1286      */
  1281     void writeExternal(DataOutput out) throws IOException {
  1287     void writeExternal(DataOutput out) throws IOException {
  1282         out.writeUTF(getId());
  1288         out.writeUTF(getId());
  1283     }
  1289     }
  1284 
  1290 
       
  1291     /**
       
  1292      * Reads the Chronology id and creates the Chronology.
       
  1293      * @param in  the input stream
       
  1294      * @return  the Chronology
       
  1295      * @throws IOException  on errors during the read
       
  1296      * @throws DateTimeException if the Chronology cannot be returned
       
  1297      */
  1285     static Chronology readExternal(DataInput in) throws IOException {
  1298     static Chronology readExternal(DataInput in) throws IOException {
  1286         String id = in.readUTF();
  1299         String id = in.readUTF();
  1287         return Chronology.of(id);
  1300         return Chronology.of(id);
  1288     }
  1301     }
  1289 
  1302