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 ceacb1c0dfdc34ed6a0dcf055e97d3ff16692313 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Tue Apr 1 16:26:47 2025 +0200 Remove an internal utility class which is no longer useful. --- .../org/apache/sis/feature/AbstractOperation.java | 18 +++++++ .../org/apache/sis/feature/EnvelopeOperation.java | 3 +- .../apache/sis/feature/ExpressionOperation.java | 3 +- .../sis/feature/GroupAsPolylineOperation.java | 3 +- .../main/org/apache/sis/feature/LinkOperation.java | 3 +- .../apache/sis/feature/StringJoinOperation.java | 3 +- .../sis/feature/privy/AttributeConvention.java | 6 +++ .../apache/sis/feature/privy/FeatureUtilities.java | 61 ---------------------- .../org/apache/sis/storage/gdal/FieldAccessor.java | 3 +- 9 files changed, 30 insertions(+), 73 deletions(-) diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java index 2ce24a14b3..a498244380 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/AbstractOperation.java @@ -26,10 +26,13 @@ import java.io.IOException; import java.io.UncheckedIOException; import org.opengis.util.GenericName; import org.opengis.metadata.Identifier; +import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.GeneralParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; import org.apache.sis.util.Classes; +import org.apache.sis.metadata.iso.citation.Citations; +import org.apache.sis.parameter.DefaultParameterDescriptorGroup; // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.feature.Attribute; @@ -321,4 +324,19 @@ public abstract class AbstractOperation extends AbstractIdentifiedType implement private static String name(final Identifier id) { return (id != null) ? id.getCode() : null; } + + /** + * Creates a parameter descriptor in the Apache SIS namespace. This convenience method shall not + * be in public <abbr>API</abbr>, because users should define operations in their own namespace. + * + * @param name the parameter group name, typically the same as operation name. + * @param parameters the parameters, or an empty array if none. + * @return description of the parameters group. + */ + static ParameterDescriptorGroup parameters(final String name, final ParameterDescriptor<?>... parameters) { + final var properties = new HashMap<String,Object>(4); + properties.put(ParameterDescriptorGroup.NAME_KEY, name); + properties.put(Identifier.AUTHORITY_KEY, Citations.SIS); + return new DefaultParameterDescriptorGroup(properties, 1, 1); + } } diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java index 3ad454ae20..fcf5897599 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/EnvelopeOperation.java @@ -31,7 +31,6 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.CoordinateOperation; import org.opengis.referencing.operation.TransformException; import org.apache.sis.feature.privy.AttributeConvention; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.feature.internal.Resources; import org.apache.sis.geometry.Envelopes; import org.apache.sis.geometry.GeneralEnvelope; @@ -81,7 +80,7 @@ final class EnvelopeOperation extends AbstractOperation { /** * The parameter descriptor for the "Envelope" operation, which does not take any parameter. */ - private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("Envelope"); + private static final ParameterDescriptorGroup EMPTY_PARAMS = parameters("Envelope"); /** * The names of all properties containing a geometry object. diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java index 7a23b3ebdf..e01675cc6b 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/ExpressionOperation.java @@ -23,7 +23,6 @@ import java.util.Collection; import java.util.function.Function; import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterDescriptorGroup; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.filter.privy.FunctionNames; import org.apache.sis.filter.privy.Visitor; @@ -57,7 +56,7 @@ final class ExpressionOperation<V> extends AbstractOperation { /** * The parameter descriptor for the "Expression" operation, which does not take any parameter. */ - private static final ParameterDescriptorGroup PARAMETERS = FeatureUtilities.parameters("Expression"); + private static final ParameterDescriptorGroup PARAMETERS = parameters("Expression"); /** * The expression to which to delegate the execution of this operation. diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java index 2aca846ee4..242418ac1c 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/GroupAsPolylineOperation.java @@ -23,7 +23,6 @@ import java.util.EnumMap; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; import org.apache.sis.feature.privy.AttributeConvention; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.feature.internal.Resources; import org.apache.sis.geometry.wrapper.Geometries; import org.apache.sis.geometry.wrapper.GeometryType; @@ -55,7 +54,7 @@ final class GroupAsPolylineOperation extends AbstractOperation { /** * The parameter descriptor for the "Group polylines" operation, which does not take any parameter. */ - private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("GroupAsPolyline"); + private static final ParameterDescriptorGroup EMPTY_PARAMS = parameters("GroupAsPolyline"); /** * Name of the property to follow in order to get the geometries to add to a polyline. diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java index 6b99151a2c..9bf239939c 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/LinkOperation.java @@ -21,7 +21,6 @@ import java.util.Map; import java.io.IOException; import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterDescriptorGroup; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.util.resources.Errors; // Specific to the geoapi-3.1 and geoapi-4.0 branches: @@ -46,7 +45,7 @@ final class LinkOperation extends AbstractOperation { /** * The parameter descriptor for the "Link" operation, which does not take any parameter. */ - private static final ParameterDescriptorGroup PARAMETERS = FeatureUtilities.parameters("Link"); + private static final ParameterDescriptorGroup PARAMETERS = parameters("Link"); /** * The type of the result. diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java index b702dc10e9..b69708ecd0 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/StringJoinOperation.java @@ -34,7 +34,6 @@ import org.apache.sis.util.Classes; import org.apache.sis.util.privy.CollectionsExt; import org.apache.sis.converter.SurjectiveConverter; import org.apache.sis.feature.privy.AttributeConvention; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.feature.internal.Resources; import org.apache.sis.util.resources.Errors; @@ -78,7 +77,7 @@ final class StringJoinOperation extends AbstractOperation { /** * The parameter descriptor for the "String join" operation, which does not take any parameter. */ - private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("StringJoin"); + private static final ParameterDescriptorGroup EMPTY_PARAMS = parameters("StringJoin"); /** * A pseudo-converter returning the identifier of a feature. This pseudo-converter is used in place diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java index 1e2c9030dc..730b971643 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/AttributeConvention.java @@ -214,6 +214,12 @@ public final class AttributeConvention extends Static { */ public static final String MAXIMAL_LENGTH = "sis:maximalLength"; + /** + * Prefix to insert before sequential number for name disambiguation. + * This is used when attribute name collisions are detected in a file. + */ + public static final String DISAMBIGUATION_SEQUENTIAL_NUMBER_PREFIX = " #"; + /** * Do not allow instantiation of this class. */ diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureUtilities.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureUtilities.java deleted file mode 100644 index e8a2ab139b..0000000000 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/privy/FeatureUtilities.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.feature.privy; - -import java.util.HashMap; -import org.opengis.metadata.Identifier; -import org.opengis.parameter.ParameterDescriptor; -import org.opengis.parameter.ParameterDescriptorGroup; -import org.apache.sis.parameter.DefaultParameterDescriptorGroup; -import org.apache.sis.metadata.iso.citation.Citations; -import org.apache.sis.util.Static; - - -/** - * Non-public utility methods for Apache SIS internal usage. - * - * @author Johann Sorel (Geomatys) - * @author Martin Desruisseaux (Geomatys) - */ -public final class FeatureUtilities extends Static { - /** - * Prefix to insert before sequential number for name disambiguation. - * This is used when attribute name collisions are detected in a file. - */ - public static final String DISAMBIGUATION_SEQUENTIAL_NUMBER_PREFIX = " #"; - - /** - * Do not allow instantiation of this class. - */ - private FeatureUtilities() { - } - - /** - * Creates a parameter descriptor in the Apache SIS namespace. This convenience method shall - * not be in public API, because users should define operations in their own namespace. - * - * @param name the parameter group name, typically the same as operation name. - * @param parameters the parameters, or an empty array if none. - * @return description of the parameters group. - */ - public static ParameterDescriptorGroup parameters(final String name, final ParameterDescriptor<?>... parameters) { - final var properties = new HashMap<String,Object>(4); - properties.put(ParameterDescriptorGroup.NAME_KEY, name); - properties.put(Identifier.AUTHORITY_KEY, Citations.SIS); - return new DefaultParameterDescriptorGroup(properties, 1, 1); - } -} diff --git a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FieldAccessor.java b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FieldAccessor.java index 58f79a4419..71e18091fd 100644 --- a/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FieldAccessor.java +++ b/optional/src/org.apache.sis.storage.gdal/main/org/apache/sis/storage/gdal/FieldAccessor.java @@ -30,7 +30,6 @@ import java.lang.foreign.ValueLayout; import java.nio.ByteBuffer; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.feature.privy.AttributeConvention; -import org.apache.sis.feature.privy.FeatureUtilities; import org.apache.sis.util.privy.Strings; @@ -101,7 +100,7 @@ abstract class FieldAccessor<V> { final void rename(final Map<String,Integer> names, final Integer value) { final String base = name; int counter = 0; - do name = base + FeatureUtilities.DISAMBIGUATION_SEQUENTIAL_NUMBER_PREFIX + (++counter); + do name = base + AttributeConvention.DISAMBIGUATION_SEQUENTIAL_NUMBER_PREFIX + (++counter); while (names.putIfAbsent(name, value) != null); }