This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 0fba975 Make Shape implementations serializable. 0fba975 is described below commit 0fba975085fbd89e8f3987835fbeff5d0e7b48d7 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Dec 12 19:36:32 2021 +0100 Make Shape implementations serializable. --- .../sis/internal/feature/j2d/DecimatedShape.java | 5 +++++ .../apache/sis/internal/feature/j2d/EmptyShape.java | 19 ++++++++++++++++++- .../apache/sis/internal/feature/j2d/ShapeWrapper.java | 8 +++++++- .../apache/sis/internal/feature/jts/ShapeAdapter.java | 8 +++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/DecimatedShape.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/DecimatedShape.java index d388918..a29d253 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/DecimatedShape.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/DecimatedShape.java @@ -37,6 +37,11 @@ import java.awt.geom.AffineTransform; */ public final class DecimatedShape extends ShapeWrapper { /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = 3842608333341518892L; + + /** * The desired resolution on each axis. */ private final double xRes, yRes; diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/EmptyShape.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/EmptyShape.java index 5ef0e34..41768f4 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/EmptyShape.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/EmptyShape.java @@ -21,6 +21,8 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; import java.awt.geom.Point2D; +import java.io.Serializable; +import java.io.ObjectStreamException; import java.util.NoSuchElementException; import org.apache.sis.internal.referencing.j2d.AbstractShape; @@ -33,7 +35,12 @@ import org.apache.sis.internal.referencing.j2d.AbstractShape; * @since 1.1 * @module */ -public final class EmptyShape extends AbstractShape implements PathIterator { +public final class EmptyShape extends AbstractShape implements Serializable, PathIterator { + /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = -45089382216341034L; + /** * The unique empty shape instance. */ @@ -61,4 +68,14 @@ public final class EmptyShape extends AbstractShape implements PathIterator { @Override public void next() {throw new NoSuchElementException();} @Override public int currentSegment( float[] coords) {throw new NoSuchElementException();} @Override public int currentSegment(double[] coords) {throw new NoSuchElementException();} + + /** + * Invoked at deserialization time for obtaining the unique instance of this shape. + * + * @return the unique {@code Shape} instance for this class. + * @throws ObjectStreamException if the object state is invalid. + */ + private Object readResolve() throws ObjectStreamException { + return INSTANCE; + } } diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/ShapeWrapper.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/ShapeWrapper.java index 835b027..ad823fd 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/ShapeWrapper.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/j2d/ShapeWrapper.java @@ -22,6 +22,7 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.PathIterator; import java.awt.geom.AffineTransform; +import java.io.Serializable; import org.apache.sis.internal.referencing.j2d.AbstractShape; @@ -34,7 +35,12 @@ import org.apache.sis.internal.referencing.j2d.AbstractShape; * @since 1.2 * @module */ -abstract class ShapeWrapper extends AbstractShape { +abstract class ShapeWrapper extends AbstractShape implements Serializable { + /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = -3917772814285085629L; + /** * The source of coordinate values. */ diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/ShapeAdapter.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/ShapeAdapter.java index e2bbf57..d6427ee 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/ShapeAdapter.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/ShapeAdapter.java @@ -22,6 +22,7 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.PathIterator; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; +import java.io.Serializable; import org.apache.sis.internal.feature.j2d.EmptyShape; import org.apache.sis.internal.referencing.j2d.AbstractShape; import org.apache.sis.internal.referencing.j2d.IntervalRectangle; @@ -47,7 +48,12 @@ import org.locationtech.jts.geom.Point; * @since 1.2 * @module */ -final class ShapeAdapter extends AbstractShape { +final class ShapeAdapter extends AbstractShape implements Serializable { + /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = -8536828815289601141L; + /** * A lightweight JTS geometry factory using the default * {@link org.locationtech.jts.geom.impl.CoordinateArraySequenceFactory}.