Ignore:
Timestamp:
2009-10-27T19:42:44+01:00 (15 years ago)
Author:
pieren
Message:

Modify serialization procedures to get core dependencies out of the cache file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r18289 r18312  
    356356
    357357    /**
    358      * Called by CacheControl when a new cache file is created on disk
     358     * Called by CacheControl when a new cache file is created on disk.
     359     * Save only primitives to keep cache independent of software changes.
    359360     * @param oos
    360361     * @throws IOException
     
    362363    public void write(ObjectOutputStream oos) throws IOException {
    363364        oos.writeInt(this.serializeFormatVersion);
    364         oos.writeObject(this.location);
    365         oos.writeObject(this.codeCommune);
     365        oos.writeObject(this.location);    // String
     366        oos.writeObject(this.codeCommune); // String
    366367        oos.writeInt(this.lambertZone);
    367368        oos.writeBoolean(this.isRaster);
    368369        if (this.isRaster) {
    369             oos.writeObject(this.rasterMin);
    370             oos.writeObject(this.rasterMax);
     370            oos.writeDouble(this.rasterMin.getX());
     371            oos.writeDouble(this.rasterMin.getY());
     372            oos.writeDouble(this.rasterMax.getX());
     373            oos.writeDouble(this.rasterMax.getY());
    371374            oos.writeDouble(this.rasterRatio);
    372375        }
    373         oos.writeObject(this.communeBBox);
    374     }
    375 
    376     /**
    377      * Called by CacheControl when a cache file is read from disk
     376        oos.writeObject(this.communeBBox.min.getX());
     377        oos.writeObject(this.communeBBox.min.getY());
     378        oos.writeObject(this.communeBBox.max.getX());
     379        oos.writeObject(this.communeBBox.max.getY());
     380    }
     381
     382    /**
     383     * Called by CacheControl when a cache file is read from disk.
     384     * Cache uses only primitives to stay independent of software changes.
    378385     * @param ois
    379386     * @throws IOException
     
    392399        this.setRaster(ois.readBoolean());
    393400        if (this.isRaster) {
    394             this.rasterMin = (EastNorth) ois.readObject();
    395             this.rasterMax = (EastNorth) ois.readObject();
     401            double X = ois.readDouble();
     402            double Y = ois.readDouble();
     403            this.rasterMin = new EastNorth(X, Y);
     404            X = ois.readDouble();
     405            Y = ois.readDouble();
     406            this.rasterMax = new EastNorth(X, Y);
    396407            this.rasterRatio = ois.readDouble();
    397408        }
    398         this.communeBBox = (EastNorthBound) ois.readObject();
     409        double minX = ois.readDouble();
     410        double minY = ois.readDouble();
     411        double maxX = ois.readDouble();
     412        double maxY = ois.readDouble();
     413        this.communeBBox =  new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
    399414        if (this.lambertZone != currentLambertZone && currentLambertZone != -1) {
    400415            JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+
Note: See TracChangeset for help on using the changeset viewer.