Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -29,7 +29,7 @@ import org.apache.sis.util.resources.Err import org.apache.sis.internal.util.Constants; // Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; +import java.util.function.Function; /** @@ -105,7 +105,7 @@ import org.apache.sis.internal.jdk8.JDK8 * @since 0.7 * @module */ -public class SQLTranslator { +public class SQLTranslator implements Function<String,String> { /** * Table names used as "sentinel value" for detecting the presence of an EPSG database. * This array lists different possible names for the same table. The first entry must be @@ -376,6 +376,7 @@ public class SQLTranslator { * @param sql the statement in MS-Access dialect. * @return the SQL statement adapted to the dialect of the target database. */ + @Override public String apply(final String sql) { final String catalog = nonEmpty(this.catalog); final String schema = nonEmpty(this.schema); @@ -402,7 +403,7 @@ public class SQLTranslator { */ final String name = sql.substring(start, end++); if (CharSequences.isUpperCase(name)) { - ansi.append(JDK8.getOrDefault(accessToAnsi, name, name)); + ansi.append(accessToAnsi.getOrDefault(name, name)); } else { if (catalog != null) { ansi.append(quote).append(catalog).append(quote).append('.'); @@ -417,10 +418,10 @@ public class SQLTranslator { ansi.append(TABLE_PREFIX); } if (quoteTableNames) { - ansi.append(JDK8.getOrDefault(accessToAnsi, name, name)).append(quote); + ansi.append(accessToAnsi.getOrDefault(name, name)).append(quote); } else { for (final String word : name.split("\\s")) { - ansi.append(JDK8.getOrDefault(accessToAnsi, word, word)); + ansi.append(accessToAnsi.getOrDefault(word, word)); } } }
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationContext.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationContext.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationContext.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationContext.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -26,7 +26,7 @@ import org.apache.sis.internal.util.Coll import org.apache.sis.util.ArgumentChecks; // Branch-dependent imports -import org.apache.sis.internal.jdk8.Predicate; +import java.util.function.Predicate; /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -975,7 +975,7 @@ public class CoordinateOperationFinder e if (SubTypes.isSingleOperation(main)) { final SingleOperation op = (SingleOperation) main; final MathTransform mt = factorySIS.getMathTransformFactory().createConcatenatedTransform(mt1, mt2); - main = createFromMathTransform(new HashMap<String,Object>(IdentifiedObjects.getProperties(main)), + main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)), sourceCRS, targetCRS, mt, op.getMethod(), op.getParameterValues(), (main instanceof Transformation) ? Transformation.class : (main instanceof Conversion) ? Conversion.class : SingleOperation.class); @@ -995,7 +995,7 @@ public class CoordinateOperationFinder e break; } } - main = createFromMathTransform(new HashMap<String,Object>(IdentifiedObjects.getProperties(main)), + main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)), main.getSourceCRS(), main.getTargetCRS(), main.getMathTransform(), null, null, type); } return main; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -79,8 +79,7 @@ import org.apache.sis.util.collection.Ba import org.apache.sis.util.resources.Vocabulary; // Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; -import org.apache.sis.internal.jdk8.Predicate; +import java.util.function.Predicate; /** @@ -786,7 +785,7 @@ class CoordinateOperationRegistry { CoordinateReferenceSystem crs; if (Utilities.equalsApproximatively(sourceCRS, crs = operation.getSourceCRS())) sourceCRS = crs; if (Utilities.equalsApproximatively(targetCRS, crs = operation.getTargetCRS())) targetCRS = crs; - final Map<String,Object> properties = new HashMap<String,Object>(derivedFrom(operation)); + final Map<String,Object> properties = new HashMap<>(derivedFrom(operation)); /* * Determine whether the operation to create is a Conversion or a Transformation * (could also be a Conversion subtype like Projection, but this is less important). @@ -1180,7 +1179,7 @@ class CoordinateOperationRegistry { } properties.put(ReferencingServices.OPERATION_TYPE_KEY, type); if (Conversion.class.isAssignableFrom(type) && transform.isIdentity()) { - JDK8.replace(properties, IdentifiedObject.NAME_KEY, AXIS_CHANGES, IDENTITY); + properties.replace(IdentifiedObject.NAME_KEY, AXIS_CHANGES, IDENTITY); } return factorySIS.createSingleOperation(properties, sourceCRS, targetCRS, null, method, transform); } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -716,7 +716,7 @@ next: for (int i=components.size(); -- * but omitting the transform should not cause the lost of the CRS with desired longitude range. */ if (single instanceof SingleOperation) { - final Map<String,Object> merge = new HashMap<String,Object>( + final Map<String,Object> merge = new HashMap<>( IdentifiedObjects.getProperties(single, CoordinateOperation.IDENTIFIERS_KEY)); merge.put(ReferencingServices.PARAMETERS_KEY, ((SingleOperation) single).getParameterValues()); if (single instanceof AbstractIdentifiedObject) { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -322,7 +322,7 @@ public class DefaultOperationMethod exte * @return the identified object properties in a mutable map. */ private static Map<String,Object> getProperties(final IdentifiedObject info, final Citation authority) { - final Map<String,Object> properties = new HashMap<String,Object>(IdentifiedObjects.getProperties(info)); + final Map<String,Object> properties = new HashMap<>(IdentifiedObjects.getProperties(info)); properties.put(NAME_KEY, new NamedIdentifier(authority, info.getName().getCode())); properties.remove(IDENTIFIERS_KEY); return properties; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -40,9 +40,6 @@ import org.apache.sis.util.ArraysExt; import org.apache.sis.util.Classes; import org.apache.sis.util.Debug; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Creates an affine transform which will map approximatively the given source positions to the given target positions. @@ -163,7 +160,7 @@ public class LinearTransformBuilder exte long length = 1; for (int s : gridSize) { ArgumentChecks.ensureStrictlyPositive("gridSize", s); - length = JDK8.multiplyExact(length, s); + length = Math.multiplyExact(length, s); } if (length > Integer.MAX_VALUE) { throw new IllegalArgumentException(Errors.format(Errors.Keys.ValueOutOfRange_4, @@ -480,7 +477,7 @@ search: for (int j=0; j<numPoints; j++) if (index < 0) { index = numPoints++; if (numPoints >= targets[0].length) { - final int n = JDK8.multiplyExact(numPoints, 2); + final int n = Math.multiplyExact(numPoints, 2); resize(sources, n); resize(targets, n); } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -648,7 +648,7 @@ public class ContextualParameters extend while (upper != 0 && values[upper - 1] == null) { upper--; } - return UnmodifiableArrayList.<GeneralParameterValue>wrap(values, 0, upper); + return UnmodifiableArrayList.wrap(values, 0, upper); } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -84,9 +84,6 @@ import org.apache.sis.util.iso.AbstractF import org.apache.sis.util.logging.Logging; import org.apache.sis.util.resources.Errors; -// Branch-specific imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Low level factory for creating {@linkplain AbstractMathTransform math transforms}. @@ -360,7 +357,7 @@ public class DefaultMathTransformFactory } final OperationMethodSet previous; synchronized (methodsByType) { - previous = JDK8.putIfAbsent(methodsByType, type, set); + previous = methodsByType.putIfAbsent(type, set); } if (previous != null) { set = previous; @@ -1394,11 +1391,9 @@ public class DefaultMathTransformFactory c = Class.forName("org.apache.sis.io.wkt.MathTransformParser").asSubclass(Parser.class) .getConstructor(MathTransformFactory.class); final Constructor<?> cp = c; // For allowing use in inner class or lambda expression. - AccessController.doPrivileged(new PrivilegedAction<Void>() { - @Override public Void run() { - cp.setAccessible(true); - return null; - } + AccessController.doPrivileged((PrivilegedAction<Void>) () -> { + cp.setAccessible(true); + return null; }); parserConstructor = c; } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransformProvider.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -85,6 +85,7 @@ import org.opengis.referencing.operation * @since 0.6 * @module */ +@FunctionalInterface public interface MathTransformProvider { /** * Creates a math transform from the specified group of parameter values. Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -214,11 +214,6 @@ final class OperationMethodSet extends S public OperationMethod next() { return OperationMethodSet.this.next(cursor++); } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } }; } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -114,7 +114,7 @@ public final strictfp class CC_Operation public void testSubtitution() throws JAXBException { final ParameterDescriptor<?>[] expected = create(REMARK); final List<GeneralParameterDescriptor> fromXML = unmarshal().descriptors(); - final List<GeneralParameterDescriptor> fromValues = UnmodifiableArrayList.<GeneralParameterDescriptor>wrap(expected); + final List<GeneralParameterDescriptor> fromValues = UnmodifiableArrayList.wrap(expected); final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4); final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge(fromXML, fromValues.toArray(new GeneralParameterDescriptor[fromValues.size()]), replacements); Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/j2d/ShapeUtilitiesViewer.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/j2d/ShapeUtilitiesViewer.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/j2d/ShapeUtilitiesViewer.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/j2d/ShapeUtilitiesViewer.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -26,7 +26,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.geom.Ellipse2D; import java.awt.geom.Path2D; import java.awt.geom.Point2D; @@ -218,10 +217,8 @@ final strictfp class ShapeUtilitiesViewe private JButton createButtonForNextTest(final Method method) { final JButton button = new JButton(CharSequences.camelCaseToSentence( method.name().toLowerCase(Locale.ENGLISH)).toString()); - button.addActionListener(new ActionListener () { - @Override public void actionPerformed(ActionEvent e) { - assignRandomPoints(method); - } + button.addActionListener((ActionEvent e) -> { + assignRandomPoints(method); }); return button; } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -19,6 +19,7 @@ package org.apache.sis.internal.referenc import java.net.URISyntaxException; import java.io.BufferedReader; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.Path; import javax.measure.quantity.Angle; @@ -32,9 +33,6 @@ import org.junit.Test; import static org.opengis.test.Assert.*; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Tests {@link FranceGeocentricInterpolation}. @@ -138,7 +136,7 @@ public final strictfp class FranceGeocen { final Path file = getResource(TEST_FILE); final DatumShiftGridFile.Float<Angle,Length> grid; - try (BufferedReader in = JDK8.newBufferedReader(file)) { + try (BufferedReader in = Files.newBufferedReader(file)) { grid = FranceGeocentricInterpolation.load(in, file); } assertEquals("cellPrecision", 0.005, grid.getCellPrecision(), STRICT); Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Path; +import java.nio.file.Files; import javax.measure.quantity.Angle; import org.opengis.geometry.Envelope; import org.opengis.util.FactoryException; @@ -33,9 +34,6 @@ import org.junit.Test; import static org.apache.sis.test.Assert.*; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Tests the {@link NADCON} grid loader. @@ -227,7 +225,7 @@ public final strictfp class NADCONTest e { Envelope envelope = new Envelope2D(null, gridX, gridY, nx - 1, ny - 1); envelope = Envelopes.transform(grid.getCoordinateToGrid().inverse(), envelope); - try (BufferedWriter out = JDK8.newBufferedWriter(file)) { + try (BufferedWriter out = Files.newBufferedWriter(file)) { out.write("NADCON EXTRACTED REGION\n"); out.write(String.format(Locale.US, "%4d %3d %3d %11.5f %11.5f %11.5f %11.5f %11.5f\n", nx, ny, 1, envelope.getMinimum(0), envelope.getSpan(0) / (nx - 1), Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -51,9 +51,6 @@ import static org.apache.sis.test.Refere import static org.apache.sis.test.TestUtilities.getSingleton; import static org.apache.sis.internal.util.StandardDateFormat.MILLISECONDS_PER_DAY; -// Branch-specific imports -import org.opengis.util.Factory; - /** * Tests {@link GeodeticObjectParser}. @@ -85,8 +82,8 @@ public final strictfp class GeodeticObje * Instantiates the parser to test. */ private void newParser(final Convention convention) { - parser = new GeodeticObjectParser(Symbols.getDefault(), Collections.<String,Element>emptyMap(), - null, null, null, convention, Transliterator.DEFAULT, null, new HashMap<Class<?>,Factory>()); + parser = new GeodeticObjectParser(Symbols.getDefault(), Collections.emptyMap(), + null, null, null, convention, Transliterator.DEFAULT, null, new HashMap<>()); assertEquals(GeodeticObjectFactory.class.getCanonicalName(), parser.getPublicFacade()); } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -290,11 +290,6 @@ public final strictfp class CoordinateSy } return unit; } - - @Override - public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) { - return direction; - } }); assertEqualsIgnoreMetadata(targetCS, actualCS); } @@ -313,16 +308,6 @@ public final strictfp class CoordinateSy public boolean accept(final CoordinateSystemAxis axis) { return Units.isLinear(axis.getUnit()); } - - @Override - public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) { - return unit; - } - - @Override - public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) { - return direction; - } }); assertEqualsIgnoreMetadata(targetCS, actualCS); } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -59,7 +59,7 @@ public final strictfp class DefaultTrans private static DefaultGeocentricCRS createCRS(final String name, final GeodeticDatum datum) { Map<String,?> properties = IdentifiedObjects.getProperties(datum, DefaultGeocentricCRS.IDENTIFIERS_KEY); if (name != null) { - final Map<String,Object> copy = new HashMap<String,Object>(properties); + final Map<String,Object> copy = new HashMap<>(properties); copy.put(DefaultGeocentricCRS.NAME_KEY, name); properties = copy; } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ConformalProjectionTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -31,9 +31,6 @@ import static java.lang.StrictMath.*; import static org.junit.Assert.*; import static org.apache.sis.referencing.operation.projection.NormalizedProjectionTest.TOLERANCE; -// Branch-specific imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Tests the {@link ConformalProjection} class. @@ -101,7 +98,7 @@ public final strictfp class ConformalPro assertEquals("f( 0°) = 1", 1, expOfNorthing(0), tolerance); assertEquals("f(-90°) = 0", 0, expOfNorthing(-PI/2), tolerance); assertTrue ("f(< -90°) < 0", expOfNorthing(-PI/2 - 0.1) < 0); - assertTrue ("f(< -90°) < 0", expOfNorthing(JDK8.nextDown(-PI/2)) < 0); + assertTrue ("f(< -90°) < 0", expOfNorthing(nextDown(-PI/2)) < 0); /* * Values around π/2 are a special case. Theoretically the result should be positive infinity. * But since we do not have an exact representatation of π/2, we instead get a high number. Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -17,7 +17,6 @@ package org.apache.sis.referencing.operation.projection; import java.util.Collections; -import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.operation.Matrix; @@ -74,7 +73,7 @@ final strictfp class NoOp extends Confor private NoOp(final Parameters parameters) { super(new Initializer(new DefaultOperationMethod( Collections.singletonMap(DefaultOperationMethod.NAME_KEY, parameters.getDescriptor().getName()), - 2, 2, parameters.getDescriptor()), parameters, Collections.<ParameterRole, ParameterDescriptor<Double>>emptyMap(), (byte) 0)); + 2, 2, parameters.getDescriptor()), parameters, Collections.emptyMap(), (byte) 0)); super.computeCoefficients(); } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -37,6 +37,7 @@ import org.junit.AfterClass; import org.junit.Test; + /** * Tests the {@link CoordinateSystemTransform} static factory method. * Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -64,7 +64,7 @@ public final strictfp class MathTransfor */ @Override public Set<OperationMethod> getAvailableMethods(Class<? extends SingleOperation> type) { - return type.isInstance(method) ? Collections.<OperationMethod>singleton(method) : Collections.<OperationMethod>emptySet(); + return type.isInstance(method) ? Collections.singleton(method) : Collections.emptySet(); } /** Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -50,7 +50,6 @@ import org.apache.sis.util.Numbers; import org.apache.sis.util.Version; // Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; import org.opengis.referencing.ReferenceIdentifier; @@ -80,21 +79,15 @@ public strictfp class CoordinateOperatio public static void main(final String[] args) throws IOException { final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class); final List<OperationMethod> methods = new ArrayList<>(factory.getAvailableMethods(SingleOperation.class)); - JDK8.removeIf(methods, new org.apache.sis.internal.jdk8.Predicate<OperationMethod>() { - @Override public boolean test(OperationMethod method) { - return method.getClass().getName().endsWith("Mock"); - } - }); - Collections.sort(methods, new java.util.Comparator<OperationMethod>() { - @Override public int compare(OperationMethod o1, OperationMethod o2) { - int c = category(o1) - category(o2); - if (c == 0) { // If the two methods are in the same category, sort by name. - final String n1 = o1.getName().getCode().replace('(',' ').replace(')',' ').replace('_',' '); - final String n2 = o2.getName().getCode().replace('(',' ').replace(')',' ').replace('_',' '); - c = n1.compareTo(n2); - } - return c; + methods.removeIf((method) -> method.getClass().getName().endsWith("Mock")); + Collections.sort(methods, (final OperationMethod o1, final OperationMethod o2) -> { + int c = category(o1) - category(o2); + if (c == 0) { // If the two methods are in the same category, sort by name. + final String n1 = o1.getName().getCode().replace('(',' ').replace(')',' ').replace('_',' '); + final String n2 = o2.getName().getCode().replace('(',' ').replace(')',' ').replace('_',' '); + c = n1.compareTo(n2); } + return c; }); try (CoordinateOperationMethods writer = new CoordinateOperationMethods()) { writer.writeIndex(methods); @@ -351,7 +344,7 @@ public strictfp class CoordinateOperatio writeName(param); String remarks = toLocalizedString(param.getRemarks()); if (remarks != null) { - Integer index = JDK8.putIfAbsent(footnotes, remarks, footnotes.size() + 1); + Integer index = footnotes.putIfAbsent(remarks, footnotes.size() + 1); if (index == null) { index = footnotes.size(); } Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -47,9 +47,6 @@ import org.apache.sis.internal.util.Cons import static java.lang.StrictMath.*; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Assertion methods used by the {@code sis-referencing} module in addition of the ones inherited @@ -411,7 +408,7 @@ public strictfp class ReferencingAssert assertFalse("e2.contains(e1)", ae.contains (e1, true)); } final int dimension = e1.getDimension(); - final int numCases = JDK8.toIntExact(round(pow(3, dimension))); + final int numCases = toIntExact(round(pow(3, dimension))); final GeneralDirectPosition pos = new GeneralDirectPosition(dimension); for (int index=0; index<numCases; index++) { int n = index; Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -41,9 +41,6 @@ import org.apache.sis.xml.MarshalContext import org.apache.sis.xml.ValueConverter; import org.apache.sis.xml.ReferenceResolver; -// Branch-dependent imports. -import org.apache.sis.internal.jdk8.JDK8; - /** * Thread-local status of a marshalling or unmarshalling processes. @@ -499,7 +496,7 @@ public final class Context extends Marsh */ public static boolean setObjectForID(final Context context, final Object object, final String id) { if (context != null) { - final Object existing = JDK8.putIfAbsent(context.identifiers, id, object); + final Object existing = context.identifiers.putIfAbsent(id, object); if (existing == null) { if (context.identifiedObjects.put(object, id) != null) { throw new AssertionError(id); // Caller forgot to invoke getExistingID(context, object). Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -152,7 +152,7 @@ public abstract class TypeRegistration { * 2) The ClassLoader between different invocations may be different in an OSGi context. */ final ArrayList<Class<?>> types = new ArrayList<>(); - final ArrayList<TypeRegistration> toImpl = (converters == null) ? new ArrayList<TypeRegistration>() : null; + final ArrayList<TypeRegistration> toImpl = (converters == null) ? new ArrayList<>() : null; if (toImpl != null || getTypes) { for (final TypeRegistration t : DefaultFactories.createServiceLoader(TypeRegistration.class)) { if (getTypes) { @@ -220,7 +220,7 @@ public abstract class TypeRegistration { if (properties == null) { return Collections.singletonMap(ROOT_ADAPTERS, c); } - final Map<String,Object> copy = new HashMap<String,Object>(properties); + final Map<String,Object> copy = new HashMap<>(properties); copy.put(ROOT_ADAPTERS, c); return copy; } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -246,7 +246,7 @@ public class SimpleMetadata implements M */ @Override public Collection<DataIdentification> getIdentificationInfo() { - return Collections.<DataIdentification>singleton(this); + return Collections.singleton(this); } /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -126,11 +126,7 @@ public enum DataDirectory { * @since 0.8 */ public static String getenv() throws SecurityException { - return AccessController.doPrivileged(new PrivilegedAction<String>() { - @Override public String run() { - return System.getenv(ENV); - } - }); + return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getenv(ENV)); } /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -88,7 +88,7 @@ public final class Supervisor extends St public static synchronized void register() { if (name == null) { name = ObjectName.WILDCARD; // In case of failure. - LogRecord record; + final LogRecord record; try { final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); final ObjectName n = new ObjectName(NAME); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractIterator.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractIterator.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractIterator.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractIterator.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -64,12 +64,4 @@ public abstract class AbstractIterator<E next = null; return value; } - - /** - * Unsupported by default. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -314,6 +314,20 @@ public abstract class AbstractMap<K,V> i } /** + * Returns the value for the given key, or {@code defaultValue} if none. + * The default implementation assumes that the map can not contain {@code null} values. + * + * @param key the key for which to get the value. + * @param defaultValue the value to return if this map does not have an entry for the given key. + * @return the value for the given key, or {@code defaultValue} if none. + */ + @Override + public V getOrDefault(final Object key, final V defaultValue) { + final V value = get(key); + return (value != null) ? value : defaultValue; + } + + /** * The message to gives to the exception to be thrown in case of unsupported operation. * * @param add {@code true} if this method is invoked from {@link #addKey(Object)} or {@link #addValue(Object)}. @@ -412,7 +426,7 @@ public abstract class AbstractMap<K,V> i @Override public boolean add(K e) {return AbstractMap.this.addKey(e);} @Override public Iterator<K> iterator() { final EntryIterator<K,V> it = entryIterator(); - return (it != null) ? new Keys<>(it) : Collections.<K>emptyIterator(); + return (it != null) ? new Keys<>(it) : Collections.emptyIterator(); } /** Overridden for the same reason than {@link AbstractMap#equals(Object). */ @@ -459,7 +473,7 @@ public abstract class AbstractMap<K,V> i @Override public boolean add(V e) {return AbstractMap.this.addValue(e);} @Override public Iterator<V> iterator() { final EntryIterator<K,V> it = entryIterator(); - return (it != null) ? new Values<>(it) : Collections.<V>emptyIterator(); + return (it != null) ? new Values<>(it) : Collections.emptyIterator(); } }; } @@ -494,7 +508,7 @@ public abstract class AbstractMap<K,V> i /** Returns an iterator compliant to the Map contract. */ @Override public Iterator<Entry<K,V>> iterator() { final EntryIterator<K,V> it = entryIterator(); - return (it != null) ? new Entries<>(it) : Collections.<Entry<K,V>>emptyIterator(); + return (it != null) ? new Entries<>(it) : Collections.emptyIterator(); } /** Overridden for the same reason than {@link AbstractMap#equals(Object). */ Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -29,8 +29,7 @@ import org.opengis.parameter.InvalidPara import static org.apache.sis.util.collection.Containers.hashMapCapacity; // Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; -import org.apache.sis.internal.jdk8.Predicate; +import java.util.function.Predicate; /** @@ -76,8 +75,12 @@ public final class CollectionsExt extend return Collections.EMPTY_LIST; } else if (type.isAssignableFrom(Set.class)) { return Collections.EMPTY_SET; - } if (type.isAssignableFrom(SortedSet.class)) { - return emptySortedSet(); + } else if (type.isAssignableFrom(NavigableSet.class)) { // Rarely used case (at least in SIS). + if (type.isAssignableFrom(SortedSet.class)) { + return Collections.emptySortedSet(); + } else { + return Collections.emptyNavigableSet(); + } } else if (type.isAssignableFrom(Queue.class)) { return emptyQueue(); } else { @@ -152,24 +155,6 @@ public final class CollectionsExt extend } /** - * Returns a {@linkplain SortedSet sorted set} which is always empty and accepts no element. - * - * <div class="note"><b>Note:</b> - * This method exists only on the JDK7 branch, not on the JDK8 branch, - * since an equivalent method has been added to the JDK.</div> - * - * @param <E> The type of elements in the empty collection. - * @return An empty collection. - * - * @see Collections#emptyList() - * @see Collections#emptySet() - */ - @SuppressWarnings({"unchecked","rawtype"}) - public static <E> SortedSet<E> emptySortedSet() { - return EmptySortedSet.INSTANCE; - } - - /** * Returns the given value as a singleton if non-null, or returns an empty set otherwise. * * @param <E> the element type. @@ -177,7 +162,7 @@ public final class CollectionsExt extend * @return a collection containing the given element if non-null, or an empty collection otherwise. */ public static <E> Set<E> singletonOrEmpty(final E element) { - return (element != null) ? Collections.singleton(element) : Collections.<E>emptySet(); + return (element != null) ? Collections.singleton(element) : Collections.emptySet(); } /** @@ -867,7 +852,7 @@ public final class CollectionsExt extend final String lower = name.toLowerCase(namesLocale); if (!name.equals(lower)) { if (generated.add(lower)) { - JDK8.putIfAbsent(map, lower, value); + map.putIfAbsent(lower, value); } else { /* * Two entries having non-lower case names got the same name after conversion to Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -24,9 +24,6 @@ import org.apache.sis.math.Fraction; import org.apache.sis.math.MathFunctions; import org.apache.sis.math.DecimalFunctions; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Basic arithmetic methods for extended precision numbers using the <cite>double-double</cite> algorithm. @@ -335,7 +332,7 @@ public final class DoubleDouble extends @Override public double doubleValue() {return value;} @Override public float floatValue() {return (float) value;} @Override public long longValue() {return Math.round(value);} - @Override public int intValue() {return JDK8.toIntExact(longValue());} + @Override public int intValue() {return Math.toIntExact(longValue());} /** * Suggests an {@link #error} for the given value. The {@code DoubleDouble} class contains a hard-coded list Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -25,9 +25,6 @@ import org.apache.sis.util.ComparisonMod import static java.lang.Math.max; import static java.lang.Math.abs; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; - /** * Miscellaneous utilities methods working on floating point numbers. @@ -186,7 +183,7 @@ public final class Numerics extends Stat if (data == null) return null; final int[] result = new int[data.length]; for (int i=0; i<data.length; i++) { - result[i] = JDK8.toIntExact(Math.round(data[i])); + result[i] = Math.toIntExact(Math.round(data[i])); } return result; } @@ -315,7 +312,7 @@ public final class Numerics extends Stat return value; } else { // Following hack is inefficient, but should rarely be needed. - return Float.parseFloat(JDK8.toUnsignedString(value)); + return Float.parseFloat(Long.toUnsignedString(value)); } } @@ -332,7 +329,7 @@ public final class Numerics extends Stat return value; } else { // Following hack is inefficient, but should rarely be needed. - return Double.parseDouble(JDK8.toUnsignedString(value)); + return Double.parseDouble(Long.toUnsignedString(value)); } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -16,16 +16,32 @@ */ package org.apache.sis.internal.util; +import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import java.text.DateFormat; +import java.text.NumberFormat; import java.text.FieldPosition; import java.text.ParsePosition; -import java.text.SimpleDateFormat; +import java.text.ParseException; // Branch-dependent imports -import org.apache.sis.internal.jdk8.Temporal; -import org.apache.sis.internal.jdk8.DateTimeException; +import java.time.DateTimeException; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.temporal.Temporal; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalAccessor; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.format.SignStyle; /** @@ -55,12 +71,12 @@ import org.apache.sis.internal.jdk8.Date * @since 0.6 * @module */ -public final class StandardDateFormat extends SimpleDateFormat { +public final class StandardDateFormat extends DateFormat { /** * For cross-version compatibility. * This number must be different between the JDK8 branch and pre-JDK8 branches. */ - private static final long serialVersionUID = 1552761359761440473L; + private static final long serialVersionUID = 2764313272939921664L; /** * The {@value} timezone ID. @@ -68,32 +84,52 @@ public final class StandardDateFormat ex public static final String UTC = "UTC"; /** - * Short version of {@link #PATTERN}, to be used when formatting temporal extents - * if the duration is greater than some threshold (typically one day). This pattern must - * be a prefix of {@link #PATTERN}, since we will use that condition for deciding - * if this pattern is really shorter (the user could have created his own date format - * with a different pattern). + * The thread-safe instance to use for reading and formatting dates. + * Only the year is mandatory, all other fields are optional. */ - public static final String SHORT_PATTERN = "yyyy-MM-dd"; + public static final DateTimeFormatter FORMAT = new DateTimeFormatterBuilder() + // parseLenient() is for allowing fields with one digit instead of two. + .parseLenient() .appendValue(ChronoField.YEAR, 4, 5, SignStyle.NORMAL) // Proleptic year (use negative number if needed). + .optionalStart().appendLiteral('-').appendValue(ChronoField.MONTH_OF_YEAR, 2) + .optionalStart().appendLiteral('-').appendValue(ChronoField.DAY_OF_MONTH, 2) + .optionalStart().appendLiteral('T').appendValue(ChronoField.HOUR_OF_DAY, 2) + .optionalStart().appendLiteral(':').appendValue(ChronoField.MINUTE_OF_HOUR, 2) + .optionalStart().appendLiteral(':').appendValue(ChronoField.SECOND_OF_MINUTE, 2) + .appendFraction(ChronoField.MILLI_OF_SECOND, 3, 3, true) + .optionalEnd().optionalEnd().optionalEnd() // Move back to the optional block of HOUR_OF_DAY. + .optionalStart().appendOffsetId() + .toFormatter(Locale.ROOT); /** - * The pattern of time. We use 3 fraction digits for the seconds because {@code SimpleDateFormat} parses the - * milliseconds as an integer instead than as fraction digits. For example with 1 fraction digits, "00:00:01.4" - * is parsed as 1.004 seconds instead of 1.4. While surprising, this is conform to the {@code SimpleDateFormat} - * specification. Note that this is different than {@link java.time.LocalDateTime} which parse those numbers as - * fraction digits. + * The kind of objects to get from calls to {@link #parseBest(CharSequence)}, in preference order. + * The time is converted to UTC timezone if possible. + * + * Tip: if we want to preserve the timezone instead than converting to UTC, we could try replacing + * {@code Instant::from} by {@code ZonedDateTime::from, OffsetDateTime::from}. */ - public static final String TIME_PATTERN = "HH:mm:ss.SSSX"; + private static TemporalQuery<?>[] QUERIES = { + Instant::from, LocalDateTime::from, LocalDate::from + }; /** - * Number of fraction digits in {@link #TIME_PATTERN}. + * Parses the given date and/or time, which may have an optional timezone. This method applies heuristic rules + * for choosing if the object should be returned as a local date, or a date and time with timezone, <i>etc</i>. + * + * @param text the character string to parse, or {@code null}. + * @return a temporal object for the given text, or {@code null} if the given text was null. + * @throws DateTimeParseException if the text can not be parsed as a date. + * + * @since 0.8 */ - private static final int NUM_FRACTION_DIGITS = 3; + public static Temporal parseBest(final CharSequence text) { + // Cast is safe if all QUERIES elements return a Temporal subtype. + return (text != null) ? (Temporal) FORMAT.parseBest(text, QUERIES) : null; + } /** - * The pattern of dates. + * The length of a day in number of milliseconds. */ - public static final String PATTERN = SHORT_PATTERN + "'T'" + TIME_PATTERN; + public static final int MILLISECONDS_PER_DAY = 24*60*60*1000; /** * Number of nanoseconds in one millisecond. @@ -106,35 +142,79 @@ public final class StandardDateFormat ex public static final long NANOS_PER_SECOND = 1000000000; /** - * The length of a day in number of milliseconds. + * Converts the given legacy {@code Date} object into a {@code java.time} implementation in given timezone. + * The method performs the following choice: + * + * <ul> + * <li>If the given date has zero values in hours, minutes, seconds and milliseconds fields in UTC timezone, + * then the returned implementation will be a {@link LocalDate}, dropping the timezone information (i.e. + * the date is considered approximative). Note that this is consistent with ISO 19162 requirement that + * dates are always in UTC, even if Apache SIS allows some flexibility.</li> + * <li>Otherwise if the timezone is not {@code null} and not UTC, then this method returns an {@link OffsetDateTime}.</li> + * <li>Otherwise this method returns a {@link LocalDateTime} in the given timezone.</li> + * </ul> + * + * @param date the date to convert, or {@code null}. + * @param zone the timezone of the temporal object to obtain, or {@code null} for UTC. + * @return the temporal object for the given date, or {@code null} if the given argument was null. */ - public static final int MILLISECONDS_PER_DAY = 24*60*60*1000; + public static Temporal toHeuristicTemporal(final Date date, ZoneId zone) { + if (date == null) { + return null; + } + final long time = date.getTime(); + if ((time % MILLISECONDS_PER_DAY) == 0) { + return LocalDate.ofEpochDay(time / MILLISECONDS_PER_DAY); + } + final Instant instant = Instant.ofEpochMilli(time); + if (zone == null) { + zone = ZoneOffset.UTC; + } else if (!zone.equals(ZoneOffset.UTC)) { + return OffsetDateTime.ofInstant(instant, zone); + } + return LocalDateTime.ofInstant(instant, zone); + } /** * Converts the given temporal object into a date. + * The given temporal object is typically the value parsed by {@link #FORMAT}. * * @param temporal the temporal object to convert, or {@code null}. * @return the legacy date for the given temporal object, or {@code null} if the argument was null. * @throws DateTimeException if a value for the field cannot be obtained. * @throws ArithmeticException if the number of milliseconds is too large. */ - public static Date toDate(final Temporal temporal) { + public static Date toDate(final TemporalAccessor temporal) { if (temporal == null) { return null; } - return new Date(temporal.millis); + long millis; + if (temporal instanceof Instant) { + millis = ((Instant) temporal).toEpochMilli(); + } else if (temporal.isSupported(ChronoField.INSTANT_SECONDS)) { + millis = Math.multiplyExact(temporal.getLong(ChronoField.INSTANT_SECONDS), 1000); + millis = Math.addExact(millis, temporal.getLong(ChronoField.NANO_OF_SECOND) / 1000000); + } else { + // Note that the timezone may be unknown here. We assume UTC. + millis = Math.multiplyExact(temporal.getLong(ChronoField.EPOCH_DAY), MILLISECONDS_PER_DAY); + if (temporal.isSupported(ChronoField.MILLI_OF_DAY)) { + millis = Math.addExact(millis, temporal.getLong(ChronoField.MILLI_OF_DAY)); + } + } + return new Date(millis); } /** - * {@code true} if the user has invoked {@link #applyPattern(String)} or {@link #applyLocalizedPattern(String)}. + * The {@code java.time} parser and formatter. This is usually the {@link #FORMAT} instance + * unless a different locale or timezone has been specified. */ - private boolean isUserSpecifiedPattern; + private DateTimeFormatter format; /** * Creates a new format for a default locale in the UTC timezone. */ public StandardDateFormat() { - this(Locale.CANADA); // Canada locale symbols are close to the ISO ones. + format = FORMAT; } /** @@ -143,7 +223,7 @@ public final class StandardDateFormat ex * @param locale the locale of the format to create. */ public StandardDateFormat(final Locale locale) { - this(locale, TimeZone.getTimeZone(UTC)); + format = FORMAT.withLocale(locale); // Same instance as FORMAT if the locales are equal. } /** @@ -153,30 +233,82 @@ public final class StandardDateFormat ex * @param zone the timezone. */ public StandardDateFormat(final Locale locale, final TimeZone zone) { - super(PATTERN, locale); - calendar = new ISOCalendar(locale, zone); + this(locale); + if (!UTC.equals(zone.getID())) { + setTimeZone(zone); + } } /** - * Sets a user-specified pattern. + * Returns the calendar, creating it when first needed. This {@code StandardDateFormat} class does not use the + * calendar, but we nevertheless create it if requested in order to comply with {@code DateFormat} contract. * - * @param pattern the user-specified pattern. + * @return a calendar, created when first needed. */ @Override - public void applyPattern(final String pattern) { - super.applyPattern(pattern); - isUserSpecifiedPattern = true; + public final Calendar getCalendar() { + if (calendar == null) { + calendar = Calendar.getInstance(getTimeZone(), format.getLocale()); + } + return calendar; + } + + /** + * Returns the number format, creating it when first needed. This {@code StandardDateFormat} class does not use the + * number format, but we nevertheless create it if requested in order to comply with {@code DateFormat} contract. + * + * @return a number format, created when first needed. + */ + @Override + public final NumberFormat getNumberFormat() { + if (numberFormat == null) { + numberFormat = NumberFormat.getInstance(format.getLocale()); + } + return numberFormat; + } + + /** + * Returns the timezone used for formatting instants. + * + * @return the timezone. + */ + @Override + public final TimeZone getTimeZone() { + final ZoneId zone = format.getZone(); + return TimeZone.getTimeZone(zone != null ? zone : ZoneOffset.UTC); + } + + /** + * Sets the timezone. + * + * @param zone the new timezone. + */ + @Override + public final void setTimeZone(final TimeZone zone) { + format = format.withZone(zone.toZoneId()); + if (calendar != null) { + super.setTimeZone(zone); + } } /** - * Sets a user-specified pattern. + * Overridden for compliance with {@code DateFormat} contract, but has no incidence on this format. * - * @param pattern the user-specified pattern. + * @param lenient value forwarded to {@link Calendar#setLenient(boolean)}. */ @Override - public void applyLocalizedPattern(final String pattern) { - super.applyLocalizedPattern(pattern); - isUserSpecifiedPattern = true; + public final void setLenient(boolean lenient) { + getCalendar().setLenient(lenient); + } + + /** + * Overridden for compliance with {@code DateFormat} contract, but has no incidence on this format. + * + * @return value fetched {@link Calendar#isLenient()}. + */ + @Override + public final boolean isLenient() { + return getCalendar().isLenient(); } /** @@ -190,15 +322,8 @@ public final class StandardDateFormat ex */ @Override public StringBuffer format(final Date date, final StringBuffer toAppendTo, final FieldPosition pos) { - if (!isUserSpecifiedPattern && (date.getTime() % MILLISECONDS_PER_DAY) == 0 && UTC.equals(getTimeZone().getID())) { - try { - super.applyPattern(SHORT_PATTERN); - return super.format(date, toAppendTo, pos); - } finally { - super.applyPattern(PATTERN); - } - } - return super.format(date, toAppendTo, pos); + format.formatTo(toHeuristicTemporal(date, null), toAppendTo); + return toAppendTo; } /** @@ -210,151 +335,74 @@ public final class StandardDateFormat ex */ @Override public Date parse(final String text, final ParsePosition position) { - if (isUserSpecifiedPattern) { - return super.parse(text, position); + try { + return toDate(format.parse(text, position)); + } catch (DateTimeException | ArithmeticException e) { + position.setErrorIndex(getErrorIndex(e, position)); + return null; } - final int fromIndex = position.getIndex(); - final String modified = dateToISO(text, fromIndex, false); - position.setIndex(0); - final Date date = super.parse(modified, position); - position.setIndex (adjustIndex(text, modified, fromIndex, position.getIndex())); - position.setErrorIndex(adjustIndex(text, modified, fromIndex, position.getErrorIndex())); - return date; } /** - * Modifies if needed a given input string in order to make it compliant with JDK7 implementation of - * {@code SimpleDateFormat}. That implementation expects the exact same number of fraction digits in - * the second fields than specified by the {@code "ss.SSS"} part of the pattern. This method adds or - * removes fraction digits as needed, and adds a {@code "Z"} suffix if the string has no timezone. - * - * <p>The string returned by this method starts at {@code fromIndex} and stop after an arbitrary amount - * of characters (may be more characters than actually needed for parsing the date).</p> - * - * @param text the text to adapt. - * @param fromIndex index in {@code text} where to start the adaptation. - * @param isTime {@code true} if parsing only a time, or {@code false} if parsing a day and a time. - * @return the modified input string, with second fraction digits added or removed. - */ - @SuppressWarnings("fallthrough") - public static String dateToISO(final CharSequence text, int fromIndex, boolean isTime) { - if (text == null) { - return null; - } - final StringBuilder modified = new StringBuilder(30); - /* - * Copy characters from the given text to the buffer as long as it seems to be part of a date. - * We do not perform a strict check, so we may copy more characters than needed; it will be the - * DateFormat' job to tell to the caller where the date ends. - */ - int numDigits = 0; - int missingTimeFields = 2; - boolean isFraction = false; - boolean isTimeZone = false; -copy: while (fromIndex < text.length()) { - char c = text.charAt(fromIndex++); - if (c >= '0' && c <= '9') { - if (++numDigits > NUM_FRACTION_DIGITS && isFraction) { - continue; // Ignore extraneous fraction digits. - } - } else { - switch (c) { - default: { - break copy; - } - case 'T': { - if (isTime) break copy; - isTime = true; - break; - } - case ':': { - if (!isTime | isFraction) break copy; - missingTimeFields--; - break; - } - case '.': { - if (!isTime | isFraction | isTimeZone) break copy; - isFraction = true; - break; - } - case '-': { - if (!isTime) break; // Separator between year-month-day: nothing to do. - // Otherwise timezone offset: same work than for the '+' case (fallthrough). - } - case '+': - case 'Z': { - if (!isTime | isTimeZone) break copy; - if (!isFraction) { - while (--missingTimeFields >= 0) { - modified.append(":00"); - } - modified.append('.'); - numDigits = 0; - } - while (numDigits < NUM_FRACTION_DIGITS) { - modified.append('0'); - numDigits++; - } - isFraction = false; - isTimeZone = true; - break; - } - } - if (numDigits == 1) { - modified.insert(modified.length() - 1, '0'); - } - numDigits = 0; - } - modified.append(c); + * Parses the given text. + * + * @param text the text to parse. + * @return the date (never null). + * @throws ParseException if the parsing failed. + */ + @Override + public Date parse(final String text) throws ParseException { + try { + return toDate(format.parse(text)); + } catch (DateTimeException | ArithmeticException e) { + throw (ParseException) new ParseException(e.getLocalizedMessage(), getErrorIndex(e, null)).initCause(e); } - /* - * Check for missing time fields and time zone. For example if the given date is - * "2005-09-22T00:00", then this method will completes it as "2005-09-22T00:00:00". - * In addition, a 'Z' suffix will be appended if needed. - */ - if (numDigits == 1) { - modified.insert(modified.length() - 1, '0'); - } - if (!isTimeZone) { - if (!isTime) { - modified.append("T00"); - } - if (!isFraction) { - while (--missingTimeFields >= 0) { - modified.append(":00"); - } - modified.append('.'); - numDigits = 0; - } - while (numDigits < NUM_FRACTION_DIGITS) { - modified.append('0'); - numDigits++; - } - modified.append('Z'); + } + + /** + * Tries to infer the index where the parsing error occurred. + */ + private static int getErrorIndex(final RuntimeException e, final ParsePosition position) { + if (e instanceof DateTimeParseException) { + return ((DateTimeParseException) e).getErrorIndex(); + } else if (position != null) { + return position.getIndex(); + } else { + return 0; } - return modified.toString(); } /** - * Maps an index in the modified string to the index in the original string. + * Returns a hash code value for this format. * - * @param text the original text specified by the user. - * @param modified the modified text that has been parsed. - * @param offset index of the first {@code text} character copied in {@code modified}. - * @param index the index in the modified string. - * @return the corresponding index in the original text. + * @return a hash code value for this format. */ - static int adjustIndex(final String text, final String modified, int offset, final int index) { - if (index < 0) { - return index; - } - if (!text.isEmpty()) { - for (int i=0; i<index; i++) { - if (modified.charAt(i) == text.charAt(offset)) { - if (++offset >= text.length()) break; - } - } - } - return offset; + @Override + public int hashCode() { + return 31 * format.hashCode(); + } + + /** + * Compares this format with the given object for equality. + * + * @param obj the object to compare with this format. + * @return if the two objects format in the same way. + */ + @Override + public boolean equals(final Object obj) { + return (obj instanceof StandardDateFormat) && format.equals(((StandardDateFormat) obj).format); + } + + /** + * Returns a clone of this format. + * + * @return a clone of this format. + */ + @Override + @SuppressWarnings("CloneDoesntCallSuperClone") + public Object clone() { + final StandardDateFormat clone = new StandardDateFormat(); + clone.format = format; + return clone; } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -47,7 +47,7 @@ import org.apache.sis.internal.util.Loca import static org.apache.sis.internal.util.StandardDateFormat.UTC; // Branch-dependent imports -import org.apache.sis.internal.jdk8.UncheckedIOException; +import java.io.UncheckedIOException; /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -17,16 +17,13 @@ package org.apache.sis.math; import java.io.Serializable; +import java.util.function.IntSupplier; import org.apache.sis.util.Numbers; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.collection.CheckedContainer; import org.apache.sis.internal.util.Numerics; import org.apache.sis.measure.NumberRange; -// Branch-dependent imports -import org.apache.sis.internal.jdk8.JDK8; -import org.apache.sis.internal.jdk8.IntSupplier; - /** * A vector backed by an array of a primitive type. This class does not copy the array, @@ -719,7 +716,7 @@ abstract class ArrayVector<E extends Num /** Returns the string representation at the given index. */ @Override public String stringValue(final int index) { - return JDK8.toUnsignedString(super.longValue(index)); + return Long.toUnsignedString(super.longValue(index)); } /** Finds the minimum and maximum values in the array or in a subset of the array. */ @@ -751,7 +748,7 @@ abstract class ArrayVector<E extends Num @Override public boolean isUnsigned() {return true;} @Override public double doubleValue(int index) {return longValue(index);} @Override public float floatValue(int index) {return longValue(index);} - @Override public long longValue(int index) {return super.intValue(index) & 0xFFFFFFFFL;} + @Override public long longValue(int index) {return Integer.toUnsignedLong(super.intValue(index));} @Override public int intValue(int index) { final int value = super.intValue(index); if (value >= 0) return value; @@ -760,7 +757,7 @@ abstract class ArrayVector<E extends Num /** Returns the string representation at the given index. */ @Override public String stringValue(final int index) { - return JDK8.toUnsignedString(super.intValue(index)); + return Integer.toUnsignedString(super.intValue(index)); } /** Finds the minimum and maximum values in the array or in a subset of the array. */ @@ -792,8 +789,8 @@ abstract class ArrayVector<E extends Num @Override public boolean isUnsigned() {return true;} @Override public double doubleValue(int index) {return intValue(index);} @Override public float floatValue(int index) {return intValue(index);} - @Override public long longValue(int index) {return super.shortValue(index) & 0xFFFFL;} - @Override public int intValue(int index) {return super.shortValue(index) & 0xFFFF;} + @Override public long longValue(int index) {return Short.toUnsignedLong(super.shortValue(index));} + @Override public int intValue(int index) {return Short.toUnsignedInt (super.shortValue(index));} @Override public short shortValue(int index) { final short value = super.shortValue(index); if (value >= 0) return value; @@ -834,8 +831,8 @@ abstract class ArrayVector<E extends Num @Override public boolean isUnsigned() {return true;} @Override public double doubleValue(int index) {return intValue(index);} @Override public float floatValue(int index) {return intValue(index);} - @Override public long longValue(int index) {return JDK8.toUnsignedLong (super.byteValue(index));} - @Override public int intValue(int index) {return JDK8.toUnsignedInt (super.byteValue(index));} + @Override public long longValue(int index) {return Byte.toUnsignedLong (super.byteValue(index));} + @Override public int intValue(int index) {return Byte.toUnsignedInt (super.byteValue(index));} @Override public short shortValue(int index) {return (short) intValue(index);} @Override public byte byteValue(int index) { final byte value = super.byteValue(index); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/CompoundDirectPositions.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/CompoundDirectPositions.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/CompoundDirectPositions.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/CompoundDirectPositions.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -153,12 +153,4 @@ final class CompoundDirectPositions impl public void setOrdinate(int dimension, double value) { throw new UnsupportedOperationException(); } - - /** - * Not needed. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Fraction.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -18,7 +18,6 @@ package org.apache.sis.math; import java.io.Serializable; import org.apache.sis.util.collection.WeakHashSet; -import org.apache.sis.internal.jdk8.JDK8; /** @@ -151,7 +150,7 @@ public final class Fraction extends Numb } } return (num == numerator && den == denominator) ? this - : new Fraction(JDK8.toIntExact(num), JDK8.toIntExact(den)); + : new Fraction(Math.toIntExact(num), Math.toIntExact(den)); } /** @@ -162,7 +161,7 @@ public final class Fraction extends Numb * @throws ArithmeticException if the result overflows. */ public Fraction negate() { - return (numerator == 0) ? this : new Fraction(-numerator, denominator); + return (numerator == 0) ? this : new Fraction(Math.negateExact(numerator), denominator); } /** @@ -176,7 +175,7 @@ public final class Fraction extends Numb // Intermediate result must be computed in a type wider that the 'numerator' and 'denominator' type. final long td = this .denominator; final long od = other.denominator; - return simplify(JDK8.addExact(od * numerator, td * other.numerator), od * td); + return simplify(Math.addExact(od * numerator, td * other.numerator), od * td); } /** @@ -190,7 +189,7 @@ public final class Fraction extends Numb // Intermediate result must be computed in a type wider that the 'numerator' and 'denominator' type. final long td = this .denominator; final long od = other.denominator; - return simplify(JDK8.subtractExact(od * numerator, td * other.numerator), od * td); + return simplify(Math.subtractExact(od * numerator, td * other.numerator), od * td); } /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1822268&r1=1822267&r2=1822268&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] Fri Jan 26 10:48:27 2018 @@ -687,7 +687,7 @@ public final class MathFunctions extends primes = MathFunctions.primes; if (index >= primes.length) { int i = primes.length; - int n = primes[i - 1] & 0xFFFF; + int n = Short.toUnsignedInt(primes[i - 1]); // Compute by block of 16 values, for reducing the amount of array resize. primes = Arrays.copyOf(primes, Math.min((index | 0xF) + 1, PRIMES_LENGTH_16_BITS)); do { @@ -696,7 +696,7 @@ testNextNumber: while (true) { int prime; int j = 0; do { - prime = primes[++j] & 0xFFFF; + prime = Short.toUnsignedInt(primes[++j]); if (n % prime == 0) { continue testNextNumber; } @@ -709,7 +709,7 @@ testNextNumber: while (true) { } } } - return primes[index] & 0xFFFF; + return Short.toUnsignedInt(primes[index]); } /** @@ -742,7 +742,7 @@ testNextNumber: while (true) { return p; } } - return primes[i] & 0xFFFF; + return Short.toUnsignedInt(primes[i]); } /**