This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 9927bf7181878f5e9cb8b20d098bc16e8901d47e Author: Martin Desruisseaux <[email protected]> AuthorDate: Sun Jul 12 18:44:34 2026 +0200 Prepare for promotion of the GeoHEIFF module to the endorsed group of modules, which is still on Java 11. --- .../org/apache/sis/storage/geoheif/ImageModel.java | 3 +- .../apache/sis/storage/geoheif/ImageResource.java | 3 +- .../sis/storage/geoheif/ImageResourceBuilder.java | 3 +- .../sis/storage/geoheif/ResourceBuilder.java | 6 ++-- .../main/org/apache/sis/storage/isobmff/Box.java | 3 +- .../org/apache/sis/storage/isobmff/Reader.java | 3 +- .../org/apache/sis/storage/isobmff/TreeNode.java | 40 +++++++++++++--------- .../apache/sis/storage/isobmff/base/Copyright.java | 3 +- .../sis/storage/isobmff/base/ItemProperties.java | 3 +- .../sis/storage/isobmff/mpeg/ComponentPalette.java | 3 +- 10 files changed, 43 insertions(+), 27 deletions(-) diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageModel.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageModel.java index 544db81dc1..5ccb5f6dec 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageModel.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageModel.java @@ -184,7 +184,8 @@ final class ImageModel { bitsPerSample[band] = bitDepth; numBits += bitDepth; maxBits = Math.max(maxBits, bitDepth); - if (colorType instanceof ComponentType ct) { + if (colorType instanceof ComponentType) { + var ct = (ComponentType) colorType; int mask = 0; if (numBits < Integer.SIZE) { mask = ((1 << bitDepth) - 1) << (Integer.SIZE - numBits); diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java index 5b8133f65f..a431290c32 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java @@ -377,7 +377,8 @@ final class ImageResource extends TiledGridCoverageResource implements StoreReso * <p><b>Note:</b> this is defined as an inner class of {@link TiledGridCoverage} subclass * because, at the time of writing this class, {@link AOI} is a protected class.</p> */ - static final class ReadContext extends ByteRanges { + // TODO: make static when allowed to compile with JDK12 (exact version not verified). + final class ReadContext extends ByteRanges { /** * Iterator over the tiles to read. */ diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResourceBuilder.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResourceBuilder.java index 33251f7b1d..2735049410 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResourceBuilder.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResourceBuilder.java @@ -395,7 +395,8 @@ final class ImageResourceBuilder implements Emptiable { for (Object id : unknownBoxes.keySet()) { if (id == null) { id = "unidentified boxes"; - } else if (id instanceof Integer fourCC) { + } else if (id instanceof Integer) { + final var fourCC = (Integer) id; id = Box.formatFourCC(fourCC); } sj.add(id.toString()); diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ResourceBuilder.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ResourceBuilder.java index 3d572ed8e9..6d90f99c24 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ResourceBuilder.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ResourceBuilder.java @@ -526,7 +526,8 @@ final class ResourceBuilder { */ for (final GroupList box : groups) { for (Box child : box.children) { - if (child instanceof EntityToGroup group) { // Should be the type of all children. + if (child instanceof EntityToGroup) { // Should be the type of all children. + final var group = (EntityToGroup) child; final GenericName name = store.createComponentName(getResourceName(group.groupID, Vocabulary.Keys.Group_1)); final var components = new ArrayList<ImageResource>(group.entityID.length); for (int entityID : group.entityID) { @@ -545,7 +546,8 @@ final class ResourceBuilder { case 1: resource = components.get(0); break; default: { final var grids = components.toArray(ImageResource[]::new); - if (child instanceof ImagePyramid pyramid) { + if (child instanceof ImagePyramid) { + final var pyramid = (ImagePyramid) child; resource = new PyramidedImageResource(store, name, pyramid, grids); } else { resource = new Group(store, name, grids); diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Box.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Box.java index 2c69492d73..d8d708480c 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Box.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Box.java @@ -94,7 +94,8 @@ public abstract class Box extends TreeNode { public String typeName() { String name = super.typeName(); Object type = typeKey(); - if (type instanceof Integer fourCC) { + if (type instanceof Integer) { + final var fourCC = (Integer) type; type = formatFourCC(fourCC); } if (type != null) { diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Reader.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Reader.java index 4e6fd5044d..cdebf7954d 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Reader.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/Reader.java @@ -344,7 +344,8 @@ public final class Reader implements Cloneable { */ final void unknownBoxType(Object type) { if (isNewWarning(type, null)) { - if (type instanceof Integer fourCC) { + if (type instanceof Integer) { + final var fourCC = (Integer) type; type = Box.formatFourCC(fourCC); } warning(Resources.Keys.UnsupportedBoxType_1, type); diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/TreeNode.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/TreeNode.java index 690b5e74d1..8aaa4e98bf 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/TreeNode.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/TreeNode.java @@ -132,16 +132,16 @@ public abstract class TreeNode { * @return the formatted value, or {@code null} if absent. */ String format(final TreeBuilder tree, Number value) { - switch (value) { - case Byte i: value = Byte .toUnsignedInt (i); break; - case Short i: value = Short .toUnsignedInt (i); break; - case Integer i: value = Integer.toUnsignedLong(i); break; - default: { - final long n = value.longValue(); - if (n < 0) { - value = new BigInteger(Long.toUnsignedString(n)); - } - break; + if (value instanceof Byte) { + value = Byte.toUnsignedInt((Byte) value); + } else if (value instanceof Short) { + value = Short.toUnsignedInt((Short) value); + } else if (value instanceof Integer) { + value = Integer.toUnsignedLong((Integer) value); + } else { + final long n = value.longValue(); + if (n < 0) { + value = new BigInteger(Long.toUnsignedString(n)); } } return tree.integerFormat.format(value); @@ -186,12 +186,17 @@ public abstract class TreeNode { * @return the formatted value. */ static String formatUnsigned(final Number value) { - return Long.toUnsignedString(switch (value) { - case Byte i -> Byte .toUnsignedLong(i); - case Short i -> Short .toUnsignedLong(i); - case Integer i -> Integer.toUnsignedLong(i); - default -> value.longValue(); - }); + final long n; + if (value instanceof Byte) { + n = Byte.toUnsignedLong((Byte) value); + } else if (value instanceof Short) { + n = Short.toUnsignedLong((Short) value); + } else if (value instanceof Integer) { + n = Integer.toUnsignedLong((Integer) value); + } else { + n = value.longValue(); + } + return Long.toUnsignedString(n); } /** @@ -483,7 +488,8 @@ public abstract class TreeNode { * Identifier codes will be converted to their four-character code (4CC) representations. * The fields to convert to 4CC are identified by the `@Interpretation` annotation. */ - if (value instanceof TreeNode addTo) { + if (value instanceof TreeNode) { + final var addTo = (TreeNode) value; appendProperties(addTo, addNode(target, camelCaseToWords(field), addTo, null)); } else { final Interpretation itpr = field.getAnnotation(Interpretation.class); diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/Copyright.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/Copyright.java index 71dda112e1..e7ff4e60e6 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/Copyright.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/Copyright.java @@ -24,6 +24,7 @@ import org.apache.sis.storage.metadata.MetadataBuilder; import org.apache.sis.storage.isobmff.FullBox; import org.apache.sis.storage.isobmff.Reader; import org.apache.sis.storage.isobmff.UnsupportedVersionException; +import org.apache.sis.pending.jdk.JDK19; /** @@ -77,7 +78,7 @@ public final class Copyright extends FullBox { code[i] = (byte) ((packed & 0b111) + 0x60); packed >>>= 3; } - language = Locale.of(new String(code, StandardCharsets.US_ASCII)); + language = JDK19.localeOf(new String(code, StandardCharsets.US_ASCII)); notice = reader.readNullTerminatedString(true); } diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/ItemProperties.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/ItemProperties.java index 25eecba05a..55f3f1b8fa 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/ItemProperties.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/base/ItemProperties.java @@ -135,7 +135,8 @@ public final class ItemProperties extends ContainerBox { */ @Override public boolean equals(final Object obj) { - if (obj instanceof ForID other) { + if (obj instanceof ForID) { + final var other = (ForID) obj; return super.equals(other) && essentials.equals(other.essentials) && missingItem == other.missingItem diff --git a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/mpeg/ComponentPalette.java b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/mpeg/ComponentPalette.java index d4e4add2cd..55eb28cd8a 100644 --- a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/mpeg/ComponentPalette.java +++ b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/isobmff/mpeg/ComponentPalette.java @@ -121,7 +121,8 @@ public final class ComponentPalette extends FullBox { for (int band=0; band<n; band++) { final Component c = components[band]; final Object type = c.type; - if (type instanceof ComponentType ct) { + if (type instanceof ComponentType) { + final var ct = (ComponentType) type; final int shift; switch (ct) { case ALPHA: shift = 3; break;
