Changeset 19096 in josm


Ignore:
Timestamp:
2024-06-03T18:08:14+02:00 (4 weeks ago)
Author:
taylor.smock
Message:

Fix #23677: Move PrimitiveData serialization back from AbstractPrimitive

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r19080 r19096  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.io.IOException;
    7 import java.io.ObjectInputStream;
    8 import java.io.ObjectOutputStream;
    96import java.text.MessageFormat;
    107import java.time.Instant;
     
    143140     * Other bits of this field are used in subclasses.
    144141     */
    145     private volatile short flags = FLAG_VISIBLE;   // visible per default
     142    protected volatile short flags = FLAG_VISIBLE;   // visible per default
    146143
    147144    /**
     
    372369        updateFlags(flag, value);
    373370        return oldFlags != flags;
    374     }
    375 
    376     /**
    377      * Write common data to a serialization stream. At time of writing, this should <i>only</i> be used by {@link PrimitiveData}.
    378      * @param oos The output stream to write to
    379      * @throws IOException see {@link ObjectOutputStream#write}
    380      */
    381     protected void writeObjectCommon(ObjectOutputStream oos) throws IOException {
    382         oos.writeLong(id);
    383         oos.writeLong(user == null ? -1 : user.getId());
    384         oos.writeInt(version);
    385         oos.writeInt(changesetId);
    386         oos.writeInt(timestamp);
    387         oos.writeObject(keys);
    388         oos.writeShort(flags);
    389     }
    390 
    391     /**
    392      * Read common data from a serialization stream. At time of writing, this should <i>only</i> be used by {@link PrimitiveData}.
    393      * @param ois The serialization stream to read from
    394      * @throws ClassNotFoundException see {@link ObjectInputStream#readObject()}
    395      * @throws IOException see {@link ObjectInputStream#read}
    396      */
    397     protected void readObjectCommon(ObjectInputStream ois) throws ClassNotFoundException, IOException {
    398         id = ois.readLong();
    399         final long userId = ois.readLong();
    400         user = userId == -1 ? null : User.getById(userId);
    401         version = ois.readInt();
    402         changesetId = ois.readInt();
    403         timestamp = ois.readInt();
    404         keys = (String[]) ois.readObject();
    405         flags = ois.readShort();
    406371    }
    407372
  • trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    r19078 r19096  
    8484
    8585    private void writeObject(ObjectOutputStream oos) throws IOException {
    86         // since super class is not Serializable
    87         super.writeObjectCommon(oos);
     86        oos.writeLong(id);
     87        oos.writeLong(user == null ? -1 : user.getId());
     88        oos.writeInt(version);
     89        oos.writeInt(changesetId);
     90        oos.writeInt(timestamp);
     91        oos.writeObject(keys);
     92        oos.writeShort(flags);
    8893        oos.defaultWriteObject();
    8994    }
    9095
    9196    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
    92         // since super class is not Serializable
    93         super.readObjectCommon(ois);
     97        id = ois.readLong();
     98        final long userId = ois.readLong();
     99        user = userId == -1 ? null : User.getById(userId);
     100        version = ois.readInt();
     101        changesetId = ois.readInt();
     102        timestamp = ois.readInt();
     103        keys = (String[]) ois.readObject();
     104        flags = ois.readShort();
    94105        ois.defaultReadObject();
    95106    }
Note: See TracChangeset for help on using the changeset viewer.