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
commit 55da1f76fb0034ffa4317fc5c52d3809d92f915d Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Jul 17 12:11:08 2023 +0200 Fix a few more compilation warnings (other than deprecation): unchecked types, varargs, lossy implicit conversion, serial, etc. --- .../apache/sis/feature/builder/AttributeTypeBuilder.java | 1 + .../sis/internal/feature/jts/GeometryTransform.java | 4 ++-- .../apache/sis/internal/jaxb/gco/GO_CharacterString.java | 4 +++- .../org/apache/sis/internal/jaxb/gco/Multiplicity.java | 3 ++- .../java/org/apache/sis/internal/jaxb/gco/NameValue.java | 7 +++++++ .../org/apache/sis/internal/jaxb/gco/UnitAdapter.java | 7 +++++-- .../apache/sis/internal/jaxb/geometry/ObjectFactory.java | 6 ++++++ .../org/apache/sis/internal/metadata/MetadataTypes.java | 6 ++++++ .../apache/sis/metadata/sql/IdentifierGeneratorTest.java | 1 - .../org/apache/sis/internal/map/ListChangeEvent.java | 4 +++- .../java/org/apache/sis/internal/map/SEPortrayer.java | 16 ++++++++-------- .../java/org/apache/sis/internal/map/SEPresentation.java | 8 ++++---- .../org/apache/sis/internal/map/SymbologyVisitor.java | 8 ++++---- .../org/apache/sis/internal/map/SEPortrayerTest.java | 6 ++---- .../java/org/apache/sis/portrayal/MapLayersTest.java | 4 ++-- .../sis/referencing/gazetteer/FinalLocationType.java | 9 +++++++++ .../referencing/gazetteer/GeohashReferenceSystem.java | 1 + .../gazetteer/MilitaryGridReferenceSystem.java | 6 +++--- .../sis/internal/jaxb/referencing/RS_Identifier.java | 6 ++++++ .../sis/internal/referencing/ReferencingTypes.java | 6 ++++++ .../apache/sis/internal/referencing/provider/NADCON.java | 1 + .../java/org/apache/sis/parameter/TensorParameters.java | 2 +- .../sis/referencing/factory/sql/EPSGDataAccess.java | 2 ++ .../internal/referencing/provider/MolodenskyTest.java | 1 + .../operation/transform/MathTransformWrapper.java | 1 + .../java/org/apache/sis/internal/jdk17/HexFormat.java | 5 ++++- .../main/java/org/apache/sis/internal/jdk17/JDK17.java | 9 +++++++++ .../sis/internal/temporal/DefaultTemporalFactory.java | 1 + .../java/org/apache/sis/internal/util/AbstractMap.java | 11 ++++++++++- .../org/apache/sis/internal/util/CollectionsExt.java | 2 ++ .../main/java/org/apache/sis/internal/util/Numerics.java | 6 +++--- .../src/main/java/org/apache/sis/math/ArrayVector.java | 5 ++++- .../main/java/org/apache/sis/measure/AngleFormat.java | 4 ++-- .../src/main/java/org/apache/sis/util/Locales.java | 1 + .../java/org/apache/sis/util/collection/Containers.java | 1 + .../org/apache/sis/util/collection/TreeTableFormat.java | 3 +-- ide-project/NetBeans/nbproject/project.properties | 2 +- .../apache/sis/internal/profile/fra/ProfileTypes.java | 6 ++++++ .../java/org/apache/sis/storage/geotiff/XMLMetadata.java | 5 +++++ .../apache/sis/internal/sql/postgis/ExtentEstimator.java | 6 +++--- .../org/apache/sis/internal/sql/postgis/Postgres.java | 2 ++ .../java/org/apache/sis/storage/sql/SQLStoreTest.java | 8 ++++---- .../apache/sis/internal/storage/wkt/StoreProvider.java | 8 ++++---- .../main/java/org/apache/sis/storage/FeatureQuery.java | 1 + .../sis/internal/storage/xml/stream/StaxDataStore.java | 10 +++++----- .../sis/internal/storage/xml/stream/StaxStreamIO.java | 8 +++++--- .../internal/storage/xml/stream/StaxStreamReader.java | 3 ++- .../internal/storage/xml/stream/StaxStreamWriter.java | 3 ++- 48 files changed, 164 insertions(+), 66 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java index 15acc606d4..3ecf905bc5 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java +++ b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java @@ -360,6 +360,7 @@ public final class AttributeTypeBuilder<V> extends PropertyTypeBuilder { * @see #characteristics() */ @SafeVarargs + @SuppressWarnings("varargs") public final AttributeTypeBuilder<V> setValidValues(final V... values) { return setCharacteristic(AttributeConvention.VALID_VALUES_CHARACTERISTIC, Set.class, CollectionsExt.immutableSet(false, values)); diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/GeometryTransform.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/GeometryTransform.java index b72499aba2..6f4d9887f0 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/GeometryTransform.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/GeometryTransform.java @@ -164,10 +164,10 @@ public abstract class GeometryTransform { * @throws TransformException if an error occurred while transforming the geometry. */ public Polygon transform(final Polygon geom) throws TransformException { - final LinearRing exterior = transform((LinearRing) geom.getExteriorRing()); + final LinearRing exterior = transform(geom.getExteriorRing()); final LinearRing[] holes = new LinearRing[geom.getNumInteriorRing()]; for (int i = 0; i < holes.length; i++) { - holes[i] = transform((LinearRing) geom.getInteriorRingN(i)); + holes[i] = transform(geom.getInteriorRingN(i)); } return geometryFactory.createPolygon(exterior, holes); } diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java index 053aeb455d..b3ba10e5fa 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java @@ -297,7 +297,9 @@ public class GO_CharacterString { if (ct != null && CodeList.class.isAssignableFrom(ct)) { final String attribute = e.getAttribute("codeListValue").trim(); if (!attribute.isEmpty()) { - text = Types.getCodeTitle(Types.forCodeName((Class) ct, attribute, true)); + @SuppressWarnings("unchecked") + final CodeList<?> c = Types.forCodeName((Class) ct, attribute, true); + text = Types.getCodeTitle(c); type = ENUM; return; } else { diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/Multiplicity.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/Multiplicity.java index 88d4512cda..4d02a7dc12 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/Multiplicity.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/Multiplicity.java @@ -72,8 +72,9 @@ public final class Multiplicity { * @param ranges the ranges. */ @SafeVarargs + @SuppressWarnings("varargs") public Multiplicity(final NumberRange<Integer>... ranges) { - this.range = Arrays.asList(ranges); + range = Arrays.asList(ranges); } /** diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/NameValue.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/NameValue.java index 32591a16ec..a9a654c629 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/NameValue.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/NameValue.java @@ -108,6 +108,10 @@ public class NameValue { */ @XmlRootElement(name = "LocalName") public static final class Local extends NameValue { + /** Invoked by reflection by JAXB on unmarshalling. */ + public Local() { + } + @Override public GenericName getName() { return Names.createLocalName(codeSpace, null, value); } @@ -118,5 +122,8 @@ public class NameValue { */ @XmlRootElement(name = "ScopedName") public static final class Scoped extends NameValue { + /** Invoked by reflection by JAXB on unmarshalling. */ + public Scoped() { + } } } diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java index 15dc475a84..dfafc1299f 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java @@ -73,8 +73,11 @@ public class UnitAdapter extends XmlAdapter<String, Unit<?>> { * code for the degrees. See {@link org.apache.sis.measure.Units#getEpsgCode(Unit, boolean)} for more information. */ public static final class ForCS extends UnitAdapter { - @Override - public String marshal(final Unit<?> value) { + /** Empty constructor used only by JAXB. */ + public ForCS() { + } + + @Override public String marshal(final Unit<?> value) { return Measure.getUOM(value, false, true); } } diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java index 69396bb939..15f88eda75 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java @@ -50,6 +50,12 @@ public class ObjectFactory { */ protected static final QName AbstractObject_QNAME = new QName(Namespaces.GML, "AbstractObject"); + /** + * Creates a default factory. + */ + public ObjectFactory() { + } + /** * Creates an instance of {@code JAXBElement<Object>}}. * diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java index f3130a96c3..efb79234b6 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java @@ -48,6 +48,12 @@ import org.opengis.metadata.spatial.Georeferenceable; * @since 0.3 */ public final class MetadataTypes extends TypeRegistration implements UnaryOperator<Object> { + /** + * Creates a default provider of additional classes to register. + */ + public MetadataTypes() { + } + /** * Adds to the given collection the metadata types that should be given to the initial JAXB context. */ diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java index 0223c9a750..7f6fe31c45 100644 --- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java +++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java @@ -77,7 +77,6 @@ public final class IdentifierGeneratorTest extends TestCase { stmt.executeUpdate("DROP TABLE \"" + TABLE + '"'); stmt.close(); generator.close(); - source.close(); } } } diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/ListChangeEvent.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/ListChangeEvent.java index d7602d64f9..335dd0fa93 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/ListChangeEvent.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/ListChangeEvent.java @@ -16,10 +16,11 @@ */ package org.apache.sis.internal.map; -import java.beans.PropertyChangeEvent; import java.util.List; +import java.beans.PropertyChangeEvent; import org.apache.sis.measure.NumberRange; + /** * Event generated by modified list properties. * @@ -27,6 +28,7 @@ import org.apache.sis.measure.NumberRange; * @version 1.5 * @since 1.5 */ +@SuppressWarnings("serial") // TODO public final class ListChangeEvent<T> extends PropertyChangeEvent { public enum Type { diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java index d7af50d65c..e48e11baa2 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java @@ -131,11 +131,11 @@ public final class SEPortrayer { */ private boolean preserveProperties; - private BiFunction<GridGeometry, Symbolizer, Double> marginSolver; + private BiFunction<GridGeometry, Symbolizer<?>, Double> marginSolver; public SEPortrayer() { filterFactory = DefaultFilterFactory.forFeatures(); - marginSolver = (GridGeometry t, Symbolizer u) -> 30.0; + marginSolver = (GridGeometry t, Symbolizer<?> u) -> 30.0; } /** @@ -165,7 +165,7 @@ public final class SEPortrayer { * The margin solver try to guess the expected symbolizer size to expand the query bounding box. * @param marginSolver */ - public void setMarginSolver(BiFunction<GridGeometry, Symbolizer, Double> marginSolver) { + public void setMarginSolver(BiFunction<GridGeometry, Symbolizer<?>, Double> marginSolver) { ArgumentChecks.ensureNonNull("marginSolver", marginSolver); this.marginSolver = marginSolver; } @@ -254,10 +254,10 @@ public final class SEPortrayer { final int elseRuleIndex = sortByElseRule(rules); { //special case for resource symbolizers //resource symbolizers must be alone in a FTS - ResourceSymbolizer resourceSymbolizer = null; + ResourceSymbolizer<?> resourceSymbolizer = null; int count = 0; for (final Rule<Feature> r : rules) { - for (final Symbolizer s : r.symbolizers()) { + for (final Symbolizer<?> s : r.symbolizers()) { count++; if (s instanceof ResourceSymbolizer) { resourceSymbolizer = (ResourceSymbolizer) s; @@ -312,7 +312,7 @@ public final class SEPortrayer { // Calculate max symbol size, to expand search envelope. double symbolsMargin = 0.0; for (Rule<Feature> rule : rules) { - for (Symbolizer symbolizer : rule.symbolizers()) { + for (Symbolizer<?> symbolizer : rule.symbolizers()) { symbolsMargin = Math.max(symbolsMargin, marginSolver.apply(canvas, symbolizer)); } } @@ -366,7 +366,7 @@ public final class SEPortrayer { //test if the rule is valid for this resource/feature if (rule.isElseFilter() || ((Filter) ruleFilter).test(feature == null ? resource : feature)) { // TODO: unsafe cast. Stream<Presentation> stream = Stream.empty(); - for (final Symbolizer symbolizer : rule.symbolizers()) { + for (final Symbolizer<?> symbolizer : rule.symbolizers()) { final SEPresentation presentation = new SEPresentation(layer, refResource, feature, symbolizer); stream = Stream.concat(stream, Stream.of(presentation)); } @@ -403,7 +403,7 @@ public final class SEPortrayer { final Set<Expression<Feature,?>> geomProperties = new HashSet<>(); if (rules != null) { for (final Rule<Feature> r : rules) { - for (final Symbolizer s : r.symbolizers()) { + for (final Symbolizer<Feature> s : r.symbolizers()) { final Expression<Feature,?> expGeom = s.getGeometry(); if (expGeom != null) { geomProperties.add(expGeom ); diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPresentation.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPresentation.java index 7df7cf5f05..7f8ce00496 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPresentation.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPresentation.java @@ -38,12 +38,12 @@ import org.opengis.feature.Feature; */ public final class SEPresentation extends Presentation { - private Symbolizer symbolizer; + private Symbolizer<?> symbolizer; public SEPresentation() { } - public SEPresentation(MapLayer layer, Resource resource, Feature candidate, Symbolizer symbolizer) { + public SEPresentation(MapLayer layer, Resource resource, Feature candidate, Symbolizer<?> symbolizer) { super(layer, resource, candidate); this.symbolizer = symbolizer; } @@ -51,11 +51,11 @@ public final class SEPresentation extends Presentation { /** * @return Symbogy Encoding symbolizer */ - public Symbolizer getSymbolizer() { + public Symbolizer<?> getSymbolizer() { return symbolizer; } - public void setSymbolizer(Symbolizer symbolizer) { + public void setSymbolizer(Symbolizer<?> symbolizer) { this.symbolizer = symbolizer; } diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SymbologyVisitor.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SymbologyVisitor.java index caf767c282..800865d90e 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SymbologyVisitor.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SymbologyVisitor.java @@ -148,7 +148,7 @@ abstract class SymbologyVisitor { } } - protected void visit(final GraphicalSymbol candidate) { + protected void visit(final GraphicalSymbol<?> candidate) { if (candidate instanceof Mark) { visit((Mark) candidate); } else if (candidate instanceof ExternalGraphic) { @@ -183,7 +183,7 @@ abstract class SymbologyVisitor { } } - protected void visit(final Description candidate) { + protected void visit(final Description<?> candidate) { } protected void visit(final Displacement<?> candidate) { @@ -222,7 +222,7 @@ abstract class SymbologyVisitor { } } - protected void visit(final LabelPlacement candidate) { + protected void visit(final LabelPlacement<?> candidate) { if (candidate instanceof PointPlacement) { visit((PointPlacement) candidate); } else if (candidate instanceof LinePlacement) { @@ -280,7 +280,7 @@ abstract class SymbologyVisitor { protected void visit(final ChannelSelection<?> candidate) { if (candidate != null) { - SelectedChannel[] channels = candidate.getChannels(); + SelectedChannel<?>[] channels = candidate.getChannels(); if (channels != null) { for (final SelectedChannel<?> sct : channels) { visit(sct); diff --git a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java index c7d3d091d6..b5e041560f 100644 --- a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java +++ b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java @@ -66,7 +66,6 @@ import org.locationtech.jts.geom.Polygon; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; import org.opengis.filter.BinaryComparisonOperator; -import org.opengis.filter.Expression; import org.opengis.filter.Filter; import org.opengis.filter.FilterFactory; import org.opengis.filter.MatchAction; @@ -648,8 +647,7 @@ public class SEPortrayerTest extends TestCase { true, MatchAction.ANY); final var symbolizer = factory.createLineSymbolizer(); - symbolizer.setPerpendicularOffset((Expression)filterFactory.property("description", String.class)); - // TODO: use a numeric property above. + symbolizer.setPerpendicularOffset(filterFactory.property("offset", Integer.class)); final var rule = factory.createRule(); rule.symbolizers().add(symbolizer); @@ -678,7 +676,7 @@ public class SEPortrayerTest extends TestCase { final SEPresentation presentation = (SEPresentation) presentations.get(0); final Feature feature = presentation.getCandidate(); final FeatureType type = feature.getType(); - assertEquals(4, type.getProperties(true).size()); + assertEquals(6, type.getProperties(true).size()); assertNotNull(type.getProperty(AttributeConvention.IDENTIFIER)); assertNotNull(type.getProperty(AttributeConvention.GEOMETRY)); assertNotNull(type.getProperty("id")); diff --git a/core/sis-portrayal/src/test/java/org/apache/sis/portrayal/MapLayersTest.java b/core/sis-portrayal/src/test/java/org/apache/sis/portrayal/MapLayersTest.java index 3276f1f952..655f00d611 100644 --- a/core/sis-portrayal/src/test/java/org/apache/sis/portrayal/MapLayersTest.java +++ b/core/sis-portrayal/src/test/java/org/apache/sis/portrayal/MapLayersTest.java @@ -47,8 +47,8 @@ public class MapLayersTest extends TestCase { layers.addPropertyChangeListener(MapLayers.COMPONENTS_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - assertTrue(evt instanceof ListChangeEvent); - final ListChangeEvent levt = (ListChangeEvent) evt; + assertTrue(evt instanceof ListChangeEvent<?>); + final ListChangeEvent<?> levt = (ListChangeEvent<?>) evt; assertEquals(layers.getComponents(), levt.getOldValue()); assertEquals(layers.getComponents(), levt.getNewValue()); assertEquals(MapLayers.COMPONENTS_PROPERTY, levt.getPropertyName()); diff --git a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java index e3d67f2b0f..966f5ff70f 100644 --- a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java +++ b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java @@ -53,49 +53,58 @@ final class FinalLocationType extends AbstractLocationType implements Serializab /** * Name of the location type. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final InternationalString name; /** * Property used as the defining characteristic of the location type. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final InternationalString theme; /** * Method(s) of uniquely identifying location instances. * This list is unmodifiable. */ + @SuppressWarnings("serial") private final List<InternationalString> identifications; /** * The way in which location instances are defined. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final InternationalString definition; /** * The reference system that comprises this location type. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final ReferenceSystemUsingIdentifiers referenceSystem; /** * Geographic area within which the location type occurs. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final GeographicExtent territoryOfUse; /** * Name of organization or class of organization able to create and destroy location instances. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. private final Party owner; /** * Parent location types (location types of which this location type is a sub-division). * This list is unmodifiable. */ + @SuppressWarnings("serial") private final List<LocationType> parents; /** * Child location types (location types which sub-divides this location type). * This list is unmodifiable. */ + @SuppressWarnings("serial") final List<LocationType> children; /** diff --git a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java index 66fdd31299..849bfcf571 100644 --- a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java +++ b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java @@ -155,6 +155,7 @@ public class GeohashReferenceSystem extends ReferencingByIdentifiers { * The coordinate operation from {@link #normalizedCRS} to the CRS specified by the user. * The target CRS is the coordinate reference system to assign to the decoded positions. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. final CoordinateOperation denormalize; /** diff --git a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java index 046d73daf9..483b63a2a6 100644 --- a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java +++ b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java @@ -167,7 +167,7 @@ public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers { /** * Size of the 100 kilometres squares, in metres. */ - static final double GRID_SQUARE_SIZE = 100_000; + static final int GRID_SQUARE_SIZE = 100_000; /** * Number of letters available for grid rows. Those letters are "ABCDEFGHJKLMNPQRSTUV" (starting at letter @@ -821,9 +821,9 @@ public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers { org.apache.sis.internal.referencing.Resources.Keys.NonHorizontalCRS_1, "areaOfInterest")); } final int precision = (int) getPrecision(); - if (precision <= 0 || precision > (int) GRID_SQUARE_SIZE) { + if (precision <= 0 || precision > GRID_SQUARE_SIZE) { throw new GazetteerException(Errors.format(Errors.Keys.ValueOutOfRange_4, - "precision", 1, (int) GRID_SQUARE_SIZE, precision)); + "precision", 1, GRID_SQUARE_SIZE, precision)); } /* * Convert area of interest (AOI) from an envelope to a Rectangle2D for use with diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java index 61353742c7..b1d66bd1d2 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java @@ -61,6 +61,12 @@ import org.opengis.metadata.Identifier; * @since 0.4 */ public final class RS_Identifier extends XmlAdapter<Code, Identifier> { + /** + * Empty constructor for JAXB. + */ + public RS_Identifier() { + } + /** * Substitutes the wrapper value read from an XML stream by the object which will * represents the identifier. JAXB calls automatically this method at unmarshalling time. diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java index 0f663d2857..88788b4593 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java @@ -35,6 +35,12 @@ import org.opengis.referencing.ReferenceSystem; * @since 0.4 */ public final class ReferencingTypes extends TypeRegistration implements UnaryOperator<Object> { + /** + * Creates a default provider of additional types to register. + */ + public ReferencingTypes() { + } + /** * Adds to the given collection the referencing types that should be given to the initial JAXB context. */ diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java index 6d3a40ecd3..38ae33d765 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java @@ -385,6 +385,7 @@ public final class NADCON extends AbstractProvider { * @param latitudeShifts the previously loaded latitude shifts, or {@code null} if not yet loaded. * @param longitudeShifts the file for the longitude grid. */ + @SuppressWarnings("lossy-conversions") // Implicit cast from double to float in compound assignment. final void readGrid(final FloatBuffer fb, final Loader latitudeShifts, final URI longitudeShifts) throws IOException, FactoryException, NoninvertibleTransformException { diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java index 893e4e66d1..46d91a750c 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java @@ -317,7 +317,7 @@ public class TensorParameters<E> implements Serializable { * Length may be different if the caller wants to generalize usage of this class to tensors. */ @SafeVarargs - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes", "varargs"}) public TensorParameters(final Class<E> elementType, final String prefix, final String separator, final ParameterDescriptor<Integer>... dimensions) { diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java index ef4980a619..10d4c9b31c 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java @@ -1347,6 +1347,7 @@ codes: for (int i=0; i<codes.length; i++) { * @throws FactoryException if the object creation failed for some other reason. */ @Override + @SuppressWarnings("try") // Explicit call to close() on an auto-closeable resource. public synchronized CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws NoSuchAuthorityCodeException, FactoryException { @@ -2811,6 +2812,7 @@ next: while (r.next()) { * @throws FactoryException if the object creation failed for some other reason. */ @Override + @SuppressWarnings("try") // Explicit call to close() on an auto-closeable resource. public synchronized CoordinateOperation createCoordinateOperation(final String code) throws NoSuchAuthorityCodeException, FactoryException { diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MolodenskyTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MolodenskyTest.java index 4bea39c1a0..4905afd09c 100644 --- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MolodenskyTest.java +++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MolodenskyTest.java @@ -42,6 +42,7 @@ public final class MolodenskyTest extends TestCase { /** * Implementation of {@link #testRedimension()} to be shared with other provider having similar capability. */ + @SuppressWarnings("deprecation") static void testRedimension(final AbstractProvider provider) { for (int sourceDimensions = 2; sourceDimensions <= 3; sourceDimensions++) { for (int targetDimensions = 2; targetDimensions <= 3; targetDimensions++) { diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java index dd9a3d3517..8bc6f9cf47 100644 --- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java +++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java @@ -54,6 +54,7 @@ public class MathTransformWrapper extends FormattableObject implements MathTrans /** * The math transform on which to delegate the work. */ + @SuppressWarnings("serial") // Most Apache SIS implementations are serializable. public final MathTransform transform; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/HexFormat.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/HexFormat.java index 7b34e540c5..73d823b230 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/HexFormat.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/HexFormat.java @@ -32,6 +32,9 @@ public final class HexFormat { private HexFormat() { } + /** + * {@return the singleton instance}. + */ public static HexFormat of() { return INSTANCE; } @@ -56,7 +59,7 @@ public final class HexFormat { } /** - * Returns the numerical value of the given hexadecimal digit. + * {@return the numerical value of the given hexadecimal digit}. * The hexadecimal digit can be the decimal digits 0 to 9, or the letters A to F ignoring case. * * <h4>Implementation note</h4> diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/JDK17.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/JDK17.java index f85d090852..ffc1bb6813 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/JDK17.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk17/JDK17.java @@ -67,6 +67,10 @@ public final class JDK17 { /** * Place holder for {@link InputStream#skipNBytes(long)} method added in JDK12. + * + * @param s the input stream where to skip bytes. + * @param n the number of bytes to skip. + * @throws IOException if an error occurred while reading bytes, including EOF. */ public static void skipNBytes(final InputStream s, long n) throws IOException { while (n > 0) { @@ -83,7 +87,12 @@ public final class JDK17 { /** * Place holder for {@link Stream#toList()} method added in JDK16. + * + * @param <T> type of elements in the stream. + * @param s the stream to convert to a list. + * @return the stream content as a list. */ + @SuppressWarnings("unchecked") public static <T> List<T> toList(final Stream<T> s) { return (List<T>) UnmodifiableArrayList.wrap(s.toArray()); } diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/temporal/DefaultTemporalFactory.java b/core/sis-utility/src/main/java/org/apache/sis/internal/temporal/DefaultTemporalFactory.java index c69ef42d31..11dcb68ead 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/temporal/DefaultTemporalFactory.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/temporal/DefaultTemporalFactory.java @@ -108,6 +108,7 @@ public final class DefaultTemporalFactory implements TemporalFactory { } /** Unsupported. */ + @SuppressWarnings("rawtypes") @Override public IntervalLength createIntervalLenght(Unit unit, int radix, int factor, int value) { throw unsupported(); } diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java index aa69eb3d24..617eba6302 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java @@ -85,6 +85,12 @@ public abstract class AbstractMap<K,V> implements Map<K,V> { * @see AbstractMap#entryIterator() */ protected abstract static class EntryIterator<K,V> { + /** + * Creates a new iterator. + */ + protected EntryIterator() { + } + /** * Moves the iterator to the next position, and returns {@code true} if there is at least one remaining element. * @@ -148,7 +154,10 @@ public abstract class AbstractMap<K,V> implements Map<K,V> { * @param keys all keys that the map may possibly contain. */ @SafeVarargs - public KeyIterator(final K... keys) {this.keys = keys;} + @SuppressWarnings("varargs") + public KeyIterator(final K... keys) { + this.keys = keys; + } /** * Moves to the next key associated to a non-null value. diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java index 542fa80b35..f4970f85df 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java @@ -200,6 +200,7 @@ public final class CollectionsExt extends Static { */ @SafeVarargs public static <T> Set<T> nonEmptySet(final T... elements) { + @SuppressWarnings("varargs") final Set<T> asSet = immutableSet(true, elements); return (asSet != null && asSet.isEmpty()) ? null : asSet; } @@ -366,6 +367,7 @@ public final class CollectionsExt extends Static { return Collections.emptySet(); } default: { + @SuppressWarnings("varargs") final Set<E> set = new LinkedHashSet<>(Arrays.asList(array)); if (excludeNull) { set.remove(null); diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java index f1f7b8ec14..e02c067420 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java @@ -28,12 +28,12 @@ import org.apache.sis.math.DecimalFunctions; import org.apache.sis.math.MathFunctions; import org.apache.sis.math.Statistics; import org.apache.sis.math.Fraction; +import org.apache.sis.internal.system.Configuration; import static java.lang.Math.min; import static java.lang.Math.max; import static java.lang.Math.abs; import static java.lang.Math.ulp; -import org.apache.sis.internal.system.Configuration; /** @@ -543,9 +543,9 @@ public final class Numerics extends Static { public static int getSignificand(final float value) { int bits = Float.floatToRawIntBits(value); final int exponent = bits & (0xFF << SIGNIFICAND_SIZE_OF_FLOAT); - bits &= (1L << SIGNIFICAND_SIZE_OF_FLOAT) - 1; + bits &= (1 << SIGNIFICAND_SIZE_OF_FLOAT) - 1; if (exponent != 0) { - bits |= (1L << SIGNIFICAND_SIZE_OF_FLOAT); + bits |= (1 << SIGNIFICAND_SIZE_OF_FLOAT); } else { bits <<= 1; } diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java b/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java index e2c830ad7f..a285d44643 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java +++ b/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java @@ -1249,7 +1249,11 @@ abstract class ArrayVector<E extends Number> extends Vector implements CheckedCo /** * A vector backed by an array of type {@code Number[]}. + * The parameterized type should be {@code <? extends Number>}, + * but using {@code <Number>} for simplicity is okay since this class is private + * and this specific type is forgotten immediately after {@code Raw} construction. */ + @SuppressWarnings({"unchecked", "rawtypes"}) private static final class Raw extends ArrayVector<Number> { /** For cross-version compatibility. */ private static final long serialVersionUID = 5444263017359778157L; @@ -1263,7 +1267,6 @@ abstract class ArrayVector<E extends Number> extends Vector implements CheckedCo } /** Returns the type of elements in the backing array. */ - @SuppressWarnings({"unchecked", "rawtypes"}) @Override public final Class getElementType() { return array.getClass().getComponentType(); } diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java b/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java index 4665a1f64f..f8b5843215 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java @@ -529,7 +529,7 @@ public class AngleFormat extends Format implements Localized { if (--endPreviousSuffix == endPreviousField) { throw illegalPattern(pattern); } - optionalFields |= (1 << (field - 1)); + optionalFields |= (byte) (1 << (field - 1)); } previousSuffix = pattern.substring(endPreviousField, endPreviousSuffix); } @@ -592,7 +592,7 @@ public class AngleFormat extends Format implements Localized { if (--endPreviousSuffix == endPreviousField) { throw illegalPattern(pattern); } - optionalFields |= (1 << expectedField); + optionalFields |= (byte) (1 << expectedField); } final String suffix = pattern.substring(endPreviousField, endPreviousSuffix); switch (expectedField) { diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java b/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java index bb01a2872b..277c5456ae 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java @@ -336,6 +336,7 @@ filter: for (final Locale locale : locales) { * @param n initial bit pattern, either {@link #LANGUAGE} or {@link #COUNTRY}. * @return a number for the given code, or 0 if a non alpha characters were found. */ + @SuppressWarnings("lossy-conversions") // Okay because we shift no more than 15 bits. private static short toNumber(final String code, short n) { final int length = code.length(); if (length >= 1 && length <= 3) { diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java index 4ddc0e2181..896431c11c 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java @@ -94,6 +94,7 @@ public final class Containers extends Static { * @see java.util.Arrays#asList(Object[]) */ @SafeVarargs + @SuppressWarnings("varargs") public static <E> List<? extends E> unmodifiableList(final E... array) { return UnmodifiableArrayList.wrap(array); } diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java index 5aa7e23416..00f67bee05 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java @@ -159,11 +159,10 @@ public class TreeTableFormat extends TabularFormat<TreeTable> { * A filter for specifying whether a node should be formatted, or {@code null} if no filtering is applied. * This is ignored at parsing time. * - * <p>A non-null value may cause the serialization to fail.</p> - * * @see #getNodeFilter() * @see #setNodeFilter(Predicate) */ + @SuppressWarnings("serial") // Serialization of lambda functions is possible (but discouraged). private Predicate<TreeTable.Node> nodeFilter; /** diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties index 1b9cd613ed..64aafc0ad4 100644 --- a/ide-project/NetBeans/nbproject/project.properties +++ b/ide-project/NetBeans/nbproject/project.properties @@ -211,7 +211,7 @@ javafx.options= # The "compile.on.save" property must be 'false' for enabling the use of "../build.xml" file. # compile.on.save = false -javac.compilerargs = -Xdoclint:syntax,html,reference,missing/protected,accessibility/protected ${javafx.options} +javac.compilerargs = -Xlint:all -Xdoclint:syntax,html,reference,missing/protected,accessibility/protected ${javafx.options} javac.deprecation = true javac.external.vm = false javadoc.html5 = true diff --git a/profiles/sis-french-profile/src/main/java/org/apache/sis/internal/profile/fra/ProfileTypes.java b/profiles/sis-french-profile/src/main/java/org/apache/sis/internal/profile/fra/ProfileTypes.java index dc1519721e..0e86857066 100644 --- a/profiles/sis-french-profile/src/main/java/org/apache/sis/internal/profile/fra/ProfileTypes.java +++ b/profiles/sis-french-profile/src/main/java/org/apache/sis/internal/profile/fra/ProfileTypes.java @@ -31,6 +31,12 @@ import org.apache.sis.internal.jaxb.TypeRegistration; * @since 0.4 */ public final class ProfileTypes extends TypeRegistration { + /** + * Creates a default provider of types to register. + */ + public ProfileTypes() { + } + /** * Adds to the given collection the metadata types that should be given to the initial JAXB context. */ diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/XMLMetadata.java b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/XMLMetadata.java index 90aff5ab53..75408c3d6e 100644 --- a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/XMLMetadata.java +++ b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/XMLMetadata.java @@ -222,6 +222,11 @@ final class XMLMetadata implements Filter { * It allows JavaFX application to support the "copy to clipboard" operation. */ static final class Root extends DefaultTreeTable.Node { + /** + * For cross-version compatibility. + */ + private static final long serialVersionUID = -3656784393688796818L; + /** * Column for the name associated to the element. */ diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/ExtentEstimator.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/ExtentEstimator.java index 433252c725..db158b8d44 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/ExtentEstimator.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/ExtentEstimator.java @@ -41,7 +41,7 @@ import org.apache.sis.internal.metadata.sql.SQLBuilder; * * @author Alexis Manin (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.4 * * @see <a href="https://postgis.net/docs/ST_EstimatedExtent.html">ST_EstimatedExtent</a> * @@ -51,7 +51,7 @@ final class ExtentEstimator { /** * The database containing the table for which to estimate the extent. */ - private final Database database; + private final Database<?> database; /** * The table for which to get the extent. @@ -82,7 +82,7 @@ final class ExtentEstimator { /** * Creates a new extent estimator for the specified table. */ - ExtentEstimator(final Database database, final TableReference table, final Column[] columns) { + ExtentEstimator(final Database<?> database, final TableReference table, final Column[] columns) { this.database = database; this.table = table; this.columns = columns; diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/Postgres.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/Postgres.java index 386b4d2256..9200f2604d 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/Postgres.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/postgis/Postgres.java @@ -47,6 +47,8 @@ import org.apache.sis.util.Version; * This class specializes some of the functions for converting PostGIS objects to Java objects. * The PostGIS database is optional; it is possible to use PostgreSQL alone as a store of features without geometries. * + * @param <G> the type of geometry objects. Depends on the backing implementation (ESRI, JTS, Java2D…). + * * @author Alexis Manin (Geomatys) * @author Martin Desruisseaux (Geomatys) * @version 1.4 diff --git a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java index 94a763cbce..8649b4145d 100644 --- a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java +++ b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java @@ -64,10 +64,10 @@ public final class SQLStoreTest extends TestOnAllDatabases { * Data used in the {@code Features.sql} test file. */ public enum City { - TOKYO ("Tōkyō", "JPN", "日本", 13622267, "Yoyogi-kōen", "Shinjuku Gyoen"), - PARIS ("Paris", "FRA", "France", 2206488, "Tuileries Garden", "Luxembourg Garden"), - MONTREAL("Montreal", "CAN", "Canada", 1704694, "Mount Royal"), - QUEBEC ("Quebec", "CAN", "Canada", 531902); + /** Tokyo (Japan). */ TOKYO ("Tōkyō", "JPN", "日本", 13622267, "Yoyogi-kōen", "Shinjuku Gyoen"), + /** Paris (France). */ PARIS ("Paris", "FRA", "France", 2206488, "Tuileries Garden", "Luxembourg Garden"), + /** Montréal (Canada). */ MONTREAL("Montreal", "CAN", "Canada", 1704694, "Mount Royal"), + /** Québec (Canada). */ QUEBEC ("Quebec", "CAN", "Canada", 531902); /** City name in Latin characters. */ public final String englishName; /** Country ISO code (3 letters). */ public final String country; diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java index 4fcc750014..83a2724842 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java @@ -129,10 +129,10 @@ public final class StoreProvider extends URIDataStore.Provider { if (length >= MIN_LENGTH) { int pos = length; int version = 1; - keyword[ 0] &= ~0x20; // Make upper-case (valid only for characters in the a-z range). - keyword[--pos] &= ~0x20; - if ((keyword[--pos] &= ~0x20) == 'R') { - keyword[--pos] &= ~0x20; // Make "CRS" suffix in upper case (otherwise, was "CS" suffix) + keyword[ 0] &= (char) ~0x20; // Make upper-case (valid only for characters in the a-z range). + keyword[--pos] &= (char) ~0x20; + if ((keyword[--pos] &= (char) ~0x20) == 'R') { + keyword [--pos] &= (char) ~0x20; // Make "CRS" suffix in upper case (otherwise, was "CS" suffix) version = 2; } while (--pos != 0) { diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java index 1d34f86d1d..8a2d96032a 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java @@ -380,6 +380,7 @@ public class FeatureQuery extends Query implements Cloneable, Serializable { * or {@code null} or an empty array if none. */ @SafeVarargs + @SuppressWarnings("varargs") public final void setSortBy(final SortProperty<Feature>... properties) { SortBy<Feature> sortBy = null; if (properties != null) { diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java index e57fb2701c..40f230b839 100644 --- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java +++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java @@ -130,7 +130,7 @@ public abstract class StaxDataStore extends URIDataStore { * * @see #close() */ - private volatile AutoCloseable stream; + private volatile Closeable stream; /** * Position of the first byte to read in the {@linkplain #stream}, or a negative value if unknown. @@ -226,8 +226,8 @@ public abstract class StaxDataStore extends URIDataStore { */ stream = connector.getStorageAs(InputStream.class); } - if (stream == null && storage instanceof AutoCloseable) { - stream = (AutoCloseable) storage; + if (stream == null && storage instanceof Closeable) { + stream = (Closeable) storage; } channelFactory = connector.getStorageAs(ChannelFactory.class); // Must be last before `closeAllExcept(…)`. connector.closeAllExcept(stream); @@ -425,7 +425,7 @@ public abstract class StaxDataStore extends URIDataStore { if (inputOrFile == null) { throw new DataStoreClosedException(getLocale(), getFormatName(), StandardOpenOption.READ); } - AutoCloseable input = stream; + Closeable input = stream; InputType type = storageToReader; /* * If the stream has already been used by a previous read operation, then we need to rewind @@ -525,7 +525,7 @@ public abstract class StaxDataStore extends URIDataStore { final synchronized XMLStreamWriter createWriter(final StaxStreamWriter target, final OutputStream temporary) throws DataStoreException, XMLStreamException, IOException { - AutoCloseable output; + Closeable output; Object outputOrFile; OutputType outputType; if (temporary == null) { diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamIO.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamIO.java index 0f99761e2f..53d5b9cab9 100644 --- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamIO.java +++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamIO.java @@ -16,6 +16,7 @@ */ package org.apache.sis.internal.storage.xml.stream; +import java.io.Closeable; import java.io.IOException; import jakarta.xml.bind.JAXBException; import javax.xml.stream.XMLStreamException; @@ -51,7 +52,7 @@ abstract class StaxStreamIO implements AutoCloseable { * or {@code null} if none. This may be the same reference than {@link StaxDataStore#stream}, * but not necessarily if we had to create a new stream for reading the data one more time. */ - AutoCloseable stream; + Closeable stream; /** * The (un)marshaller pool, fetched when first needed. The same pool is shared by all {@code StaxStreamIO} @@ -90,12 +91,13 @@ abstract class StaxStreamIO implements AutoCloseable { * Closes the input or output stream and releases any resources used by this XML reader or writer. * This reader or writer cannot be used anymore after this method has been invoked. * + * @throws JAXBException if an error occurred while releasing JAXB resources. * @throws XMLStreamException if an error occurred while releasing XML reader/writer resources. * @throws IOException if an error occurred while closing the input or output stream. */ @Override - public void close() throws Exception { - final AutoCloseable s = stream; + public void close() throws JAXBException, XMLStreamException, IOException { + final Closeable s = stream; stream = null; if (s != null && owner.canClose(s)) { s.close(); diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java index f64ad1b5e7..bf5e11bc5d 100644 --- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java +++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java @@ -500,11 +500,12 @@ parse: switch (value.length()) { * Closes the input stream and releases any resources used by this XML reader. * This reader cannot be used anymore after this method has been invoked. * + * @throws JAXBException if an error occurred while releasing JAXB resources. * @throws XMLStreamException if an error occurred while releasing XML reader resources. * @throws IOException if an error occurred while closing the input stream. */ @Override - public void close() throws Exception { + public void close() throws JAXBException, XMLStreamException, IOException { final Unmarshaller m = unmarshaller; if (m != null) { unmarshaller = null; diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java index a65b38191a..41973e4f64 100644 --- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java +++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java @@ -322,11 +322,12 @@ public abstract class StaxStreamWriter extends StaxStreamIO implements Consumer< * Closes the output stream and releases any resources used by this XML writer. * This writer cannot be used anymore after this method has been invoked. * + * @throws JAXBException if an error occurred while releasing JAXB resources. * @throws XMLStreamException if an error occurred while releasing XML writer resources. * @throws IOException if an error occurred while closing the output stream. */ @Override - public void close() throws Exception { + public void close() throws JAXBException, XMLStreamException, IOException { final Marshaller m = marshaller; if (m != null) { marshaller = null;