Merge the addition of AlbersEqualArea projection from JDK7 branch.
git-svn-id: https://svn.apache.org/repos/asf/sis/branches/JDK6@1754380 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/application/pom.xml b/application/pom.xml
index 92d0621..983073d 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/application/sis-console/pom.xml b/application/sis-console/pom.xml
index e7a2412..f64b3ad 100644
--- a/application/sis-console/pom.xml
+++ b/application/sis-console/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>application</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java b/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java
index 838a61a..32de1ac 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java
@@ -114,11 +114,14 @@
final TreeTable table;
try {
final JMXServiceURL url = new JMXServiceURL(path);
- try (JMXConnector jmxc = JMXConnectorFactory.connect(url)) {
+ final JMXConnector jmxc = JMXConnectorFactory.connect(url);
+ try {
final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
final SupervisorMBean bean = JMX.newMBeanProxy(mbsc, new ObjectName(Supervisor.NAME), SupervisorMBean.class);
table = bean.configuration(sections, locale, timezone);
warnings = bean.warnings(locale);
+ } finally {
+ jmxc.close();
}
} catch (IOException e) {
error(Errors.format(Errors.Keys.CanNotConnectTo_1, path), e);
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/Command.java b/application/sis-console/src/main/java/org/apache/sis/console/Command.java
index d0eda7b..9b33698 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/Command.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/Command.java
@@ -154,17 +154,15 @@
command = new HelpCommand(-1, args);
} else {
commandName = commandName.toLowerCase(Locale.US);
- switch (commandName) {
- case "help": command = new HelpCommand (commandIndex, args); break;
- case "about": command = new AboutCommand (commandIndex, args); break;
- case "mime-type": command = new MimeTypeCommand (commandIndex, args); break;
- case "metadata": command = new MetadataCommand (commandIndex, args); break;
- case "crs": command = new CRSCommand (commandIndex, args); break;
- case "identifier": command = new IdentifierCommand(commandIndex, args); break;
- case "transform": command = new TransformCommand (commandIndex, args); break;
- default: throw new InvalidCommandException(Errors.format(
- Errors.Keys.UnknownCommand_1, commandName), commandName);
- }
+ if (commandName.equals("help")) command = new HelpCommand (commandIndex, args);
+ else if (commandName.equals("about")) command = new AboutCommand (commandIndex, args);
+ else if (commandName.equals("mime-type")) command = new MimeTypeCommand (commandIndex, args);
+ else if (commandName.equals("metadata")) command = new MetadataCommand (commandIndex, args);
+ else if (commandName.equals("crs")) command = new CRSCommand (commandIndex, args);
+ else if (commandName.equals("identifier")) command = new IdentifierCommand(commandIndex, args);
+ else if (commandName.equals("transform")) command = new TransformCommand (commandIndex, args);
+ else throw new InvalidCommandException(Errors.format(
+ Errors.Keys.UnknownCommand_1, commandName), commandName);
}
this.commandName = commandName;
CommandRunner.instance = command; // For ResourcesDownloader only.
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java b/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java
index ff5dc72..baef15d 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java
@@ -160,8 +160,8 @@
{
boolean isTest = false;
this.validOptions = validOptions;
- options = new EnumMap<>(Option.class);
- files = new ArrayList<>(arguments.length);
+ options = new EnumMap<Option,String>(Option.class);
+ files = new ArrayList<String>(arguments.length);
for (int i=0; i<arguments.length; i++) {
final String arg = arguments[i];
if (i == commandIndex) {
@@ -200,7 +200,7 @@
debug = options.containsKey(option = Option.DEBUG);
value = options.get(option = Option.LOCALE);
- locale = (value != null) ? Locales.parse(value) : Locale.getDefault(Locale.Category.DISPLAY);
+ locale = (value != null) ? Locales.parse(value) : Locale.getDefault();
value = options.get(option = Option.TIMEZONE);
timezone = (value != null) ? TimeZone.getTimeZone(value) : TimeZone.getDefault();
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java b/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
index 24ab26a..d6161cc 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
@@ -123,7 +123,7 @@
if (metadata != null) {
final List<Row> rows;
if (metadata instanceof Metadata) {
- rows = new ArrayList<>();
+ rows = new ArrayList<Row>();
final Identifier id = ((Metadata) metadata).getMetadataIdentifier();
if (id != null) {
CharSequence desc = id.getDescription();
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java b/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
index 93919e8..2b4c92b 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
@@ -135,8 +135,11 @@
*/
final Object readMetadataOrCRS() throws DataStoreException, FactoryException {
if (useStandardInput()) {
- try (DataStore store = DataStores.open(System.in)) {
+ final DataStore store = DataStores.open(System.in);
+ try {
return store.getMetadata();
+ } finally {
+ store.close();
}
} else if (hasUnexpectedFileCount(1, 1)) {
hasUnexpectedFileCount = true;
@@ -146,8 +149,11 @@
if (CodeType.guess(file).isCRS) {
return CRS.forCode(file);
} else {
- try (DataStore store = DataStores.open(file)) {
+ final DataStore store = DataStores.open(file);
+ try {
return store.getMetadata();
+ } finally {
+ store.close();
}
}
}
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java b/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java
index 88590ef..d3ac129 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java
@@ -22,14 +22,10 @@
import java.net.URISyntaxException;
import org.apache.sis.storage.DataStores;
import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.CharSequences;
// Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.FileSystemNotFoundException;
+import org.apache.sis.internal.jdk7.Files;
/**
@@ -93,13 +89,8 @@
// If the URI is not absolute, we will not be able to convert to Path.
// Open as a String, leaving the conversion to DataStore implementations.
type = DataStores.probeContentType(file);
- } else try {
- type = Files.probeContentType(Paths.get(uri));
- } catch (IllegalArgumentException | FileSystemNotFoundException e) {
+ } else {
type = DataStores.probeContentType(uri);
- } catch (NoSuchFileException e) {
- error(Errors.format(Errors.Keys.CanNotOpen_1, uri), e);
- return Command.IO_EXCEPTION_EXIT_CODE;
}
/*
* Output of Unix "file --mime-type" Unix command is of the form:
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java b/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
index bee7105..fbc2c2a 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
@@ -39,8 +39,8 @@
import static org.apache.sis.internal.util.Constants.EPSG;
// Branch-dependent imports
-import java.nio.file.AccessDeniedException;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.AccessDeniedException;
+import org.apache.sis.internal.jdk7.Path;
/**
@@ -99,7 +99,7 @@
* The localized answers expected from the users. Keys are words like "Yes" or "No"
* and boolean values are the meaning of the keys.
*/
- private final Map<String,Boolean> answers = new HashMap<>();
+ private final Map<String,Boolean> answers = new HashMap<String,Boolean>();
/**
* {@code true} if the user has accepted the EPSG terms of use, {@code false} if (s)he refused,
diff --git a/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java b/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
index 035e194..fa45048 100644
--- a/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
+++ b/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
@@ -172,8 +172,11 @@
throw new InvalidOptionException(Errors.format(Errors.Keys.IllegalOptionValue_2, name, identifier), e, name);
} else {
final Metadata metadata;
- try (DataStore store = DataStores.open(identifier)) {
+ final DataStore store = DataStores.open(identifier);
+ try {
metadata = store.getMetadata();
+ } finally {
+ store.close();
}
if (metadata != null) {
for (final ReferenceSystem rs : metadata.getReferenceSystemInfo()) {
@@ -207,13 +210,19 @@
final boolean useStandardInput = useStandardInput();
if (useStandardInput || !files.isEmpty()) {
if (useStandardInput) {
- try (LineNumberReader in = new LineNumberReader(new InputStreamReader(System.in, encoding))) {
+ LineNumberReader in = new LineNumberReader(new InputStreamReader(System.in, encoding));
+ try {
points = readCoordinates(in, "stdin");
+ } finally {
+ in.close();
}
} else {
for (final String file : files) {
- try (LineNumberReader in = new LineNumberReader(new InputStreamReader(new FileInputStream(file), encoding))) {
+ LineNumberReader in = new LineNumberReader(new InputStreamReader(new FileInputStream(file), encoding));
+ try {
points = readCoordinates(in, file);
+ } finally {
+ in.close();
}
}
}
@@ -526,7 +535,7 @@
* @return the coordinate values.
*/
private List<double[]> readCoordinates(final LineNumberReader in, final String filename) throws IOException {
- final List<double[]> points = new ArrayList<>();
+ final List<double[]> points = new ArrayList<double[]>();
try {
String line;
while ((line = in.readLine()) != null) {
diff --git a/application/sis-console/src/test/java/org/apache/sis/console/CommandRunnerTest.java b/application/sis-console/src/test/java/org/apache/sis/console/CommandRunnerTest.java
index f8c93b4..b750ebf 100644
--- a/application/sis-console/src/test/java/org/apache/sis/console/CommandRunnerTest.java
+++ b/application/sis-console/src/test/java/org/apache/sis/console/CommandRunnerTest.java
@@ -28,7 +28,7 @@
import static org.apache.sis.test.TestUtilities.getSingleton;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
diff --git a/application/sis-javafx/pom.xml b/application/sis-javafx/pom.xml
index 351ec3c..b2b9788 100644
--- a/application/sis-javafx/pom.xml
+++ b/application/sis-javafx/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>application</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/application/sis-openoffice/pom.xml b/application/sis-openoffice/pom.xml
index 7526d76..b8784a3 100644
--- a/application/sis-openoffice/pom.xml
+++ b/application/sis-openoffice/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>application</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
index d90d818..53ff5de 100644
--- a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
+++ b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
@@ -94,7 +94,7 @@
* @return the angle format for this pattern and the given locale.
*/
private AngleFormat getAngleFormat(final Locale locale) {
- final CacheKey<AngleFormat> key = new CacheKey<>(AngleFormat.class, pattern, locale, null);
+ final CacheKey<AngleFormat> key = new CacheKey<AngleFormat>(AngleFormat.class, pattern, locale, null);
AngleFormat format = key.peek();
if (format == null) {
final Cache.Handler<AngleFormat> handler = key.lock();
diff --git a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
index 67ca574..6870fe1 100644
--- a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
+++ b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
@@ -20,7 +20,7 @@
import org.apache.sis.util.collection.Cache;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -37,7 +37,7 @@
/**
* The cache shared by all formulas.
*/
- private static final Cache<CacheKey<?>, Object> cache = new Cache<>(32, 10, true);
+ private static final Cache<CacheKey<?>,Object> cache = new Cache<CacheKey<?>,Object>(32, 10, true);
/**
* The type of cached value.
diff --git a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
index 1403936..1ed0222 100644
--- a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
+++ b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
@@ -111,7 +111,7 @@
private IdentifiedObject getIdentifiedObject(final String codeOrPath, CodeType type)
throws FactoryException, DataStoreException
{
- final CacheKey<IdentifiedObject> key = new CacheKey<>(IdentifiedObject.class, codeOrPath, null, null);
+ final CacheKey<IdentifiedObject> key = new CacheKey<IdentifiedObject>(IdentifiedObject.class, codeOrPath, null, null);
IdentifiedObject object = key.peek();
if (object == null) {
final Cache.Handler<IdentifiedObject> handler = key.lock();
@@ -131,8 +131,11 @@
* Try to read a dataset from a file or URL, then get its CRS.
*/
final Metadata metadata;
- try (DataStore store = DataStores.open(codeOrPath)) {
+ final DataStore store = DataStores.open(codeOrPath);
+ try {
metadata = store.getMetadata();
+ } finally {
+ store.close();
}
if (metadata != null) {
for (final ReferenceSystem rs : metadata.getReferenceSystemInfo()) {
@@ -168,7 +171,7 @@
final IdentifiedObject object;
final CodeType type = CodeType.guess(codeOrPath);
if (type.isCRS) {
- object = new CacheKey<>(IdentifiedObject.class, codeOrPath, null, null).peek();
+ object = new CacheKey<IdentifiedObject>(IdentifiedObject.class, codeOrPath, null, null).peek();
} else {
object = getIdentifiedObject(codeOrPath, type);
}
@@ -194,7 +197,7 @@
*/
@Override
public String getAxis(final String codeOrPath, final int dimension) {
- final CacheKey<String> key = new CacheKey<>(String.class, codeOrPath, dimension, null);
+ final CacheKey<String> key = new CacheKey<String>(String.class, codeOrPath, dimension, null);
String name = key.peek();
if (name == null) {
final Cache.Handler<String> handler = key.lock();
@@ -257,7 +260,7 @@
*/
@Override
public double[][] getGeographicArea(final String codeOrPath) {
- final CacheKey<GeographicBoundingBox> key = new CacheKey<>(GeographicBoundingBox.class, codeOrPath, null, null);
+ final CacheKey<GeographicBoundingBox> key = new CacheKey<GeographicBoundingBox>(GeographicBoundingBox.class, codeOrPath, null, null);
GeographicBoundingBox area = key.peek();
if (area == null) {
final Cache.Handler<GeographicBoundingBox> handler = key.lock();
diff --git a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
index 4867fa2..8bc5220 100644
--- a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
+++ b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
@@ -35,6 +35,9 @@
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.registry.XRegistryKey;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* The registration of all formulas provided in this package.
@@ -116,8 +119,11 @@
for (final String filename : content) {
final File packFile = new File(directory, filename);
final File jarFile = new File(directory, filename.substring(0, filename.length() - PACK.length()) + "jar");
- try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile))) {
+ final JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile));
+ try {
unpacker.unpack(packFile, out);
+ } finally {
+ out.close();
}
packFile.delete();
}
@@ -142,7 +148,10 @@
} catch (InvocationTargetException e) {
fatalException(caller, "Failed to install EPSG geodetic dataset.", e.getTargetException());
return false;
- } catch (ReflectiveOperationException | LinkageError e) {
+ } catch (Exception e) { // This is (ReflectiveOperationException | LinkageError) on the JDK7 branch.
+ classpathException(caller, e);
+ return false;
+ } catch (LinkageError e) {
classpathException(caller, e);
return false;
}
@@ -167,7 +176,7 @@
* Logs the given exception for a classpath problem.
*/
private static void classpathException(final String method, final Throwable exception) {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder message = new StringBuilder("Can not find Apache SIS classes.").append(lineSeparator)
.append("Classpath = ").append(System.getProperty("java.class.path"));
final ClassLoader loader = ReferencingFunctions.class.getClassLoader();
diff --git a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
index deb45a5..9610dc3 100644
--- a/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
+++ b/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
@@ -108,7 +108,7 @@
* Get the coordinate operation from the cache if possible, or compute it otherwise.
*/
final boolean hasAreaOfInterest = hasAreaOfInterest();
- final CacheKey<CoordinateOperation> key = new CacheKey<>(CoordinateOperation.class, targetCRS, sourceCRS,
+ final CacheKey<CoordinateOperation> key = new CacheKey<CoordinateOperation>(CoordinateOperation.class, targetCRS, sourceCRS,
hasAreaOfInterest ? new double[] {westBoundLongitude, eastBoundLongitude,
southBoundLatitude, northBoundLatitude} : null);
operation = key.peek();
diff --git a/application/sis-webapp/pom.xml b/application/sis-webapp/pom.xml
index 1fb436c..8882dcc 100644
--- a/application/sis-webapp/pom.xml
+++ b/application/sis-webapp/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>application</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
<groupId>org.apache.sis.application</groupId>
@@ -77,7 +77,7 @@
</executions>
</plugin>
<plugin>
- <groupId>org.eclipse.jetty</groupId>
+ <groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<stopKey>stopJetty</stopKey>
@@ -92,9 +92,12 @@
<goal>start</goal>
</goals>
<configuration>
- <httpConnector>
- <port>${jettyPort}</port>
- </httpConnector>
+ <connectors>
+ <!-- This is how the specify the port with Jetty 8. Note that Jetty 9 has a different way. -->
+ <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+ <port>${jettyPort}</port>
+ </connector>
+ </connectors>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
<systemProperties>
diff --git a/core/pom.xml b/core/pom.xml
index 5a0efa2..4b23e00 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/core/sis-build-helper/pom.xml b/core/sis-build-helper/pom.xml
index 06a4e10..e7d457f 100644
--- a/core/sis-build-helper/pom.xml
+++ b/core/sis-build-helper/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -89,7 +89,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
- <version>3.4</version>
+ <version>3.3</version> <!-- Last version compatible with JDK6 -->
<executions>
<execution>
<id>default-descriptor</id>
@@ -118,7 +118,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
- <version>3.4</version>
+ <version>3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -160,7 +160,7 @@
This copy will not be needed anymore if http://jira.codehaus.org/browse/MNG-3328
get fixed. -->
<profile>
- <id>jdk7-tools.jar</id>
+ <id>jdk6-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
index f3210aa..4ac22f7 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/Assembler.java
@@ -111,13 +111,13 @@
/**
* The {@code title} attributes found in abbreviations.
*/
- private final Map<String,String> abbreviations = new HashMap<>();
+ private final Map<String,String> abbreviations = new HashMap<String,String>();
/**
* Whether we found an abbreviation after the last {@code h?} element.
* This is used in order to avoid inserting too many abbreviation title.
*/
- private final Set<String> writtenAbbreviations = new HashSet<>();
+ private final Set<String> writtenAbbreviations = new HashSet<String>();
/**
* Section numbers, incremented when a new {@code <h1>}, {@code <h2>}, <i>etc.</i> element is found.
@@ -304,25 +304,20 @@
}
case Node.ELEMENT_NODE: {
final String name = node.getNodeName();
- switch (name) {
- case "xi:include": {
+ /* switch (name) */ {
+ if (name.equals("xi:include")) {
childNodes = replaceByBody(((Element) node).getAttribute("href"), node);
- break;
}
- case "aside":
- case "article": {
+ else if (name.equals("aside") || name.equals("article")) {
index = false;
- break;
}
- case "abbr": {
+ else if (name.equals("abbr")) {
processAbbreviation((Element) node);
- break;
}
- case "pre": {
+ else if (name.equals("pre")) {
colorizer.highlight(node, ((Element) node).getAttribute("class"));
- break;
}
- case "code": {
+ else if (name.equals("code")) {
if (!((Element) node).hasAttribute("class")) {
final String style = colorizer.styleForSingleIdentifier(node.getTextContent());
if (style != null) {
@@ -335,7 +330,7 @@
}
return; // Do not scan recursively the <code> text content.
}
- default: {
+ else {
if (name.length() == 2 && name.charAt(0) == 'h') {
final int c = name.charAt(1) - '0';
if (c >= 1 && c <= 9) {
@@ -363,7 +358,6 @@
}
}
}
- break;
}
}
break;
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/CodeColorizer.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/CodeColorizer.java
index 86ece72..843b426 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/CodeColorizer.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/book/CodeColorizer.java
@@ -47,7 +47,7 @@
/**
* Lists of Java keywords.
*/
- public static final Set<String> JAVA_KEYWORDS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ public static final Set<String> JAVA_KEYWORDS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
"abstract", "continue", "for", "new", "switch",
"assert", "default", "goto", "package", "synchronized",
"boolean", "do", "if", "private", "this",
@@ -106,20 +106,23 @@
*/
public CodeColorizer(final Document document) throws IOException, BookException {
this.document = document;
- identifierSpecifiers = new HashMap<>(1000);
+ identifierSpecifiers = new HashMap<String,Specifier>(1000);
for (final Specifier specifier : Specifier.values()) {
final String filename = specifier.name() + ".lst";
final InputStream in = CodeColorizer.class.getResourceAsStream(filename);
if (in == null) {
throw new FileNotFoundException(filename);
}
- try (final BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"))) {
+ final BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ try {
String line;
while ((line = r.readLine()) != null) {
if (identifierSpecifiers.put(line, specifier) != null) {
throw new BookException(line + " is defined twice in " + specifier);
}
}
+ } finally {
+ r.close();
}
}
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
index bdba477..1564e71 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
@@ -28,8 +28,6 @@
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.nio.file.FileSystemException;
-import java.nio.file.Files;
import com.sun.javadoc.RootDoc;
import com.sun.tools.doclets.formats.html.HtmlDoclet;
@@ -164,9 +162,9 @@
* Copy the standard CSS file, skipping the import of DejaVu font
* since our custom CSS file does not use it.
*/
- try (final BufferedReader in = openReader(stylesheetFile);
- final BufferedWriter out = openWriter(standardFile))
- {
+ final BufferedReader in = openReader(stylesheetFile);
+ final BufferedWriter out = openWriter(standardFile);
+ try {
String line;
while ((line = in.readLine()) != null) {
if (!line.equals("@import url('resources/fonts/dejavu.css');")) {
@@ -174,14 +172,17 @@
out.newLine();
}
}
+ } finally {
+ out.close();
+ in.close();
}
}
/*
* Copy the custom CSS file, skipping comments for more compact file.
*/
- try (final BufferedReader in = openReader(inputFile);
- final BufferedWriter out = openWriter(stylesheetFile))
- {
+ final BufferedReader in = openReader(inputFile);
+ final BufferedWriter out = openWriter(stylesheetFile);
+ try {
String line;
while ((line = in.readLine()) != null) {
if (line.length() < 2 || line.charAt(1) != '*') {
@@ -189,6 +190,9 @@
out.newLine();
}
}
+ } finally {
+ out.close();
+ in.close();
}
}
@@ -210,27 +214,18 @@
!name.equals(STYLESHEET);
}
});
- try {
- for (final File input : inputFiles) {
- final File output = new File(outputDirectory, input.getName());
- if (!output.exists()) { // For avoiding a failure if the target exists.
- Files.createLink(output.toPath(), input.toPath());
+ final byte[] buffer = new byte[4096];
+ for (final File input : inputFiles) {
+ final FileInputStream in = new FileInputStream(input);
+ final FileOutputStream out = new FileOutputStream(new File(outputDirectory, input.getName()));
+ try {
+ int c;
+ while ((c = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, c);
}
- }
- } catch (UnsupportedOperationException | FileSystemException e) {
- /*
- * If hard links are not supported, performs plain copy instead.
- */
- final byte[] buffer = new byte[4096];
- for (final File input : inputFiles) {
- try (final FileInputStream in = new FileInputStream(input);
- final FileOutputStream out = new FileOutputStream(new File(outputDirectory, input.getName())))
- {
- int c;
- while ((c = in.read(buffer)) >= 0) {
- out.write(buffer, 0, c);
- }
- }
+ } finally {
+ out.close();
+ in.close();
}
}
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
index 11a3b33..b575d83 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
@@ -123,11 +123,14 @@
modified = false;
this.file = file;
content.setLength(0);
- try (final Reader in = new InputStreamReader(new FileInputStream(file), ENCODING)) {
+ final Reader in = new InputStreamReader(new FileInputStream(file), ENCODING);
+ try {
int n;
while ((n = in.read(buffer)) >= 0) {
content.append(buffer, 0, n);
}
+ } finally {
+ in.close();
}
}
@@ -137,8 +140,11 @@
*/
private void save() throws IOException {
if (modified) {
- try (final Writer out = new OutputStreamWriter(new FileOutputStream(file), ENCODING)) {
+ final Writer out = new OutputStreamWriter(new FileOutputStream(file), ENCODING);
+ try {
out.append(content);
+ } finally {
+ out.close();
}
}
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
index 6936fc8..79b6678 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
@@ -83,7 +83,8 @@
final String artifactBase = FINALNAME_PREFIX + version;
try {
final File targetFile = new File(distributionDirectory(targetDirectory), artifactBase + ".zip");
- try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(targetFile)) {
+ final ZipArchiveOutputStream zip = new ZipArchiveOutputStream(targetFile);
+ try {
zip.setLevel(9);
appendRecursively(sourceDirectory, artifactBase, zip, new byte[8192]);
/*
@@ -105,6 +106,8 @@
zip.closeArchiveEntry();
}
});
+ } finally {
+ zip.close();
}
} catch (IOException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
@@ -129,11 +132,14 @@
}
out.putArchiveEntry(entry);
if (!entry.isDirectory()) {
- try (FileInputStream in = new FileInputStream(file)) {
+ final FileInputStream in = new FileInputStream(file);
+ try {
int n;
while ((n = in.read(buffer)) >= 0) {
out.write(buffer, 0, n);
}
+ } finally {
+ in.close();
}
}
out.closeArchiveEntry();
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
index 750fb71..917cf7d 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
@@ -36,11 +36,6 @@
import static org.apache.sis.internal.maven.Filenames.*;
-// Related to JDK7
-import java.nio.file.Path;
-import java.nio.file.Files;
-import java.nio.file.FileSystemException;
-
/**
* Collects <code>.jar</code> files in a single "{@code target/binaries}" directory.
@@ -226,19 +221,6 @@
* @param copy The destination file to create.
*/
private static void linkFileToDirectory(final File file, final File copy) throws IOException {
- final Path source = file.toPath();
- final Path target = copy.toPath();
- try {
- Files.createLink(target, source);
- return;
- } catch (UnsupportedOperationException | FileSystemException e) {
- /*
- * If hard links are not supported, edit the "content.txt" file instead.
- * Note that a hard link may be unsupported because the source and target
- * are on different Windows drives or mount points, in which case we get
- * a FileSystemException instead than UnsupportedOperationException.
- */
- }
/*
* If we can not use hard links, creates or updates a "target/content.txt" file instead.
* This file will contains the list of all dependencies, without duplicated values.
@@ -247,11 +229,14 @@
final Set<String> dependencies = loadDependencyList(dependenciesFile);
if (dependencies.add(file.getPath())) {
// Save the dependencies list only if it has been modified.
- try (BufferedWriter out = new BufferedWriter(new FileWriter(dependenciesFile))) {
+ final BufferedWriter out = new BufferedWriter(new FileWriter(dependenciesFile));
+ try {
for (final String dependency : dependencies) {
out.write(dependency);
out.newLine();
}
+ } finally {
+ out.close();
}
}
}
@@ -262,9 +247,10 @@
* platforms that do not support hard links.
*/
static Set<String> loadDependencyList(final File dependenciesFile) throws IOException {
- final Set<String> dependencies = new LinkedHashSet<>();
+ final Set<String> dependencies = new LinkedHashSet<String>();
if (dependenciesFile.exists()) {
- try (BufferedReader in = new BufferedReader(new FileReader(dependenciesFile))) {
+ final BufferedReader in = new BufferedReader(new FileReader(dependenciesFile));
+ try {
String line;
while ((line = in.readLine()) != null) {
line = line.trim();
@@ -272,6 +258,8 @@
dependencies.add(line);
}
}
+ } finally {
+ in.close();
}
}
return dependencies;
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
index 43e35c9..c7ca1ee 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
@@ -83,7 +83,7 @@
*
* @see #isMergeAllowed(String)
*/
- private final Set<String> entriesDone = new HashSet<>();
+ private final Set<String> entriesDone = new HashSet<String>();
/**
* Returns {@code true} if entries of the given name are allowed to be concatenated
@@ -147,7 +147,8 @@
for (final File input : inputJARs.keySet()) {
if (!input.getName().startsWith("sis-")) {
String packageName = null;
- try (JarFile jar = new JarFile(input, false)) {
+ final JarFile jar = new JarFile(input, false);
+ try {
final Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
@@ -182,6 +183,8 @@
manifest.getEntries().put(packageName, attributes);
}
}
+ } finally {
+ jar.close();
}
}
}
@@ -216,7 +219,8 @@
for (final Iterator<Map.Entry<File,PackInput>> it = inputJARs.entrySet().iterator(); it.hasNext();) {
final Map.Entry<File,PackInput> inputJAR = it.next();
it.remove(); // Needs to be removed before the inner loop below.
- try (PackInput input = inputJAR.getValue()) {
+ final PackInput input = inputJAR.getValue();
+ try {
for (JarEntry entry; (entry = input.nextEntry()) != null;) {
final String name = entry.getName();
boolean isMergeAllowed = false;
@@ -241,6 +245,8 @@
}
outputStream.closeEntry();
}
+ } finally {
+ input.close();
}
}
}
@@ -326,10 +332,16 @@
p.put(DEFLATE_HINT, TRUE); // Ignore all JAR deflation requests.
p.put(UNKNOWN_ATTRIBUTE, ERROR); // Throw an error if an attribute is unrecognized
p.put(CODE_ATTRIBUTE_PFX+"LocalVariableTable", STRIP); // discard debug attributes.
- try (JarFile jarFile = new JarFile(inputFile)) {
- try (OutputStream deflater = new GZIPOutputStream(out)) {
+ final JarFile jarFile = new JarFile(inputFile);
+ try {
+ final OutputStream deflater = new GZIPOutputStream(out);
+ try {
packer.pack(jarFile, deflater);
+ } finally {
+ deflater.close();
}
+ } finally {
+ jarFile.close();
}
if (!inputFile.delete()) {
throw new IOException("Can't delete temporary file: " + inputFile);
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
index 205906d..2f9a201 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
@@ -92,7 +92,7 @@
private Map<File,PackInput> getInputJARs() throws IOException {
final Set<String> filenames = JarCollector.loadDependencyList(new File(binariesDirectory, CONTENT_FILE));
filenames.addAll(Arrays.asList(binariesDirectory.list(this)));
- final Map<File,PackInput> inputJARs = new LinkedHashMap<>(filenames.size() * 4/3);
+ final Map<File,PackInput> inputJARs = new LinkedHashMap<File,PackInput>(filenames.size() * 4/3);
for (final String filename : filenames) {
File file = new File(filename);
if (!file.isAbsolute()) {
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java
index d61b808..ae9f475 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java
@@ -97,7 +97,9 @@
file = new File(file.getParentFile(), reference.substring(0, sep));
final String anchor = reference.substring(sep + 1);
final StringBuilder buffer = new StringBuilder();
- try (final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) {
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
/*
* Search the anchor.
*/
@@ -131,6 +133,12 @@
}
} catch (IOException e) {
printError(position, "Error reading " + file + ":\n" + e);
+ } finally {
+ if (in != null) try {
+ in.close();
+ } catch (IOException e) {
+ printError(position, "Error reading " + file + ":\n" + e);
+ }
}
return buffer.toString();
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
index bac916d..451038c 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
@@ -50,10 +50,10 @@
*/
try {
configuration = (Configuration) ConfigurationImpl.class.getMethod("getInstance").invoke(null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // ReflectiveOperationException on the JDK7 branch
try {
configuration = ConfigurationImpl.class.newInstance();
- } catch (ReflectiveOperationException e2) {
+ } catch (Exception e2) { // ReflectiveOperationException on the JDK7 branch
return null; // Allowed by this method contract.
}
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
index 7a3d438..409d366 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
@@ -85,8 +85,9 @@
if (!ze.getName().equals(JarFile.MANIFEST_NAME)) {
return in;
}
- final List<String> lines = new ArrayList<>();
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, MANIFEST_ENCODING))) {
+ final List<String> lines = new ArrayList<String>();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(in, MANIFEST_ENCODING));
+ try {
String line;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("SHA1-Digest:")) {
@@ -100,6 +101,8 @@
}
lines.add(line);
}
+ } finally {
+ reader.close();
}
/*
* 'in' has been closed at this point (indirectly, by closing the reader).
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
index 076cad5..37a2adb 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
@@ -157,7 +157,8 @@
final File manifestFile = new File(sourceDirectory, manifestName);
final File[] jars = outputDirectory.listFiles(this);
final File[] rdbs = sourceDirectory.listFiles(this);
- try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile))) {
+ final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
+ try {
out.setLevel(9);
if (manifestFile.isFile()) {
copyFiltered(manifestFile, out, manifestName);
@@ -206,16 +207,21 @@
}
if (packer != null && name.endsWith(".jar")) {
name = name.substring(0, name.length()-3) + "pack";
- try (JarFile jar = new FilteredJarFile(file)) {
+ final JarFile jar = new FilteredJarFile(file);
+ try {
out.putNextEntry(new ZipEntry(name));
packer.pack(jar, out);
out.closeEntry();
+ } finally {
+ jar.close();
}
} else {
copy(file, out, name);
}
}
}
+ } finally {
+ out.close();
}
}
@@ -237,12 +243,15 @@
entry.setCrc(getCRC32(file));
}
out.putNextEntry(entry);
- try (InputStream in = new FileInputStream(file)) {
+ final InputStream in = new FileInputStream(file);
+ try {
final byte[] buffer = new byte[4*1024];
int length;
while ((length = in.read(buffer)) >= 0) {
out.write(buffer, 0, length);
}
+ } finally {
+ in.close();
}
out.closeEntry();
}
@@ -257,7 +266,8 @@
final ZipEntry entry = new ZipEntry(name);
out.putNextEntry(entry);
final Writer writer = new OutputStreamWriter(out, ENCODING);
- try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), ENCODING))) {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), ENCODING));
+ try {
String line; while ((line=in.readLine()) != null) {
int r=-1; while ((r=line.indexOf(SUBSTITUTE, r+1)) >= 0) {
line = line.substring(0, r) + finalName + line.substring(r + SUBSTITUTE.length());
@@ -265,6 +275,8 @@
writer.write(line);
writer.write('\n');
}
+ } finally {
+ in.close();
}
writer.flush();
out.closeEntry();
@@ -275,12 +287,15 @@
*/
private static long getCRC32(final File file) throws IOException {
final CRC32 crc = new CRC32();
- try (InputStream in = new FileInputStream(file)) {
+ final InputStream in = new FileInputStream(file);
+ try {
final byte[] buffer = new byte[4*1024];
int length;
while ((length = in.read(buffer)) >= 0) {
crc.update(buffer, 0, length);
}
+ } finally {
+ in.close();
}
return crc.getValue();
}
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java b/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
index bc5d130..c10baeb 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
@@ -103,13 +103,13 @@
* Integer IDs allocated to resource keys. This map will be shared for all languages
* of a given resource bundle.
*/
- private final Map<Integer,String> allocatedIDs = new HashMap<>();
+ private final Map<Integer,String> allocatedIDs = new HashMap<Integer,String>();
/**
* Resource keys and their localized values. This map will be cleared for each language
* in a resource bundle.
*/
- private final Map<Object,Object> resources = new HashMap<>();
+ private final Map<Object,Object> resources = new HashMap<Object,Object>();
/**
* The resources bundle base classes.
@@ -169,7 +169,8 @@
* @throws IOException If an error occurred while reading the source file.
*/
private void loadKeyValues() throws IOException {
- try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(bundleClass), JAVA_ENCODING))) {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(bundleClass), JAVA_ENCODING));
+ try {
String line;
while ((line = in.readLine()) != null) {
if ((line = line.trim()).startsWith(KEY_MODIFIERS)) {
@@ -188,6 +189,8 @@
}
}
}
+ } finally {
+ in.close();
}
}
@@ -271,9 +274,12 @@
*/
private static Properties loadRawProperties(final File file) throws IOException {
final Properties properties;
- try (InputStream input = new FileInputStream(file)) {
+ final InputStream input = new FileInputStream(file);
+ try {
properties = new Properties();
properties.load(input);
+ } finally {
+ input.close();
}
return properties;
}
@@ -433,12 +439,15 @@
throw new IOException("Can't create the " + directory + " directory.");
}
final int count = allocatedIDs.isEmpty() ? 0 : Collections.max(allocatedIDs.keySet()) + 1;
- try (DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
+ final DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
+ try {
out.writeInt(count);
for (int i=0; i<count; i++) {
final String value = (String) resources.get(allocatedIDs.get(i));
out.writeUTF((value != null) ? value : "");
}
+ } finally {
+ out.close();
}
}
@@ -469,7 +478,8 @@
* on the same line than the class declaration).
*/
boolean modified;
- try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), JAVA_ENCODING))) {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), JAVA_ENCODING));
+ try {
for (int state=0; state<=2; state++) {
final String regex;
switch (state) {
@@ -574,10 +584,15 @@
buffer.append(line).append(lineSeparator);
}
}
+ } finally {
+ in.close();
}
if (modified) {
- try (Writer out = new OutputStreamWriter(new FileOutputStream(file), JAVA_ENCODING)) {
+ final Writer out = new OutputStreamWriter(new FileOutputStream(file), JAVA_ENCODING);
+ try {
out.write(buffer.toString());
+ } finally {
+ out.close();
}
}
}
diff --git a/core/sis-feature/pom.xml b/core/sis-feature/pom.xml
index f9ed7fa..9fa8dc1 100644
--- a/core/sis-feature/pom.xml
+++ b/core/sis-feature/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>core</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
index d380ccd..dd77d77 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
@@ -37,6 +37,7 @@
import org.opengis.feature.AttributeType;
import org.opengis.feature.InvalidPropertyValueException;
import org.opengis.feature.MultiValuedPropertyException;
+import org.apache.sis.internal.jdk7.JDK7;
/**
@@ -125,8 +126,8 @@
public static <V> AbstractAttribute<V> create(final AttributeType<V> type) {
ArgumentChecks.ensureNonNull("type", type);
return isSingleton(type.getMaximumOccurs())
- ? new SingletonAttribute<>(type)
- : new MultiValuedAttribute<>(type);
+ ? new SingletonAttribute<V>(type)
+ : new MultiValuedAttribute<V>(type);
}
/**
@@ -141,8 +142,8 @@
static <V> AbstractAttribute<V> create(final AttributeType<V> type, final Object value) {
ArgumentChecks.ensureNonNull("type", type);
return isSingleton(type.getMaximumOccurs())
- ? new SingletonAttribute<>(type, value)
- : new MultiValuedAttribute<>(type, value);
+ ? new SingletonAttribute<V>(type, value)
+ : new MultiValuedAttribute<V>(type, value);
}
/**
@@ -467,7 +468,7 @@
final StringBuilder buffer = FieldType.toString("Attribute", type,
Classes.getShortName(type.getValueClass()), getValues().iterator());
if (characteristics != null && !characteristics.isEmpty()) {
- buffer.append(System.lineSeparator());
+ buffer.append(JDK7.lineSeparator());
String separator = "└─ characteristics: ";
for (final Map.Entry<String,Attribute<?>> entry : characteristics.entrySet()) {
buffer.append(separator).append(entry.getKey()).append('=').append(entry.getValue().getValue());
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
index f10d67e..93a000f 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
@@ -178,6 +178,7 @@
* @param value The value to wrap.
* @return A {@code Property} wrapping the given value.
*/
+ @SuppressWarnings({"unchecked","rawtypes"})
final Property createProperty(final String name, final Object value) {
final PropertyType pt = type.getProperty(name);
if (pt instanceof AttributeType<?>) {
@@ -566,7 +567,7 @@
*/
@SuppressWarnings("unchecked")
private static <V> Collection<V> singletonList(final Class<V> valueClass, final int minimumOccurs, final Object value) {
- final CheckedArrayList<V> values = new CheckedArrayList<>(valueClass, Math.max(minimumOccurs, 4));
+ final CheckedArrayList<V> values = new CheckedArrayList<V>(valueClass, Math.max(minimumOccurs, 4));
values.add((V) value); // Type will be checked by CheckedArrayList.
return values;
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
index 7a11f9e..985dc2c 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
@@ -29,7 +29,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.IdentifiedType;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java
index c8205c5..e447045 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java
@@ -29,7 +29,7 @@
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
@@ -95,7 +95,7 @@
* @param identification the map given by user to sub-class constructor.
*/
final Map<String,Object> resultIdentification(final Map<String,?> identification) {
- final Map<String,Object> properties = new HashMap<>(6);
+ final Map<String,Object> properties = new HashMap<String,Object>(6);
for (final Map.Entry<String,?> entry : identification.entrySet()) {
final String key = entry.getKey();
if (key != null && key.startsWith(RESULT_PREFIX)) {
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicTypeMap.java b/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicTypeMap.java
index 49a11f5..8fdf502 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicTypeMap.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicTypeMap.java
@@ -55,7 +55,7 @@
*/
@SuppressWarnings("unchecked")
private static final WeakValueHashMap<AttributeType<?>[],CharacteristicTypeMap> SHARED =
- new WeakValueHashMap<>((Class) AttributeType[].class);
+ new WeakValueHashMap<AttributeType<?>[],CharacteristicTypeMap>((Class) AttributeType[].class);
/*
* This class has intentionally no reference to the AttributeType for which we are providing characteristics.
@@ -111,7 +111,7 @@
private CharacteristicTypeMap(final AttributeType<?> source, final AttributeType<?>[] characterizedBy) {
this.characterizedBy = characterizedBy;
int index = 0;
- final Map<String,Integer> indices = new HashMap<>(Containers.hashMapCapacity(characterizedBy.length));
+ final Map<String,Integer> indices = new HashMap<String,Integer>(Containers.hashMapCapacity(characterizedBy.length));
for (int i=0; i<characterizedBy.length; i++) {
final AttributeType<?> attribute = characterizedBy[i];
ensureNonNullElement("characterizedBy", i, attribute);
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
index eca2f2a..ec23dad 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
@@ -199,7 +199,7 @@
* this desired feature in an association of the 'creating' feature, instead than beeing
* the 'creating' feature itself. This is a little bit unusual, but not illegal.
*/
- final List<FeatureType> deferred = new ArrayList<>();
+ final List<FeatureType> deferred = new ArrayList<FeatureType>();
type = search(creating, name, deferred);
if (type == null) {
/*
@@ -287,7 +287,7 @@
* @return The feature of the given name, or {@code null} if none.
*/
private static FeatureType deepSearch(final List<FeatureType> deferred, final GenericName name) {
- final Map<FeatureType,Boolean> done = new IdentityHashMap<>(8);
+ final Map<FeatureType,Boolean> done = new IdentityHashMap<FeatureType,Boolean>(8);
for (int i=0; i<deferred.size();) {
FeatureType valueType = deferred.get(i++);
if (done.put(valueType, Boolean.TRUE) == null) {
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
index 8c2f904..008c86e 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
@@ -31,7 +31,7 @@
import static org.apache.sis.util.ArgumentChecks.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
index 2890bc2..6d79e90 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
@@ -39,7 +39,7 @@
import org.apache.sis.internal.util.UnmodifiableArrayList;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.JDK8;
import org.opengis.feature.PropertyType;
import org.opengis.feature.AttributeType;
@@ -303,9 +303,9 @@
*/
private void computeTransientFields() {
final int capacity = Containers.hashMapCapacity(properties.size());
- byName = new LinkedHashMap<>(capacity);
- indices = new LinkedHashMap<>(capacity);
- assignableTo = new HashSet<>(4);
+ byName = new LinkedHashMap<String,PropertyType>(capacity);
+ indices = new LinkedHashMap<String,Integer>(capacity);
+ assignableTo = new HashSet<GenericName>(4);
assignableTo.add(super.getName());
scanPropertiesFrom(this);
allProperties = UnmodifiableArrayList.wrap(byName.values().toArray(new PropertyType[byName.size()]));
@@ -349,7 +349,7 @@
*
* In the 'aliases' map below, null values will be assigned to ambiguous short names.
*/
- final Map<String, PropertyType> aliases = new LinkedHashMap<>();
+ final Map<String, PropertyType> aliases = new LinkedHashMap<String, PropertyType>();
for (final PropertyType property : allProperties) {
final GenericName name = property.getName();
final LocalName tip = name.tip();
@@ -504,7 +504,7 @@
final FeatureType valueType = ((FeatureAssociationRole) property).getValueType();
if (valueType != this) {
if (previous == null) {
- previous = new IdentityHashMap<>(8);
+ previous = new IdentityHashMap<FeatureType,Boolean>(8);
}
Boolean r = previous.put(valueType, Boolean.FALSE);
if (r == null) {
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/EnvelopeOperation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/EnvelopeOperation.java
index 0f851b3..cc05bc6 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/EnvelopeOperation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/EnvelopeOperation.java
@@ -37,7 +37,6 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
@@ -46,6 +45,7 @@
import org.opengis.feature.Property;
import org.opengis.feature.PropertyType;
import org.apache.sis.internal.jdk8.JDK8;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -137,7 +137,7 @@
* The map values will be the default Coordinate Reference System, or null if none.
*/
boolean characterizedByCRS = false;
- final Map<String,CoordinateReferenceSystem> names = new LinkedHashMap<>(4);
+ final Map<String,CoordinateReferenceSystem> names = new LinkedHashMap<String,CoordinateReferenceSystem>(4);
for (IdentifiedType property : geometryAttributes) {
if (AttributeConvention.isGeometryAttribute(property)) {
final GenericName name = property.getName();
@@ -200,7 +200,7 @@
}
}
}
- resultType = FeatureOperations.POOL.unique(new DefaultAttributeType<>(
+ resultType = FeatureOperations.POOL.unique(new DefaultAttributeType<Envelope>(
resultIdentification(identification), Envelope.class, 1, 1, null));
this.crs = crs;
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
index dc07ff1..7e7f3ab 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
@@ -87,7 +87,7 @@
/**
* An instance created when first needed and potentially shared.
*/
- private static final AtomicReference<FeatureFormat> INSTANCE = new AtomicReference<>();
+ private static final AtomicReference<FeatureFormat> INSTANCE = new AtomicReference<FeatureFormat>();
/**
* The locale for international strings.
@@ -98,8 +98,8 @@
* Creates a new formatter for the default locale and timezone.
*/
public FeatureFormat() {
- super(Locale.getDefault(Locale.Category.FORMAT), TimeZone.getDefault());
- displayLocale = Locale.getDefault(Locale.Category.DISPLAY);
+ super(Locale.getDefault(), TimeZone.getDefault());
+ displayLocale = super.getLocale(); // This is different on the JDK7 branch.
columnSeparator = " │ ";
}
@@ -127,22 +127,6 @@
}
/**
- * Returns the locale for the given category.
- *
- * <ul>
- * <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for values.</li>
- * <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for labels.</li>
- * </ul>
- *
- * @param category The category for which a locale is desired.
- * @return The locale for the given category (never {@code null}).
- */
- @Override
- public Locale getLocale(final Locale.Category category) {
- return (category == Locale.Category.DISPLAY) ? displayLocale : super.getLocale(category);
- }
-
- /**
* Invoked when the formatter needs to move to the next column.
*/
private void nextColumn(final TableAppender table) {
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
index db7582b..3f4e5a7 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
@@ -114,7 +114,7 @@
/**
* The pool of operations or operation dependencies created so far, for sharing exiting instances.
*/
- static final WeakHashSet<PropertyType> POOL = new WeakHashSet<>(PropertyType.class);
+ static final WeakHashSet<PropertyType> POOL = new WeakHashSet<PropertyType>(PropertyType.class);
/**
* Do not allow instantiation of this class.
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java b/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java
index cff9ad6..4ecbc39 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java
@@ -73,7 +73,7 @@
* @return The features or attribute values in a <cite>live</cite> collection.
*/
public Collection<V> getValues() {
- return new PropertySingleton<>(this);
+ return new PropertySingleton<V>(this);
}
/**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java
index cb4b8f9..afad3d5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java
@@ -65,7 +65,7 @@
static ParameterDescriptorGroup parameters(final String name, final int minimumOccurs,
final ParameterDescriptor<?>... parameters)
{
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(ParameterDescriptorGroup.NAME_KEY, name);
properties.put(Identifier.AUTHORITY_KEY, Citations.SIS);
return new DefaultParameterDescriptorGroup(properties, minimumOccurs, 1);
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
index bef2109..d946dd1 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
@@ -68,7 +68,7 @@
*/
public MultiValuedAssociation(final FeatureAssociationRole role) {
super(role);
- values = new CheckedArrayList<>(Feature.class);
+ values = new CheckedArrayList<Feature>(Feature.class);
}
/**
@@ -80,7 +80,7 @@
MultiValuedAssociation(final FeatureAssociationRole role, final Object values) {
super(role);
if (values == null) {
- this.values = new CheckedArrayList<>(Feature.class);
+ this.values = new CheckedArrayList<Feature>(Feature.class);
} else {
this.values = CheckedArrayList.castOrCopy((CheckedArrayList<?>) values, Feature.class);
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java b/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
index 222096a..e7dfc51 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
@@ -71,7 +71,7 @@
*/
public MultiValuedAttribute(final AttributeType<V> type) {
super(type);
- values = new CheckedArrayList<>(type.getValueClass());
+ values = new CheckedArrayList<V>(type.getValueClass());
final V value = type.getDefaultValue();
if (value != null) {
values.add(value);
@@ -90,7 +90,7 @@
super(type);
final Class<V> valueClass = type.getValueClass();
if (values == null) {
- this.values = new CheckedArrayList<>(valueClass);
+ this.values = new CheckedArrayList<V>(valueClass);
} else {
final Class<?> actual = ((CheckedContainer<?>) values).getElementType();
if (actual == valueClass) {
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
index a5b2e89..9e68dd6 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
@@ -17,7 +17,7 @@
package org.apache.sis.feature;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureAssociationRole;
import org.opengis.feature.InvalidPropertyValueException;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAttribute.java b/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAttribute.java
index 8ef42a6..a7389e5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAttribute.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAttribute.java
@@ -17,7 +17,7 @@
package org.apache.sis.feature;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.AttributeType;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java b/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
index 6e0df3c..ebd60d4 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
@@ -27,7 +27,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.Property;
import org.opengis.feature.Attribute;
import org.opengis.feature.FeatureAssociation;
@@ -110,7 +110,7 @@
public SparseFeature(final DefaultFeatureType type) {
super(type);
indices = type.indices();
- properties = new HashMap<>();
+ properties = new HashMap<Integer, Object>();
}
/**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java b/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
index 84fef89..54ee9e9 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
@@ -33,7 +33,7 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.UncheckedIOException;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
@@ -162,7 +162,7 @@
attributeNames[i] = name.toString();
converters[i] = ObjectConverters.find(String.class, ((AttributeType<?>) attributeType).getValueClass());
}
- resultType = FeatureOperations.POOL.unique(new DefaultAttributeType<>(
+ resultType = FeatureOperations.POOL.unique(new DefaultAttributeType<String>(
resultIdentification(identification), String.class, 1, 1, null));
this.delimiter = delimiter;
this.prefix = (prefix == null) ? "" : prefix;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
index ec9954c..e5d1abf 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
@@ -30,7 +30,7 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.AttributeType;
import org.opengis.feature.PropertyType;
@@ -70,7 +70,7 @@
/**
* Builders for the characteristics associated to the attribute.
*/
- private final List<CharacteristicTypeBuilder<?>> characteristics = new ArrayList<>();
+ private final List<CharacteristicTypeBuilder<?>> characteristics = new ArrayList<CharacteristicTypeBuilder<?>>();
/**
* Creates a new {@code AttributeType} builder for values of the given class.
@@ -95,7 +95,7 @@
valueClass = template.getValueClass();
defaultValue = template.getDefaultValue();
for (final AttributeType<?> c : template.characteristics().values()) {
- characteristics.add(new CharacteristicTypeBuilder<>(this, c));
+ characteristics.add(new CharacteristicTypeBuilder(this, c));
}
}
@@ -177,7 +177,6 @@
* @see #characteristics()
* @see AttributeConvention#VALID_VALUES_CHARACTERISTIC
*/
- @SafeVarargs
public final AttributeTypeBuilder<V> setValidValues(final V... values) {
return setCharacteristic(AttributeConvention.VALID_VALUES_CHARACTERISTIC,
Set.class, CollectionsExt.immutableSet(false, values));
@@ -255,7 +254,7 @@
*/
public <C> CharacteristicTypeBuilder<C> addCharacteristic(final Class<C> type) {
ensureNonNull("type", type);
- final CharacteristicTypeBuilder<C> characteristic = new CharacteristicTypeBuilder<>(this, type);
+ final CharacteristicTypeBuilder<C> characteristic = new CharacteristicTypeBuilder<C>(this, type);
characteristics.add(characteristic);
clearCache();
return characteristic;
@@ -273,7 +272,7 @@
*/
public <C> CharacteristicTypeBuilder<C> addCharacteristic(final AttributeType<C> template) {
ensureNonNull("template", template);
- final CharacteristicTypeBuilder<C> characteristic = new CharacteristicTypeBuilder<>(this, template);
+ final CharacteristicTypeBuilder<C> characteristic = new CharacteristicTypeBuilder<C>(this, template);
characteristics.add(characteristic);
clearCache();
return characteristic;
@@ -334,7 +333,7 @@
* @see #setCRS(CoordinateReferenceSystem)
*/
public List<CharacteristicTypeBuilder<?>> characteristics() {
- return new RemoveOnlyList<>(characteristics);
+ return new RemoveOnlyList<CharacteristicTypeBuilder<?>>(characteristics);
}
/**
@@ -381,6 +380,6 @@
for (int i=0; i<chrts.length; i++) {
chrts[i] = characteristics.get(i).build();
}
- return new DefaultAttributeType<>(identification(), valueClass, minimumOccurs, maximumOccurs, defaultValue, chrts);
+ return new DefaultAttributeType<V>(identification(), valueClass, minimumOccurs, maximumOccurs, defaultValue, chrts);
}
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
index 49177f9..5cbe8f5 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
@@ -21,7 +21,7 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.AttributeType;
@@ -212,7 +212,7 @@
*/
final AttributeType<V> build() {
if (characteristic == null) {
- characteristic = new DefaultAttributeType<>(identification(), valueClass, 0, 1, defaultValue);
+ characteristic = new DefaultAttributeType<V>(identification(), valueClass, 0, 1, defaultValue);
}
return characteristic;
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
index 794553c..082aaf6 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
@@ -35,7 +35,8 @@
import org.apache.sis.util.ArraysExt;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.JDK7;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
@@ -169,8 +170,8 @@
factory = DefaultFactories.forBuildin(NameFactory.class);
}
nameFactory = factory;
- properties = new ArrayList<>();
- superTypes = new ArrayList<>();
+ properties = new ArrayList<PropertyTypeBuilder>();
+ superTypes = new ArrayList<FeatureType>();
idDelimiter = ":";
defaultMinimumOccurs = 1;
defaultMaximumOccurs = 1;
@@ -181,7 +182,7 @@
for (final PropertyType p : template.getProperties(false)) {
final PropertyTypeBuilder builder;
if (p instanceof AttributeType<?>) {
- builder = new AttributeTypeBuilder<>(this, (AttributeType<?>) p);
+ builder = new AttributeTypeBuilder(this, (AttributeType<?>) p);
} else if (p instanceof FeatureAssociationRole) {
builder = new AssociationRoleBuilder(this, (FeatureAssociationRole) p);
} else {
@@ -420,7 +421,7 @@
* @see #addAssociation(FeatureAssociationRole)
*/
public List<PropertyTypeBuilder> properties() {
- return new RemoveOnlyList<>(properties);
+ return new RemoveOnlyList<PropertyTypeBuilder>(properties);
}
/**
@@ -448,7 +449,7 @@
// We disallow Feature.class because that type shall be handled as association instead than attribute.
throw new IllegalArgumentException(errors().getString(Errors.Keys.IllegalArgumentValue_2, "valueClass", valueClass));
}
- final AttributeTypeBuilder<V> property = new AttributeTypeBuilder<>(this, valueClass);
+ final AttributeTypeBuilder<V> property = new AttributeTypeBuilder<V>(this, valueClass);
properties.add(property);
clearCache();
return property;
@@ -465,7 +466,7 @@
*/
public <V> AttributeTypeBuilder<V> addAttribute(final AttributeType<V> template) {
ensureNonNull("template", template);
- final AttributeTypeBuilder<V> property = new AttributeTypeBuilder<>(this, template);
+ final AttributeTypeBuilder<V> property = new AttributeTypeBuilder<V>(this, template);
properties.add(property);
clearCache();
return property;
@@ -676,7 +677,7 @@
separator = ", ";
}
buffer.append(" {");
- separator = System.lineSeparator();
+ separator = JDK7.lineSeparator();
for (final PropertyTypeBuilder p : properties) {
p.toString(buffer.append(separator).append(" ").append(p.getClass().getSimpleName()));
}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
index 5698c61..1cab04e 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
@@ -29,7 +29,7 @@
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.opengis.feature.IdentifiedType;
@@ -61,7 +61,7 @@
* The feature name, definition, designation and description.
* The name is mandatory; all other information are optional.
*/
- private final Map<String,Object> identification = new HashMap<>(4);
+ private final Map<String,Object> identification = new HashMap<String,Object>(4);
/**
* Creates a new builder initialized to the values of an existing type.
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
index 824956b..1269eb2 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
@@ -65,7 +65,7 @@
ymin = envt.getMethod("getMinY", (Class[]) null);
xmax = envt.getMethod("getMaxX", (Class[]) null);
ymax = envt.getMethod("getMaxY", (Class[]) null);
- } catch (ClassNotFoundException | NoSuchMethodException e) {
+ } catch (Exception e) { // (ClassNotFoundException | NoSuchMethodException) on the JDK7 branch.
Logging.getLogger(Loggers.GEOMETRY).log(Level.CONFIG, e.toString());
type = null;
genv = null;
@@ -125,7 +125,7 @@
ymin = (Double) MIN_Y.invoke(env, (Object[]) null);
xmax = (Double) MAX_X.invoke(env, (Object[]) null);
ymax = (Double) MAX_Y.invoke(env, (Object[]) null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
if (e instanceof InvocationTargetException) {
final Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicMapTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicMapTest.java
index 221cd1e..74a94cd 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicMapTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicMapTest.java
@@ -46,7 +46,7 @@
* @return A {@code "temperature"} attribute with two characteristics: {@code "accuracy"} and {@code "units"}.
*/
public static AbstractAttribute<Float> temperature() {
- return new SingletonAttribute<>(CharacteristicTypeMapTest.temperature(), 20f);
+ return new SingletonAttribute<Float>(CharacteristicTypeMapTest.temperature(), 20f);
}
/**
@@ -56,8 +56,9 @@
* @param name Either {@code "accuracy"} or {@code "units"}.
* @return An attribute for the given name.
*/
+ @SuppressWarnings({"unchecked","rawtypes"}) // Not needed on JDK7 branch.
private static AbstractAttribute<?> create(final AbstractAttribute<?> temperature, final String name) {
- return new SingletonAttribute<>(((DefaultAttributeType<?>) temperature.getType()).characteristics().get(name));
+ return new SingletonAttribute(((DefaultAttributeType<?>) temperature.getType()).characteristics().get(name));
}
/**
@@ -278,8 +279,8 @@
assertArrayEquals("keySet", new String[] {"accuracy", "units"}, characteristics.keySet().toArray());
assertArrayEquals("values", new Object[] { accuracy , units }, characteristics.values().toArray());
assertArrayEquals("entrySet", new Object[] {
- new SimpleEntry<>("accuracy", accuracy),
- new SimpleEntry<>("units", units)
+ new SimpleEntry<String,Attribute<?>>("accuracy", accuracy),
+ new SimpleEntry<String,Attribute<?>>("units", units)
}, characteristics.entrySet().toArray());
}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicTypeMapTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicTypeMapTest.java
index 95ce9f9..659364a 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicTypeMapTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/CharacteristicTypeMapTest.java
@@ -47,9 +47,9 @@
*/
public static DefaultAttributeType<Float> temperature() {
final DefaultAttributeType<?> units, accuracy;
- units = new DefaultAttributeType<>(singletonMap(NAME_KEY, "units"), String.class, 1, 1, "°C", (DefaultAttributeType[]) null);
- accuracy = new DefaultAttributeType<>(singletonMap(NAME_KEY, "accuracy"), Float.class, 1, 1, 0.1f, (DefaultAttributeType[]) null);
- return new DefaultAttributeType<>(singletonMap(NAME_KEY, "temperature"), Float.class, 1, 1, null, accuracy, units);
+ units = new DefaultAttributeType<String>(singletonMap(NAME_KEY, "units"), String.class, 1, 1, "°C", (DefaultAttributeType[]) null);
+ accuracy = new DefaultAttributeType<Float> (singletonMap(NAME_KEY, "accuracy"), Float.class, 1, 1, 0.1f, (DefaultAttributeType[]) null);
+ return new DefaultAttributeType<Float> (singletonMap(NAME_KEY, "temperature"), Float.class, 1, 1, null, accuracy, units);
}
/**
@@ -94,8 +94,8 @@
assertArrayEquals("keySet", new String[] {"accuracy", "units"}, characteristics.keySet().toArray());
assertArrayEquals("values", new Object[] { accuracy , units }, characteristics.values().toArray());
assertArrayEquals("entrySet", new Object[] {
- new SimpleEntry<>("accuracy", accuracy),
- new SimpleEntry<>("units", units)
+ new SimpleEntry<String,AttributeType<?>>("accuracy", accuracy),
+ new SimpleEntry<String,AttributeType<?>>("units", units)
}, characteristics.entrySet().toArray());
}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
index d72eedc..10e84b6 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
@@ -64,7 +64,7 @@
assertNull(identification.put(DefaultAttributeType.DEFINITION_KEY + "_fr", "Le nom de la ville."));
assertNull(identification.put(DefaultAttributeType.DEFINITION_KEY + "_ja", "都市の名前。"));
assertNull(identification.put(DefaultAttributeType.DESCRIPTION_KEY, "Some verbose description."));
- final DefaultAttributeType<String> city = new DefaultAttributeType<>(identification,
+ final DefaultAttributeType<String> city = new DefaultAttributeType<String>(identification,
String.class, 1, 1, "Utopia");
identification.clear();
return city;
@@ -79,7 +79,7 @@
assertNull(identification.put(DefaultAttributeType.NAME_KEY, "population"));
// We may add more properties here in a future version.
- final DefaultAttributeType<Integer> population = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> population = new DefaultAttributeType<Integer>(
identification, Integer.class, 1, 1, null);
identification.clear();
return population;
@@ -103,7 +103,7 @@
* @return An attribute type for university names.
*/
public static DefaultAttributeType<String> universities() {
- return new DefaultAttributeType<>(
+ return new DefaultAttributeType<String>(
singletonMap(DefaultAttributeType.NAME_KEY, "universities"),
String.class, 0, Integer.MAX_VALUE, null);
}
@@ -113,7 +113,8 @@
* This is the kind of attribute created by the ShapeFile reader.
*/
static DefaultAttributeType<String> attribute(final String name) {
- return new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, name), String.class, 1, 1, null);
+ return new DefaultAttributeType<String>(singletonMap(DefaultAttributeType.NAME_KEY, name),
+ String.class, 1, 1, null);
}
/**
@@ -152,7 +153,7 @@
@Test
@SuppressWarnings("ObjectEqualsNull")
public void testEquals() {
- final Map<String,Object> identification = new HashMap<>(4);
+ final Map<String,Object> identification = new HashMap<String,Object>(4);
final DefaultAttributeType<Integer> a1 = population(identification);
final DefaultAttributeType<Integer> a2 = population(identification);
assertFalse ("equals", a1.equals(null));
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
index 1f91d44..48b1070 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
@@ -58,7 +58,7 @@
* @return The feature for a city.
*/
public static DefaultFeatureType city() {
- final Map<String,Object> identification = new HashMap<>();
+ final Map<String,Object> identification = new HashMap<String,Object>();
final DefaultAttributeType<String> city = DefaultAttributeTypeTest.city(identification);
final DefaultAttributeType<Integer> population = DefaultAttributeTypeTest.population(identification);
@@ -115,14 +115,14 @@
* @return The feature for a metropolis.
*/
public static DefaultFeatureType metropolis() {
- final Map<String,Object> identification = new HashMap<>(4);
+ final Map<String,Object> identification = new HashMap<String,Object>(4);
assertNull(identification.put(DefaultFeatureType.NAME_KEY, "Metropolis"));
assertNull(identification.put(DefaultFeatureType.NAME_KEY + "_fr", "Métropole"));
return new DefaultFeatureType(identification, false,
new DefaultFeatureType[] {city()},
- new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, "region"),
+ new DefaultAttributeType<CharSequence>(singletonMap(DefaultAttributeType.NAME_KEY, "region"),
CharSequence.class, 1, 1, null),
- new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, "isGlobal"),
+ new DefaultAttributeType<Boolean>(singletonMap(DefaultAttributeType.NAME_KEY, "isGlobal"),
Boolean.class, 1, 1, null));
}
@@ -138,8 +138,8 @@
* Creates a sub-type of the "metropolis" type with the "region" attribute overridden to the given type.
* The given type should be {@link InternationalString}, but we allow other types for testing argument checks.
*/
- private static DefaultFeatureType worldMetropolis(final DefaultFeatureType metropolis,
- final DefaultFeatureType universityCity, final DefaultAttributeType<?> temperature, final Class<?> regionType)
+ private static <T> DefaultFeatureType worldMetropolis(final DefaultFeatureType metropolis,
+ final DefaultFeatureType universityCity, final DefaultAttributeType<?> temperature, final Class<T> regionType)
{
return new DefaultFeatureType(singletonMap(DefaultFeatureType.NAME_KEY, "World metropolis"), false,
new DefaultFeatureType[] { // Super types
@@ -147,7 +147,7 @@
universityCity
},
new DefaultAttributeType<?>[] { // Properties
- new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, "region"), regionType, 1, 1, null),
+ new DefaultAttributeType<T>(singletonMap(DefaultAttributeType.NAME_KEY, "region"), regionType, 1, 1, null),
temperature
});
}
@@ -247,7 +247,7 @@
@Test
@DependsOnMethod("testSimple")
public void testComplex() {
- final Map<String,Object> identification = new HashMap<>();
+ final Map<String,Object> identification = new HashMap<String,Object>();
final DefaultAttributeType<String> city = DefaultAttributeTypeTest.city(identification);
final DefaultAttributeType<Integer> population = DefaultAttributeTypeTest.population(identification);
testComplex(city, population, 0, 0); // Simple
@@ -265,7 +265,7 @@
final DefaultAttributeType<Integer> population,
final int minimumOccurs, final int maximumOccurs)
{
- final DefaultAttributeType<String> festival = new DefaultAttributeType<>(
+ final DefaultAttributeType<String> festival = new DefaultAttributeType<String>(
singletonMap(DefaultAttributeType.NAME_KEY, "festival"),
String.class, minimumOccurs, maximumOccurs, null);
@@ -299,11 +299,11 @@
@Test
@DependsOnMethod("testSimple")
public void testNameCollision() {
- final DefaultAttributeType<String> city = new DefaultAttributeType<>(
+ final DefaultAttributeType<String> city = new DefaultAttributeType<String>(
singletonMap(DefaultAttributeType.NAME_KEY, "name"), String.class, 1, 1, null);
- final DefaultAttributeType<Integer> cityId = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> cityId = new DefaultAttributeType<Integer>(
singletonMap(DefaultAttributeType.NAME_KEY, "name"), Integer.class, 1, 1, null);
- final DefaultAttributeType<Integer> population = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> population = new DefaultAttributeType<Integer>(
singletonMap(DefaultAttributeType.NAME_KEY, "population"), Integer.class, 1, 1, null);
final Map<String,String> identification = singletonMap(DefaultAttributeType.NAME_KEY, "City");
@@ -327,13 +327,13 @@
@DependsOnMethod("testNameCollision")
public void testQualifiedNames() {
final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
- final DefaultAttributeType<String> city = new DefaultAttributeType<>(
+ final DefaultAttributeType<String> city = new DefaultAttributeType<String>(
singletonMap(DefaultAttributeType.NAME_KEY, factory.createGenericName(null, "ns1", "name")),
String.class, 1, 1, null);
- final DefaultAttributeType<Integer> cityId = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> cityId = new DefaultAttributeType<Integer>(
singletonMap(DefaultAttributeType.NAME_KEY, factory.createGenericName(null, "ns2", "name")),
Integer.class, 1, 1, null);
- final DefaultAttributeType<Integer> population = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> population = new DefaultAttributeType<Integer>(
singletonMap(DefaultAttributeType.NAME_KEY, factory.createGenericName(null, "ns1", "population")),
Integer.class, 1, 1, null);
final DefaultFeatureType feature = new DefaultFeatureType(
@@ -402,7 +402,7 @@
final DefaultFeatureType metroCapital = new DefaultFeatureType(
singletonMap(DefaultFeatureType.NAME_KEY, "Metropolis and capital"), false,
new DefaultFeatureType[] {metropolis, capital},
- new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, "country"),
+ new DefaultAttributeType<String>(singletonMap(DefaultAttributeType.NAME_KEY, "country"),
String.class, 1, 1, null));
assertUnmodifiable(metroCapital);
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/EnvelopeOperationTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/EnvelopeOperationTest.java
index 5969fbe..51ed9dc 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/EnvelopeOperationTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/EnvelopeOperationTest.java
@@ -67,17 +67,17 @@
* @return the feature for a school.
*/
private static DefaultFeatureType school(final int defaultGeometry) throws FactoryException {
- final DefaultAttributeType<?> standardCRS = new DefaultAttributeType<>(
+ final DefaultAttributeType<?> standardCRS = new DefaultAttributeType<CoordinateReferenceSystem>(
name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84_φλ);
- final DefaultAttributeType<?> normalizedCRS = new DefaultAttributeType<>(
+ final DefaultAttributeType<?> normalizedCRS = new DefaultAttributeType<CoordinateReferenceSystem>(
name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84);
final PropertyType[] attributes = {
- new DefaultAttributeType<>(name("name"), String.class, 1, 1, null),
- new DefaultAttributeType<>(name("classes"), Polygon.class, 1, 1, null, standardCRS),
- new DefaultAttributeType<>(name("climbing wall"), Point.class, 1, 1, null, standardCRS),
- new DefaultAttributeType<>(name("gymnasium"), Polygon.class, 1, 1, null, normalizedCRS),
+ new DefaultAttributeType<String> (name("name"), String.class, 1, 1, null),
+ new DefaultAttributeType<Polygon>(name("classes"), Polygon.class, 1, 1, null, standardCRS),
+ new DefaultAttributeType<Point> (name("climbing wall"), Point.class, 1, 1, null, standardCRS),
+ new DefaultAttributeType<Polygon>(name("gymnasium"), Polygon.class, 1, 1, null, normalizedCRS),
null,
null
};
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureMemoryBenchmark.java b/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureMemoryBenchmark.java
index 9c4c5a3..8b33fd5 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureMemoryBenchmark.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureMemoryBenchmark.java
@@ -69,13 +69,13 @@
* @param isSimple In the case of non-SIS implementation, whether we use simple features or complex features.
*/
private FeatureMemoryBenchmark(final boolean useSIS, final boolean isSimple) {
- features = new ArrayList<>(100000);
+ features = new ArrayList<Object>(100000);
this.isSimple = isSimple;
if (useSIS) {
- type = new DefaultFeatureType (singletonMap("name", "City"), false, null,
- new DefaultAttributeType<>(singletonMap("name", "city"), String.class, 1, 1, null),
- new DefaultAttributeType<>(singletonMap("name", "longitude"), Float.class, 1, 1, null),
- new DefaultAttributeType<>(singletonMap("name", "latitude"), Float.class, 1, 1, null));
+ type = new DefaultFeatureType (singletonMap("name", "City"), false, null,
+ new DefaultAttributeType<String>(singletonMap("name", "city"), String.class, 1, 1, null),
+ new DefaultAttributeType<Float> (singletonMap("name", "longitude"), Float.class, 1, 1, null),
+ new DefaultAttributeType<Float> (singletonMap("name", "latitude"), Float.class, 1, 1, null));
} else {
type = null;
}
@@ -87,14 +87,14 @@
* The old feature implementation.
*/
private static final class SimpleFeature {
- final HashMap<String, Object> attributes = new HashMap<>(8);
+ final HashMap<String,Object> attributes = new HashMap<String,Object>(8);
}
/**
* A more complete feature implementation.
*/
private static final class ComplexFeature {
- final HashMap<String, List<Property>> properties = new HashMap<>(8);
+ final HashMap<String, List<Property>> properties = new HashMap<String, List<Property>>(8);
}
/**
@@ -108,7 +108,7 @@
}
static List<Property> asList(final Object value) {
- final List<Property> list = new ArrayList<>(2);
+ final List<Property> list = new ArrayList<Property>(2);
list.add(new Property(value));
return list;
}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java b/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java
index c794d54..dbca8d2 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java
@@ -264,7 +264,7 @@
public void testCustomAttribute() {
feature = createFeature(DefaultFeatureTypeTest.city());
final AbstractAttribute<String> wrong = SingletonAttributeTest.parliament();
- final CustomAttribute<String> city = new CustomAttribute<>(Features.cast(
+ final CustomAttribute<String> city = new CustomAttribute<String>(Features.cast(
(DefaultAttributeType<?>) feature.getType().getProperty("city"), String.class));
feature.setProperty(city);
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/MultiValuedAttributeTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/MultiValuedAttributeTest.java
index 5252d3e..b394f7b 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/MultiValuedAttributeTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/MultiValuedAttributeTest.java
@@ -41,7 +41,7 @@
* The cardinality is [0 … ∞].
*/
static MultiValuedAttribute<String> universities() {
- return new MultiValuedAttribute<>(DefaultAttributeTypeTest.universities());
+ return new MultiValuedAttribute<String>(DefaultAttributeTypeTest.universities());
}
/**
@@ -49,7 +49,7 @@
* This attribute has no default value.
*/
private static MultiValuedAttribute<Integer> population() {
- return new MultiValuedAttribute<>(DefaultAttributeTypeTest.population(new HashMap<String,Object>(4)));
+ return new MultiValuedAttribute<Integer>(DefaultAttributeTypeTest.population(new HashMap<String,Object>(4)));
}
/**
@@ -106,7 +106,7 @@
@Test
@DependsOnMethod("testValue")
public void testDefaultValue() {
- final AbstractAttribute<String> attribute = new MultiValuedAttribute<>(DefaultAttributeTypeTest.city());
+ final AbstractAttribute<String> attribute = new MultiValuedAttribute<String>(DefaultAttributeTypeTest.city());
assertEquals ("value", "Utopia", attribute.getValue());
assertArrayEquals("values", new String[] {"Utopia"}, attribute.getValues().toArray());
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
index 315c4b7..5dcdaf6 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
@@ -50,9 +50,9 @@
* Creates a new test case.
*/
public PropertySingletonTest() {
- attribute = new SingletonAttribute<>(new DefaultAttributeType<>(
+ attribute = new SingletonAttribute<Integer>(new DefaultAttributeType<Integer>(
singletonMap(DefaultAttributeType.NAME_KEY, "test"), Integer.class, 0, 1, null));
- singleton = new PropertySingleton<>(attribute);
+ singleton = new PropertySingleton<Integer>(attribute);
}
/**
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAttributeTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAttributeTest.java
index 99cd2c5..6e41bc3 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAttributeTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAttributeTest.java
@@ -49,7 +49,7 @@
* This attribute has a default value.
*/
static SingletonAttribute<String> city() {
- return new SingletonAttribute<>(DefaultAttributeTypeTest.city());
+ return new SingletonAttribute<String>(DefaultAttributeTypeTest.city());
}
/**
@@ -57,7 +57,7 @@
* This attribute has no default value.
*/
static SingletonAttribute<Integer> population() {
- return new SingletonAttribute<>(DefaultAttributeTypeTest.population(new HashMap<String,Object>(4)));
+ return new SingletonAttribute<Integer>(DefaultAttributeTypeTest.population(new HashMap<String,Object>(4)));
}
/**
@@ -65,7 +65,7 @@
* This applies only to features of type "Capital".
*/
static SingletonAttribute<String> parliament() {
- return new SingletonAttribute<>(DefaultAttributeTypeTest.parliament());
+ return new SingletonAttribute<String>(DefaultAttributeTypeTest.parliament());
}
/**
diff --git a/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java b/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
index 0aa6b38..58565ce 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
@@ -58,8 +58,8 @@
* @return The feature for a person.
*/
private static DefaultFeatureType person() {
- final PropertyType nameType = new DefaultAttributeType<>(name("name"), String.class, 1, 1, null);
- final PropertyType ageType = new DefaultAttributeType<>(name("age"), Integer.class, 1, 1, null);
+ final PropertyType nameType = new DefaultAttributeType<String> (name("name"), String.class, 1, 1, null);
+ final PropertyType ageType = new DefaultAttributeType<Integer>(name("age"), Integer.class, 1, 1, null);
final PropertyType cmpType = FeatureOperations.compound(name("concat"), "/", "<<:", ":>>", nameType, ageType);
return new DefaultFeatureType(name("person"), false, null, nameType, ageType, cmpType);
}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/internal/feature/AttributeConventionTest.java b/core/sis-feature/src/test/java/org/apache/sis/internal/feature/AttributeConventionTest.java
index b24bc6d..31296af 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/internal/feature/AttributeConventionTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/internal/feature/AttributeConventionTest.java
@@ -61,10 +61,10 @@
final Map<String,?> properties = Collections.singletonMap(DefaultAttributeType.NAME_KEY, "geometry");
assertFalse("AttributeType<Integer>", AttributeConvention.isGeometryAttribute(
- new DefaultAttributeType<>(properties, Integer.class, 1, 1, null)));
+ new DefaultAttributeType<Integer>(properties, Integer.class, 1, 1, null)));
assertTrue("AttributeType<Point>", AttributeConvention.isGeometryAttribute(
- new DefaultAttributeType<>(properties, Point.class, 1, 1, null)));
+ new DefaultAttributeType<Point>(properties, Point.class, 1, 1, null)));
}
/**
@@ -74,18 +74,18 @@
@Test
public void testGetCrsCharacteristic() {
final Map<String,?> properties = Collections.singletonMap(DefaultAttributeType.NAME_KEY, "geometry");
- DefaultAttributeType<Point> type = new DefaultAttributeType<>(properties, Point.class, 1, 1, null);
+ DefaultAttributeType<Point> type = new DefaultAttributeType<Point>(properties, Point.class, 1, 1, null);
assertFalse("characterizedByCRS", AttributeConvention.characterizedByCRS(type));
assertNull("getCRSCharacteristic", AttributeConvention.getCRSCharacteristic(type.newInstance()));
/*
* Creates an attribute associated to an attribute (i.e. a "characteristic") for storing
* the Coordinate Reference System of the "geometry" attribute. Then test again.
*/
- final DefaultAttributeType<CoordinateReferenceSystem> characteristic = new DefaultAttributeType<>(
+ final DefaultAttributeType<CoordinateReferenceSystem> characteristic = new DefaultAttributeType<CoordinateReferenceSystem>(
Collections.singletonMap(DefaultAttributeType.NAME_KEY, AttributeConvention.CRS_CHARACTERISTIC),
CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84);
- type = new DefaultAttributeType<>(properties, Point.class, 1, 1, null, characteristic);
+ type = new DefaultAttributeType<Point>(properties, Point.class, 1, 1, null, characteristic);
assertTrue("characterizedByCRS", AttributeConvention.characterizedByCRS(type));
assertEquals(HardCodedCRS.WGS84, AttributeConvention.getCRSCharacteristic(type.newInstance()));
}
@@ -97,18 +97,18 @@
@Test
public void testGetMaximalLengthCharacteristic() {
final Map<String,?> properties = Collections.singletonMap(DefaultAttributeType.NAME_KEY, "name");
- DefaultAttributeType<String> type = new DefaultAttributeType<>(properties, String.class, 1, 1, null);
+ DefaultAttributeType<String> type = new DefaultAttributeType<String>(properties, String.class, 1, 1, null);
assertFalse("characterizedByMaximalLength", AttributeConvention.characterizedByMaximalLength(type));
assertNull("getMaximalLengthCharacteristic", AttributeConvention.getMaximalLengthCharacteristic(type.newInstance()));
/*
* Creates an attribute associated to an attribute (i.e. a "characteristic") for storing
* the maximal length of the "name" attribute. Then test again.
*/
- final DefaultAttributeType<Integer> characteristic = new DefaultAttributeType<>(
+ final DefaultAttributeType<Integer> characteristic = new DefaultAttributeType<Integer>(
Collections.singletonMap(DefaultAttributeType.NAME_KEY, AttributeConvention.MAXIMAL_LENGTH_CHARACTERISTIC),
Integer.class, 1, 1, 120);
- type = new DefaultAttributeType<>(properties, String.class, 1, 1, null, characteristic);
+ type = new DefaultAttributeType<String>(properties, String.class, 1, 1, null, characteristic);
assertTrue("characterizedByMaximalLength", AttributeConvention.characterizedByMaximalLength(type));
assertEquals(Integer.valueOf(120), AttributeConvention.getMaximalLengthCharacteristic(type.newInstance()));
}
diff --git a/core/sis-metadata/pom.xml b/core/sis-metadata/pom.xml
index 156d45b..af891e0 100644
--- a/core/sis-metadata/pom.xml
+++ b/core/sis-metadata/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>core</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
index b06f944..2be6f10 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
@@ -133,7 +133,7 @@
final String encoding;
try {
encoding = (String) marshaller.getProperty(Marshaller.JAXB_ENCODING);
- } catch (PropertyException | ClassCastException e) {
+ } catch (Exception e) { // (PropertyException | ClassCastException) on the JDK7 branch.
// Should never happen. But if it happen anyway, just let the
// characterEncoding unitialized: it will not be marshalled.
Context.warningOccured(Context.current(), PT_Locale.class, "beforeMarshal", e, true);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
index a7984ea..d63022a 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/geometry/ObjectFactory.java
@@ -59,7 +59,7 @@
*/
@XmlElementDecl(name = "AbstractObject", namespace = Namespaces.GML)
public JAXBElement<Object> createObject(final Object value) {
- return new JAXBElement<>(AbstractObject_QNAME, Object.class, null, value);
+ return new JAXBElement<Object>(AbstractObject_QNAME, Object.class, null, value);
}
/**
@@ -77,7 +77,7 @@
substitutionHeadName = "AbstractObject",
substitutionHeadNamespace = Namespaces.GML) // Not necessary according javadoc, but appears to be in practice (JAXB 2.1 bug?)
public JAXBElement<Object> createAbstractGML(final Object value) {
- return new JAXBElement<>(AbstractGML_QNAME, Object.class, null, value);
+ return new JAXBElement<Object>(AbstractGML_QNAME, Object.class, null, value);
}
/**
@@ -95,6 +95,6 @@
substitutionHeadName = "AbstractGML",
substitutionHeadNamespace = Namespaces.GML) // Not necessary according javadoc, but appears to be in practice (JAXB 2.1 bug?)
public JAXBElement<Object> createAbstractGeometry(final Object value) {
- return new JAXBElement<>(AbstractGeometry_QNAME, Object.class, null, value);
+ return new JAXBElement<Object>(AbstractGeometry_QNAME, Object.class, null, value);
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
index aba8634..f09686f 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
@@ -24,7 +24,7 @@
import org.apache.sis.util.ComparisonMode;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
index a476f7a..ea366f3 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
@@ -43,7 +43,7 @@
import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java
index eb1561b..fd17160 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java
@@ -100,7 +100,7 @@
* For each direction, the opposite direction.
* This map shall be immutable after construction.
*/
- private static final Map<AxisDirection,AxisDirection> OPPOSITES = new HashMap<>(20);
+ private static final Map<AxisDirection,AxisDirection> OPPOSITES = new HashMap<AxisDirection,AxisDirection>(20);
static {
put(OTHER, OTHER);
put(NORTH, SOUTH);
@@ -132,7 +132,7 @@
* Proposed abbreviations for some axis directions.
* This map shall be immutable after construction.
*/
- private static final Map<AxisDirection,String> ABBREVIATIONS = new HashMap<>(12);
+ private static final Map<AxisDirection,String> ABBREVIATIONS = new HashMap<AxisDirection,String>(12);
static {
final Map<AxisDirection,String> m = ABBREVIATIONS;
m.put(FUTURE, "t");
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java
index de5e357..fe890d8 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java
@@ -145,7 +145,7 @@
*/
private static final Map<String,String> VALUES;
static {
- final Map<String,String> values = new HashMap<>(22); // 18 elements + 25%, rounded to highest integer.
+ final Map<String,String> values = new HashMap<String,String>(22);
final StringBuilder buffer = new StringBuilder(22); // Length of the longuest string: "Gravity-related height"
try {
for (final Field f : AxisNames.class.getFields()) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ExcludedSet.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ExcludedSet.java
index ea9bb97..b5dc636 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ExcludedSet.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ExcludedSet.java
@@ -86,7 +86,7 @@
*/
@Override
public Iterator<E> iterator() {
- return Collections.emptyIterator();
+ return Collections.<E>emptySet().iterator();
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
index 6120faf..3543edb 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
@@ -27,7 +27,7 @@
import org.apache.sis.util.ArgumentChecks;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
index 227fc74..3279aba 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
@@ -114,7 +114,7 @@
*
* @since 0.7
*/
- private static final Map<String,String> AUTHORITIES = new HashMap<>(12);
+ private static final Map<String,String> AUTHORITIES = new HashMap<String,String>(12);
static {
add(Constants.EPSG); // IOGP
add(Constants.OGC); // Open Geospatial Consortium
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
index 8c69f8a..ee219ca 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
@@ -31,7 +31,7 @@
import static org.apache.sis.util.Characters.Filter.LETTERS_AND_DIGITS;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java
index 473c47a..9c48365 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java
@@ -133,7 +133,7 @@
if (Containers.isNullOrEmpty(otherLocales)) {
merged = LegacyPropertyAdapter.asCollection(defaultLocale);
} else {
- merged = new ArrayList<>(otherLocales.size() + 1);
+ merged = new ArrayList<Locale>(otherLocales.size() + 1);
if (defaultLocale == null) {
defaultLocale = Locale.getDefault();
if (otherLocales.contains(defaultLocale)) {
@@ -180,7 +180,7 @@
values.add(newValue);
} else {
if (!(values instanceof List<?>)) {
- values = new ArrayList<>(values);
+ values = new ArrayList<T>(values);
}
((List<T>) values).set(0, newValue);
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/SensorType.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/SensorType.java
index dc4cfb0..329e15c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/SensorType.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/SensorType.java
@@ -44,7 +44,7 @@
* List of all enumerations of this type.
* Must be declared before any enum declaration.
*/
- private static final List<SensorType> VALUES = new ArrayList<>();
+ private static final List<SensorType> VALUES = new ArrayList<SensorType>();
/**
* The sensor is a radiometer.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
index 3716076..62cb33d 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
@@ -93,8 +93,8 @@
CharSequence citedResponsibleParty = null;
PresentationForm presentationForm = null;
Citation[] copyFrom = null; // Copy citedResponsibleParty from those citations.
- switch (key) {
- case "ISO 19115-1": {
+ { // This is a switch(String) on the JDK7 branch
+ if (key.equals("ISO 19115-1")) {
title = "Geographic Information — Metadata Part 1: Fundamentals";
edition = "ISO 19115-1:2014(E)";
code = "19115-1";
@@ -102,9 +102,7 @@
version = "2014(E)";
citedResponsibleParty = "International Organization for Standardization";
presentationForm = PresentationForm.DOCUMENT_DIGITAL;
- break;
- }
- case "ISO 19115-2": {
+ } else if (key.equals("ISO 19115-2")) {
title = "Geographic Information — Metadata Part 2: Extensions for imagery and gridded data";
edition = "ISO 19115-2:2009(E)";
code = "19115-2";
@@ -112,9 +110,7 @@
version = "2009(E)";
copyFrom = new Citation[] {Citations.ISO_19115.get(0)};
presentationForm = PresentationForm.DOCUMENT_DIGITAL;
- break;
- }
- case "WMS": {
+ } else if (key.equals("WMS")) {
title = "Web Map Server"; // OGC title
alternateTitle = "Geographic Information — Web map server interface"; // ISO title
alternateIdentifiers = new Identifier[] {
@@ -126,23 +122,17 @@
codeSpace = "OGC";
copyFrom = new Citation[] {Citations.OGC, Citations.ISO_19115.get(0)};
presentationForm = PresentationForm.DOCUMENT_DIGITAL;
- break;
- }
- case Constants.OGC: {
+ } else if (key.equals(Constants.OGC)) {
title = "Identifiers in OGC namespace";
code = Constants.OGC;
citedResponsibleParty = "Open Geospatial Consortium";
presentationForm = PresentationForm.DOCUMENT_DIGITAL;
- break;
- }
- case Constants.IOGP: { // Not in public API (see Citations.IOGP javadoc)
+ } else if (key.equals(Constants.IOGP)) { // Not in public API (see Citations.IOGP javadoc)
title = "Using the EPSG Geodetic Parameter Dataset"; // Geomatics Guidance Note number 7, part 1
code = Constants.IOGP;
copyFrom = new Citation[] {Citations.EPSG};
presentationForm = PresentationForm.DOCUMENT_DIGITAL;
- break;
- }
- case Constants.EPSG: {
+ } else if (key.equals(Constants.EPSG)) {
title = "EPSG Geodetic Parameter Dataset";
code = Constants.EPSG;
codeSpace = Constants.IOGP;
@@ -155,32 +145,22 @@
* After we moved the content of this citation in a database,
* EPSGDataAccess.getAuthority() should use this citation as a template.
*/
- break;
- }
- case Constants.SIS: {
+ } else if (key.equals(Constants.SIS)) {
title = "Apache Spatial Information System";
code = key;
- break;
- }
- case "ISBN": {
+ } else if (key.equals("ISBN")) {
title = "International Standard Book Number";
alternateTitle = key;
- break;
- }
- case "ISSN": {
+ } else if (key.equals("ISSN")) {
title = "International Standard Serial Number";
alternateTitle = key;
- break;
- }
- case "Proj4": {
+ } else if (key.equals("Proj4")) {
title = "Proj.4";
- break;
- }
- case "S57": {
+ } else if (key.equals("S57")) {
title = "S-57";
- break;
+ } else {
+ return super.createCitation(key);
}
- default: return super.createCitation(key);
}
/*
* Do not use the 'c.getFoo().add(foo)' pattern below. Use the 'c.setFoo(singleton(foo))' pattern instead.
@@ -225,8 +205,8 @@
*/
@Override
public String getInformation(final String key, final Locale locale) {
- switch (key) {
- case "DataSource": {
+ /* switch (key) */ {
+ if (key.equals("DataSource")) {
Object server = null, database = null;
try {
final DataSource ds = Initializer.getDataSource();
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/TransformationAccuracy.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/TransformationAccuracy.java
index 23fbe57..058db40 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/TransformationAccuracy.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/TransformationAccuracy.java
@@ -55,7 +55,8 @@
/**
* Cache the positional accuracies. Most coordinate operation use a small set of accuracy values.
*/
- private static final WeakValueHashMap<Double,PositionalAccuracy> CACHE = new WeakValueHashMap<>(Double.class);
+ private static final WeakValueHashMap<Double,PositionalAccuracy> CACHE =
+ new WeakValueHashMap<Double,PositionalAccuracy>(Double.class);
/**
* Do not allow instantiation of this class.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
index 4b2481e..a8deb96 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
@@ -45,9 +45,9 @@
// Branch-dependent imports
import java.util.concurrent.Callable;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
/**
@@ -261,7 +261,7 @@
* of encoding issues if the path contains spaces or non-ASCII characters.
*/
path = Paths.get(home).relativize(path);
- } catch (IllegalArgumentException | SecurityException e) {
+ } catch (Exception e) { // (IllegalArgumentException | SecurityException e) on the JDK7 branch.
// The path can not be relativized. This is okay.
Logging.recoverableException(Logging.getLogger(Loggers.SQL), Initializer.class, "getDataSource", e);
}
@@ -284,7 +284,7 @@
* it properly if the schemas creation below fail.
*/
Shutdown.register(new Callable<Object>() {
- @Override public Object call() throws ReflectiveOperationException {
+ @Override public Object call() throws Exception {
shutdown();
return null;
}
@@ -297,11 +297,13 @@
if (create) {
final Method m = source.getClass().getMethod("setCreateDatabase", String.class);
m.invoke(source, "create");
- try (Connection c = source.getConnection()) {
+ Connection c = source.getConnection();
+ try {
for (Initializer init : DefaultFactories.createServiceLoader(Initializer.class)) {
init.createSchema(c);
}
} finally {
+ c.close();
m.invoke(source, "no"); // Any value other than "create".
}
}
@@ -403,7 +405,7 @@
* @throws ReflectiveOperationException if an error occurred while
* setting the shutdown property on the Derby data source.
*/
- private static synchronized void shutdown() throws ReflectiveOperationException {
+ private static synchronized void shutdown() throws Exception {
final DataSource ds = source;
if (ds != null) { // Should never be null, but let be safe.
source = null; // Clear now in case of failure in remaining code.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
index 4e4c8f8..e816b65 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
@@ -36,6 +36,7 @@
// Branch-specific imports
import org.apache.sis.internal.jdk8.JDK8;
import org.apache.sis.internal.jdk8.BiFunction;
+import org.apache.sis.internal.jdk7.AutoCloseable;
/**
@@ -54,7 +55,8 @@
* @version 0.7
* @module
*/
-public class ScriptRunner implements AutoCloseable {
+@AutoCloseable
+public class ScriptRunner {
/**
* The database user having read (not write) permissions.
*
@@ -107,7 +109,7 @@
*
* @see #replace(String, String)
*/
- private final Map<String,String> replacements = new HashMap<>();
+ private final Map<String,String> replacements = new HashMap<String,String>();
/**
* A sentinel value for the {@linkplain #replace replacements} map meaning that {@code ScriptRunner}
@@ -602,7 +604,6 @@
*
* @throws SQLException If an error occurred while closing the statement.
*/
- @Override
public void close() throws SQLException {
statement.close();
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
index 71efe8c..6cd36e3 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
@@ -179,7 +179,7 @@
this.numberFormat = numberFormat;
exponentSymbol = null;
}
- ignoredElements = new LinkedHashMap<>();
+ ignoredElements = new LinkedHashMap<String, List<String>>();
}
/**
@@ -348,7 +348,6 @@
try {
return Units.valueOf(text);
} catch (IllegalArgumentException e2) {
- e.addSuppressed(e2);
throw e;
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
index 7adc769..c482e9c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
@@ -104,7 +104,7 @@
* Creates a new, initially empty, set of colors.
*/
public Colors() {
- map = new EnumMap<>(ElementKind.class);
+ map = new EnumMap<ElementKind,X364>(ElementKind.class);
}
/**
@@ -113,7 +113,7 @@
* @param colors The set of colors to copy.
*/
public Colors(final Colors colors) {
- map = new EnumMap<>(colors.map);
+ map = new EnumMap<ElementKind,X364>(colors.map);
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
index 8e46040..ee7d214 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
@@ -41,6 +41,7 @@
// Branch-dependent imports
import org.apache.sis.internal.jdk8.JDK8;
+import org.apache.sis.internal.jdk7.JDK7;
/**
@@ -123,7 +124,7 @@
keyword = name;
offset = singleton.offset;
locale = singleton.locale;
- list = new LinkedList<>(); // Needs to be a modifiable list.
+ list = new LinkedList<Object>(); // Needs to be a modifiable list.
list.add(singleton);
}
@@ -134,7 +135,7 @@
keyword = toCopy.keyword;
offset = toCopy.offset;
locale = toCopy.locale;
- list = new LinkedList<>(toCopy.list); // Needs to be a modifiable list.
+ list = new LinkedList<Object>(toCopy.list); // Needs to be a modifiable list.
final ListIterator<Object> it = list.listIterator();
while (it.hasNext()) {
final Object value = it.next();
@@ -219,7 +220,7 @@
* - Otherwise, if the first character is a quote, then the value is taken as a String.
* - Otherwise, the element is parsed as a number or as a date, depending of 'isTemporal' boolean value.
*/
- final List<Object> list = new LinkedList<>();
+ final List<Object> list = new LinkedList<Object>();
final String separator = parser.symbols.trimmedSeparator();
while (lower < length) {
final int firstChar = text.codePointAt(lower);
@@ -776,7 +777,7 @@
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
- format(buffer, 0, System.lineSeparator());
+ format(buffer, 0, JDK7.lineSeparator());
return buffer.toString();
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
index e056e65..7b673e1 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
@@ -82,7 +82,7 @@
* Since {@code toString()} is typically invoked for debugging purpose, a single formatter for
* any thread is presumed sufficient.</div>
*/
- private static final AtomicReference<Formatter> FORMATTER = new AtomicReference<>();
+ private static final AtomicReference<Formatter> FORMATTER = new AtomicReference<Formatter>();
/**
* Default constructor.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
index 15e8b2f..1d9a5e9 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
@@ -83,6 +83,9 @@
import org.apache.sis.metadata.iso.ImmutableIdentifier;
import org.apache.sis.metadata.iso.extent.Extents;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Provides support methods for formatting a <cite>Well Known Text</cite> (WKT).
@@ -201,7 +204,7 @@
*
* @see #getEnclosingElement(int)
*/
- private final List<FormattableObject> enclosingElements = new ArrayList<>();
+ private final List<FormattableObject> enclosingElements = new ArrayList<FormattableObject>();
/**
* The contextual units for writing lengths, angles or other type of measurements.
@@ -212,7 +215,7 @@
* @see #addContextualUnit(Unit)
* @see #toContextualUnit(Unit)
*/
- private final Map<Unit<?>, Unit<?>> units = new HashMap<>(4);
+ private final Map<Unit<?>, Unit<?>> units = new HashMap<Unit<?>, Unit<?>>(4);
/**
* A bits mask of elements which defined a contextual units.
@@ -344,7 +347,7 @@
ArgumentChecks.ensureNonNull("convention", convention);
ArgumentChecks.ensureNonNull("symbols", symbols);
ArgumentChecks.ensureBetween("indentation", WKTFormat.SINGLE_LINE, Byte.MAX_VALUE, indentation);
- this.locale = Locale.getDefault(Locale.Category.DISPLAY);
+ this.locale = Locale.getDefault();
this.convention = convention;
this.authority = convention.getNameAuthority();
this.symbols = symbols.immutable();
@@ -565,7 +568,7 @@
buffer.append(symbols.getSeparator());
}
} else if (requestNewLine) {
- buffer.append(System.lineSeparator()).append(CharSequences.spaces(margin));
+ buffer.append(JDK7.lineSeparator()).append(CharSequences.spaces(margin));
}
requestNewLine = false;
}
@@ -1640,7 +1643,7 @@
final Warnings warnings = this.warnings; // Protect against accidental changes.
if (warnings != null) {
final StringBuffer buffer = this.buffer;
- final String ln = System.lineSeparator();
+ final String ln = JDK7.lineSeparator();
buffer.append(ln).append(ln);
if (colors != null) {
buffer.append(X364.BACKGROUND_RED.sequence()).append(X364.BOLD.sequence()).append(' ');
@@ -1651,7 +1654,7 @@
}
buffer.append(ln);
final int n = warnings.getNumMessages();
- final Set<String> done = new HashSet<>();
+ final Set<String> done = new HashSet<String>();
for (int i=0; i<n; i++) {
String message = Exceptions.getLocalizedMessage(warnings.getException(i), locale);
if (message == null) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
index 1f05c1b..04053ed 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -160,12 +160,12 @@
* A map of properties to be given to the factory constructor methods.
* This map will be recycled for each object to be parsed.
*/
- private final Map<String,Object> properties = new HashMap<>(4);
+ private final Map<String,Object> properties = new HashMap<String,Object>(4);
/**
* Order of coordinate system axes. Used only if {@code AXIS[…]} elements contain {@code ORDER[…]} sub-element.
*/
- private final Map<CoordinateSystemAxis,Integer> axisOrder = new IdentityHashMap<>(4);
+ private final Map<CoordinateSystemAxis,Integer> axisOrder = new IdentityHashMap<CoordinateSystemAxis,Integer>(4);
/**
* The last vertical CRS found during the parsing, or {@code null} if none.
@@ -301,7 +301,6 @@
verticalElements = verticalElements.complete(crsFactory, csFactory);
} catch (FactoryException e) {
if (ex == null) ex = e;
- else ex.addSuppressed(e);
}
if (verticalElements != null) {
warning(null, (String) null, Errors.formatInternational(Errors.Keys.CanNotAssignUnitToDimension_2,
@@ -661,7 +660,9 @@
if (verify == null) {
try {
verify = parseUnit(name);
- } catch (IllegalArgumentException | ParseException e) {
+ } catch (IllegalArgumentException e) {
+ log(new LogRecord(Level.FINE, e.toString()));
+ } catch (ParseException e) {
log(new LogRecord(Level.FINE, e.toString()));
}
if (verify != null) try {
@@ -734,7 +735,7 @@
final String expected = type;
type = element.pullVoidElement("type").keyword;
dimension = element.pullInteger("dimension");
- csProperties = new HashMap<>(parseMetadataAndClose(element, "CS", null));
+ csProperties = new HashMap<String,Object>(parseMetadataAndClose(element, "CS", null));
if (expected != null) {
if (!expected.equalsIgnoreCase(type)) {
throw new LocalizedParseException(errorLocale, Errors.Keys.UnexpectedValueInElement_2,
@@ -769,7 +770,7 @@
CoordinateSystemAxis[] axes = null;
CoordinateSystemAxis axis = parseAxis(type == null ? MANDATORY : OPTIONAL, parent, type, defaultUnit);
if (axis != null) {
- final List<CoordinateSystemAxis> list = new ArrayList<>(dimension + 2);
+ final List<CoordinateSystemAxis> list = new ArrayList<CoordinateSystemAxis>(dimension + 2);
do {
list.add(axis);
axis = parseAxis(list.size() < dimension ? MANDATORY : OPTIONAL, parent, type, defaultUnit);
@@ -795,12 +796,12 @@
AxisDirection dy = AxisDirection.NORTH;
AxisDirection direction = null; // Depth, height or time axis direction.
Unit<?> unit = defaultUnit; // Depth, height or time axis unit.
- switch (type) {
+ /*switch (type)*/ {
/*
* Cartesian — we can create axes only for geodetic datum, in which case the axes are for
* two-dimensional Projected or three-dimensional Geocentric CRS.
*/
- case WKTKeywords.Cartesian: {
+ if (type.equals(WKTKeywords.Cartesian)) {
if (!(datum instanceof GeodeticDatum)) {
throw parent.missingComponent(WKTKeywords.Axis);
}
@@ -817,7 +818,6 @@
nz = AxisNames.ELLIPSOIDAL_HEIGHT;
unit = SI.METRE;
}
- break;
}
/*
* Ellipsoidal — can be two- or three- dimensional, in which case the height can
@@ -826,7 +826,7 @@
* - WKT 1 said explicitely that the default order is (longitude, latitude).
* - WKT 2 has no default, and allows only (latitude, longitude) order.
*/
- case WKTKeywords.ellipsoidal: {
+ else if (type.equals(WKTKeywords.ellipsoidal)) {
if (defaultUnit == null) {
throw parent.missingComponent(WKTKeywords.AngleUnit);
}
@@ -843,13 +843,12 @@
nz = AxisNames.ELLIPSOIDAL_HEIGHT;
unit = SI.METRE;
}
- break;
}
/*
* Vertical — the default name and symbol depends on whether this is depth,
* geoidal height, ellipsoidal height (non-standard) or other kind of heights.
*/
- case WKTKeywords.vertical: {
+ else if (type.equals(WKTKeywords.vertical)) {
if (defaultUnit == null) {
throw parent.missingComponent(WKTKeywords.Unit);
}
@@ -871,36 +870,33 @@
nz = AxisNames.ELLIPSOIDAL_HEIGHT;
}
}
- break;
}
/*
* Temporal — axis name and abbreviation not yet specified by ISO 19111.
*/
- case WKTKeywords.temporal: {
+ else if (type.equals(WKTKeywords.temporal)) {
if (defaultUnit == null) {
throw parent.missingComponent(WKTKeywords.TimeUnit);
}
direction = AxisDirection.FUTURE;
nz = "Time";
z = "t";
- break;
}
/*
* Parametric — axis name and abbreviation not yet specified by ISO 19111_2.
*/
- case WKTKeywords.parametric: {
+ else if (type.equals(WKTKeywords.parametric)) {
if (defaultUnit == null) {
throw parent.missingComponent(WKTKeywords.ParametricUnit);
}
direction = AxisDirection.OTHER;
nz = "Parametric";
z = "p";
- break;
}
/*
* Unknown CS type — we can not guess which axes to create.
*/
- default: {
+ else {
throw parent.missingComponent(WKTKeywords.Axis);
}
}
@@ -936,60 +932,64 @@
/*
* Finally, delegate to the factory method corresponding to the CS type and the number of axes.
*/
- switch (type) {
- case WKTKeywords.ellipsoidal: {
+ /*switch (type)*/ {
+ if (type.equals(WKTKeywords.ellipsoidal)) {
switch (axes.length) {
case 2: return csFactory.createEllipsoidalCS(csProperties, axes[0], axes[1]);
case 3: return csFactory.createEllipsoidalCS(csProperties, axes[0], axes[1], axes[2]);
}
dimension = (axes.length < 2) ? 2 : 3; // For error message.
- break;
}
- case WKTKeywords.Cartesian: {
+ else if (type.equals(WKTKeywords.Cartesian)) {
switch (axes.length) {
case 2: return csFactory.createCartesianCS(csProperties, axes[0], axes[1]);
case 3: return csFactory.createCartesianCS(csProperties, axes[0], axes[1], axes[2]);
}
dimension = (axes.length < 2) ? 2 : 3; // For error message.
- break;
}
- case WKTKeywords.affine: {
+ else if (type.equals(WKTKeywords.affine)) {
switch (axes.length) {
case 2: return csFactory.createAffineCS(csProperties, axes[0], axes[1]);
case 3: return csFactory.createAffineCS(csProperties, axes[0], axes[1], axes[2]);
}
dimension = (axes.length < 2) ? 2 : 3; // For error message.
- break;
}
- case WKTKeywords.vertical: {
- if (axes.length != (dimension = 1)) break;
- return csFactory.createVerticalCS(csProperties, axes[0]);
+ else if (type.equals(WKTKeywords.vertical)) {
+ if (axes.length == (dimension = 1)) {
+ return csFactory.createVerticalCS(csProperties, axes[0]);
+ }
}
- case WKTKeywords.temporal: {
- if (axes.length != (dimension = 1)) break;
- return csFactory.createTimeCS(csProperties, axes[0]);
+ else if (type.equals(WKTKeywords.temporal)) {
+ if (axes.length == (dimension = 1)) {
+ return csFactory.createTimeCS(csProperties, axes[0]);
+ }
}
- case WKTKeywords.linear: {
- if (axes.length != (dimension = 1)) break;
- return csFactory.createLinearCS(csProperties, axes[0]);
+ else if (type.equals(WKTKeywords.linear)) {
+ if (axes.length == (dimension = 1)) {
+ return csFactory.createLinearCS(csProperties, axes[0]);
+ }
}
- case WKTKeywords.polar: {
- if (axes.length != (dimension = 2)) break;
- return csFactory.createPolarCS(csProperties, axes[0], axes[1]);
+ else if (type.equals(WKTKeywords.polar)) {
+ if (axes.length == (dimension = 2)) {
+ return csFactory.createPolarCS(csProperties, axes[0], axes[1]);
+ }
}
- case WKTKeywords.cylindrical: {
- if (axes.length != (dimension = 3)) break;
- return csFactory.createCylindricalCS(csProperties, axes[0], axes[1], axes[2]);
+ else if (type.equals(WKTKeywords.cylindrical)) {
+ if (axes.length == (dimension = 3)) {
+ return csFactory.createCylindricalCS(csProperties, axes[0], axes[1], axes[2]);
+ }
}
- case WKTKeywords.spherical: {
- if (axes.length != (dimension = 3)) break;
- return csFactory.createSphericalCS(csProperties, axes[0], axes[1], axes[2]);
+ else if (type.equals(WKTKeywords.spherical)) {
+ if (axes.length == (dimension = 3)) {
+ return csFactory.createSphericalCS(csProperties, axes[0], axes[1], axes[2]);
+ }
}
- case WKTKeywords.parametric: {
- if (axes.length != (dimension = 1)) break;
- return csFactory.createParametricCS(csProperties, axes[0]);
+ else if (type.equals(WKTKeywords.parametric)) {
+ if (axes.length == (dimension = 1)) {
+ return csFactory.createParametricCS(csProperties, axes[0]);
+ }
}
- default: {
+ else {
warning(parent, WKTKeywords.CS, Errors.formatInternational(Errors.Keys.UnknownType_1, type), null);
return referencing.createAbstractCS(csProperties, axes);
}
@@ -1299,7 +1299,7 @@
return opFactory.getOperationMethod(name);
} catch (FactoryException e) {
if (suppressed != null) {
- e.addSuppressed(suppressed);
+// e.addSuppressed(suppressed); // Not available on JDK6.
}
throw element.parseFailed(e);
}
@@ -2175,7 +2175,7 @@
}
final String name = element.pullString("name");
CoordinateReferenceSystem crs;
- final List<CoordinateReferenceSystem> components = new ArrayList<>(4);
+ final List<CoordinateReferenceSystem> components = new ArrayList<CoordinateReferenceSystem>(4);
while ((crs = parseCoordinateReferenceSystem(element, components.size() < 2)) != null) {
components.add(crs);
}
@@ -2239,7 +2239,9 @@
*/
properties.put("conversion.name", name);
return referencing.createDerivedCRS(properties, (SingleCRS) baseCRS, method, toBase.inverse(), derivedCS);
- } catch (FactoryException | NoninvertibleTransformException exception) {
+ } catch (FactoryException exception) {
+ throw element.parseFailed(exception);
+ } catch (NoninvertibleTransformException exception) {
throw element.parseFailed(exception);
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Symbols.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Symbols.java
index ab32e65..308e741 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Symbols.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Symbols.java
@@ -27,6 +27,9 @@
import static org.apache.sis.util.ArgumentChecks.*;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* The set of symbols to use for <cite>Well Known Text</cite> (WKT) parsing and formatting.
@@ -253,7 +256,7 @@
*
* @return The locale for dates and numbers.
*
- * @see WKTFormat#getLocale(Locale.Category)
+ * @see WKTFormat#getLocale()
*/
@Override
public final Locale getLocale() {
@@ -542,7 +545,7 @@
final String lineSeparator() {
final String separator = getSeparator();
return separator.substring(0, CharSequences.skipTrailingWhitespaces(separator, 0, separator.length()))
- .concat(System.lineSeparator());
+ .concat(JDK7.lineSeparator());
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Transliterator.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Transliterator.java
index 49d45b8..4a80226 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Transliterator.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Transliterator.java
@@ -114,7 +114,7 @@
*/
private static final Map<AxisDirection,String> CARTESIAN;
static {
- final Map<AxisDirection,String> m = new HashMap<>(12);
+ final Map<AxisDirection,String> m = new HashMap<AxisDirection,String>(12);
m.put(AxisDirection.EAST, AxisNames.EASTING);
m.put(AxisDirection.WEST, AxisNames.WESTING);
m.put(AxisDirection.NORTH, AxisNames.NORTHING);
@@ -263,25 +263,22 @@
* @return The axis name to use. Can not be null.
*/
public String toLongAxisName(final String csType, final AxisDirection direction, final String name) {
- if (csType != null) switch (csType) {
- case WKTKeywords.ellipsoidal: {
+ if (csType != null) /*switch (csType)*/ {
+ if (csType.equals(WKTKeywords.ellipsoidal)) {
if (isLatLong(AxisNames.LATITUDE, name)) return AxisNames.GEODETIC_LATITUDE;
if (isLatLong(AxisNames.LONGITUDE, name)) return AxisNames.GEODETIC_LONGITUDE;
- break;
}
- case WKTKeywords.spherical: {
+ else if (csType.equals(WKTKeywords.spherical)) {
if (isLatLong(AxisNames.LATITUDE, name)) return AxisNames.SPHERICAL_LATITUDE;
if (isLatLong(AxisNames.LONGITUDE, name)) return AxisNames.SPHERICAL_LONGITUDE;
- break;
}
- case WKTKeywords.Cartesian: {
+ else if (csType.equals(WKTKeywords.Cartesian)) {
if (name.length() <= 1) {
final String c = CARTESIAN.get(direction);
if (c != null) {
return c;
}
}
- break;
}
}
return AxisNames.toCamelCase(name);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
index 5914eb8..da99af2 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
@@ -253,7 +253,7 @@
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private Map<String,Element> fragments() {
if (fragments == null) {
- fragments = new TreeMap<>();
+ fragments = new TreeMap<String,Element>();
}
return fragments;
}
@@ -264,33 +264,12 @@
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private Map<Class<?>,Factory> factories() {
if (factories == null) {
- factories = new HashMap<>(8);
+ factories = new HashMap<Class<?>,Factory>(8);
}
return factories;
}
/**
- * Returns the locale for the given category. This method implements the following mapping:
- *
- * <ul>
- * <li>{@link java.util.Locale.Category#FORMAT}: the value of {@link Symbols#getLocale()},
- * normally fixed to {@link Locale#ROOT}, used for number formatting.</li>
- * <li>{@link java.util.Locale.Category#DISPLAY}: the {@code locale} given at construction time,
- * used for {@link InternationalString} localization.</li>
- * </ul>
- *
- * @param category The category for which a locale is desired.
- * @return The locale for the given category (never {@code null}).
- */
- @Override
- public Locale getLocale(final Locale.Category category) {
- if (category == Locale.Category.FORMAT) {
- return symbols.getLocale();
- }
- return super.getLocale(category);
- }
-
- /**
* Returns the symbols used for parsing and formatting WKT.
*
* @return The current set of symbols used for parsing and formatting WKT.
@@ -681,7 +660,7 @@
short error = Errors.Keys.NotAUnicodeIdentifier_1;
if (CharSequences.isUnicodeIdentifier(name)) {
if (sharedValues == null) {
- sharedValues = new HashMap<>();
+ sharedValues = new HashMap<Object,Object>();
}
final ParsePosition pos = new ParsePosition(0);
final Element element = new Element(parser(), wkt, pos, sharedValues);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java
index 6e4587f..2c8abcf 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java
@@ -37,6 +37,9 @@
import org.apache.sis.util.resources.Messages;
import org.apache.sis.util.resources.Vocabulary;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Warnings that occurred during a <cite>Well Known Text</cite> (WKT) parsing or formatting.
@@ -185,13 +188,13 @@
final void add(final InternationalString message, final Exception cause, final String[] source) {
assert (message != null) || (cause != null);
if (messages == null) {
- messages = new ArrayList<>(4); // We expect few items.
+ messages = new ArrayList<Object>(4); // We expect few items.
}
messages.add(message);
messages.add(cause);
if (cause != null) {
if (exceptionSources == null) {
- exceptionSources = new LinkedHashMap<>(4); // We expect few items.
+ exceptionSources = new LinkedHashMap<Exception, String[]>(4); // We expect few items.
}
exceptionSources.put(cause, source);
}
@@ -205,7 +208,7 @@
if (!published) {
ignoredElements = ignoredElements.isEmpty()
? Collections.<String, List<String>>emptyMap()
- : new LinkedHashMap<>(ignoredElements);
+ : new LinkedHashMap<String, List<String>>(ignoredElements);
published = true;
}
}
@@ -348,7 +351,7 @@
*/
public String toString(final Locale locale) {
final StringBuilder buffer = new StringBuilder(250);
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final Messages resources = Messages.getResources(locale);
buffer.append(resources.getString(isParsing ? Messages.Keys.IncompleteParsing_1
: Messages.Keys.NonConformFormatting_1, root));
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java
index 9bd64a6..560c793 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java
@@ -146,7 +146,7 @@
* by their unmodifiable variant. The keys are assumed already immutable.
*/
if (object instanceof Map<?,?>) {
- final Map<Object,Object> map = new LinkedHashMap<>((Map<?,?>) object);
+ final Map<Object,Object> map = new LinkedHashMap<Object,Object>((Map<?,?>) object);
for (final Iterator<Map.Entry<Object,Object>> it=map.entrySet().iterator(); it.hasNext();) {
final Map.Entry<Object,Object> entry = it.next();
entry.setValue(clone(entry.getValue()));
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java
index fa5934a..a46523e 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java
@@ -70,7 +70,7 @@
// PropertyAccessor.information(int) never return null if the index is valid.
throw new NoSuchElementException();
}
- return new SimpleImmutableEntry<>(accessor.name(index++, keyPolicy), value);
+ return new SimpleImmutableEntry<String,ExtendedElementInformation>(accessor.name(index++, keyPolicy), value);
}
};
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
index 5011933..3656b1f 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
@@ -208,7 +208,7 @@
ensureNonNull("dependencies", dependencies);
this.citation = citation;
this.interfacePackage = interfacePackage.getName() + '.';
- this.accessors = new ConcurrentHashMap<>(); // Also defined in readObject(…)
+ this.accessors = new ConcurrentHashMap<Class<?>,Object>(); // Also defined in readObject(…)
if (dependencies.length == 0) {
this.dependencies = null;
} else {
@@ -230,7 +230,7 @@
MetadataStandard(final String citation, final String interfacePackage, final MetadataStandard[] dependencies) {
this.citation = new SimpleCitation(citation);
this.interfacePackage = interfacePackage;
- this.accessors = new ConcurrentHashMap<>();
+ this.accessors = new ConcurrentHashMap<Class<?>,Object>();
this.dependencies = dependencies; // No clone, since this constructor is for internal use only.
}
@@ -445,7 +445,7 @@
* Gets every interfaces from the supplied package in declaration order,
* including the ones declared in the super-class.
*/
- final Set<Class<?>> interfaces = new LinkedHashSet<>();
+ final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
for (Class<?> t=type; t!=null; t=t.getSuperclass()) {
getInterfaces(t, interfaces);
}
@@ -971,12 +971,13 @@
* Assigns a {@link ConcurrentMap} instance to the given field.
* Used on deserialization only.
*/
+ @SuppressWarnings("rawtypes")
final void setMapForField(final Class<?> classe, final String name) {
try {
final Field field = classe.getDeclaredField(name);
field.setAccessible(true);
- field.set(this, new ConcurrentHashMap<>());
- } catch (ReflectiveOperationException e) {
+ field.set(this, new ConcurrentHashMap());
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new AssertionError(e); // Should never happen (tested by MetadataStandardTest).
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
index 1d099b5..628d16b 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
@@ -287,7 +287,7 @@
if (target != null) {
target.clear();
} else {
- target = new CheckedArrayList<>(elementType, source.size());
+ target = new CheckedArrayList<E>(elementType, source.size());
}
target.addAll(source);
}
@@ -334,7 +334,7 @@
if (target != null) {
target.clear();
} else {
- target = new CheckedHashSet<>(elementType, source.size());
+ target = new CheckedHashSet<E>(elementType, source.size());
}
target.addAll(source);
}
@@ -401,7 +401,7 @@
if (useSet(elementType)) {
target = createSet(elementType, capacity);
} else {
- target = new CheckedArrayList<>(elementType, capacity);
+ target = new CheckedArrayList<E>(elementType, capacity);
}
}
target.addAll(source);
@@ -425,7 +425,7 @@
if (isNullOrEmpty(source)) {
return null;
}
- final List<E> target = new CheckedArrayList<>(elementType, source.size());
+ final List<E> target = new CheckedArrayList<E>(elementType, source.size());
target.addAll(source);
return target;
}
@@ -445,7 +445,7 @@
if (isNullOrEmpty(source)) {
return null;
}
- final Set<E> target = new CheckedHashSet<>(elementType, source.size());
+ final Set<E> target = new CheckedHashSet<E>(elementType, source.size());
target.addAll(source);
return target;
}
@@ -473,7 +473,7 @@
if (useSet(elementType)) {
target = createSet(elementType, capacity);
} else {
- target = new CheckedArrayList<>(elementType, capacity);
+ target = new CheckedArrayList<E>(elementType, capacity);
}
target.addAll(source);
return target;
@@ -500,7 +500,7 @@
if (useSet(elementType)) {
collection = createSet(elementType, INITIAL_CAPACITY);
} else {
- collection = new CheckedArrayList<>(elementType, 1);
+ collection = new CheckedArrayList<E>(elementType, 1);
}
collection.add(value);
return collection;
@@ -541,7 +541,7 @@
* initially empty lists, but as of JDK8 this lazy instantiation works only for list having
* the default capacity.
*/
- return new CheckedArrayList<>(elementType);
+ return new CheckedArrayList<E>(elementType);
}
return Collections.emptyList();
}
@@ -603,7 +603,7 @@
} else {
if (isModifiable) {
// Do not specify an initial capacity for the reason explained in nonNullList(…).
- return new CheckedArrayList<>(elementType);
+ return new CheckedArrayList<E>(elementType);
} else {
return Collections.emptyList();
}
@@ -622,7 +622,7 @@
if (CodeList.class.isAssignableFrom(elementType) && Modifier.isFinal(elementType.getModifiers())) {
return new CodeListSet(elementType);
}
- return new CheckedHashSet<>(elementType, capacity);
+ return new CheckedHashSet<E>(elementType, capacity);
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
index 9069ca9..3d5992b 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
@@ -74,7 +74,7 @@
// PropertyAccessor.name(int) never return null if the index is valid.
throw new NoSuchElementException();
}
- return new SimpleImmutableEntry<>(accessor.name(index++, keyPolicy), value);
+ return new SimpleImmutableEntry<String,String>(accessor.name(index++, keyPolicy), value);
}
};
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/ObjectPair.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/ObjectPair.java
index da2ac09..f5af5ee 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/ObjectPair.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/ObjectPair.java
@@ -39,7 +39,7 @@
*/
static final ThreadLocal<Set<ObjectPair>> CURRENT = new ThreadLocal<Set<ObjectPair>>() {
@Override protected Set<ObjectPair> initialValue() {
- return new HashSet<>();
+ return new HashSet<ObjectPair>();
}
};
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
index ab9645e..bc417d3 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
@@ -264,7 +264,7 @@
/*
* Compute all information derived from getters: setters, property names, value types.
*/
- mapping = new HashMap<>(hashMapCapacity(allCount));
+ mapping = new HashMap<String,Integer>(hashMapCapacity(allCount));
names = new String[allCount];
elementTypes = new Class<?>[allCount];
Method[] setters = null;
@@ -407,7 +407,7 @@
* Indices map is used for choosing what to do in case of name collision.
*/
Method[] getters = (MetadataStandard.IMPLEMENTATION_CAN_ALTER_API ? implementation : type).getMethods();
- final Map<String,Integer> indices = new HashMap<>(hashMapCapacity(getters.length));
+ final Map<String,Integer> indices = new HashMap<String,Integer>(hashMapCapacity(getters.length));
boolean hasExtraGetter = false;
int count = 0;
for (Method candidate : getters) {
@@ -650,7 +650,7 @@
// implements the interface where the getter come from.
throw new AssertionError(error);
}
- information = new PropertyInformation<>(standard, name, getter, elementType, range);
+ information = new PropertyInformation(standard, name, getter, elementType, range);
informations[index] = information;
}
return information;
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
index 738e7d4..d0229e6 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
@@ -95,7 +95,7 @@
*/
PropertyComparator(Class<?> implementation) {
this.implementation = implementation;
- order = new HashMap<>();
+ order = new HashMap<Object,Integer>();
do {
final XmlType xml = implementation.getAnnotation(XmlType.class);
if (xml != null) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
index 5bb3746..b160d01 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
@@ -45,7 +45,7 @@
* If the final operation requested by the user is {@code prune()}, then this map will contain a mix of
* {@code false} and {@code true} values since the operation will unconditionally walk through the entire tree.
*/
- private static final RecursivityGuard<Boolean> MAPS = new RecursivityGuard<>();
+ private static final RecursivityGuard<Boolean> MAPS = new RecursivityGuard<Boolean>();
/**
* For internal usage only.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/RecursivityGuard.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/RecursivityGuard.java
index 09ffe3d..90318ec 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/RecursivityGuard.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/RecursivityGuard.java
@@ -50,7 +50,7 @@
* The recursivity guard to use during {@code hashCode()} computations.
* The values have no meaning for this map; only the keys matter.
*/
- static final RecursivityGuard<Object> HASH_CODES = new RecursivityGuard<>();
+ static final RecursivityGuard<Object> HASH_CODES = new RecursivityGuard<Object>();
/**
* Creates a new thread-local map.
@@ -63,6 +63,6 @@
*/
@Override
protected Map<Object,V> initialValue() {
- return new IdentityHashMap<>();
+ return new IdentityHashMap<Object,V>();
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
index 60072ef..94441f6 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
@@ -83,7 +83,7 @@
super(citation, interfacePackage, dependencies);
this.implementationPackage = implementationPackage;
this.acronyms = acronyms;
- this.implementations = new IdentityHashMap<>();
+ this.implementations = new IdentityHashMap<Class<?>,Class<?>>();
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
index 4d9a32f..2aa5d41 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
@@ -448,13 +448,13 @@
it.next(); // Inefficient way to move at the desired index, but hopefully rare.
}
return it.next();
- } catch (NullPointerException | IndexOutOfBoundsException | NoSuchElementException e) {
+ } catch (RuntimeException e) { // (NullPointerException | IndexOutOfBoundsException | NoSuchElementException) on JDK7.
/*
* May happen if the collection for this metadata property changed after the iteration
* in the TreeNodeChildren. Users should not keep TreeNode references instances for a
* long time, but instead iterate again over TreeNodeChildren when needed.
*/
- throw new ConcurrentModificationException(e);
+ throw (ConcurrentModificationException) new ConcurrentModificationException().initCause(e);
}
}
@@ -489,7 +489,7 @@
((List) values).set(indexInList, value);
} catch (IndexOutOfBoundsException e) {
// Same rational than in the getUserObject() method.
- throw new ConcurrentModificationException(e);
+ throw (ConcurrentModificationException) new ConcurrentModificationException().initCause(e);
}
}
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
index f306a70..46e1db1 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
@@ -26,6 +26,9 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Debug;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* The collection of children to be returned by {@link TreeNode#getChildren()}.
@@ -398,7 +401,7 @@
if (nextValue != null) {
subIterator = ((Iterable<?>) nextValue).iterator();
} else {
- subIterator = Collections.emptyIterator();
+ subIterator = Collections.emptySet().iterator();
// Null collections are illegal (it shall be empty collections instead),
// but we try to keep the iterator robut to ill-formed metadata, because
// we want AbstractMetadata.toString() to work so we can spot problems.
@@ -532,7 +535,7 @@
@Debug
@Override
public String toString() {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(512);
parent.toString(buffer);
buffer.append(lineSeparator);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
index 577fc17..7554211 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
@@ -135,7 +135,7 @@
synchronized (TreeTableView.class) {
if (format == null) {
final TreeTableFormat f = new TreeTableFormat(
- Locale.getDefault(Locale.Category.FORMAT), TimeZone.getDefault());
+ Locale.getDefault(), TimeZone.getDefault());
f.setColumns(TableColumn.NAME, TableColumn.VALUE);
format = f;
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
index 159ee6f..f40979c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
@@ -858,7 +858,7 @@
if (newValue == null) {
return;
}
- newValues = new ArrayList<>(1);
+ newValues = new ArrayList<CitationDate>(1);
} else {
final Iterator<CitationDate> it = newValues.iterator();
while (it.hasNext()) {
@@ -982,7 +982,7 @@
checkWritePermission();
final InternationalString i18n = (newValue != null) ? new SimpleInternationalString(newValue) : null;
final List<Citation> newValues = (metadataStandards != null)
- ? new ArrayList<>(metadataStandards)
+ ? new ArrayList<Citation>(metadataStandards)
: new ArrayList<Citation>(1);
DefaultCitation citation = newValues.isEmpty() ? null : DefaultCitation.castOrCopy(newValues.get(0));
if (citation == null) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
index 1d73e7d..dfdc26c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
@@ -41,7 +41,7 @@
import static org.apache.sis.util.collection.Containers.property;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
index ce64be6..8565578 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
@@ -182,7 +182,7 @@
*
* @since 0.4
*/
- public static final IdentifierSpace<Integer> EPSG = new CitationConstant.Authority<>(Constants.EPSG);
+ public static final IdentifierSpace<Integer> EPSG = new CitationConstant.Authority<Integer>(Constants.EPSG);
/**
* The authority for identifiers of objects defined by the
@@ -266,7 +266,7 @@
* @see #EPSG
* @see #ESRI
*/
- public static final IdentifierSpace<String> OGC = new CitationConstant.Authority<>(Constants.OGC);
+ public static final IdentifierSpace<String> OGC = new CitationConstant.Authority<String>(Constants.OGC);
/**
* The authority for identifiers of objects defined by <a href="http://www.esri.com">ESRI</a>.
@@ -301,7 +301,7 @@
* @see #OGC
* @see #EPSG
*/
- public static final IdentifierSpace<String> ESRI = new CitationConstant.Authority<>("ESRI");
+ public static final IdentifierSpace<String> ESRI = new CitationConstant.Authority<String>("ESRI");
/**
* The authority for identifiers of objects defined by the
@@ -333,7 +333,7 @@
*
* @since 0.4
*/
- public static final IdentifierSpace<String> NETCDF = new CitationConstant.Authority<>("NetCDF");
+ public static final IdentifierSpace<String> NETCDF = new CitationConstant.Authority<String>("NetCDF");
/**
* The authority for identifiers of objects defined by the
@@ -348,7 +348,7 @@
*
* @since 0.4
*/
- public static final IdentifierSpace<Integer> GEOTIFF = new CitationConstant.Authority<>("GeoTIFF");
+ public static final IdentifierSpace<Integer> GEOTIFF = new CitationConstant.Authority<Integer>("GeoTIFF");
/**
* The authority for identifiers of objects defined by the <a href="http://trac.osgeo.org/proj/">Proj.4</a> project.
@@ -361,7 +361,7 @@
*
* @since 0.4
*/
- public static final IdentifierSpace<String> PROJ4 = new CitationConstant.Authority<>("Proj4");
+ public static final IdentifierSpace<String> PROJ4 = new CitationConstant.Authority<String>("Proj4");
/**
* The authority for identifiers of objects defined by MapInfo.
@@ -374,7 +374,7 @@
*
* @since 0.6
*/
- public static final IdentifierSpace<Integer> MAP_INFO = new CitationConstant.Authority<>("MapInfo");
+ public static final IdentifierSpace<Integer> MAP_INFO = new CitationConstant.Authority<Integer>("MapInfo");
/**
* The <a href="http://www.iho.int/iho_pubs/standard/S-57Ed3.1/31Main.pdf">IHO transfer standard
@@ -388,7 +388,7 @@
*
* @since 0.6
*/
- public static final IdentifierSpace<Integer> S57 = new CitationConstant.Authority<>("S57");
+ public static final IdentifierSpace<Integer> S57 = new CitationConstant.Authority<Integer>("S57");
/**
* The <cite>International Standard Book Number</cite> (ISBN) defined by ISO-2108.
@@ -403,7 +403,7 @@
*
* @see DefaultCitation#getISBN()
*/
- public static final IdentifierSpace<String> ISBN = new NonMarshalledAuthority<>("ISBN", NonMarshalledAuthority.ISBN);
+ public static final IdentifierSpace<String> ISBN = new NonMarshalledAuthority<String>("ISBN", NonMarshalledAuthority.ISBN);
/**
* The <cite>International Standard Serial Number</cite> (ISSN) defined by ISO-3297.
@@ -418,7 +418,7 @@
*
* @see DefaultCitation#getISSN()
*/
- public static final IdentifierSpace<String> ISSN = new NonMarshalledAuthority<>("ISSN", NonMarshalledAuthority.ISSN);
+ public static final IdentifierSpace<String> ISSN = new NonMarshalledAuthority<String>("ISSN", NonMarshalledAuthority.ISSN);
/**
* The codespace of objects that are specific to the <a href="http://sis.apache.org">Apache SIS</a> project.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
index ce3f9f4..72f604a 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
@@ -254,7 +254,7 @@
if (newValue instanceof DefaultTelephone) {
newValues = ((DefaultTelephone) newValue).getOwner();
} else {
- newValues = new ArrayList<>(4);
+ newValues = new ArrayList<Telephone>(4);
for (String number : newValue.getVoices()) {
newValues.add(new DefaultTelephone(number, TelephoneType.VOICE));
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
index 6e41609..7b7108c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
@@ -240,7 +240,7 @@
final Collection<Telephone> getOwner() {
if (owner == null) {
if (isModifiable()) {
- owner = new ArrayList<>(4);
+ owner = new ArrayList<Telephone>(4);
owner.add(this);
} else {
owner = Collections.<Telephone>singletonList(this);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
index 0f69bd9..917faa8 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
@@ -36,7 +36,7 @@
import static java.lang.Double.doubleToLongBits;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
index f848b9f..d5b1697 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
@@ -289,7 +289,7 @@
if (min == null && max == null) {
return null;
}
- return new Range<>(Date.class, min, true, max, true);
+ return new Range<Date>(Date.class, min, true, max, true);
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
index d45c791..4bbff1e 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
@@ -189,7 +189,7 @@
* If there is more than one value, replace only the first one and keep all other ones unchanged.
* The intend is to be consistent with the getter method, which returns the first element.
*/
- final ArrayList<Identifier> identifiers = new ArrayList<>(name.getIdentifiers());
+ final ArrayList<Identifier> identifiers = new ArrayList<Identifier>(name.getIdentifiers());
if (identifiers.isEmpty()) {
identifiers.add(newValue);
} else {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
index c31317c..9142f10 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
@@ -357,7 +357,7 @@
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Collection<Identifier> getIdentifiers() {
if (identifiers == null) {
- identifiers = new CheckedArrayList<>(Identifier.class);
+ identifiers = new CheckedArrayList<Identifier>(Identifier.class);
}
return identifiers;
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/OperationName.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/OperationName.java
index a36035f..eec4366 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/OperationName.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/OperationName.java
@@ -87,7 +87,7 @@
* were identified only by a name in a {@code <srv:operationName>} element.</p>
*/
static void resolve(final Collection<OperationMetadata> containsOperations, final Collection<CoupledResource> coupledResources) {
- final Map<String,OperationMetadata> byName = new HashMap<>();
+ final Map<String,OperationMetadata> byName = new HashMap<String,OperationMetadata>();
for (final OperationMetadata operation : containsOperations) {
add(byName, operation.getOperationName(), operation);
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/OtherLocalesTest.java b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/OtherLocalesTest.java
index 720cea1..b87a306 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/OtherLocalesTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/OtherLocalesTest.java
@@ -42,7 +42,7 @@
*/
@Test
public void testFilter() {
- final Collection<Locale> languages = new LinkedHashSet<>();
+ final Collection<Locale> languages = new LinkedHashSet<Locale>();
final Collection<Locale> otherLocales = OtherLocales.filter(languages);
assertEquals("size", 0, otherLocales.size());
/*
@@ -119,7 +119,7 @@
assertSame("Shall set value in-place.", locales, OtherLocales.setFirst(locales, GERMAN));
assertArrayEquals(new Locale[] {GERMAN, JAPANESE, FRENCH}, locales.toArray());
- locales = new LinkedHashSet<>(Arrays.asList(ENGLISH, JAPANESE, FRENCH));
+ locales = new LinkedHashSet<Locale>(Arrays.asList(ENGLISH, JAPANESE, FRENCH));
locales = OtherLocales.setFirst(locales, ITALIAN);
assertArrayEquals(new Locale[] {ITALIAN, JAPANESE, FRENCH}, locales.toArray());
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
index c8d2278..0d8fd03 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
@@ -44,7 +44,7 @@
* @throws ReflectiveOperationException should never happen.
*/
@Test
- public void verifyConstantValues() throws ReflectiveOperationException {
+ public void verifyConstantValues() throws Exception {
for (final Field field : WKTKeywords.class.getDeclaredFields()) {
final String name = field.getName();
final int modifiers = field.getModifiers();
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
index f22b5ea..6b25518 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
@@ -24,8 +24,8 @@
import static org.junit.Assume.*;
// Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
/**
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java b/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
index dd9bc30..4c15c07 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
@@ -296,7 +296,7 @@
@Test
@DependsOnMethod({"testPullString", "testPullElement"})
public void testFragments() throws ParseException {
- sharedValues = new HashMap<>();
+ sharedValues = new HashMap<Object,Object>();
Element frag = parse("Frag[“A”,“B”,“A”]");
parser.fragments.put("MyFrag", frag);
try {
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
index 0202eef..f01d834 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
@@ -68,7 +68,7 @@
final Map<String,ExtendedElementInformation> descriptions = MetadataStandard.ISO_19115.asInformationMap(
EnvironmentalRecord.class, KeyNamePolicy.UML_IDENTIFIER);
- final Set<String> expected = new HashSet<>(Arrays.asList(
+ final Set<String> expected = new HashSet<String>(Arrays.asList(
"averageAirTemperature", "maxAltitude", "maxRelativeHumidity", "meteorologicalConditions"
));
assertEquals(expected, descriptions.keySet());
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
index db61aec..47de96f 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
@@ -266,7 +266,7 @@
final Map<String,Object> map = std.asValueMap(instance,
KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
assertFalse(map.isEmpty()); // Actually 'testValueMap()' job, but verified for safety.
- assertEquals("hashCode()", new HashSet<>(map.values()).hashCode() + Citation.class.hashCode(),
+ assertEquals("hashCode()", new HashSet<Object>(map.values()).hashCode() + Citation.class.hashCode(),
std.hashCode(instance));
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
index 59ace57..cb2b58f 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
@@ -134,7 +134,7 @@
}
final ControlledVocabulary[] codes = (ControlledVocabulary[]) type.getMethod("values", (Class[]) null).invoke(null, (Object[]) null);
return codes[random.nextInt(codes.length)];
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
fail(e.toString());
}
if (Locale.class.isAssignableFrom(type)) {
@@ -149,7 +149,7 @@
final Class<?> impl = getImplementation(type);
if (impl != null) try {
return impl.getConstructor((Class<?>[]) null).newInstance((Object[]) null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
fail(e.toString());
}
}
@@ -208,7 +208,7 @@
final Object instance;
try {
instance = accessor.implementation.getConstructor((Class<?>[]) null).newInstance((Object[]) null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
fail(e.toString());
return;
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
index e965263..85a9675 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
@@ -52,21 +52,21 @@
final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
assertArrayEquals(new Object[] {
- new SimpleEntry<>("title", "title"),
- new SimpleEntry<>("alternateTitle", "alternateTitles"),
- new SimpleEntry<>("date", "dates"),
- new SimpleEntry<>("edition", "edition"),
- new SimpleEntry<>("editionDate", "editionDate"),
- new SimpleEntry<>("identifier", "identifiers"),
- new SimpleEntry<>("citedResponsibleParty", "citedResponsibleParties"),
- new SimpleEntry<>("presentationForm", "presentationForms"),
- new SimpleEntry<>("series", "series"),
- new SimpleEntry<>("otherCitationDetails", "otherCitationDetails"),
-// new SimpleEntry<>("collectiveTitle", "collectiveTitle"), -- deprecated as of ISO 19115:2014
- new SimpleEntry<>("ISBN", "ISBN"),
- new SimpleEntry<>("ISSN", "ISSN"),
- new SimpleEntry<>("graphic", "graphics"),
- new SimpleEntry<>("onlineResource", "onlineResources")
+ new SimpleEntry<String,String>("title", "title"),
+ new SimpleEntry<String,String>("alternateTitle", "alternateTitles"),
+ new SimpleEntry<String,String>("date", "dates"),
+ new SimpleEntry<String,String>("edition", "edition"),
+ new SimpleEntry<String,String>("editionDate", "editionDate"),
+ new SimpleEntry<String,String>("identifier", "identifiers"),
+ new SimpleEntry<String,String>("citedResponsibleParty", "citedResponsibleParties"),
+ new SimpleEntry<String,String>("presentationForm", "presentationForms"),
+ new SimpleEntry<String,String>("series", "series"),
+ new SimpleEntry<String,String>("otherCitationDetails", "otherCitationDetails"),
+// new SimpleEntry<String,String>("collectiveTitle", "collectiveTitle"), -- deprecated as of ISO 19115:2014
+ new SimpleEntry<String,String>("ISBN", "ISBN"),
+ new SimpleEntry<String,String>("ISSN", "ISSN"),
+ new SimpleEntry<String,String>("graphic", "graphics"),
+ new SimpleEntry<String,String>("onlineResource", "onlineResources")
}, map.entrySet().toArray());
assertEquals("alternateTitles", map.get("alternateTitle"));
@@ -78,7 +78,7 @@
*/
@Test
public void testSentences() {
- final Map<String,String> map, expected = new HashMap<>();
+ final Map<String,String> map, expected = new HashMap<String,String>();
map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, JAVABEANS_PROPERTY, SENTENCE);
assertNull(expected.put("averageAirTemperature", "Average air temperature"));
assertNull(expected.put("maxAltitude", "Max altitude"));
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
index 1c7a457..bc7994d 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
@@ -553,7 +553,7 @@
final List<InternationalString> newTitles = Arrays.<InternationalString>asList(
new SimpleInternationalString("New title 1"),
new SimpleInternationalString("New title 2"));
- final List<InternationalString> merged = new ArrayList<>(oldTitles);
+ final List<InternationalString> merged = new ArrayList<InternationalString>(oldTitles);
assertTrue(merged.addAll(newTitles));
// Set the title.
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyInformationTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyInformationTest.java
index 324eaad..a983638 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyInformationTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyInformationTest.java
@@ -58,7 +58,7 @@
private static <T> PropertyInformation<T> create(final Class<T> elementType, final String method,
final String property) throws NoSuchMethodException
{
- return new PropertyInformation<>(HardCodedCitations.ISO_19115, property,
+ return new PropertyInformation<T>(HardCodedCitations.ISO_19115, property,
Citation.class.getMethod(method), elementType, null);
}
@@ -140,7 +140,7 @@
@Test
@SuppressWarnings("UnnecessaryBoxing")
public void testGetDomainValue() throws NoSuchMethodException {
- final ExtendedElementInformation information = new PropertyInformation<>(HardCodedCitations.ISO_19115,
+ final ExtendedElementInformation information = new PropertyInformation<Double>(HardCodedCitations.ISO_19115,
"maxRelativeHumidity", EnvironmentalRecord.class.getMethod("getMaxRelativeHumidity"), Double.class,
DefaultEnvironmentalRecord.class.getMethod("getMaxRelativeHumidity").getAnnotation(ValueRange.class));
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
index 4f5357a..2d6b1a1 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
@@ -371,7 +371,7 @@
* @param children The collection from which to remove elements.
*/
private static void testRemove(final Random random, final TreeNodeChildren children) {
- final List<TreeTable.Node> reference = new ArrayList<>(children);
+ final List<TreeTable.Node> reference = new ArrayList<TreeTable.Node>(children);
assertFalse("The collection shall not be initially empty.", reference.isEmpty());
do {
final Iterator<TreeTable.Node> rit = reference.iterator(); // The reference iterator.
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
index f0d27f3..8c20cea 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
@@ -96,13 +96,19 @@
final Object original = create(ValueExistencePolicy.NON_EMPTY);
final Object deserialized;
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
+ final ObjectOutputStream out = new ObjectOutputStream(buffer);
+ try {
out.writeObject(original);
+ } finally {
+ out.close();
}
// Now reads the object we just serialized.
final byte[] data = buffer.toByteArray();
- try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
+ try {
deserialized = in.readObject();
+ } finally {
+ in.close();
}
assertMultilinesEquals(EXPECTED, formatNameAndValue((TreeTableView) deserialized));
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
index b917300..db1d971 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
@@ -64,21 +64,21 @@
final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
assertArrayEquals(new Object[] {
- new SimpleEntry<>("title", InternationalString.class),
- new SimpleEntry<>("alternateTitle", InternationalString.class),
- new SimpleEntry<>("date", CitationDate.class),
- new SimpleEntry<>("edition", InternationalString.class),
- new SimpleEntry<>("editionDate", Date.class),
- new SimpleEntry<>("identifier", Identifier.class),
- new SimpleEntry<>("citedResponsibleParty", Responsibility.class),
- new SimpleEntry<>("presentationForm", PresentationForm.class),
- new SimpleEntry<>("series", Series.class),
- new SimpleEntry<>("otherCitationDetails", InternationalString.class),
-// new SimpleEntry<>("collectiveTitle", InternationalString.class), -- deprecated as of ISO 19115:2014
- new SimpleEntry<>("ISBN", String.class),
- new SimpleEntry<>("ISSN", String.class),
- new SimpleEntry<>("graphic", BrowseGraphic.class),
- new SimpleEntry<>("onlineResource", OnlineResource.class)
+ new SimpleEntry<String,Class<?>>("title", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("alternateTitle", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("date", CitationDate.class),
+ new SimpleEntry<String,Class<?>>("edition", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("editionDate", Date.class),
+ new SimpleEntry<String,Class<?>>("identifier", Identifier.class),
+ new SimpleEntry<String,Class<?>>("citedResponsibleParty", Responsibility.class),
+ new SimpleEntry<String,Class<?>>("presentationForm", PresentationForm.class),
+ new SimpleEntry<String,Class<?>>("series", Series.class),
+ new SimpleEntry<String,Class<?>>("otherCitationDetails", InternationalString.class),
+// new SimpleEntry<String,Class<?>>("collectiveTitle", InternationalString.class), -- deprecated as of ISO 19115:2014
+ new SimpleEntry<String,Class<?>>("ISBN", String.class),
+ new SimpleEntry<String,Class<?>>("ISSN", String.class),
+ new SimpleEntry<String,Class<?>>("graphic", BrowseGraphic.class),
+ new SimpleEntry<String,Class<?>>("onlineResource", OnlineResource.class)
}, map.entrySet().toArray());
assertEquals(InternationalString.class, map.get("alternateTitle"));
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
index d7169d1..22131d2 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
@@ -141,10 +141,10 @@
final Map<String,Object> map = createCitation();
assertEquals(1, citation.getIdentifiers().size());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("ISBN", "9782505004509")
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509")
}, map.entrySet().toArray());
}
@@ -165,16 +165,16 @@
assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("alternateTitles", emptyList()),
- new SimpleEntry<>("dates", emptyList()),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", emptySet()),
- new SimpleEntry<>("otherCitationDetails", emptyList()),
- new SimpleEntry<>("ISBN", "9782505004509"),
- new SimpleEntry<>("graphics", emptyList()),
- new SimpleEntry<>("onlineResources", emptyList())
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("alternateTitles", emptyList()),
+ new SimpleEntry<String,Object>("dates", emptyList()),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", emptySet()),
+ new SimpleEntry<String,Object>("otherCitationDetails", emptyList()),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509"),
+ new SimpleEntry<String,Object>("graphics", emptyList()),
+ new SimpleEntry<String,Object>("onlineResources", emptyList())
}, all.entrySet().toArray());
}
@@ -195,17 +195,17 @@
assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("alternateTitles", emptyList()),
- new SimpleEntry<>("dates", emptyList()),
- new SimpleEntry<>("edition", NilReason.UNKNOWN.createNilObject(InternationalString.class)),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", emptySet()),
- new SimpleEntry<>("otherCitationDetails", emptyList()),
- new SimpleEntry<>("ISBN", "9782505004509"),
- new SimpleEntry<>("graphics", emptyList()),
- new SimpleEntry<>("onlineResources", emptyList())
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("alternateTitles", emptyList()),
+ new SimpleEntry<String,Object>("dates", emptyList()),
+ new SimpleEntry<String,Object>("edition", NilReason.UNKNOWN.createNilObject(InternationalString.class)),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", emptySet()),
+ new SimpleEntry<String,Object>("otherCitationDetails", emptyList()),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509"),
+ new SimpleEntry<String,Object>("graphics", emptyList()),
+ new SimpleEntry<String,Object>("onlineResources", emptyList())
}, all.entrySet().toArray());
}
@@ -224,21 +224,21 @@
assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("alternateTitles", emptyList()),
- new SimpleEntry<>("dates", emptyList()),
- new SimpleEntry<>("edition", NilReason.UNKNOWN.createNilObject(InternationalString.class)),
- new SimpleEntry<>("editionDate", null),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", emptySet()),
- new SimpleEntry<>("series", null),
- new SimpleEntry<>("otherCitationDetails", emptyList()),
-// new SimpleEntry<>("collectiveTitle", null), -- deprecated as of ISO 19115:2014.
- new SimpleEntry<>("ISBN", "9782505004509"),
- new SimpleEntry<>("ISSN", null),
- new SimpleEntry<>("graphics", emptyList()),
- new SimpleEntry<>("onlineResources", emptyList())
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("alternateTitles", emptyList()),
+ new SimpleEntry<String,Object>("dates", emptyList()),
+ new SimpleEntry<String,Object>("edition", NilReason.UNKNOWN.createNilObject(InternationalString.class)),
+ new SimpleEntry<String,Object>("editionDate", null),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", emptySet()),
+ new SimpleEntry<String,Object>("series", null),
+ new SimpleEntry<String,Object>("otherCitationDetails", emptyList()),
+// new SimpleEntry<String,Object>("collectiveTitle", null), -- deprecated as of ISO 19115:2014.
+ new SimpleEntry<String,Object>("ISBN", "9782505004509"),
+ new SimpleEntry<String,Object>("ISSN", null),
+ new SimpleEntry<String,Object>("graphics", emptyList()),
+ new SimpleEntry<String,Object>("onlineResources", emptyList())
}, all.entrySet().toArray());
}
@@ -263,8 +263,8 @@
assertNull("ISBN shall have been removed.", citation.getISBN());
assertTrue("ISBN shall have been removed.", citation.getIdentifiers().isEmpty());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author))
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author))
}, map.entrySet().toArray());
/*
* Add a value. Result shall be:
@@ -278,9 +278,9 @@
assertNull(map.put("presentationForm", DOCUMENT_HARDCOPY));
assertEquals(DOCUMENT_HARDCOPY, getSingleton(citation.getPresentationForms()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", singleton(DOCUMENT_HARDCOPY))
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", singleton(DOCUMENT_HARDCOPY))
}, map.entrySet().toArray());
/*
* Add back the ISBN value. Result shall be:
@@ -297,11 +297,11 @@
assertEquals("9782505004509", citation.getISBN());
assertEquals("ISBN shall appears in the identifier list.", 1, citation.getIdentifiers().size());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", singleton(DOCUMENT_HARDCOPY)),
- new SimpleEntry<>("ISBN", "9782505004509")
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", singleton(DOCUMENT_HARDCOPY)),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509")
}, map.entrySet().toArray());
}
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/APIVerifier.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/APIVerifier.java
index 2933b7b..b9559b0 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/APIVerifier.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/APIVerifier.java
@@ -36,6 +36,9 @@
import static org.junit.Assert.*;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Verifies the API changes caused by the ISO 19115:2003 to ISO 19115:2014 upgrade.
@@ -91,7 +94,7 @@
private void verifyAPI(final MetadataStandard standard, final Properties changes)
throws ClassNotFoundException, NoSuchMethodException
{
- final Set<Method> classChanges = new HashSet<>();
+ final Set<Method> classChanges = new HashSet<Method>();
for (final Map.Entry<Object,Object> entry : changes.entrySet()) {
final Class<?> implementation = standard.getImplementation(Class.forName((String) entry.getKey()));
for (final String change : (String[]) CharSequences.split((String) entry.getValue(), ' ')) {
@@ -151,21 +154,20 @@
* @param snapshotJAR Path to the JAR file of the GeoAPI interfaces that we would implement if it was released.
* @param unitsJAR Path to the JAR file containing the {@code Unit} class. This is a GeoAPI dependency.
* @param out Where to write the API differences between {@code releasedJAR} and {@code snapshotJAR}.
- * @throws ReflectiveOperationException if an error occurred while processing the JAR file content.
- * @throws IOException if an error occurred while reading the JAR files or writing to {@code out}.
+ * @throws Exception if an error occurred while processing the JAR file content.
*/
public static void listAPIChanges(final File releasedJAR, final File snapshotJAR, final File unitsJAR,
- final Appendable out) throws ReflectiveOperationException, IOException
+ final Appendable out) throws Exception
{
- final String lineSeparator = System.lineSeparator();
- final Map<String,Boolean> methodChanges = new TreeMap<>();
- final List<String> incompatibleChanges = new ArrayList<>();
+ final String lineSeparator = JDK7.lineSeparator();
+ final Map<String,Boolean> methodChanges = new TreeMap<String,Boolean>();
+ final List<String> incompatibleChanges = new ArrayList<String>();
final ClassLoader parent = APIVerifier.class.getClassLoader().getParent();
final URL dependency = unitsJAR.toURI().toURL();
- try (final JarFile newJARContent = new JarFile(snapshotJAR);
- final URLClassLoader oldAPI = new URLClassLoader(new URL[] {releasedJAR.toURI().toURL(), dependency}, parent);
- final URLClassLoader newAPI = new URLClassLoader(new URL[] {snapshotJAR.toURI().toURL(), dependency}, parent))
- {
+ final JarFile newJARContent = new JarFile(snapshotJAR);
+ final URLClassLoader oldAPI = new URLClassLoader(new URL[] {releasedJAR.toURI().toURL(), dependency}, parent);
+ final URLClassLoader newAPI = new URLClassLoader(new URL[] {snapshotJAR.toURI().toURL(), dependency}, parent);
+ try {
final Class<? extends Annotation> newUML = Class.forName("org.opengis.annotation.UML", false, newAPI).asSubclass(Annotation.class);
final Method newIdentifier = newUML.getMethod("identifier", (Class[]) null);
final Enumeration<JarEntry> entries = newJARContent.entries();
@@ -228,6 +230,8 @@
}
}
}
+ } finally {
+ newJARContent.close();
}
if (!incompatibleChanges.isEmpty()) {
out.append(lineSeparator)
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
index f27b009..60b1910 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
@@ -235,24 +235,17 @@
@Override
protected String getExpectedXmlElementName(final Class<?> enclosing, final UML uml) {
String name = super.getExpectedXmlElementName(enclosing, uml);
- switch (name) {
- case "MD_Scope": { // ISO 19115:2014
+ /*switch (name)*/ {
+ if (name.equals("MD_Scope")) { // ISO 19115:2014
name = "DQ_Scope"; // ISO 19115:2003
- break;
- }
- case "distributedComputingPlatform": {
+ } else if (name.equals("distributedComputingPlatform")) {
name = "DCP";
- break;
- }
- case "stepDateTime": {
+ } else if (name.equals("stepDateTime")) {
name = "dateTime";
- break;
- }
- case "locale": {
+ } else if (name.equals("locale")) {
if (enclosing == org.opengis.metadata.content.FeatureCatalogueDescription.class) {
name = "language";
}
- break;
}
}
return name;
@@ -287,19 +280,19 @@
@Override
protected String getExpectedXmlTypeForElement(final Class<?> type, final Class<?> impl) {
final String rootName = type.getAnnotation(UML.class).identifier();
- switch (rootName) {
+ /* switch (rootName) */ { // "String in switch" on the JDK7 branch.
// We don't know yet what is the type of this one.
- case "MD_FeatureTypeList": {
+ if (rootName.equals("MD_FeatureTypeList")) {
return null;
}
// Following prefix was changed in ISO 19115 corrigendum,
// but ISO 19139 still use the old prefix.
- case "SV_ServiceIdentification": {
+ if (rootName.equals("SV_ServiceIdentification")) {
return "MD_ServiceIdentification_Type";
}
// Following prefix was changed in ISO 19115:2014,
// but ISO 19139 still use the old prefix.
- case "MD_Scope": {
+ if (rootName.equals("MD_Scope")) {
return "DQ_Scope_Type";
}
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
index 098fc1d..a425b62 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
@@ -106,13 +106,13 @@
final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
final DataIdentification identification = new DataIdentification() {
@Override public InternationalString getAbstract() {
- Map<Locale, String> names = new HashMap<>();
+ Map<Locale, String> names = new HashMap<Locale, String>();
names.put(Locale.ENGLISH, "Description");
return factory.createInternationalString(names);
}
@Override public InternationalString getEnvironmentDescription() {
- Map<Locale, String> names = new HashMap<>();
+ Map<Locale, String> names = new HashMap<Locale, String>();
names.put(Locale.ENGLISH, "Environment");
return factory.createInternationalString(names);
}
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
index c668d53..9892ccf 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
@@ -53,7 +53,7 @@
* Returns the properties map to be used in argument to test methods.
*/
private static Map<String,Object> properties() {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
assertNull(properties.put(CODE_KEY, "This is a code"));
assertNull(properties.put(AUTHORITY_KEY, "This is an authority"));
assertNull(properties.put(VERSION_KEY, "This is a version"));
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
index 2438ae3..1373c6b 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java
@@ -19,7 +19,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Locale;
-import java.nio.charset.StandardCharsets;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.DateType;
import org.opengis.metadata.identification.KeywordType;
@@ -38,6 +37,9 @@
import static java.util.Collections.singleton;
import static org.apache.sis.test.MetadataAssert.*;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.StandardCharsets;
+
/**
* Tests {@link DefaultDataIdentification}.
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java b/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
index ad3e137..3c1c42e 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
@@ -24,6 +24,9 @@
import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Convention;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Assertion methods used by the {@code sis-metadata} module in addition of the ones inherited
@@ -128,7 +131,7 @@
WKT_FORMAT.setConvention(convention);
wkt = WKT_FORMAT.format(object);
}
- if (!wkt.matches(expected.replace("\n", System.lineSeparator()))) {
+ if (!wkt.matches(expected.replace("\n", JDK7.lineSeparator()))) {
fail("WKT does not match the expected regular expression. The WKT that we got is:\n" + wkt);
}
}
diff --git a/core/sis-referencing/pom.xml b/core/sis-referencing/pom.xml
index 23ea78a..7d5899a 100644
--- a/core/sis-referencing/pom.xml
+++ b/core/sis-referencing/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>core</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
<groupId>org.apache.sis.core</groupId>
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
index 4a27434..6861851 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
@@ -40,7 +40,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
index c038aed..7ecd707 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
@@ -49,7 +49,7 @@
import static org.apache.sis.math.MathFunctions.isPositive;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
index 8948a48..c26d515 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
@@ -42,7 +42,7 @@
import static org.apache.sis.internal.referencing.Formulas.isPoleToPole;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
index 3757d79..37b6fc1 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
@@ -31,7 +31,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
index 95bc8b7..ead2a3d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
@@ -29,7 +29,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
index 0d36a30..b018bd1 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
@@ -50,7 +50,7 @@
import static org.apache.sis.geometry.AbstractEnvelope.isNegativeUnsafe;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
index 8891a9b..8926b1c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
@@ -628,7 +628,7 @@
if (warning == null) {
warning = exception;
} else {
- warning.addSuppressed(exception);
+ // warning.addSuppressed(exception) on the JDK7 branch.
}
continue;
}
@@ -706,7 +706,7 @@
if (warning == null) {
warning = exception;
} else {
- warning.addSuppressed(exception);
+ // warning.addSuppressed(exception) on the JDK7 branch.
}
continue;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
index cb35bb2..59ab11f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
@@ -34,7 +34,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -310,7 +310,7 @@
GeneralDirectPosition e = (GeneralDirectPosition) super.clone();
field.set(e, ordinates.clone());
return e;
- } catch (ReflectiveOperationException | CloneNotSupportedException exception) {
+ } catch (Exception exception) { // (ReflectiveOperationException | CloneNotSupportedException) on JDK7
// Should not happen, since we are cloneable.
// Should not happen, since the "ordinates" field exists.
// etc...
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
index f4ca500..cce6f0e 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
@@ -1038,7 +1038,7 @@
GeneralEnvelope e = (GeneralEnvelope) super.clone();
field.set(e, ordinates.clone());
return e;
- } catch (CloneNotSupportedException | ReflectiveOperationException exception) {
+ } catch (Exception exception) { // (CloneNotSupportedException | ReflectiveOperationException) on JDK7
// Should not happen, since we are cloneable, the
// field is known to exist and we made it accessible.
throw new AssertionError(exception);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
index 1bc14ec..cf68df4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
@@ -492,8 +492,6 @@
} catch (TransformException exception) {
if (warning == null) {
warning = exception;
- } else {
- warning.addSuppressed(exception);
}
continue;
}
@@ -558,8 +556,6 @@
} catch (TransformException exception) {
if (warning == null) {
warning = exception;
- } else {
- warning.addSuppressed(exception);
}
continue;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
index 253332d..04d3223 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
@@ -258,7 +258,7 @@
* by the 'complete' descriptor. If the descriptor is a group, then this 'replacement' method will
* be invoked recursively for each parameter in the group.
*/
- final Map<String,Object> merged = new HashMap<>(expected);
+ final Map<String,Object> merged = new HashMap<String,Object>(expected);
merged.putAll(actual); // May overwrite pre-defined properties.
mergeArrays(GeneralParameterDescriptor.ALIAS_KEY, GenericName.class, provided.getAlias(), merged, complete.getName());
mergeArrays(GeneralParameterDescriptor.IDENTIFIERS_KEY, Identifier.class, provided.getIdentifiers(), merged, null);
@@ -298,7 +298,8 @@
boolean canSubstitute)
{
boolean isCompatible = true;
- final Set<GeneralParameterDescriptor> included = new HashSet<>(Containers.hashMapCapacity(provided.length));
+ final Set<GeneralParameterDescriptor> included =
+ new HashSet<GeneralParameterDescriptor>(Containers.hashMapCapacity(provided.length));
for (int i=0; i<provided.length; i++) {
final GeneralParameterDescriptor p = provided[i];
try {
@@ -369,7 +370,7 @@
final ParameterDescriptor<T> complete)
{
final Class<T> valueClass = complete.getValueClass();
- return new DefaultParameterDescriptor<>(merged,
+ return new DefaultParameterDescriptor<T>(merged,
provided.getMinimumOccurs(),
provided.getMaximumOccurs(),
// Values below this point are not provided in GML documents,
@@ -396,7 +397,7 @@
if (size == 0) {
return false;
}
- final Set<NamedIdentifier> c = new HashSet<>(Containers.hashMapCapacity(size));
+ final Set<NamedIdentifier> c = new HashSet<NamedIdentifier>(Containers.hashMapCapacity(size));
for (final T e : complete) {
c.add(toNamedIdentifier(e));
}
@@ -432,7 +433,7 @@
* 2) Replace 'provided' instances by 'complete' instances, since the later
* are sometime pre-defined instances defined as static final constants.
*/
- final Map<NamedIdentifier,T> c = new LinkedHashMap<>();
+ final Map<NamedIdentifier,T> c = new LinkedHashMap<NamedIdentifier,T>();
for (final T e : provided) c.put(toNamedIdentifier(e), e);
for (final T e : complete) c.put(toNamedIdentifier(e), e);
c.remove(toNamedIdentifier(remove));
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
index 9ff1146..994da85 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
@@ -87,6 +87,7 @@
@XmlElement(name = "ParameterValue", type = DefaultParameterValue.class),
@XmlElement(name = "ParameterValueGroup", type = DefaultParameterValueGroup.class)
})
+ @SuppressWarnings({"rawtypes", "unchecked"})
public GeneralParameterValue getElement() {
final GeneralParameterValue metadata = this.metadata;
if (metadata instanceof DefaultParameterValue<?>) {
@@ -96,7 +97,7 @@
return (DefaultParameterValueGroup) metadata;
}
if (metadata instanceof ParameterValue) {
- return new DefaultParameterValue<>((ParameterValue<?>) metadata);
+ return new DefaultParameterValue((ParameterValue<?>) metadata);
}
if (metadata instanceof ParameterValueGroup) {
return new DefaultParameterValueGroup((ParameterValueGroup) metadata);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
index 75e7020..3e75717 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
@@ -225,7 +225,8 @@
if (replacement != null) {
if (p instanceof ParameterValue<?>) {
final ParameterValue<?> source = (ParameterValue<?>) p;
- final ParameterValue<?> target = new DefaultParameterValue<>((ParameterDescriptor<?>) replacement);
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ final ParameterValue<?> target = new DefaultParameterValue((ParameterDescriptor<?>) replacement);
final Object value = source.getValue();
final Unit<?> unit = source.getUnit();
if (unit == null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
index 6c0457f..7384812 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
@@ -145,7 +145,7 @@
return fromValues;
}
final Map<String,GeneralParameterDescriptor> union =
- new LinkedHashMap<>(Containers.hashMapCapacity(descriptors.size()));
+ new LinkedHashMap<String,GeneralParameterDescriptor>(Containers.hashMapCapacity(descriptors.size()));
/*
* Collect the descriptors declared explicitely in the ParameterDescriptorGroup. We should never have
* two descriptors of the same name since the DefaultParameterDescriptorGroup constructor checked for
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/MergedProperties.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/MergedProperties.java
index 791b51a..35215b7 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/MergedProperties.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/MergedProperties.java
@@ -69,11 +69,11 @@
@Override
protected EntryIterator<String,Object> entryIterator() {
if (merge == null) {
- merge = new HashMap<>(defaultProperties);
+ merge = new HashMap<String,Object>(defaultProperties);
merge.putAll(properties);
merge.remove(null);
}
- return new IteratorAdapter<>(merge); // That iterator will skip null values.
+ return new IteratorAdapter<String,Object>(merge); // That iterator will skip null values.
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
index ea01ab4..b95cc14 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
@@ -290,7 +290,7 @@
}
name = CharSequences.trimWhitespaces(name, 0, i).toString();
if (!name.isEmpty()) {
- final Map<String,Object> copy = new HashMap<>(properties);
+ final Map<String,Object> copy = new HashMap<String,Object>(properties);
copy.put(IdentifiedObject.NAME_KEY, name);
return copy;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
index 2e58f42..09e40f5 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
@@ -649,7 +649,7 @@
}
properties = Collections.emptyMap();
}
- final HashMap<String,Object> p = new HashMap<>(properties);
+ final HashMap<String,Object> p = new HashMap<String,Object>(properties);
JDK8.putIfAbsent(p, CRS_FACTORY, crsFactory);
JDK8.putIfAbsent(p, CS_FACTORY, csFactory);
properties = p;
@@ -694,12 +694,12 @@
*/
@Override
public String getInformation(final String key, final Locale locale) {
- switch (key) {
+ /*switch (key)*/ {
/*
* Get the version of the EPSG database and the version of the database software.
* This operation can be relatively costly as it may open a JDBC connection.
*/
- case Constants.EPSG: {
+ if (key.equals(Constants.EPSG)) {
final Citation authority;
try {
authority = CRS.getAuthorityFactory(Constants.EPSG).getAuthority();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
index ef21364..6f5e24c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
@@ -201,6 +201,7 @@
* @param parameter The parameter to append to the WKT, or {@code null} if none.
* @param formatter The formatter where to append the parameter.
*/
+ @SuppressWarnings({"unchecked","rawtypes"}) // Not needed on JDK7 branch.
public static void append(GeneralParameterValue parameter, final Formatter formatter) {
if (parameter instanceof ParameterValueGroup) {
boolean first = true;
@@ -214,7 +215,7 @@
}
if (parameter instanceof ParameterValue<?>) {
if (!(parameter instanceof FormattableObject)) {
- parameter = new DefaultParameterValue<>((ParameterValue<?>) parameter);
+ parameter = new DefaultParameterValue((ParameterValue<?>) parameter);
}
formatter.append((FormattableObject) parameter);
formatter.newLine();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
index b177e87..40dc159 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
@@ -55,7 +55,7 @@
* @see ProjectiveTransform
*/
public class AffineTransform2D extends ImmutableAffineTransform
- implements LinearTransform2D, LenientComparable, Parameterized
+ implements MathTransform2D, LinearTransform, LenientComparable, Parameterized
{
/**
* Serial number for inter-operability with different versions.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java
deleted file mode 100644
index 359ad6a..0000000
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java
+++ /dev/null
@@ -1,41 +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.internal.referencing.j2d;
-
-import org.opengis.referencing.operation.MathTransform2D;
-import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
-
-
-/**
- * A two dimensional, linear transform.
- * The intend of this interface is to resolve type conflict in the {@link #inverse()} method.
- *
- * @author Martin Desruisseaux (Geomatys)
- * @since 0.7
- * @version 0.7
- * @module
- */
-public interface LinearTransform2D extends MathTransform2D, LinearTransform {
- /**
- * Returns the inverse transform, which shall be linear and two-dimensional.
- *
- * @return The inverse transform.
- */
- @Override
- LinearTransform2D inverse() throws NoninvertibleTransformException;
-}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
index 9782c9a..c0d9239 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
@@ -16,13 +16,15 @@
*/
package org.apache.sis.internal.referencing.j2d;
-import java.util.Objects;
import java.awt.geom.AffineTransform;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.referencing.operation.MathTransform;
import org.apache.sis.internal.system.Semaphores;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* An affine transform that remember the parameters used for its construction.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
index 3bcf9a1..d5e1446 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
@@ -94,7 +94,7 @@
@Workaround(library="JDK", version="1.7")
private static Map<String,Object> toMap(final IdentifiedObject parameters) {
ArgumentChecks.ensureNonNull("parameters", parameters);
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(NAME_KEY, parameters.getName());
final Collection<Identifier> identifiers = parameters.getIdentifiers();
int size = identifiers.size();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
index 15913f4..116f0e8 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java
@@ -116,7 +116,7 @@
}
data[dim] = compressed;
}
- return new DatumShiftGridCompressed<>(grid, averages, data, scale);
+ return new DatumShiftGridCompressed<C,T>(grid, averages, data, scale);
}
/**
@@ -124,7 +124,7 @@
*/
@Override
final DatumShiftGridFile<C,T> setData(final Object[] other) {
- return new DatumShiftGridCompressed<>(this, averages, (short[][]) other, scale);
+ return new DatumShiftGridCompressed<C,T>(this, averages, (short[][]) other, scale);
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
index 3aea174..22c4ef2 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
@@ -32,7 +32,8 @@
import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
// Branch-specific imports
-import java.nio.file.Path;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
import org.apache.sis.internal.jdk8.JDK8;
@@ -200,7 +201,7 @@
for (final GeneralParameterDescriptor gd : descriptor.descriptors()) {
if (gd instanceof ParameterDescriptor<?>) {
final ParameterDescriptor<?> d = (ParameterDescriptor<?>) gd;
- if (Path.class.isAssignableFrom(d.getValueClass())) {
+ if (File.class.isAssignableFrom(d.getValueClass())) {
parameters.getOrCreate(d).setValue(files[i]);
if (++i == files.length) break;
}
@@ -317,7 +318,7 @@
*/
@Override
final DatumShiftGridFile<C,T> setData(final Object[] other) {
- return new Float<>(this, (float[][]) other);
+ return new Float<C,T>(this, (float[][]) other);
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
index 07eed53..95fddd7 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
@@ -31,8 +31,8 @@
import org.apache.sis.referencing.factory.MissingFactoryResourceException;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.NoSuchFileException;
+import org.apache.sis.internal.jdk7.Path;
+import java.io.FileNotFoundException;
/**
@@ -160,7 +160,7 @@
*/
static FactoryException canNotLoad(final String format, final Path file, final Exception cause) {
final String message = Errors.format(Errors.Keys.CanNotParseFile_2, format, file);
- if (cause instanceof NoSuchFileException) {
+ if (cause instanceof FileNotFoundException) {
return new MissingFactoryResourceException(message, cause);
} else {
return new FactoryDataException(message, cause);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java
index 6c1c726..4f44ddc 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/EPSGName.java
@@ -114,7 +114,7 @@
* @return A map of properties for building the operation method.
*/
public static Map<String,Object> properties(final int identifier, final String name, final GenericName nameOGC) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(IDENTIFIERS_KEY, identifier(identifier));
properties.put(NAME_KEY, create(name));
if (nameOGC != null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
index 6f5eccc..a615051 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
@@ -56,8 +56,9 @@
import static java.lang.Float.parseFloat;
// Branch-specific imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
import org.apache.sis.internal.jdk8.JDK8;
@@ -142,7 +143,7 @@
/**
* The operation parameter descriptor for the <cite>Geocentric translation file</cite> parameter value.
*/
- public static final ParameterDescriptor<Path> FILE;
+ public static final ParameterDescriptor<File> FILE;
/**
* The group of all parameters expected by this coordinate operation. The only parameter formally defined by EPSG
@@ -155,7 +156,7 @@
FILE = builder
.addIdentifier("8727")
.addName("Geocentric translation file")
- .create(Path.class, Paths.get(DEFAULT));
+ .setRemarks(NTv2.WARNING).create(File.class, Paths.get(DEFAULT));
PARAMETERS = builder
.addIdentifier("9655")
.addName("France geocentric interpolation")
@@ -284,7 +285,7 @@
default: throw new InvalidParameterValueException(Errors.format(
Errors.Keys.IllegalArgumentValue_2, "dim", dim), "dim", dim);
}
- final Path file = pg.getMandatoryValue(FILE);
+ final Path file = Path.castOrCopy(pg.getMandatoryValue(FILE));
final DatumShiftGridFile<Angle,Length> grid = getOrLoad(file,
isRecognized(file) ? new double[] {TX, TY, TZ} : null, PRECISION);
MathTransform tr = createGeodeticTransformation(factory,
@@ -333,11 +334,16 @@
try {
grid = handler.peek();
if (grid == null) {
- try (final BufferedReader in = JDK8.newBufferedReader(resolved)) {
- DatumShiftGridLoader.log(FranceGeocentricInterpolation.class, file);
- final DatumShiftGridFile.Float<Angle,Length> g = load(in, file);
- grid = DatumShiftGridCompressed.compress(g, averages, scale);
- } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+ try {
+ final BufferedReader in = JDK8.newBufferedReader(resolved);
+ try {
+ DatumShiftGridLoader.log(FranceGeocentricInterpolation.class, file);
+ final DatumShiftGridFile.Float<Angle,Length> g = load(in, file);
+ grid = DatumShiftGridCompressed.compress(g, averages, scale);
+ } finally {
+ in.close();
+ }
+ } catch (Exception e) { // Multi-catch on the JDK7 branch.
// NumberFormatException, ArithmeticException, NoSuchElementException, possibly other.
throw DatumShiftGridLoader.canNotLoad(HEADER, file, e);
}
@@ -417,7 +423,7 @@
Δy = gridGeometry[5];
nx = JDK8.toIntExact(Math.round((xf - x0) / Δx + 1));
ny = JDK8.toIntExact(Math.round((yf - y0) / Δy + 1));
- grid = new DatumShiftGridFile.Float<>(3,
+ grid = new DatumShiftGridFile.Float<Angle,Length>(3,
NonSI.DEGREE_ANGLE, SI.METRE, false,
x0, y0, Δx, Δy, nx, ny, PARAMETERS, file);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
index 6877dc3..7c1ddcf 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
@@ -97,11 +97,11 @@
new NamedIdentifier(Citations.GEOTIFF, "SemiMajor"),
new NamedIdentifier(Citations.PROJ4, "a")
};
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(AUTHORITY_KEY, Citations.OGC);
properties.put(NAME_KEY, Constants.SEMI_MAJOR);
properties.put(ALIAS_KEY, aliases);
- SEMI_MAJOR = new DefaultParameterDescriptor<>(properties, 1, 1, Double.class, valueDomain, null, null);
+ SEMI_MAJOR = new DefaultParameterDescriptor<Double>(properties, 1, 1, Double.class, valueDomain, null, null);
/*
* Change in-place the name and aliases (we do not need to create new objects)
* before to create the SEMI_MINOR descriptor.
@@ -111,14 +111,14 @@
aliases[1] = new NamedIdentifier(Citations.NETCDF, "semi_minor_axis");
aliases[2] = new NamedIdentifier(Citations.GEOTIFF, "SemiMinor");
aliases[3] = new NamedIdentifier(Citations.PROJ4, "b");
- SEMI_MINOR = new DefaultParameterDescriptor<>(properties, 1, 1, Double.class, valueDomain, null, null);
+ SEMI_MINOR = new DefaultParameterDescriptor<Double>(properties, 1, 1, Double.class, valueDomain, null, null);
/*
* SIS-specific parameter for debugging purpose only.
*/
properties.clear();
properties.put(AUTHORITY_KEY, Citations.SIS);
properties.put(NAME_KEY, "eccentricity");
- ECCENTRICITY = new DefaultParameterDescriptor<>(properties, 1, 1, Double.class,
+ ECCENTRICITY = new DefaultParameterDescriptor<Double>(properties, 1, 1, Double.class,
MeasurementRange.create(0d, true, 1d, true, null), null, null);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
index be48620..eeb1b69 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
@@ -246,7 +246,9 @@
if (value != null) {
return value;
}
- } catch (ParameterNotFoundException | IllegalStateException e) {
+ } catch (ParameterNotFoundException e) {
+ // Ignore - this is okay for this method contract.
+ } catch (IllegalStateException e) {
// Ignore - this is okay for this method contract.
}
return Double.NaN;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
index ef89649..251b0bf 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
@@ -43,9 +43,10 @@
import org.apache.sis.internal.system.DataDirectory;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.Files;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
+import org.apache.sis.internal.jdk7.Files;
/**
@@ -75,13 +76,13 @@
* The operation parameter descriptor for the <cite>"Latitude difference file"</cite> parameter value.
* The default value is {@code "conus.las"}.
*/
- private static final ParameterDescriptor<Path> LATITUDE;
+ private static final ParameterDescriptor<File> LATITUDE;
/**
* The operation parameter descriptor for the <cite>"Longitude difference file"</cite> parameter value.
* The default value is {@code "conus.los"}.
*/
- private static final ParameterDescriptor<Path> LONGITUDE;
+ private static final ParameterDescriptor<File> LONGITUDE;
/**
* The group of all parameters expected by this coordinate operation.
@@ -92,11 +93,11 @@
LATITUDE = builder
.addIdentifier("8657")
.addName("Latitude difference file")
- .create(Path.class, Paths.get("conus.las"));
+ .setRemarks(NTv2.WARNING).create(File.class, Paths.get("conus.las"));
LONGITUDE = builder
.addIdentifier("8658")
.addName("Longitude difference file")
- .create(Path.class, Paths.get("conus.los"));
+ .setRemarks(NTv2.WARNING).create(File.class, Paths.get("conus.los"));
PARAMETERS = builder
.addIdentifier("9613")
.addName("NADCON")
@@ -135,7 +136,8 @@
{
final Parameters pg = Parameters.castOrWrap(values);
return InterpolatedTransform.createGeodeticTransformation(factory,
- getOrLoad(pg.getMandatoryValue(LATITUDE), pg.getMandatoryValue(LONGITUDE)));
+ getOrLoad(Path.castOrCopy(pg.getMandatoryValue(LATITUDE)),
+ Path.castOrCopy(pg.getMandatoryValue(LONGITUDE))));
}
/**
@@ -151,7 +153,7 @@
{
final Path rlat = DataDirectory.DATUM_CHANGES.resolve(latitudeShifts).toAbsolutePath();
final Path rlon = DataDirectory.DATUM_CHANGES.resolve(longitudeShifts).toAbsolutePath();
- final Object key = new AbstractMap.SimpleImmutableEntry<>(rlat, rlon);
+ final Object key = new AbstractMap.SimpleImmutableEntry<Path,Path>(rlat, rlon);
DatumShiftGridFile<?,?> grid = DatumShiftGridFile.CACHE.peek(key);
if (grid == null) {
final Cache.Handler<DatumShiftGridFile<?,?>> handler = DatumShiftGridFile.CACHE.lock(key);
@@ -164,18 +166,24 @@
// Note: buffer size must be divisible by the size of 'float' data type.
final ByteBuffer buffer = ByteBuffer.allocate(4096).order(ByteOrder.LITTLE_ENDIAN);
final FloatBuffer fb = buffer.asFloatBuffer();
- try (final ReadableByteChannel in = Files.newByteChannel(rlat)) {
+ ReadableByteChannel in = Files.newByteChannel(rlat);
+ try {
DatumShiftGridLoader.log(NADCON.class, CharSequences.commonPrefix(
latitudeShifts.toString(), longitudeShifts.toString()).toString() + '…');
loader = new Loader(in, buffer, file);
loader.readGrid(fb, null, longitudeShifts);
+ } finally {
+ in.close();
}
buffer.clear();
file = longitudeShifts;
- try (final ReadableByteChannel in = Files.newByteChannel(rlon)) {
+ in = Files.newByteChannel(rlon);
+ try {
new Loader(in, buffer, file).readGrid(fb, loader, null);
+ } finally {
+ in.close();
}
- } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+ } catch (Exception e) { // Multi-catch on the JDK7 branch.
throw DatumShiftGridLoader.canNotLoad("NADCON", file, e);
}
grid = DatumShiftGridCompressed.compress(loader.grid, null, loader.grid.accuracy);
@@ -392,7 +400,7 @@
if (latitudeShifts == null) {
dim = 1; // Dimension of latitudes.
scale = DEGREES_TO_SECONDS * Δy; // NADCON shifts are positive north.
- grid = new DatumShiftGridFile.Float<>(2, NonSI.DEGREE_ANGLE, NonSI.DEGREE_ANGLE,
+ grid = new DatumShiftGridFile.Float<Angle,Angle>(2, NonSI.DEGREE_ANGLE, NonSI.DEGREE_ANGLE,
true, x0, y0, Δx, Δy, nx, ny, PARAMETERS, file, longitudeShifts);
grid.accuracy = SECOND_PRECISION / DEGREES_TO_SECONDS;
} else {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
index befbd28..2385563 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
@@ -51,9 +51,12 @@
import org.apache.sis.util.resources.Messages;
// Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.charset.StandardCharsets;
+import java.io.File;
+import org.opengis.util.InternationalString;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.StandardCharsets;
import org.apache.sis.internal.jdk8.JDK8;
@@ -75,10 +78,18 @@
private static final long serialVersionUID = -4027618007780159180L;
/**
+ * Warns the user that the parameter type will change from {@link File}
+ * to {@link java.nio.file.Path} when Apache SIS will upgrade to Java 7.
+ */
+ static final InternationalString WARNING = new SimpleInternationalString(
+ "The parameter type will change from ‘java.io.File’ to ‘java.nio.file.Path’ " +
+ "when Apache SIS will upgrade to Java 7.");
+
+ /**
* The operation parameter descriptor for the <cite>"Latitude and longitude difference file"</cite> parameter value.
* The file extension is typically {@code ".gsb"}. There is no default value.
*/
- private static final ParameterDescriptor<Path> FILE;
+ private static final ParameterDescriptor<File> FILE;
/**
* The group of all parameters expected by this coordinate operation.
@@ -89,7 +100,7 @@
FILE = builder
.addIdentifier("8656")
.addName("Latitude and longitude difference file")
- .create(Path.class, null);
+ .setRemarks(WARNING).create(File.class, null);
PARAMETERS = builder
.addIdentifier("9615")
.addName("NTv2")
@@ -127,7 +138,8 @@
throws ParameterNotFoundException, FactoryException
{
final Parameters pg = Parameters.castOrWrap(values);
- return InterpolatedTransform.createGeodeticTransformation(factory, getOrLoad(pg.getMandatoryValue(FILE)));
+ return InterpolatedTransform.createGeodeticTransformation(factory,
+ getOrLoad(Path.castOrCopy(pg.getMandatoryValue(FILE))));
}
/**
@@ -145,12 +157,17 @@
try {
grid = handler.peek();
if (grid == null) {
- try (final ReadableByteChannel in = Files.newByteChannel(resolved)) {
- DatumShiftGridLoader.log(NTv2.class, file);
- final Loader loader = new Loader(in, file);
- grid = loader.readGrid();
- loader.reportWarnings();
- } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+ try {
+ final ReadableByteChannel in = Files.newByteChannel(resolved);
+ try {
+ DatumShiftGridLoader.log(NTv2.class, file);
+ final Loader loader = new Loader(in, file);
+ grid = loader.readGrid();
+ loader.reportWarnings();
+ } finally {
+ in.close();
+ }
+ } catch (Exception e) { // Multi-catch on the JDK7 branch.
throw DatumShiftGridLoader.canNotLoad("NTv2", file, e);
}
grid = grid.useSharedData();
@@ -196,7 +213,7 @@
*/
private static final Map<String,Integer> TYPES;
static {
- final Map<String,Integer> types = new HashMap<>(32);
+ final Map<String,Integer> types = new HashMap<String,Integer>(32);
final Integer string = STRING_TYPE; // Autoboxing
final Integer integer = INTEGER_TYPE;
final Integer real = DOUBLE_TYPE;
@@ -254,7 +271,7 @@
*/
Loader(final ReadableByteChannel channel, final Path file) throws IOException, FactoryException {
super(channel, ByteBuffer.allocate(4096), file);
- this.header = new LinkedHashMap<>();
+ this.header = new LinkedHashMap<String,Object>();
ensureBufferContains(RECORD_LENGTH);
if (isLittleEndian(buffer.getInt(KEY_LENGTH))) {
buffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -331,7 +348,7 @@
* sign of longitude translations; instead, this reversal will be handled by grid.coordinateToGrid
* MathTransform and its inverse.
*/
- final DatumShiftGridFile.Float<Angle,Angle> grid = new DatumShiftGridFile.Float<>(2,
+ final DatumShiftGridFile.Float<Angle,Angle> grid = new DatumShiftGridFile.Float<Angle,Angle>(2,
unit, unit, true, -xmin, ymin, -dx, dy, width, height, PARAMETERS, file);
@SuppressWarnings("MismatchedReadAndWriteOfArray") final float[] tx = grid.offsets[0];
@SuppressWarnings("MismatchedReadAndWriteOfArray") final float[] ty = grid.offsets[1];
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
index b711b35..c4f7ce9 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
@@ -37,7 +37,7 @@
import static org.apache.sis.internal.jaxb.referencing.CC_GeneralOperationParameter.DEFAULT_OCCURRENCE;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -330,6 +330,7 @@
* @return {@code "Parameter"} or {@code "ParameterGroup"}.
*/
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
formatter.setInvalidWKT(this, null);
@@ -337,7 +338,7 @@
for (GeneralParameterDescriptor parameter : ((ParameterDescriptorGroup) this).descriptors()) {
if (!(parameter instanceof FormattableObject)) {
if (parameter instanceof ParameterDescriptor<?>) {
- parameter = new DefaultParameterDescriptor<>((ParameterDescriptor<?>) parameter);
+ parameter = new DefaultParameterDescriptor((ParameterDescriptor<?>) parameter);
} else if (parameter instanceof ParameterDescriptorGroup) {
parameter = new DefaultParameterDescriptorGroup((ParameterDescriptorGroup) parameter);
} else {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
index 0ae1793..dc21301 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
@@ -42,7 +42,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureCanCast;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -290,7 +290,7 @@
*/
public static <T> DefaultParameterDescriptor<T> castOrCopy(final ParameterDescriptor<T> object) {
return (object == null) || (object instanceof DefaultParameterDescriptor<?>)
- ? (DefaultParameterDescriptor<T>) object : new DefaultParameterDescriptor<>(object);
+ ? (DefaultParameterDescriptor<T>) object : new DefaultParameterDescriptor<T>(object);
}
/**
@@ -432,7 +432,7 @@
*/
@Override
public ParameterValue<T> createValue() {
- return new DefaultParameterValue<>(this);
+ return new DefaultParameterValue<T>(this);
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
index 85a12a3..a83448a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
@@ -280,7 +280,7 @@
@Override public boolean contains(final Object object) {
Set<GeneralParameterDescriptor> s = asSet;
if (s == null) {
- asSet = s = new HashSet<>(this); // No synchronization: not a big problem if created twice.
+ asSet = s = new HashSet<GeneralParameterDescriptor>(this); // No synchronization: not a big problem if created twice.
}
return s.contains(object);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
index 4cd4bc3..9192cc6 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
@@ -57,8 +57,7 @@
import static org.apache.sis.util.Utilities.deepEquals;
// Branch-dependent imports
-import java.util.Objects;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -471,7 +470,7 @@
/**
* Returns a reference to a file or a part of a file containing one or more parameter values.
* The default implementation can convert the following value types:
- * {@link URI}, {@link URL}, {@link Path}, {@link File}.
+ * {@link URI}, {@link URL}, {@link File}.
*
* @return The reference to a file containing parameter values.
* @throws InvalidParameterTypeException if the value is not a reference to a file or an URI.
@@ -489,9 +488,6 @@
if (value instanceof File) {
return ((File) value).toURI();
}
- if (value instanceof Path) {
- return ((Path) value).toUri();
- }
Exception cause = null;
try {
if (value instanceof URL) {
@@ -511,7 +507,7 @@
* Returns {@code true} if the given value is an instance of one of the types documented in {@link #valueFile()}.
*/
private static boolean isFile(final Object value) {
- return (value instanceof URI || value instanceof URL || value instanceof File || value instanceof Path);
+ return (value instanceof URI || value instanceof URL || value instanceof File);
}
/**
@@ -522,7 +518,6 @@
if (value instanceof String) {
final Class<?> type = descriptor.getValueClass();
return (type == URI.class) || (type == URL.class)
- || Path.class.isAssignableFrom(type)
|| File.class.isAssignableFrom(type);
}
return isFile(value);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
index c40e8b3..50a8d14 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
@@ -43,7 +43,7 @@
import org.apache.sis.util.Utilities;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -340,7 +340,7 @@
public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
ArgumentChecks.ensureNonNull("name", name);
final ParameterValueList values = this.values; // Protect against accidental changes.
- final List<ParameterValueGroup> groups = new ArrayList<>(4);
+ final List<ParameterValueGroup> groups = new ArrayList<ParameterValueGroup>(4);
final int size = values.size();
for (int i=0; i<size; i++) {
final GeneralParameterDescriptor descriptor = values.descriptor(i);
@@ -443,7 +443,7 @@
if (!mode.isIgnoringMetadata()) {
return Utilities.deepEquals(expected.values(), actual.values(), mode);
}
- final List<GeneralParameterValue> values = new LinkedList<>(expected.values());
+ final List<GeneralParameterValue> values = new LinkedList<GeneralParameterValue>(expected.values());
scan: for (final GeneralParameterValue param : actual.values()) {
final Iterator<GeneralParameterValue> it = values.iterator();
while (it.hasNext()) {
@@ -567,7 +567,8 @@
* <gml:parameterValue> element. The implementation is known to be DefaultParameterDescriptorGroup
* because this is the type declared in the JAXBContext and in adapters.
*/
- final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4);
+ final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements =
+ new IdentityHashMap<GeneralParameterDescriptor,GeneralParameterDescriptor>(4);
((DefaultParameterDescriptorGroup) addTo.descriptor).merge(getDescriptors(parameters), replacements);
addTo.clear(); // Because references to parameter descriptors have changed.
setValues(parameters, replacements, addTo);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java
index 25ee5c0..48f24aa 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionDescriptor.java
@@ -75,16 +75,14 @@
boolean hasP1 = false;
boolean hasP2 = false;
for (final ParameterDescriptor<?> param : parameters) {
- switch (param.getName().getCode()) {
- case Constants.STANDARD_PARALLEL_1: hasP1 = true; break;
- case Constants.STANDARD_PARALLEL_2: hasP2 = true; break;
- default: {
- for (final GenericName alias : param.getAlias()) {
- switch (alias.tip().toString()) {
- case Constants.STANDARD_PARALLEL_1: hasP1 = true; break;
- case Constants.STANDARD_PARALLEL_2: hasP2 = true; break;
- }
- }
+ String code = param.getName().getCode();
+ if (code.equals(Constants.STANDARD_PARALLEL_1)) hasP1 = true;
+ else if (code.equals(Constants.STANDARD_PARALLEL_2)) hasP2 = true;
+ else {
+ for (final GenericName alias : param.getAlias()) {
+ code = alias.tip().toString();
+ if (code.equals(Constants.STANDARD_PARALLEL_1)) hasP1 = true;
+ else if (code.equals(Constants.STANDARD_PARALLEL_2)) hasP2 = true;
}
}
if (hasP1 & hasP2) break;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
index 122535d..b044089 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
@@ -34,7 +34,7 @@
import static org.apache.sis.metadata.iso.citation.Citations.NETCDF;
// Branch-specific imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -168,7 +168,7 @@
* This is used in some NetCDF files instead of {@code SEMI_MAJOR} and {@code SEMI_MINOR}.
* This is not a standard parameter.
*/
- static final ParameterDescriptor<Double> DESCRIPTOR = new DefaultParameterDescriptor<>(
+ static final ParameterDescriptor<Double> DESCRIPTOR = new DefaultParameterDescriptor<Double>(
InverseFlattening.toMap(Constants.EARTH_RADIUS), 0, 1, Double.class,
MeasurementRange.createGreaterThan(0.0, SI.METRE), null, null);
@@ -252,7 +252,7 @@
* This is used in some NetCDF files instead of {@code SEMI_MINOR}.
* This is not a standard parameter.
*/
- static final ParameterDescriptor<Double> DESCRIPTOR = new DefaultParameterDescriptor<>(
+ static final ParameterDescriptor<Double> DESCRIPTOR = new DefaultParameterDescriptor<Double>(
toMap(Constants.INVERSE_FLATTENING), 0, 1, Double.class,
MeasurementRange.createGreaterThan(0.0, Unit.ONE), null, null);
@@ -370,7 +370,7 @@
* All names known to Apache SIS for the "is IVF definitive" parameter.
* This is not a standard parameter.
*/
- static final ParameterDescriptor<Boolean> DESCRIPTOR = new DefaultParameterDescriptor<>(
+ static final ParameterDescriptor<Boolean> DESCRIPTOR = new DefaultParameterDescriptor<Boolean>(
InverseFlattening.toMap(Constants.IS_IVF_DEFINITIVE), 0, 1, Boolean.class, null, null, Boolean.FALSE);
/**
@@ -434,7 +434,7 @@
* This is used in some NetCDF files instead of {@link #STANDARD_PARALLEL_1} and
* {@link #STANDARD_PARALLEL_2}. This is not a standard parameter.
*/
- static final ParameterDescriptor<double[]> DESCRIPTOR = new DefaultParameterDescriptor<>(
+ static final ParameterDescriptor<double[]> DESCRIPTOR = new DefaultParameterDescriptor<double[]>(
InverseFlattening.toMap(Constants.STANDARD_PARALLEL),
0, 1, double[].class, null, null, null);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
index 2e51be2..188c570 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
@@ -67,6 +67,7 @@
* @param numRow The parameter for the number of rows.
* @param numCol The parameter for the number of columns.
*/
+ @SuppressWarnings("unchecked")
MatrixParameters(final ParameterDescriptor<Integer> numRow, final ParameterDescriptor<Integer> numCol) {
super(Double.class, "elt_", "_", numRow, numCol);
}
@@ -154,7 +155,7 @@
*/
@Override
protected ParameterDescriptor<Double> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(ParameterDescriptor.NAME_KEY,
new NamedIdentifier(Citations.OGC, Constants.OGC, indicesToName(indices), null, null));
final String c = indicesToAlias(indices);
@@ -162,7 +163,7 @@
properties.put(ParameterDescriptor.ALIAS_KEY,
new NamedIdentifier(Citations.SIS, Constants.SIS, c, null, null));
}
- return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, getDefaultValue(indices));
+ return new DefaultParameterDescriptor<Double>(properties, 0, 1, Double.class, null, null, getDefaultValue(indices));
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
index cf1501b..bd97fb1 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
@@ -103,7 +103,7 @@
*/
return wkt;
}
- final Map<String,Object> properties = new HashMap<>(6);
+ final Map<String,Object> properties = new HashMap<String,Object>(6);
/*
* Declare the EPSG identifier only for A0, A1, A2, B0, B1 and B2.
*/
@@ -114,7 +114,7 @@
}
properties.put(ParameterDescriptor.NAME_KEY, name);
properties.put(ParameterDescriptor.ALIAS_KEY, wkt.getName());
- return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, wkt.getDefaultValue());
+ return new DefaultParameterDescriptor<Double>(properties, 0, 1, Double.class, null, null, wkt.getDefaultValue());
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
index eaf68c2..0481f40 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
@@ -268,7 +268,7 @@
} else if (Number.class.isAssignableFrom(valueClass)) {
valueDomain = new NumberRange((Class) valueClass, (Number) minimumValue, true, (Number) maximumValue, true);
} else {
- valueDomain = new Range<>(valueClass, minimumValue, true, maximumValue, true);
+ valueDomain = new Range<T>(valueClass, minimumValue, true, maximumValue, true);
}
return create(valueClass, valueDomain, null, defaultValue);
}
@@ -319,7 +319,7 @@
final ParameterDescriptor<T> descriptor;
onCreate(false);
try {
- descriptor = new DefaultParameterDescriptor<>(properties, required ? 1 : 0, 1,
+ descriptor = new DefaultParameterDescriptor<T>(properties, required ? 1 : 0, 1,
valueClass, valueDomain, validValues, defaultValue);
} finally {
onCreate(true);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
index dc8eb48..317df52 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
@@ -115,7 +115,7 @@
/**
* An instance created when first needed and potentially shared.
*/
- private static final AtomicReference<ParameterFormat> INSTANCE = new AtomicReference<>();
+ private static final AtomicReference<ParameterFormat> INSTANCE = new AtomicReference<ParameterFormat>();
/**
* The default column separator. User can change the separator
@@ -259,8 +259,8 @@
* Creates a new formatter for the default locale and timezone.
*/
public ParameterFormat() {
- super(Locale.getDefault(Locale.Category.FORMAT), TimeZone.getDefault());
- displayLocale = Locale.getDefault(Locale.Category.DISPLAY);
+ super(Locale.getDefault(), TimeZone.getDefault());
+ displayLocale = super.getLocale(); // Implemented as Locale.getDefault(Locale.Category.DISPLAY) on the JDK7 branch.
columnSeparator = SEPARATOR;
}
@@ -288,22 +288,6 @@
}
/**
- * Returns the locale for the given category.
- *
- * <ul>
- * <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for values.</li>
- * <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for labels.</li>
- * </ul>
- *
- * @param category The category for which a locale is desired.
- * @return The locale for the given category (never {@code null}).
- */
- @Override
- public Locale getLocale(final Locale.Category category) {
- return (category == Locale.Category.DISPLAY) ? displayLocale : super.getLocale(category);
- }
-
- /**
* Returns the amount of information to put in the table.
* The default value is {@link ContentLevel#BRIEF}.
*
@@ -451,7 +435,7 @@
final boolean showObligation = !isBrief || (values == null);
final boolean hasColors = (colors != null);
final String lineSeparator = this.lineSeparator;
- final Map<String,Integer> remarks = new LinkedHashMap<>();
+ final Map<String,Integer> remarks = new LinkedHashMap<String,Integer>();
final ParameterTableRow header = new ParameterTableRow(group, displayLocale, preferredCodespaces, remarks, isBrief);
final String groupCodespace = header.getCodeSpace();
/*
@@ -463,7 +447,7 @@
int codespaceWidth = 0;
final Collection<?> elements = (values != null) ? values.values() : group.descriptors();
final Map<GeneralParameterDescriptor, ParameterTableRow> descriptorValues =
- new LinkedHashMap<>(hashMapCapacity(elements.size()));
+ new LinkedHashMap<GeneralParameterDescriptor, ParameterTableRow>(hashMapCapacity(elements.size()));
List<Object> deferredGroups = null; // To be created only if needed (it is usually not).
for (final Object element : elements) {
final GeneralParameterValue parameter;
@@ -477,7 +461,7 @@
}
if (descriptor instanceof ParameterDescriptorGroup) {
if (deferredGroups == null) {
- deferredGroups = new ArrayList<>(4);
+ deferredGroups = new ArrayList<Object>(4);
}
deferredGroups.add(element);
continue;
@@ -817,8 +801,8 @@
* the scope of some alias to be processed below.
*/
boolean hasIdentifiers = false;
- final List<String[]> rows = new ArrayList<>();
- final Map<String,Integer> columnIndices = new LinkedHashMap<>();
+ final List<String[]> rows = new ArrayList<String[]>();
+ final Map<String,Integer> columnIndices = new LinkedHashMap<String,Integer>();
columnIndices.put(null, 0); // See above comment for the meaning of "null" here.
if (preferredCodespaces != null) {
for (final String codespace : preferredCodespaces) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
index 160a034..6aa363f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
@@ -129,9 +129,9 @@
ParameterTableRow(final IdentifiedObject object, final Locale locale, final Set<String> preferredCodespaces,
final Map<String,Integer> remarks, final boolean isBrief)
{
- values = new ArrayList<>(2); // In the vast majority of cases, we will have only one value.
- units = new ArrayList<>(2);
- identifiers = new LinkedHashMap<>();
+ values = new ArrayList<Object>(2); // In the vast majority of cases, we will have only one value.
+ units = new ArrayList<Object>(2);
+ identifiers = new LinkedHashMap<String,Set<Object>>();
Identifier name = object.getName();
if (name != null) { // Paranoiac check.
final String codespace = name.getCodeSpace();
@@ -218,7 +218,7 @@
}
Set<Object> ids = identifiers.get(codespace);
if (ids == null) {
- ids = new LinkedHashSet<>(8);
+ ids = new LinkedHashSet<Object>(8);
identifiers.put(codespace, ids);
}
ids.add(identifier);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
index dc2ca59..64ad601 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
@@ -36,6 +36,9 @@
import org.apache.sis.util.resources.Errors;
import org.apache.sis.referencing.IdentifiedObjects;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* The list to be returned by {@link DefaultParameterValueGroup#values()}.
@@ -327,7 +330,7 @@
if (size == 0) {
return "[]";
}
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder();
for (int i=0; i<size; i++) {
buffer.append(values[i]).append(lineSeparator);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
index 7cb6812..4ffdd82 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
@@ -742,7 +742,7 @@
throws InvalidParameterNameException, InvalidParameterValueException
{
final Integer ZERO = 0;
- final Map<String,Integer> occurrences = new HashMap<>();
+ final Map<String,Integer> occurrences = new HashMap<String,Integer>();
for (final GeneralParameterValue value : values.values()) {
final String name = value.getDescriptor().getName().getCode();
final int occurrence = JDK8.getOrDefault(occurrences, name, ZERO);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
index 1b70c87..edbcada 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
@@ -47,7 +47,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -233,13 +233,13 @@
/*
* For the WKT1 convention, the "num_row" and "num_col" parameters are mandatory.
*/
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(Identifier.AUTHORITY_KEY, Citations.OGC);
properties.put(Identifier.CODE_KEY, Constants.NUM_ROW);
- ParameterDescriptor<Integer> numRow = new DefaultParameterDescriptor<>(
+ ParameterDescriptor<Integer> numRow = new DefaultParameterDescriptor<Integer>(
properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
properties.put(Identifier.CODE_KEY, Constants.NUM_COL);
- ParameterDescriptor<Integer> numCol = new DefaultParameterDescriptor<>(
+ ParameterDescriptor<Integer> numCol = new DefaultParameterDescriptor<Integer>(
properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
WKT1 = new MatrixParameters(numRow, numCol);
/*
@@ -247,9 +247,9 @@
* size if fixed to 3×3. However since we still need them, we will declare them as optional
* and we will hide them from the descriptor unless the matrix size is different than 3×3.
*/
- numRow = new DefaultParameterDescriptor<>(IdentifiedObjects.getProperties(numRow),
+ numRow = new DefaultParameterDescriptor<Integer>(IdentifiedObjects.getProperties(numRow),
0, 1, Integer.class, valueDomain, null, defaultSize);
- numCol = new DefaultParameterDescriptor<>(IdentifiedObjects.getProperties(numCol),
+ numCol = new DefaultParameterDescriptor<Integer>(IdentifiedObjects.getProperties(numCol),
0, 1, Integer.class, valueDomain, null, defaultSize);
ALPHANUM = new MatrixParametersAlphaNum(numRow, numCol);
}
@@ -314,7 +314,6 @@
* @param dimensions The parameter for the size of each dimension, usually in an array of length 2.
* Length may be different if the caller wants to generalize usage of this class to tensors.
*/
- @SafeVarargs
@SuppressWarnings({"unchecked", "rawtypes"})
public TensorParameters(final Class<E> elementType, final String prefix, final String separator,
final ParameterDescriptor<Integer>... dimensions)
@@ -497,7 +496,7 @@
protected ParameterDescriptor<E> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
final Citation authority = dimensions[0].getName().getAuthority();
final String name = indicesToName(indices);
- return new DefaultParameterDescriptor<>(
+ return new DefaultParameterDescriptor<E>(
Collections.singletonMap(ParameterDescriptor.NAME_KEY, new NamedIdentifier(authority, name)),
0, 1, elementType, null, null, getDefaultValue(indices));
}
@@ -727,7 +726,7 @@
* @return A new parameter group initialized to the default values.
*/
public ParameterValueGroup createValueGroup(final Map<String,?> properties) {
- return new TensorValues<>(properties, this);
+ return new TensorValues<E>(properties, this);
}
/**
@@ -745,7 +744,7 @@
throw new IllegalStateException();
}
ArgumentChecks.ensureNonNull("matrix", matrix);
- final TensorValues<E> values = new TensorValues<>(properties, this);
+ final TensorValues<E> values = new TensorValues<E>(properties, this);
values.setMatrix(matrix);
return values;
}
@@ -840,7 +839,7 @@
final Field field = TensorParameters.class.getDeclaredField("parameters");
field.setAccessible(true);
field.set(this, createCache());
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new AssertionError(e);
}
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
index 6b6575d..cec3198 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
@@ -148,7 +148,7 @@
@Override
@SuppressWarnings("CloneDoesntCallSuperClone")
public ParameterValueGroup clone() {
- return new TensorValues<>(this, true);
+ return new TensorValues<E>(this, true);
}
/**
@@ -156,7 +156,7 @@
*/
@Override
public ParameterValueGroup createValue() {
- return new TensorValues<>(this, false);
+ return new TensorValues<E>(this, false);
}
/**
@@ -306,7 +306,7 @@
*/
@Override
public List<GeneralParameterValue> values() {
- final List<GeneralParameterValue> addTo = new ArrayList<>();
+ final List<GeneralParameterValue> addTo = new ArrayList<GeneralParameterValue>();
for (final ParameterValue<Integer> dimension : dimensions) {
if (!isOmitted(dimension)) {
addTo.add(dimension);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java
index 052efbd..055088a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java
@@ -68,7 +68,7 @@
*/
@SuppressWarnings("rawtypes")
private static final WeakHashSet<UnmodifiableParameterValue> POOL =
- new WeakHashSet<>(UnmodifiableParameterValue.class);
+ new WeakHashSet<UnmodifiableParameterValue>(UnmodifiableParameterValue.class);
/**
* Creates a new parameter with the same value than the given one.
@@ -89,7 +89,7 @@
if (parameter == null || parameter instanceof UnmodifiableParameterValue<?>) {
return (UnmodifiableParameterValue<T>) parameter;
} else {
- return POOL.unique(new UnmodifiableParameterValue<>(parameter));
+ return POOL.unique(new UnmodifiableParameterValue<T>(parameter));
}
}
@@ -121,6 +121,6 @@
@Override
@SuppressWarnings("CloneDoesntCallSuperClone")
public DefaultParameterValue<T> clone() {
- return new DefaultParameterValue<>(this);
+ return new DefaultParameterValue<T>(this);
}
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java b/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
index f7a0bc2..fb62579 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
@@ -34,7 +34,7 @@
import org.apache.sis.internal.util.UnmodifiableArrayList;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -156,7 +156,7 @@
@Override
public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
ArgumentChecks.ensureNonNull("name", name);
- final List<ParameterValueGroup> groups = new ArrayList<>(4);
+ final List<ParameterValueGroup> groups = new ArrayList<ParameterValueGroup>(4);
for (final GeneralParameterValue value : values) {
if (value instanceof ParameterValueGroup) {
if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
index 7df7e33..274718b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
@@ -67,7 +67,7 @@
import static org.apache.sis.internal.util.CollectionsExt.immutableSet;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
index e4d5281..c1f5db4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
@@ -35,7 +35,7 @@
import static org.apache.sis.util.collection.Containers.property;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
index 59d2459..088f304 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
@@ -59,10 +59,10 @@
* plus the EPSG factory.
*/
static final MultiAuthoritiesFactory ALL = new MultiAuthoritiesFactory(
- new AuthorityFactories<>(CRSAuthorityFactory.class),
- new AuthorityFactories<>(CSAuthorityFactory.class),
- new AuthorityFactories<>(DatumAuthorityFactory.class),
- new AuthorityFactories<>(CoordinateOperationAuthorityFactory.class))
+ new AuthorityFactories<CRSAuthorityFactory>(CRSAuthorityFactory.class),
+ new AuthorityFactories<CSAuthorityFactory>(CSAuthorityFactory.class),
+ new AuthorityFactories<DatumAuthorityFactory>(DatumAuthorityFactory.class),
+ new AuthorityFactories<CoordinateOperationAuthorityFactory>(CoordinateOperationAuthorityFactory.class))
{
/** Anonymous constructor */ {
setLenient(true);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
index 2e431ad..5d9e4ed 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
@@ -224,9 +224,9 @@
*/
protected Builder() {
assert verifyParameterizedType(getClass());
- properties = new HashMap<>(8);
- aliases = new ArrayList<>(); // Will often stay empty (default constructor handles those cases well).
- identifiers = new ArrayList<>();
+ properties = new HashMap<String,Object>(8);
+ aliases = new ArrayList<GenericName>(); // Will often stay empty (default constructor handles those cases well).
+ identifiers = new ArrayList<Identifier> ();
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
index da31039..f7323e1 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
@@ -634,7 +634,7 @@
singles = ((DefaultCompoundCRS) crs).getSingleComponents();
} else {
final List<CoordinateReferenceSystem> elements = ((CompoundCRS) crs).getComponents();
- singles = new ArrayList<>(elements.size());
+ singles = new ArrayList<SingleCRS>(elements.size());
ReferencingUtilities.getSingleComponents(elements, singles);
}
} else {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
index a789252..8f79235 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
@@ -390,7 +390,7 @@
this.southUTM = southUTM;
this.firstZone = firstZone;
this.lastZone = lastZone;
- cachedUTM = new HashMap<>();
+ cachedUTM = new HashMap<Integer,ProjectedCRS>();
}
/**
@@ -1571,7 +1571,7 @@
* Returns the same properties than the given object, except for the identifier which is set to the given code.
*/
private static Map<String,?> properties(final IdentifiedObject template, final short code) {
- final Map<String,Object> properties = new HashMap<>(IdentifiedObjects.getProperties(template, EXCLUDE));
+ final Map<String,Object> properties = new HashMap<String,Object>(IdentifiedObjects.getProperties(template, EXCLUDE));
properties.put(GeographicCRS.IDENTIFIERS_KEY, new NamedIdentifier(Citations.EPSG, String.valueOf(code)));
return properties;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
index beedd24..119d50b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
@@ -124,7 +124,7 @@
final boolean geographic = type.isAssignableFrom(GeographicCRS.class);
final boolean geocentric = type.isAssignableFrom(GeocentricCRS.class);
final boolean projected = type.isAssignableFrom(ProjectedCRS .class);
- final Set<String> codes = new LinkedHashSet<>();
+ final Set<String> codes = new LinkedHashSet<String>();
if (pm) codes.add(StandardDefinitions.GREENWICH);
for (final CommonCRS crs : CommonCRS.values()) {
if (ellipsoid) add(codes, crs.ellipsoid);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
index 59257c9..9b2515b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
@@ -128,7 +128,7 @@
* specified authority has been found.
*/
public static Set<String> getNames(final IdentifiedObject object, final Citation authority) {
- final Set<String> names = new LinkedHashSet<>(8);
+ final Set<String> names = new LinkedHashSet<String>(8);
getName(object, authority, names);
return names;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
index 34cf9bf..0984679 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
@@ -39,7 +39,7 @@
import org.apache.sis.util.ArgumentChecks;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java
index 3933d44..c752140 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java
@@ -79,7 +79,7 @@
* The mapping from key names to the index expected by the {@link #getAt(IdentifiedObject, int)} method.
* This map shall not be modified after construction (for multi-thread safety without synchronization).
*/
- private static final Map<String,Integer> INDICES = new HashMap<>(16);
+ private static final Map<String,Integer> INDICES = new HashMap<String,Integer>(16);
static {
for (int i=0; i<KEYS.length; i++) {
if (INDICES.put(KEYS[i], i) != null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
index 59d2b40..619e71f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
@@ -101,7 +101,7 @@
* @return The map of properties to give to constructors or factory methods.
*/
private static Map<String,Object> properties(final int code, final String name, final String alias, final boolean world) {
- final Map<String,Object> map = new HashMap<>(8);
+ final Map<String,Object> map = new HashMap<String,Object>(8);
if (code != 0) {
map.put(IDENTIFIERS_KEY, new NamedIdentifier(Citations.EPSG, String.valueOf(code)));
}
@@ -242,7 +242,7 @@
* If an other prime meridian is desired, the EPSG database shall be used.
*/
static PrimeMeridian primeMeridian() {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(NAME_KEY, new NamedIdentifier(Citations.EPSG, "Greenwich")); // Name is fixed by ISO 19111.
properties.put(IDENTIFIERS_KEY, new NamedIdentifier(Citations.EPSG, GREENWICH));
return new DefaultPrimeMeridian(properties, 0, NonSI.DEGREE_ANGLE);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
index 54b1827..10c3e25 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
@@ -45,7 +45,7 @@
import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -302,7 +302,7 @@
final AbstractCRS setCached(final AxesConvention convention, AbstractCRS crs) {
assert Thread.holdsLock(this);
if (forConvention == null) {
- forConvention = new EnumMap<>(AxesConvention.class);
+ forConvention = new EnumMap<AxesConvention,AbstractCRS>(AxesConvention.class);
} else if (crs != this) {
for (final AbstractCRS existing : forConvention.values()) {
if (crs.equals(existing)) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
index 49fa56b..5aef803 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
@@ -328,7 +328,7 @@
* @see #getSingleComponents()
*/
private boolean setSingleComponents(final List<? extends CoordinateReferenceSystem> crs) {
- final List<SingleCRS> flattened = new ArrayList<>(crs.size());
+ final List<SingleCRS> flattened = new ArrayList<SingleCRS>(crs.size());
final boolean identical = ReferencingUtilities.getSingleComponents(crs, flattened);
singles = UnmodifiableArrayList.wrap(flattened.toArray(new SingleCRS[flattened.size()]));
return identical;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
index 1386e65..210bb8b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
@@ -294,12 +294,12 @@
{
if (baseCRS != null && derivedCS != null) {
final String type = getType(baseCRS, derivedCS);
- if (type != null) switch (type) {
- case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, conversion, derivedCS);
- case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, conversion, (VerticalCS) derivedCS);
- case WKTKeywords.TimeCRS: return new Temporal (properties, (TemporalCRS) baseCRS, conversion, (TimeCS) derivedCS);
- case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, conversion, (ParametricCS) derivedCS);
- case WKTKeywords.EngineeringCRS: {
+ if (type != null) {
+ if (WKTKeywords.GeodeticCRS .equals(type)) return new Geodetic (properties, (GeodeticCRS) baseCRS, conversion, derivedCS);
+ if (WKTKeywords.VerticalCRS .equals(type)) return new Vertical (properties, (VerticalCRS) baseCRS, conversion, (VerticalCS) derivedCS);
+ if (WKTKeywords.TimeCRS .equals(type)) return new Temporal (properties, (TemporalCRS) baseCRS, conversion, (TimeCS) derivedCS);
+ if (WKTKeywords.ParametricCRS .equals(type)) return new Parametric(properties, (ParametricCRS) baseCRS, conversion, (ParametricCS) derivedCS);
+ if (WKTKeywords.EngineeringCRS.equals(type)) {
/*
* This case may happen for baseCRS of kind GeodeticCRS, ProjectedCRS or EngineeringCRS.
* But only the later is associated to EngineeringDatum; the two formers are associated
@@ -311,7 +311,6 @@
if (baseCRS instanceof EngineeringCRS) {
return new Engineering(properties, (EngineeringCRS) baseCRS, conversion, derivedCS);
}
- break;
}
}
}
@@ -349,17 +348,16 @@
{
if (baseCRS != null && derivedCS != null) {
final String type = getType(baseCRS, derivedCS);
- if (type != null) switch (type) {
- case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, interpolationCRS, method, baseToDerived, derivedCS);
- case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, interpolationCRS, method, baseToDerived, (VerticalCS) derivedCS);
- case WKTKeywords.TimeCRS: return new Temporal (properties, (TemporalCRS) baseCRS, interpolationCRS, method, baseToDerived, (TimeCS) derivedCS);
- case WKTKeywords.ParametricCRS: return new Parametric(properties, (ParametricCRS) baseCRS, interpolationCRS, method, baseToDerived, (ParametricCS) derivedCS);
- case WKTKeywords.EngineeringCRS: {
+ if (type != null) {
+ if (WKTKeywords.GeodeticCRS .equals(type)) return new Geodetic (properties, (GeodeticCRS) baseCRS, interpolationCRS, method, baseToDerived, derivedCS);
+ if (WKTKeywords.VerticalCRS .equals(type)) return new Vertical (properties, (VerticalCRS) baseCRS, interpolationCRS, method, baseToDerived, (VerticalCS) derivedCS);
+ if (WKTKeywords.TimeCRS .equals(type)) return new Temporal (properties, (TemporalCRS) baseCRS, interpolationCRS, method, baseToDerived, (TimeCS) derivedCS);
+ if (WKTKeywords.ParametricCRS .equals(type)) return new Parametric(properties, (ParametricCRS) baseCRS, interpolationCRS, method, baseToDerived, (ParametricCS) derivedCS);
+ if (WKTKeywords.EngineeringCRS.equals(type)) {
if (baseCRS instanceof EngineeringCRS) {
// See the comment in create(Map, SingleCRS, Conversion, CoordinateSystem)
return new Engineering(properties, (EngineeringCRS) baseCRS, interpolationCRS, method, baseToDerived, derivedCS);
}
- break;
}
}
}
@@ -381,12 +379,12 @@
return (DefaultDerivedCRS) object;
} else {
final String type = getType(object.getBaseCRS(), object.getCoordinateSystem());
- if (type != null) switch (type) {
- case WKTKeywords.GeodeticCRS: return new Geodetic (object);
- case WKTKeywords.VerticalCRS: return new Vertical (object);
- case WKTKeywords.TimeCRS: return new Temporal (object);
- case WKTKeywords.ParametricCRS: return new Parametric (object);
- case WKTKeywords.EngineeringCRS: return new Engineering(object);
+ if (type != null) {
+ if (WKTKeywords.GeodeticCRS .equals(type)) return new Geodetic (object);
+ if (WKTKeywords.VerticalCRS .equals(type)) return new Vertical (object);
+ if (WKTKeywords.TimeCRS .equals(type)) return new Temporal (object);
+ if (WKTKeywords.ParametricCRS .equals(type)) return new Parametric (object);
+ if (WKTKeywords.EngineeringCRS.equals(type)) return new Engineering(object);
}
return new DefaultDerivedCRS(object);
}
@@ -597,12 +595,10 @@
if (longKeyword == null) {
return null;
}
- switch (longKeyword) {
- case WKTKeywords.GeodeticCRS: shortKeyword = WKTKeywords.GeodCRS; break;
- case WKTKeywords.VerticalCRS: shortKeyword = WKTKeywords.VertCRS; break;
- case WKTKeywords.EngineeringCRS: shortKeyword = WKTKeywords.EngCRS; break;
- default: return longKeyword;
- }
+ if (longKeyword.equals(WKTKeywords.GeodeticCRS)) shortKeyword = WKTKeywords.GeodCRS;
+ else if (longKeyword.equals(WKTKeywords.VerticalCRS)) shortKeyword = WKTKeywords.VertCRS;
+ else if (longKeyword.equals(WKTKeywords.EngineeringCRS)) shortKeyword = WKTKeywords.EngCRS;
+ else return longKeyword;
return formatter.shortOrLong(shortKeyword, longKeyword);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
index 219104c..24654d7 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
@@ -261,7 +261,7 @@
if (EPSG.equals(identifier.getCodeSpace())) try {
final int i = Arrays.binarySearch(EPSG_CODES, Short.parseShort(identifier.getCode()));
if (i >= 0) {
- final Map<String,Object> c = new HashMap<>(properties);
+ final Map<String,Object> c = new HashMap<String,Object>(properties);
c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.WMS, CRS, Short.toString(CRS_CODES[i])));
properties = c;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
index 2885788..a71eee3 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
@@ -332,7 +332,7 @@
public synchronized AbstractCS forConvention(final AxesConvention convention) {
ensureNonNull("convention", convention);
if (derived == null) {
- derived = new EnumMap<>(AxesConvention.class);
+ derived = new EnumMap<AxesConvention,AbstractCS>(AxesConvention.class);
}
AbstractCS cs = derived.get(convention);
if (cs == null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
index 4096ec1..2b187c7 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
@@ -40,7 +40,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
index e17e5e1..c5543c9 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
@@ -71,7 +71,7 @@
import static org.apache.sis.internal.referencing.NilReferencingObject.UNNAMED;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -144,7 +144,7 @@
*
* @see #isHeuristicMatchForName(String)
*/
- private static final Map<String,Object> ALIASES = new HashMap<>(12);
+ private static final Map<String,Object> ALIASES = new HashMap<String,Object>(12);
static {
final Boolean latitude = Boolean.TRUE;
final Boolean longitude = Boolean.FALSE;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
index a466b49..b4fd9c4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
@@ -112,7 +112,7 @@
*
* @see #order(AxisDirection)
*/
- private static final Map<AxisDirection,Integer> ORDER = new HashMap<>();
+ private static final Map<AxisDirection,Integer> ORDER = new HashMap<AxisDirection,Integer>();
static {
final Map<AxisDirection,Integer> m = ORDER;
// Get ordinal of last compass direction defined by GeoAPI. We will continue on the horizontal plane.
@@ -236,7 +236,7 @@
final String abbreviation = axis.getAbbreviation();
final String newAbbr = sameDirection ? abbreviation :
AxisDirections.suggestAbbreviation(axis.getName().getCode(), newDir, newUnit);
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
if (newAbbr.equals(abbreviation)) {
properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
} else {
@@ -369,7 +369,7 @@
min -= offset;
max -= offset;
if (min < max) { // Paranoiac check, but also a way to filter NaN values when offset is infinite.
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, min);
properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, max);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
index 3ad4413..f948ddd 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
@@ -44,7 +44,7 @@
import static org.apache.sis.util.collection.Containers.property;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
index 84bfe22..687d35d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
@@ -39,7 +39,7 @@
import static org.apache.sis.referencing.operation.matrix.Matrix4.SIZE;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
index 6485fbd..b0e3148 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
@@ -38,7 +38,7 @@
import org.apache.sis.measure.Units;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
index 73e9f83..8f50dea 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
@@ -50,7 +50,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
index 725d061..fd2810a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
@@ -52,7 +52,7 @@
import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -418,7 +418,7 @@
*/
public Matrix getPositionVectorTransformation(final GeodeticDatum targetDatum, final Extent areaOfInterest) {
ensureNonNull("targetDatum", targetDatum);
- final ExtentSelector<BursaWolfParameters> selector = new ExtentSelector<>(areaOfInterest);
+ final ExtentSelector<BursaWolfParameters> selector = new ExtentSelector<BursaWolfParameters>(areaOfInterest);
BursaWolfParameters candidate = select(targetDatum, selector);
if (candidate != null) {
return createTransformation(candidate, areaOfInterest);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
index 233a260..a40f985 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
@@ -34,7 +34,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
index 0bb13ae..f0696bc 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
@@ -43,7 +43,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.referencing.Formulas;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
index 48017ba..a7101e6 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
@@ -37,7 +37,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
index 8080ed4..3b8d552 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
@@ -36,7 +36,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java
index 5d90139..738b9df 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java
@@ -35,7 +35,7 @@
import org.apache.sis.internal.metadata.NameMeaning;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
index 77c43e2..c0e6495 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
@@ -569,7 +569,7 @@
*/
private static final Map<String, AuthorityFactoryProxy<?>> BY_URN_TYPE;
static {
- final Map<String, AuthorityFactoryProxy<?>> map = new HashMap<>(14);
+ final Map<String, AuthorityFactoryProxy<?>> map = new HashMap<String, AuthorityFactoryProxy<?>>(14);
map.put("crs", CRS);
map.put("datum", DATUM);
map.put("ellipsoid", ELLIPSOID);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CacheRecord.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CacheRecord.java
index 70c12ca..dd911ac 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CacheRecord.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CacheRecord.java
@@ -102,7 +102,7 @@
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
static void printCacheContent(final Map<?,?> cache, PrintWriter out) {
- final List<CacheRecord> list = new ArrayList<>(cache.size() + 10);
+ final List<CacheRecord> list = new ArrayList<CacheRecord>(cache.size() + 10);
int codeLength = 0;
int identityLength = 0;
for (final Map.Entry<?,?> entry : cache.entrySet()) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
index e1aa146..51d5be4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
@@ -209,7 +209,7 @@
* @see #getCodeSpaces()
*/
private static final Set<String> CODESPACES = Collections.unmodifiableSet(
- new LinkedHashSet<>(Arrays.asList(Constants.OGC, Constants.CRS, "AUTO", AUTO2)));
+ new LinkedHashSet<String>(Arrays.asList(Constants.OGC, Constants.CRS, "AUTO", AUTO2)));
/**
* The bit for saying that a namespace is the legacy {@code "AUTO"} namespace.
@@ -262,7 +262,7 @@
* Constructs a default factory for the {@code CRS} authority.
*/
public CommonAuthorityFactory() {
- codes = new LinkedHashMap<>();
+ codes = new LinkedHashMap<String,Class<?>>();
}
/**
@@ -291,7 +291,7 @@
static String reformat(final String code) {
try {
return format(Integer.parseInt(code.substring(skipNamespace(code) & ~LEGACY_MASK)));
- } catch (NoSuchAuthorityCodeException | NumberFormatException e) {
+ } catch (Exception e) { // (NoSuchAuthorityCodeException | NumberFormatException) on the JDK7 branch.
Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), CommonAuthorityFactory.class, "reformat", e);
return null;
}
@@ -695,7 +695,7 @@
csFactory.createCoordinateSystemAxis(Collections.singletonMap(CartesianCS.NAME_KEY, "i"), "i", AxisDirection.EAST, NonSI.PIXEL),
csFactory.createCoordinateSystemAxis(Collections.singletonMap(CartesianCS.NAME_KEY, "j"), "j", AxisDirection.SOUTH, NonSI.PIXEL));
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(EngineeringDatum.NAME_KEY, cs.getName());
properties.put(EngineeringDatum.ANCHOR_POINT_KEY, "Origin is in upper left.");
displayCRS = DefaultFactories.forBuildin(CRSFactory.class).createEngineeringCRS(properties,
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
index edc4fb0..70e2d90 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
@@ -61,7 +61,9 @@
import org.apache.sis.util.resources.Messages;
// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
import org.apache.sis.internal.jdk8.JDK8;
+import org.apache.sis.internal.jdk7.AutoCloseable;
/**
@@ -101,15 +103,16 @@
* @version 0.7
* @module
*/
+@AutoCloseable
public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFactory>
- extends GeodeticAuthorityFactory implements AutoCloseable
+ extends GeodeticAuthorityFactory
{
/**
* Duration of data access operations that should be logged, in nanoseconds.
* Any operation that take longer than this amount of time to execute will have a message logged.
* The log level depends on the execution duration as specified in {@link PerformanceLevel}.
*/
- private static final long DURATION_FOR_LOGGING = 10_000_000L; // 10 milliseconds.
+ private static final long DURATION_FOR_LOGGING = 10000000L; // 10 milliseconds.
/**
* The authority, cached after first requested.
@@ -122,7 +125,7 @@
*
* @see #isDefault(Class)
*/
- private final Map<Class<?>,Boolean> inherited = new IdentityHashMap<>();
+ private final Map<Class<?>,Boolean> inherited = new IdentityHashMap<Class<?>,Boolean>();
/**
* The pool of cached objects.
@@ -135,7 +138,7 @@
*
* <p>Every access to this pool must be synchronized on {@code findPool}.</p>
*/
- private final Map<IdentifiedObject,FindEntry> findPool = new WeakHashMap<>();
+ private final Map<IdentifiedObject,FindEntry> findPool = new WeakHashMap<IdentifiedObject,FindEntry>();
/**
* Holds the reference to a Data Access Object used by {@link ConcurrentAuthorityFactory}, together with
@@ -199,14 +202,14 @@
/**
* The Data Access Object in use by the current thread.
*/
- private final ThreadLocal<DataAccessRef<DAO>> currentDAO = new ThreadLocal<>();
+ private final ThreadLocal<DataAccessRef<DAO>> currentDAO = new ThreadLocal<DataAccessRef<DAO>>();
/**
* The Data Access Object instances previously created and released for future reuse.
* Last used factories must be {@linkplain Deque#addLast(Object) added last}.
* This is used as a LIFO stack.
*/
- private final Deque<DataAccessRef<DAO>> availableDAOs = new LinkedList<>();
+ private final Deque<DataAccessRef<DAO>> availableDAOs = new LinkedList<DataAccessRef<DAO>>();
/**
* The amount of Data Access Objects that can still be created. This number is decremented in a block
@@ -236,13 +239,13 @@
*
* @see #getTimeout(TimeUnit)
*/
- private long timeout = 60_000_000_000L; // 1 minute
+ private long timeout = 60000000000L; // 1 minute
/**
* The maximal difference between the scheduled time and the actual time in order to perform the factory disposal,
* in nanoseconds. This is used as a tolerance value for possible wait time inaccuracy.
*/
- static final long TIMEOUT_RESOLUTION = 200_000_000L; // 0.2 second
+ static final long TIMEOUT_RESOLUTION = 200000000L; // 0.2 second
/**
* Constructs an instance with a default number of threads and a default number of entries to keep
@@ -295,7 +298,7 @@
* error unless the above property has been set to 'true'.
*/
remainingDAOs = maxConcurrentQueries;
- cache = new Cache<>(20, maxStrongReferences, false);
+ cache = new Cache<Key,Object>(20, maxStrongReferences, false);
cache.setKeyCollisionAllowed(true);
/*
* The shutdown hook serves two purposes:
@@ -306,7 +309,7 @@
* 2) Closes the Data Access Objects at JVM shutdown time if the application is standalone,
* or when the bundle is uninstalled if running inside an OSGi or Servlet container.
*/
- Shutdown.register(new ShutdownHook<>(this));
+ Shutdown.register(new ShutdownHook<DAO>(this));
}
/**
@@ -394,7 +397,7 @@
e.setUnavailableFactory(this);
throw e;
}
- usage = new DataAccessRef<>(factory);
+ usage = new DataAccessRef<DAO>(factory);
}
assert usage.depth == 0 : usage;
usage.timestamp = System.nanoTime();
@@ -408,7 +411,10 @@
synchronized (availableDAOs) {
remainingDAOs++;
}
- throw e;
+ if (e instanceof FactoryException) throw (FactoryException) e;
+ if (e instanceof RuntimeException) throw (RuntimeException) e;
+ if (e instanceof Error) throw (Error) e;
+ throw new RuntimeException(e); // Should never happen.
}
currentDAO.set(usage);
}
@@ -516,7 +522,7 @@
// Cancel closing for that factory.
it.remove();
synchronized (availableDAOs) {
- recycle(new DataAccessRef<>(factory));
+ recycle(new DataAccessRef<DAO>(factory));
}
}
}
@@ -550,7 +556,7 @@
final List<DAO> factories;
final boolean isEmpty;
synchronized (availableDAOs) {
- factories = new ArrayList<>(availableDAOs.size());
+ factories = new ArrayList<DAO>(availableDAOs.size());
final Iterator<DataAccessRef<DAO>> it = availableDAOs.iterator();
final long nanoTime = System.nanoTime();
while (it.hasNext()) {
@@ -2009,7 +2015,7 @@
*/
static <DAO extends GeodeticAuthorityFactory> List<DAO> clear(final Deque<DataAccessRef<DAO>> availableDAOs) {
assert Thread.holdsLock(availableDAOs);
- final List<DAO> factories = new ArrayList<>(availableDAOs.size());
+ final List<DAO> factories = new ArrayList<DAO>(availableDAOs.size());
DataAccessRef<DAO> dao;
while ((dao = availableDAOs.pollFirst()) != null) {
factories.add(dao.factory);
@@ -2029,13 +2035,13 @@
Exception exception = null;
for (int i=factories.size(); --i>=0;) {
final DAO factory = factories.get(i);
- if (factory instanceof AutoCloseable) try {
- ((AutoCloseable) factory).close();
+ if (JDK7.isAutoCloseable(factory)) try {
+ JDK7.close(factory);
} catch (Exception e) {
if (exception == null) {
exception = e;
} else {
- exception.addSuppressed(e);
+ // exception.addSuppressed(e) on the JDK7 branch.
}
}
}
@@ -2058,7 +2064,6 @@
*
* @throws FactoryException if an error occurred while closing the Data Access Objects.
*/
- @Override
public void close() throws FactoryException {
try {
final List<DAO> factories;
@@ -2095,7 +2100,7 @@
return s;
}
}
- return s + System.lineSeparator() + usage;
+ return s + JDK7.lineSeparator() + usage;
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
index b209f2f..d684be8 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
@@ -257,8 +257,8 @@
properties = CollectionsExt.compact(new HashMap<String,Object>(properties));
}
defaultProperties = properties;
- pool = new WeakHashSet<>(AbstractIdentifiedObject.class);
- parser = new AtomicReference<>();
+ pool = new WeakHashSet<AbstractIdentifiedObject>(AbstractIdentifiedObject.class);
+ parser = new AtomicReference<Parser>();
}
/**
@@ -1629,7 +1629,7 @@
parserConstructor = c;
}
p = c.newInstance(defaultProperties, this, getMathTransformFactory());
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new FactoryException(e);
}
final Object object;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
index 4b0bdc3..dba40c8 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
@@ -490,7 +490,7 @@
* @see #createFromNames(IdentifiedObject)
*/
Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
- final Set<IdentifiedObject> result = new LinkedHashSet<>(); // We need to preserve order.
+ final Set<IdentifiedObject> result = new LinkedHashSet<IdentifiedObject>(); // We need to preserve order.
for (final String code : getCodeCandidates(object)) {
final IdentifiedObject candidate;
try {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
index 04e091a..5ff4bfe 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
@@ -44,7 +44,8 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
+import org.apache.sis.internal.jdk7.JDK7;
import org.apache.sis.internal.jdk8.JDK8;
@@ -95,7 +96,7 @@
* <p><b>Note:</b> using {@code ConcurrentHahMap} would be more efficient.
* But the later does not support null values and does not preserve insertion order.</p>
*/
- final Map<String,T> objects = new LinkedHashMap<>();
+ final Map<String,T> objects = new LinkedHashMap<String,T>();
/**
* The {@link #objects} keys, created for iteration purpose when first needed and cleared when the map is modified.
@@ -227,7 +228,7 @@
public void setAuthorityCodes(final String... codes) {
synchronized (objects) {
this.codes = null;
- final Map<String,T> copy = new HashMap<>(objects);
+ final Map<String,T> copy = new HashMap<String,T>(objects);
objects.clear();
for (final String code : codes) {
objects.put(code, copy.get(code));
@@ -565,7 +566,7 @@
* Returns the message to format below the logging for giving the cause of an error.
*/
private static String getCause(Throwable cause) {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder trace = new StringBuilder(180);
while (cause != null) {
trace.append(lineSeparator).append(" • ").append(Classes.getShortClassName(cause));
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
index 3b5c7eb..cd07b85 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
@@ -229,8 +229,8 @@
else nullMask |= (1 << i);
}
providers = ArraysExt.resize(p, length);
- factories = new ConcurrentHashMap<>();
- warnings = new HashMap<>();
+ factories = new ConcurrentHashMap<AuthorityFactoryIdentifier, AuthorityFactory>();
+ warnings = new HashMap<AuthorityFactoryIdentifier, Boolean>();
isIterationCompleted = new AtomicInteger(nullMask);
}
@@ -310,13 +310,13 @@
private final Iterator<AuthorityFactory> factories = getAllFactories();
/** An iterator over the codes of the current factory. */
- private Iterator<String> codes = Collections.emptyIterator();
+ private Iterator<String> codes = Collections.<String>emptySet().iterator();
/** The prefix to prepend before codes, or {@code null} if none. */
private String prefix;
/** For filtering duplicated codes when there is many versions of the same authority. */
- private final Set<String> done = new HashSet<>();
+ private final Set<String> done = new HashSet<String>();
/** Tests if there is more codes to return. */
@Override public boolean hasNext() {
@@ -350,7 +350,7 @@
/**
* The cache of values returned by {@link #getAuthorityCodes(AuthorityFactory)}.
*/
- private final Map<AuthorityFactory, Set<String>> cache = new IdentityHashMap<>();
+ private final Map<AuthorityFactory, Set<String>> cache = new IdentityHashMap<AuthorityFactory, Set<String>>();
/**
* Returns the authority codes for the given factory.
@@ -394,7 +394,7 @@
public int size() {
if (size < 0) {
int n = 0;
- final Set<String> done = new HashSet<>();
+ final Set<String> done = new HashSet<String>();
for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
final AuthorityFactory factory = it.next();
if (done.add(getCodeSpace(factory))) {
@@ -475,7 +475,7 @@
public Set<String> getCodeSpaces() {
Set<String> union = codeSpaces;
if (union == null) {
- union = new LinkedHashSet<>();
+ union = new LinkedHashSet<String>();
for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
union.addAll(getCodeSpaces(it.next()));
}
@@ -533,7 +533,7 @@
* condition is meet, threads can safely use their iterators concurrently.</p>
*/
final Iterator<AuthorityFactory> getAllFactories() {
- return new LazySynchronizedIterator<>(providers);
+ return new LazySynchronizedIterator<AuthorityFactory>(providers);
}
/**
@@ -1556,8 +1556,8 @@
@Override
final Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
if (finders == null) try {
- final ArrayList<IdentifiedObjectFinder> list = new ArrayList<>();
- final Map<AuthorityFactory,Boolean> unique = new IdentityHashMap<>();
+ final ArrayList<IdentifiedObjectFinder> list = new ArrayList<IdentifiedObjectFinder>();
+ final Map<AuthorityFactory,Boolean> unique = new IdentityHashMap<AuthorityFactory,Boolean>();
final Iterator<AuthorityFactory> it = ((MultiAuthoritiesFactory) factory).getAllFactories();
while (it.hasNext()) {
final AuthorityFactory candidate = it.next();
@@ -1574,7 +1574,7 @@
} catch (BackingStoreException e) {
throw e.unwrapOrRethrow(FactoryException.class);
}
- final Set<IdentifiedObject> found = new LinkedHashSet<>();
+ final Set<IdentifiedObject> found = new LinkedHashSet<IdentifiedObject>();
for (final IdentifiedObjectFinder finder : finders) {
found.addAll(finder.find(object));
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
index 315e633..dd67e19 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
@@ -190,7 +190,7 @@
* See class Javadoc for more information.
*/
final CloseableReference<AuthorityCodes> createReference() {
- return new CloseableReference<>(this, factory, statements);
+ return new CloseableReference<AuthorityCodes>(this, factory, statements);
}
/**
@@ -296,13 +296,16 @@
sql[ONE] = null; // Not needed anymore.
}
statement.setInt(1, n);
- try (ResultSet results = statement.executeQuery()) {
+ final ResultSet results = statement.executeQuery();
+ try {
while (results.next()) {
String name = results.getString(1);
if (name != null) {
return name;
}
}
+ } finally {
+ results.close();
}
}
}
@@ -379,7 +382,7 @@
* The serialized map of authority codes is disconnected from the underlying database.
*/
protected Object writeReplace() throws ObjectStreamException {
- return new LinkedHashMap<>(this);
+ return new LinkedHashMap<String,String>(this);
}
/*
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AxisName.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AxisName.java
index e654b39..20822de 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AxisName.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AxisName.java
@@ -16,7 +16,7 @@
*/
package org.apache.sis.referencing.factory.sql;
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.util.Debug;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/BursaWolfInfo.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/BursaWolfInfo.java
index 76fb17f..f29d7e4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/BursaWolfInfo.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/BursaWolfInfo.java
@@ -199,12 +199,12 @@
static void filter(final GeodeticAuthorityFactory factory, final BursaWolfInfo[] candidates,
final List<BursaWolfInfo> addTo) throws FactoryException
{
- final Map<Integer,ExtentSelector<BursaWolfInfo>> added = new LinkedHashMap<>();
+ final Map<Integer,ExtentSelector<BursaWolfInfo>> added = new LinkedHashMap<Integer,ExtentSelector<BursaWolfInfo>>();
for (BursaWolfInfo candidate : candidates) {
final Integer target = candidate.target;
ExtentSelector<BursaWolfInfo> selector = added.get(target);
if (selector == null) {
- selector = new ExtentSelector<>(null);
+ selector = new ExtentSelector<BursaWolfInfo>(null);
added.put(target, selector);
}
selector.evaluate(candidate.getDomainOfValidity(factory), candidate);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CloseableReference.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CloseableReference.java
index 9a6c327..07ffd9c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CloseableReference.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CloseableReference.java
@@ -73,7 +73,7 @@
if (exception == null) {
exception = e;
} else {
- exception.addSuppressed(e);
+ // exception.addSuppressed(e) on the JDK7 branch.
}
}
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
index f43b913..88569ef 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
@@ -49,7 +49,7 @@
*/
CoordinateOperationSet(final AuthorityFactory factory) {
super(factory, CoordinateOperation.class);
- projections = new HashMap<>();
+ projections = new HashMap<String,Integer>();
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 8bedf04..91b8ce8 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -119,7 +119,9 @@
import static org.apache.sis.internal.referencing.ServicesForMetadata.CONNECTION;
// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
import org.apache.sis.internal.jdk8.JDK8;
+import org.apache.sis.internal.jdk7.AutoCloseable;
import org.apache.sis.internal.util.StandardDateFormat;
@@ -163,8 +165,9 @@
*
* @see <a href="http://sis.apache.org/tables/CoordinateReferenceSystems.html">List of authority codes</a>
*/
+@AutoCloseable
public class EPSGDataAccess extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
- CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized, AutoCloseable
+ CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
{
/**
* The deprecated ellipsoidal coordinate systems and their replacements. Those coordinate systems are deprecated
@@ -181,7 +184,7 @@
@Workaround(library = "EPSG:6401-6420", version = "8.9") // Deprecated in 2002 but still present in 2016.
private static final Map<Integer,Integer> DEPRECATED_CS = deprecatedCS();
static Map<Integer,Integer> deprecatedCS() {
- final Map<Integer,Integer> m = new HashMap<>(24);
+ final Map<Integer,Integer> m = new HashMap<Integer,Integer>(24);
// Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree
Integer replacement = 6422;
@@ -232,7 +235,7 @@
* A pool of prepared statements. Keys are {@link String} objects related to their originating method
* (for example "Ellipsoid" for {@link #createEllipsoid(String)}).
*/
- private final Map<String,PreparedStatement> statements = new HashMap<>();
+ private final Map<String,PreparedStatement> statements = new HashMap<String,PreparedStatement>();
/**
* The set of authority codes for different types. This map is used by the {@link #getAuthorityCodes(Class)}
@@ -250,7 +253,7 @@
* and returns {@code false} if some are found (thus blocking the call to {@link #close()}
* by the {@link org.apache.sis.referencing.factory.ConcurrentAuthorityFactory} timer).</p>
*/
- private final Map<Class<?>, CloseableReference<AuthorityCodes>> authorityCodes = new HashMap<>();
+ private final Map<Class<?>, CloseableReference<AuthorityCodes>> authorityCodes = new HashMap<Class<?>, CloseableReference<AuthorityCodes>>();
/**
* Cache for axis names. This service is not provided by {@code ConcurrentAuthorityFactory}
@@ -258,7 +261,7 @@
*
* @see #getAxisName(int)
*/
- private final Map<Integer,AxisName> axisNames = new HashMap<>();
+ private final Map<Integer,AxisName> axisNames = new HashMap<Integer,AxisName>();
/**
* Cache for the number of dimensions of coordinate systems. This service is not provided by
@@ -266,7 +269,7 @@
*
* @see #getDimensionForCS(int)
*/
- private final Map<Integer,Integer> csDimensions = new HashMap<>();
+ private final Map<Integer,Integer> csDimensions = new HashMap<Integer,Integer>();
/**
* Cache for whether conversions are projections. This service is not provided by {@code ConcurrentAuthorityFactory}
@@ -274,7 +277,7 @@
*
* @see #isProjection(int)
*/
- private final Map<Integer,Boolean> isProjection = new HashMap<>();
+ private final Map<Integer,Boolean> isProjection = new HashMap<Integer,Boolean>();
/**
* Cache of naming systems other than EPSG. There is usually few of them (at most 15).
@@ -282,13 +285,13 @@
*
* @see #createProperties(String, String, String, String, boolean)
*/
- private final Map<String,NameSpace> namingSystems = new HashMap<>();
+ private final Map<String,NameSpace> namingSystems = new HashMap<String,NameSpace>();
/**
* The properties to be given the objects to construct.
* Reused every time {@code createProperties(…)} is invoked.
*/
- private final Map<String,Object> properties = new HashMap<>();
+ private final Map<String,Object> properties = new HashMap<String,Object>();
/**
* A safety guard for preventing never-ending loops in recursive calls to some {@code createFoo(String)} methods.
@@ -302,7 +305,7 @@
*
* Keys are EPSG codes and values are the type of object being constructed (but those values are not yet used).
*/
- private final Map<Integer,Class<?>> safetyGuard = new HashMap<>();
+ private final Map<Integer,Class<?>> safetyGuard = new HashMap<Integer,Class<?>>();
/**
* {@code true} for disabling the logging of warnings when this factory creates deprecated objects.
@@ -427,9 +430,9 @@
final String query = translator.apply("SELECT VERSION_NUMBER, VERSION_DATE FROM [Version History]" +
" ORDER BY VERSION_DATE DESC, VERSION_HISTORY_CODE DESC");
String version = null;
- try (Statement statement = connection.createStatement();
- ResultSet result = statement.executeQuery(query))
- {
+ final Statement statement = connection.createStatement();
+ final ResultSet result = statement.executeQuery(query);
+ try {
while (result.next()) {
version = getOptionalString(result, 1);
final Date date = result.getDate(2); // Local timezone.
@@ -439,6 +442,9 @@
break;
}
}
+ } finally {
+ result.close();
+ statement.close();
}
/*
* Add some hard-coded links to EPSG resources, and finally add the JDBC driver name and version number.
@@ -582,7 +588,7 @@
result = codes;
} else {
if (result instanceof AuthorityCodes) {
- result = new LinkedHashMap<>(result);
+ result = new LinkedHashMap<String,String>(result);
}
result.putAll(codes);
}
@@ -705,12 +711,15 @@
}
statement.setString(1, toLikePattern(code));
Integer resolved = null;
- try (ResultSet result = statement.executeQuery()) {
+ final ResultSet result = statement.executeQuery();
+ try {
while (result.next()) {
if (SQLUtilities.filterFalsePositive(code, result.getString(2))) {
resolved = ensureSingleton(getOptionalInteger(result, 1), resolved, code);
}
}
+ } finally {
+ result.close();
}
if (resolved != null) {
primaryKeys[i] = resolved;
@@ -1011,10 +1020,10 @@
private String getSupersession(final String table, final Integer code, final Locale locale) throws SQLException {
String reason = null;
Object replacedBy = null;
- try (ResultSet result = executeQuery("Deprecation",
+ final ResultSet result = executeQuery("Deprecation",
"SELECT OBJECT_TABLE_NAME, DEPRECATION_REASON, REPLACED_BY" +
- " FROM [Deprecation] WHERE OBJECT_CODE = ?", code))
- {
+ " FROM [Deprecation] WHERE OBJECT_CODE = ?", code);
+ try {
while (result.next()) {
if (tableMatches(table, result.getString(1))) {
reason = getOptionalString (result, 2);
@@ -1022,6 +1031,8 @@
break;
}
}
+ } finally {
+ result.close();
}
if (replacedBy == null) {
replacedBy = '(' + Vocabulary.getResources(locale).getString(Vocabulary.Keys.None).toLowerCase(locale) + ')';
@@ -1076,14 +1087,14 @@
* - We do not perform this replacement directly in our EPSG database because ASCII letters are more
* convenient for implementing accent-insensitive searches.
*/
- final List<GenericName> aliases = new ArrayList<>();
- try (ResultSet result = executeQuery("Alias",
+ final List<GenericName> aliases = new ArrayList<GenericName>();
+ final ResultSet result = executeQuery("Alias",
"SELECT OBJECT_TABLE_NAME, NAMING_SYSTEM_NAME, ALIAS" +
" FROM [Alias] INNER JOIN [Naming System]" +
" ON [Alias].NAMING_SYSTEM_CODE =" +
" [Naming System].NAMING_SYSTEM_CODE" +
- " WHERE OBJECT_CODE = ?", code))
- {
+ " WHERE OBJECT_CODE = ?", code);
+ try {
while (result.next()) {
if (tableMatches(table, result.getString(1))) {
final String naming = getOptionalString(result, 2);
@@ -1103,6 +1114,8 @@
}
}
}
+ } finally {
+ result.close();
}
/*
* At this point we can fill the properties map.
@@ -1228,7 +1241,8 @@
}
query.append(" FROM ").append(table.table)
.append(" WHERE ").append(column).append(isPrimaryKey ? " = ?" : " LIKE ?");
- try (PreparedStatement stmt = connection.prepareStatement(translator.apply(query.toString()))) {
+ final PreparedStatement stmt = connection.prepareStatement(translator.apply(query.toString()));
+ try {
/*
* Check if at least one record is found for the code or the name.
* Ensure that there is not two values for the same code or name.
@@ -1239,12 +1253,15 @@
stmt.setString(1, toLikePattern(code));
}
Integer present = null;
- try (ResultSet result = stmt.executeQuery()) {
+ final ResultSet result = stmt.executeQuery();
+ try {
while (result.next()) {
if (isPrimaryKey || SQLUtilities.filterFalsePositive(code, result.getString(2))) {
present = ensureSingleton(getOptionalInteger(result, 1), present, code);
}
}
+ } finally {
+ result.close();
}
if (present != null) {
if (found >= 0) {
@@ -1252,6 +1269,8 @@
}
found = i;
}
+ } finally {
+ stmt.close();
}
}
} catch (SQLException exception) {
@@ -1308,7 +1327,9 @@
{
ArgumentChecks.ensureNonNull("code", code);
CoordinateReferenceSystem returnValue = null;
- try (ResultSet result = executeQuery("Coordinate Reference System", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Coordinate Reference System", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME",
"SELECT COORD_REF_SYS_CODE," + // [ 1]
" COORD_REF_SYS_NAME," + // [ 2]
" AREA_OF_USE_CODE," + // [ 3]
@@ -1323,8 +1344,8 @@
" CMPD_HORIZCRS_CODE," + // [12] For CompoundCRS only
" CMPD_VERTCRS_CODE" + // [13] For CompoundCRS only
" FROM [Coordinate Reference System]" +
- " WHERE COORD_REF_SYS_CODE = ?", code))
- {
+ " WHERE COORD_REF_SYS_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -1342,15 +1363,16 @@
*/
final CRSFactory crsFactory = owner.crsFactory;
final CoordinateReferenceSystem crs;
- switch (type.toLowerCase(Locale.US)) {
+ { // On the JDK7 branch, this is a switch on strings.
/* ----------------------------------------------------------------------
* GEOGRAPHIC CRS
*
* NOTE: 'createProperties' MUST be invoked after any call to an other
* 'createFoo' method. Consequently, do not factor out.
* ---------------------------------------------------------------------- */
- case "geographic 2d":
- case "geographic 3d": {
+ if (type.equalsIgnoreCase("geographic 2d") ||
+ type.equalsIgnoreCase("geographic 3d"))
+ {
Integer csCode = getInteger(code, result, 8);
if (replaceDeprecatedCS) {
csCode = JDK8.getOrDefault(DEPRECATED_CS, csCode, csCode);
@@ -1372,7 +1394,6 @@
}
crs = crsFactory.createGeographicCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), datum, cs);
- break;
}
/* ----------------------------------------------------------------------
* PROJECTED CRS
@@ -1380,7 +1401,7 @@
* NOTE: This method invokes itself indirectly, through createGeographicCRS.
* Consequently we can not use 'result' anymore after this block.
* ---------------------------------------------------------------------- */
- case "projected": {
+ else if (type.equalsIgnoreCase("projected")) {
final String csCode = getString(code, result, 8);
final String geoCode = getString(code, result, 10);
final String opCode = getString(code, result, 11);
@@ -1452,17 +1473,15 @@
} finally {
endOfRecursivity(ProjectedCRS.class, epsg);
}
- break;
}
/* ----------------------------------------------------------------------
* VERTICAL CRS
* ---------------------------------------------------------------------- */
- case "vertical": {
+ else if (type.equalsIgnoreCase("vertical")) {
final VerticalCS cs = owner.createVerticalCS (getString(code, result, 8));
final VerticalDatum datum = owner.createVerticalDatum(getString(code, result, 9));
crs = crsFactory.createVerticalCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), datum, cs);
- break;
}
/* ----------------------------------------------------------------------
* TEMPORAL CRS
@@ -1470,13 +1489,11 @@
* NOTE : The original EPSG database does not define any temporal CRS.
* This block is a SIS-specific extension.
* ---------------------------------------------------------------------- */
- case "time":
- case "temporal": {
+ else if (type.equalsIgnoreCase("time") || type.equalsIgnoreCase("temporal")) {
final TimeCS cs = owner.createTimeCS (getString(code, result, 8));
final TemporalDatum datum = owner.createTemporalDatum(getString(code, result, 9));
crs = crsFactory.createTemporalCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), datum, cs);
- break;
}
/* ----------------------------------------------------------------------
* COMPOUND CRS
@@ -1484,7 +1501,7 @@
* NOTE: This method invokes itself recursively.
* Consequently, we can not use 'result' anymore.
* ---------------------------------------------------------------------- */
- case "compound": {
+ else if (type.equalsIgnoreCase("compound")) {
final String code1 = getString(code, result, 12);
final String code2 = getString(code, result, 13);
result.close();
@@ -1499,12 +1516,11 @@
// Note: Do not invoke 'createProperties' sooner.
crs = crsFactory.createCompoundCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), crs1, crs2);
- break;
}
/* ----------------------------------------------------------------------
* GEOCENTRIC CRS
* ---------------------------------------------------------------------- */
- case "geocentric": {
+ else if (type.equalsIgnoreCase("geocentric")) {
final CoordinateSystem cs = owner.createCoordinateSystem(getString(code, result, 8));
final GeodeticDatum datum = owner.createGeodeticDatum (getString(code, result, 9));
final Map<String,Object> properties = createProperties("Coordinate Reference System",
@@ -1517,32 +1533,29 @@
throw new FactoryDataException(error().getString(
Errors.Keys.IllegalCoordinateSystem_1, cs.getName()));
}
- break;
}
/* ----------------------------------------------------------------------
* ENGINEERING CRS
* ---------------------------------------------------------------------- */
- case "engineering": {
+ else if (type.equalsIgnoreCase("engineering")) {
final CoordinateSystem cs = owner.createCoordinateSystem(getString(code, result, 8));
final EngineeringDatum datum = owner.createEngineeringDatum(getString(code, result, 9));
crs = crsFactory.createEngineeringCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), datum, cs);
- break;
}
/* ----------------------------------------------------------------------
* PARAMETRIC CRS
* ---------------------------------------------------------------------- */
- case "parametric": {
+ else if (type.equalsIgnoreCase("engineering")) {
final ParametricCS cs = owner.createParametricCS (getString(code, result, 8));
final ParametricDatum datum = owner.createParametricDatum(getString(code, result, 9));
crs = crsFactory.createParametricCRS(createProperties("Coordinate Reference System",
name, epsg, area, scope, remarks, deprecated), datum, cs);
- break;
}
/* ----------------------------------------------------------------------
* UNKNOWN CRS
* ---------------------------------------------------------------------- */
- default: {
+ else {
throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
}
}
@@ -1553,6 +1566,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(CoordinateReferenceSystem.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(CoordinateReferenceSystem.class, code);
@@ -1585,7 +1604,9 @@
public synchronized Datum createDatum(final String code) throws NoSuchAuthorityCodeException, FactoryException {
ArgumentChecks.ensureNonNull("code", code);
Datum returnValue = null;
- try (ResultSet result = executeQuery("Datum", "DATUM_CODE", "DATUM_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Datum", "DATUM_CODE", "DATUM_NAME",
"SELECT DATUM_CODE," +
" DATUM_NAME," +
" DATUM_TYPE," +
@@ -1598,8 +1619,8 @@
" ELLIPSOID_CODE," + // Only for geodetic type
" PRIME_MERIDIAN_CODE" + // Only for geodetic type
" FROM [Datum]" +
- " WHERE DATUM_CODE = ?", code))
- {
+ " WHERE DATUM_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -1629,14 +1650,14 @@
*/
final DatumFactory datumFactory = owner.datumFactory;
final Datum datum;
- switch (type.toLowerCase(Locale.US)) {
+ { // On the JDK7 branch, this is a switch on strings.
/*
* The "geodetic" case invokes createProperties(…) indirectly through calls to
* createEllipsoid(String) and createPrimeMeridian(String), so we must protect
* the properties map from changes.
*/
- case "geodetic": {
- properties = new HashMap<>(properties); // Protect from changes
+ if (type.equalsIgnoreCase("geodetic")) {
+ properties = new HashMap<String,Object>(properties); // Protect from changes
final Ellipsoid ellipsoid = owner.createEllipsoid (getString(code, result, 10));
final PrimeMeridian meridian = owner.createPrimeMeridian(getString(code, result, 11));
final BursaWolfParameters[] param = createBursaWolfParameters(meridian, epsg);
@@ -1644,7 +1665,6 @@
properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, param);
}
datum = datumFactory.createGeodeticDatum(properties, ellipsoid, meridian);
- break;
}
/*
* Vertical datum type is hard-coded to geoidal. It would be possible to infer other
@@ -1652,15 +1672,14 @@
* associated to the same EPSG code. Since vertical datum type is no longer part of
* ISO 19111:2007, it is probably not worth to handle such cases.
*/
- case "vertical": {
+ else if (type.equalsIgnoreCase("vertical")) {
datum = datumFactory.createVerticalDatum(properties, VerticalDatumType.GEOIDAL);
- break;
}
/*
* Origin date is stored in ORIGIN_DESCRIPTION field. A column of SQL type
* "date" type would have been better, but we do not modify the EPSG model.
*/
- case "temporal": {
+ else if (type.equalsIgnoreCase("temporal")) {
final Date originDate;
if (anchor == null || anchor.isEmpty()) {
throw new FactoryDataException(error().getString(Errors.Keys.DatumOriginShallBeDate));
@@ -1675,20 +1694,17 @@
throw new FactoryDataException(error().getString(Errors.Keys.DatumOriginShallBeDate), e);
}
datum = datumFactory.createTemporalDatum(properties, originDate);
- break;
}
/*
* Straightforward case.
*/
- case "engineering": {
+ else if (type.equalsIgnoreCase("engineering")) {
datum = datumFactory.createEngineeringDatum(properties);
- break;
}
- case "parametric": {
+ else if (type.equalsIgnoreCase("parametric")) {
datum = datumFactory.createParametricDatum(properties);
- break;
}
- default: {
+ else {
throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
}
}
@@ -1699,6 +1715,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(Datum.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(Datum.class, code);
@@ -1729,8 +1751,8 @@
if (code == BursaWolfInfo.TARGET_DATUM) {
return null;
}
- final List<BursaWolfInfo> bwInfos = new ArrayList<>();
- try (ResultSet result = executeQuery("BursaWolfParametersSet",
+ final List<BursaWolfInfo> bwInfos = new ArrayList<BursaWolfInfo>();
+ ResultSet result = executeQuery("BursaWolfParametersSet",
"SELECT COORD_OP_CODE," +
" COORD_OP_METHOD_CODE," +
" TARGET_CRS_CODE," +
@@ -1742,8 +1764,8 @@
" AND COORD_OP_METHOD_CODE <= " + BursaWolfInfo.MAX_METHOD_CODE +
" AND SOURCE_CRS_CODE IN " +
"(SELECT COORD_REF_SYS_CODE FROM [Coordinate Reference System] WHERE DATUM_CODE = ?)" +
- " ORDER BY TARGET_CRS_CODE, COORD_OP_ACCURACY, COORD_OP_CODE DESC", code))
- {
+ " ORDER BY TARGET_CRS_CODE, COORD_OP_ACCURACY, COORD_OP_CODE DESC", code);
+ try {
while (result.next()) {
final BursaWolfInfo info = new BursaWolfInfo(
getInteger(code, result, 1), // Operation
@@ -1754,6 +1776,8 @@
bwInfos.add(info);
}
}
+ } finally {
+ result.close();
}
int size = bwInfos.size();
if (size == 0) {
@@ -1797,20 +1821,22 @@
continue;
}
final BursaWolfParameters bwp = new BursaWolfParameters(datum, info.getDomainOfValidity(owner));
- try (ResultSet result = executeQuery("BursaWolfParameters",
+ result = executeQuery("BursaWolfParameters",
"SELECT PARAMETER_CODE," +
" PARAMETER_VALUE," +
" UOM_CODE" +
" FROM [Coordinate_Operation Parameter Value]" +
" WHERE COORD_OP_CODE = ?" +
- " AND COORD_OP_METHOD_CODE = ?", info.operation, info.method))
- {
+ " AND COORD_OP_METHOD_CODE = ?", info.operation, info.method);
+ try {
while (result.next()) {
BursaWolfInfo.setBursaWolfParameter(bwp,
getInteger(info.operation, result, 1),
getDouble (info.operation, result, 2),
owner.createUnit(getString(info.operation, result, 3)), locale);
}
+ } finally {
+ result.close();
}
if (info.isFrameRotation()) {
// Coordinate frame rotation (9607): same as 9606,
@@ -1851,7 +1877,9 @@
{
ArgumentChecks.ensureNonNull("code", code);
Ellipsoid returnValue = null;
- try (ResultSet result = executeQuery("Ellipsoid", "ELLIPSOID_CODE", "ELLIPSOID_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Ellipsoid", "ELLIPSOID_CODE", "ELLIPSOID_NAME",
"SELECT ELLIPSOID_CODE," +
" ELLIPSOID_NAME," +
" SEMI_MAJOR_AXIS," +
@@ -1861,8 +1889,8 @@
" REMARKS," +
" DEPRECATED" +
" FROM [Ellipsoid]" +
- " WHERE ELLIPSOID_CODE = ?", code))
- {
+ " WHERE ELLIPSOID_CODE = ?", code);
+
while (result.next()) {
/*
* One of 'semiMinorAxis' and 'inverseFlattening' values can be NULL in the database.
@@ -1904,6 +1932,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(Ellipsoid.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(Ellipsoid.class, code);
@@ -1940,7 +1974,9 @@
{
ArgumentChecks.ensureNonNull("code", code);
PrimeMeridian returnValue = null;
- try (ResultSet result = executeQuery("Prime Meridian", "PRIME_MERIDIAN_CODE", "PRIME_MERIDIAN_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Prime Meridian", "PRIME_MERIDIAN_CODE", "PRIME_MERIDIAN_NAME",
"SELECT PRIME_MERIDIAN_CODE," +
" PRIME_MERIDIAN_NAME," +
" GREENWICH_LONGITUDE," +
@@ -1948,8 +1984,8 @@
" REMARKS," +
" DEPRECATED" +
" FROM [Prime Meridian]" +
- " WHERE PRIME_MERIDIAN_CODE = ?", code))
- {
+ " WHERE PRIME_MERIDIAN_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -1964,6 +2000,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(PrimeMeridian.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(PrimeMeridian.class, code);
@@ -1998,15 +2040,17 @@
{
ArgumentChecks.ensureNonNull("code", code);
Extent returnValue = null;
- try (ResultSet result = executeQuery("Area", "AREA_CODE", "AREA_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Area", "AREA_CODE", "AREA_NAME",
"SELECT AREA_OF_USE," +
" AREA_SOUTH_BOUND_LAT," +
" AREA_NORTH_BOUND_LAT," +
" AREA_WEST_BOUND_LON," +
" AREA_EAST_BOUND_LON" +
" FROM [Area]" +
- " WHERE AREA_CODE = ?", code))
- {
+ " WHERE AREA_CODE = ?", code);
+
while (result.next()) {
final String description = getOptionalString(result, 1);
double ymin = getOptionalDouble(result, 2);
@@ -2037,6 +2081,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(Extent.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(Extent.class, code);
@@ -2077,7 +2127,9 @@
{
ArgumentChecks.ensureNonNull("code", code);
CoordinateSystem returnValue = null;
- try (ResultSet result = executeQuery("Coordinate System", "COORD_SYS_CODE", "COORD_SYS_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Coordinate System", "COORD_SYS_CODE", "COORD_SYS_NAME",
"SELECT COORD_SYS_CODE," +
" COORD_SYS_NAME," +
" COORD_SYS_TYPE," +
@@ -2085,8 +2137,8 @@
" REMARKS," +
" DEPRECATED" +
" FROM [Coordinate System]" +
- " WHERE COORD_SYS_CODE = ?", code))
- {
+ " WHERE COORD_SYS_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -2102,73 +2154,61 @@
*/
final CSFactory csFactory = owner.csFactory;
CoordinateSystem cs = null;
- switch (type.toLowerCase(Locale.US)) {
- case WKTKeywords.ellipsoidal: {
+ { // On the JDK7 branch, this is a switch on strings.
+ if (type.equalsIgnoreCase(WKTKeywords.ellipsoidal)) {
switch (dimension) {
case 2: cs = csFactory.createEllipsoidalCS(properties, axes[0], axes[1]); break;
case 3: cs = csFactory.createEllipsoidalCS(properties, axes[0], axes[1], axes[2]); break;
}
- break;
}
- case "cartesian": { // Need lower-case "c"
+ else if (type.equalsIgnoreCase("cartesian")) { // Need lower-case "c"
switch (dimension) {
case 2: cs = csFactory.createCartesianCS(properties, axes[0], axes[1]); break;
case 3: cs = csFactory.createCartesianCS(properties, axes[0], axes[1], axes[2]); break;
}
- break;
}
- case WKTKeywords.spherical: {
+ else if (type.equalsIgnoreCase(WKTKeywords.spherical)) {
switch (dimension) {
case 3: cs = csFactory.createSphericalCS(properties, axes[0], axes[1], axes[2]); break;
}
- break;
}
- case WKTKeywords.vertical:
- case "gravity-related": {
+ else if (type.equalsIgnoreCase(WKTKeywords.vertical) || type.equalsIgnoreCase("gravity-related")) {
switch (dimension) {
case 1: cs = csFactory.createVerticalCS(properties, axes[0]); break;
}
- break;
}
- case "time":
- case WKTKeywords.temporal: {
+ else if (type.equalsIgnoreCase("time") || type.equalsIgnoreCase(WKTKeywords.temporal)) {
switch (dimension) {
case 1: cs = csFactory.createTimeCS(properties, axes[0]); break;
}
- break;
}
- case WKTKeywords.parametric: {
+ else if (type.equalsIgnoreCase(WKTKeywords.parametric)) {
switch (dimension) {
case 1: cs = csFactory.createParametricCS(properties, axes[0]); break;
}
- break;
}
- case WKTKeywords.linear: {
+ else if (type.equalsIgnoreCase(WKTKeywords.linear)) {
switch (dimension) {
case 1: cs = csFactory.createLinearCS(properties, axes[0]); break;
}
- break;
}
- case WKTKeywords.polar: {
+ else if (type.equalsIgnoreCase(WKTKeywords.polar)) {
switch (dimension) {
case 2: cs = csFactory.createPolarCS(properties, axes[0], axes[1]); break;
}
- break;
}
- case WKTKeywords.cylindrical: {
+ else if (type.equalsIgnoreCase(WKTKeywords.cylindrical)) {
switch (dimension) {
case 3: cs = csFactory.createCylindricalCS(properties, axes[0], axes[1], axes[2]); break;
}
- break;
}
- case WKTKeywords.affine: {
+ else if (type.equalsIgnoreCase(WKTKeywords.affine)) {
switch (dimension) {
case 2: cs = csFactory.createAffineCS(properties, axes[0], axes[1]); break;
case 3: cs = csFactory.createAffineCS(properties, axes[0], axes[1], axes[2]); break;
}
- break;
}
- default: {
+ else {
throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
}
}
@@ -2179,6 +2219,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(CoordinateSystem.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(CoordinateSystem.class, code);
@@ -2197,13 +2243,15 @@
private Integer getDimensionForCS(final Integer cs) throws SQLException {
Integer dimension = csDimensions.get(cs);
if (dimension == null) {
- try (ResultSet result = executeQuery("Dimension",
+ final ResultSet result = executeQuery("Dimension",
" SELECT COUNT(COORD_AXIS_CODE)" +
" FROM [Coordinate Axis]" +
- " WHERE COORD_SYS_CODE = ?", cs))
- {
+ " WHERE COORD_SYS_CODE = ?", cs);
+ try {
dimension = result.next() ? result.getInt(1) : 0;
csDimensions.put(cs, dimension);
+ } finally {
+ result.close();
}
}
return (dimension != 0) ? dimension : null;
@@ -2226,12 +2274,12 @@
{
int i = 0;
final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[dimension];
- try (ResultSet result = executeQuery("AxisOrder",
+ final ResultSet result = executeQuery("AxisOrder",
"SELECT COORD_AXIS_CODE" +
" FROM [Coordinate Axis]" +
" WHERE COORD_SYS_CODE = ?" +
- " ORDER BY [ORDER]", cs))
- {
+ " ORDER BY [ORDER]", cs);
+ try {
while (result.next()) {
final String axis = getString(cs, result, 1);
if (i < axes.length) {
@@ -2243,6 +2291,8 @@
}
++i;
}
+ } finally {
+ result.close();
}
if (i != axes.length) {
throw new FactoryDataException(error().getString(Errors.Keys.MismatchedDimension_2, axes.length, i));
@@ -2278,15 +2328,17 @@
{
ArgumentChecks.ensureNonNull("code", code);
CoordinateSystemAxis returnValue = null;
- try (ResultSet result = executeQuery("Coordinate Axis", "COORD_AXIS_CODE", null,
+ ResultSet result = null;
+ try {
+ result = executeQuery("Coordinate Axis", "COORD_AXIS_CODE", null,
"SELECT COORD_AXIS_CODE," +
" COORD_AXIS_NAME_CODE," +
" COORD_AXIS_ORIENTATION," +
" COORD_AXIS_ABBREVIATION," +
" UOM_CODE" +
" FROM [Coordinate Axis]" +
- " WHERE COORD_AXIS_CODE = ?", code))
- {
+ " WHERE COORD_AXIS_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger(code, result, 1);
final Integer nameCode = getInteger(code, result, 2);
@@ -2307,6 +2359,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(CoordinateSystemAxis.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(CoordinateSystemAxis.class, code);
@@ -2322,11 +2380,11 @@
assert Thread.holdsLock(this);
AxisName returnValue = axisNames.get(code);
if (returnValue == null) {
- try (ResultSet result = executeQuery("Coordinate Axis Name",
+ final ResultSet result = executeQuery("Coordinate Axis Name",
"SELECT COORD_AXIS_NAME, DESCRIPTION, REMARKS" +
" FROM [Coordinate Axis Name]" +
- " WHERE COORD_AXIS_NAME_CODE = ?", code))
- {
+ " WHERE COORD_AXIS_NAME_CODE = ?", code);
+ try {
while (result.next()) {
final String name = getString(code, result, 1);
String description = getOptionalString(result, 2);
@@ -2334,11 +2392,13 @@
if (description == null) {
description = remarks;
} else if (remarks != null) {
- description += System.lineSeparator() + remarks;
+ description += JDK7.lineSeparator() + remarks;
}
final AxisName axis = new AxisName(name, description);
returnValue = ensureSingleton(axis, returnValue, code);
}
+ } finally {
+ result.close();
}
if (returnValue == null) {
throw noSuchAuthorityCode(AxisName.class, String.valueOf(code));
@@ -2376,15 +2436,17 @@
public synchronized Unit<?> createUnit(final String code) throws NoSuchAuthorityCodeException, FactoryException {
ArgumentChecks.ensureNonNull("code", code);
Unit<?> returnValue = null;
- try (ResultSet result = executeQuery("Unit of Measure", "UOM_CODE", "UNIT_OF_MEAS_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Unit of Measure", "UOM_CODE", "UNIT_OF_MEAS_NAME",
"SELECT UOM_CODE," +
" FACTOR_B," +
" FACTOR_C," +
" TARGET_UOM_CODE," +
" UNIT_OF_MEAS_NAME" +
" FROM [Unit of Measure]" +
- " WHERE UOM_CODE = ?", code))
- {
+ " WHERE UOM_CODE = ?", code);
+
while (result.next()) {
final int source = getInteger(code, result, 1);
final double b = getOptionalDouble(result, 2);
@@ -2416,6 +2478,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(Unit.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(Unit.class, code);
@@ -2451,14 +2519,16 @@
{
ArgumentChecks.ensureNonNull("code", code);
ParameterDescriptor<?> returnValue = null;
- try (ResultSet result = executeQuery("Coordinate_Operation Parameter", "PARAMETER_CODE", "PARAMETER_NAME",
- "SELECT PARAMETER_CODE," +
- " PARAMETER_NAME," +
- " DESCRIPTION," +
- " DEPRECATED" +
- " FROM [Coordinate_Operation Parameter]" +
- " WHERE PARAMETER_CODE = ?", code))
- {
+ ResultSet result = null;
+ try {
+ result = executeQuery("Coordinate_Operation Parameter", "PARAMETER_CODE", "PARAMETER_NAME",
+ "SELECT PARAMETER_CODE," +
+ " PARAMETER_NAME," +
+ " DESCRIPTION," +
+ " DEPRECATED" +
+ " FROM [Coordinate_Operation Parameter]" +
+ " WHERE PARAMETER_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -2469,10 +2539,10 @@
* If the parameter appears to have at least one non-null value in the "Parameter File Name" column,
* then the type is assumed to be URI as a string. Otherwise, the type is a floating point number.
*/
- try (ResultSet r = executeQuery("ParameterType",
+ ResultSet r = executeQuery("ParameterType",
"SELECT PARAM_VALUE_FILE_REF FROM [Coordinate_Operation Parameter Value]" +
- " WHERE (PARAMETER_CODE = ?) AND PARAM_VALUE_FILE_REF IS NOT NULL", epsg))
- {
+ " WHERE (PARAMETER_CODE = ?) AND PARAM_VALUE_FILE_REF IS NOT NULL", epsg);
+ try {
while (r.next()) {
String element = getOptionalString(r, 1);
if (element != null && !element.isEmpty()) {
@@ -2480,6 +2550,8 @@
break;
}
}
+ } finally {
+ r.close();
}
/*
* Search for units. We typically have many different units but all of the same dimension
@@ -2489,13 +2561,13 @@
* (EPSG:8617) parameter value may be in metres or in degrees. In such case the units Set
* will have two elements.
*/
- final Set<Unit<?>> units = new LinkedHashSet<>();
- try (ResultSet r = executeQuery("ParameterUnit",
+ final Set<Unit<?>> units = new LinkedHashSet<Unit<?>>();
+ r = executeQuery("ParameterUnit",
"SELECT UOM_CODE FROM [Coordinate_Operation Parameter Value]" +
" WHERE (PARAMETER_CODE = ?)" +
" GROUP BY UOM_CODE" +
- " ORDER BY COUNT(UOM_CODE) DESC", epsg))
- {
+ " ORDER BY COUNT(UOM_CODE) DESC", epsg);
+ try {
next: while (r.next()) {
final String c = getOptionalString(r, 1);
if (c != null) {
@@ -2508,6 +2580,8 @@
units.add(candidate);
}
}
+ } finally {
+ r.close();
}
/*
* Determines if the inverse operation can be performed by reversing the parameter sign.
@@ -2515,10 +2589,10 @@
* to accept both.
*/
InternationalString isReversible = null;
- try (ResultSet r = executeQuery("ParameterSign",
+ r = executeQuery("ParameterSign",
"SELECT DISTINCT PARAM_SIGN_REVERSAL FROM [Coordinate_Operation Parameter Usage]" +
- " WHERE (PARAMETER_CODE = ?)", epsg))
- {
+ " WHERE (PARAMETER_CODE = ?)", epsg);
+ try {
if (r.next()) {
final String v = r.getString(1);
if (v != null && !r.next()) {
@@ -2529,6 +2603,8 @@
}
}
}
+ } finally {
+ r.close();
}
/*
* Now creates the parameter descriptor.
@@ -2543,12 +2619,19 @@
final Map<String, Object> properties =
createProperties("Coordinate_Operation Parameter", name, epsg, isReversible, deprecated);
properties.put(Identifier.DESCRIPTION_KEY, description);
- final ParameterDescriptor<?> descriptor = new DefaultParameterDescriptor<>(properties,
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ final ParameterDescriptor<?> descriptor = new DefaultParameterDescriptor(properties,
1, 1, type, valueDomain, null, null);
returnValue = ensureSingleton(descriptor, returnValue, code);
}
} catch (SQLException exception) {
throw databaseFailure(OperationMethod.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(OperationMethod.class, code);
@@ -2564,16 +2647,18 @@
* @throws SQLException if a SQL statement failed.
*/
private ParameterDescriptor<?>[] createParameterDescriptors(final Integer method) throws FactoryException, SQLException {
- final List<ParameterDescriptor<?>> descriptors = new ArrayList<>();
- try (ResultSet result = executeQuery("Coordinate_Operation Parameter Usage",
+ final List<ParameterDescriptor<?>> descriptors = new ArrayList<ParameterDescriptor<?>>();
+ final ResultSet result = executeQuery("Coordinate_Operation Parameter Usage",
"SELECT PARAMETER_CODE" +
" FROM [Coordinate_Operation Parameter Usage]" +
" WHERE COORD_OP_METHOD_CODE = ?" +
- " ORDER BY SORT_ORDER", method))
- {
+ " ORDER BY SORT_ORDER", method);
+ try {
while (result.next()) {
descriptors.add(owner.createParameterDescriptor(getString(method, result, 1)));
}
+ } finally {
+ result.close();
}
return descriptors.toArray(new ParameterDescriptor<?>[descriptors.size()]);
}
@@ -2589,7 +2674,7 @@
private void fillParameterValues(final Integer method, final Integer operation, final ParameterValueGroup parameters)
throws FactoryException, SQLException
{
- try (ResultSet result = executeQuery("Coordinate_Operation Parameter Value",
+ final ResultSet result = executeQuery("Coordinate_Operation Parameter Value",
"SELECT CP.PARAMETER_NAME," +
" CV.PARAMETER_VALUE," +
" CV.PARAM_VALUE_FILE_REF," +
@@ -2602,8 +2687,8 @@
" AND (CV.COORD_OP_METHOD_CODE = CU.COORD_OP_METHOD_CODE)" +
" WHERE CV.COORD_OP_METHOD_CODE = ?" +
" AND CV.COORD_OP_CODE = ?" +
- " ORDER BY CU.SORT_ORDER", method, operation))
- {
+ " ORDER BY CU.SORT_ORDER", method, operation);
+ try {
while (result.next()) {
final String name = getString(operation, result, 1);
final double value = getOptionalDouble(result, 2);
@@ -2652,6 +2737,8 @@
throw new FactoryDataException(error().getString(Errors.Keys.CanNotSetParameterValue_1, name), exception);
}
}
+ } finally {
+ result.close();
}
}
@@ -2682,14 +2769,16 @@
{
ArgumentChecks.ensureNonNull("code", code);
OperationMethod returnValue = null;
- try (ResultSet result = executeQuery("Coordinate_Operation Method", "COORD_OP_METHOD_CODE", "COORD_OP_METHOD_NAME",
+ ResultSet result = null;
+ try {
+ result = executeQuery("Coordinate_Operation Method", "COORD_OP_METHOD_CODE", "COORD_OP_METHOD_NAME",
"SELECT COORD_OP_METHOD_CODE," +
" COORD_OP_METHOD_NAME," +
" REMARKS," +
" DEPRECATED" +
" FROM [Coordinate_Operation Method]" +
- " WHERE COORD_OP_METHOD_CODE = ?", code))
- {
+ " WHERE COORD_OP_METHOD_CODE = ?", code);
+
while (result.next()) {
final Integer epsg = getInteger (code, result, 1);
final String name = getString (code, result, 2);
@@ -2705,6 +2794,12 @@
}
} catch (SQLException exception) {
throw databaseFailure(OperationMethod.class, code, exception);
+ } finally {
+ if (result != null) try {
+ result.close();
+ } catch (SQLException e) {
+ // Suppressed exception on the JDK7 branch.
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(OperationMethod.class, code);
@@ -2740,7 +2835,7 @@
ArgumentChecks.ensureNonNull("code", code);
CoordinateOperation returnValue = null;
try {
- try (ResultSet result = executeQuery("Coordinate_Operation", "COORD_OP_CODE", "COORD_OP_NAME",
+ final ResultSet result = executeQuery("Coordinate_Operation", "COORD_OP_CODE", "COORD_OP_NAME",
"SELECT COORD_OP_CODE," +
" COORD_OP_NAME," +
" COORD_OP_TYPE," +
@@ -2754,8 +2849,9 @@
" REMARKS," +
" DEPRECATED" +
" FROM [Coordinate_Operation]" +
- " WHERE COORD_OP_CODE = ?", code))
- {
+ " WHERE COORD_OP_CODE = ?", code);
+
+ try {
while (result.next()) {
final Integer epsg = getInteger(code, result, 1);
final String name = getString (code, result, 2);
@@ -2861,17 +2957,19 @@
* we are going to invoke this method recursively in the following lines.
*/
result.close();
- opProperties = new HashMap<>(opProperties); // Because this class uses a shared map.
- final List<String> codes = new ArrayList<>();
- try (ResultSet cr = executeQuery("Coordinate_Operation Path",
+ opProperties = new HashMap<String,Object>(opProperties); // Because this class uses a shared map.
+ final List<String> codes = new ArrayList<String>();
+ final ResultSet cr = executeQuery("Coordinate_Operation Path",
"SELECT SINGLE_OPERATION_CODE" +
" FROM [Coordinate_Operation Path]" +
" WHERE (CONCAT_OPERATION_CODE = ?)" +
- " ORDER BY OP_PATH_STEP", epsg))
- {
+ " ORDER BY OP_PATH_STEP", epsg);
+ try {
while (cr.next()) {
codes.add(getString(code, cr, 1));
}
+ } finally {
+ cr.close();
}
final CoordinateOperation[] operations = new CoordinateOperation[codes.size()];
ensureNoCycle(CoordinateOperation.class, epsg);
@@ -2941,6 +3039,8 @@
return returnValue;
}
}
+ } finally {
+ result.close();
}
} catch (SQLException exception) {
throw databaseFailure(CoordinateOperation.class, code, exception);
@@ -3004,10 +3104,13 @@
" AND COORD_REF_SYS_CODE = ?";
}
final Integer targetKey = searchTransformations ? null : pair[1];
- try (ResultSet result = executeQuery(key, sql, pair)) {
+ final ResultSet result = executeQuery(key, sql, pair);
+ try {
while (result.next()) {
set.addAuthorityCode(getString(label, result, 1), targetKey);
}
+ } finally {
+ result.close();
}
} while ((searchTransformations = !searchTransformations) == true);
/*
@@ -3119,7 +3222,7 @@
} finally {
setIgnoringAxes(previous);
}
- codes = new LinkedHashSet<>(Containers.hashMapCapacity(find.size()));
+ codes = new LinkedHashSet<Number>(Containers.hashMapCapacity(find.size()));
for (final IdentifiedObject dep : find) {
Identifier id = IdentifiedObjects.getIdentifier(dep, Citations.EPSG);
if (id != null) try { // Should never be null, but let be safe.
@@ -3164,9 +3267,10 @@
* - A floating point number, in which case the search will be performed
* with a tolerance threshold of 1 cm for a planet of the size of Earth.
*/
- final Set<String> result = new LinkedHashSet<>(); // We need to preserve order in this set.
+ final Set<String> result = new LinkedHashSet<String>(); // We need to preserve order in this set.
try {
- try (PreparedStatement s = connection.prepareStatement(translator.apply(buffer.toString()))) {
+ final PreparedStatement s = connection.prepareStatement(translator.apply(buffer.toString()));
+ try {
for (final Number code : codes) {
if (isFloat) {
final double value = code.doubleValue();
@@ -3177,12 +3281,17 @@
} else {
s.setInt(1, code.intValue());
}
- try (ResultSet r = s.executeQuery()) {
+ final ResultSet r = s.executeQuery();
+ try {
while (r.next()) {
result.add(r.getString(1));
}
+ } finally {
+ r.close();
}
}
+ } finally {
+ s.close();
}
result.remove(null); // Should not have null element, but let be safe.
/*
@@ -3213,13 +3322,15 @@
final boolean isProjection(final Integer code) throws SQLException {
Boolean projection = isProjection.get(code);
if (projection == null) {
- try (ResultSet result = executeQuery("isProjection",
+ final ResultSet result = executeQuery("isProjection",
"SELECT COORD_REF_SYS_CODE" +
" FROM [Coordinate Reference System]" +
" WHERE PROJECTION_CONV_CODE = ?" +
- " AND CAST(COORD_REF_SYS_KIND AS " + TableInfo.ENUM_REPLACEMENT + ") LIKE 'projected%'", code))
- {
+ " AND CAST(COORD_REF_SYS_KIND AS " + TableInfo.ENUM_REPLACEMENT + ") LIKE 'projected%'", code);
+ try {
projection = result.next();
+ } finally {
+ result.close();
}
isProjection.put(code, projection);
}
@@ -3271,7 +3382,8 @@
" INNER JOIN [Coordinate_Operation] AS CO ON TGT.PROJECTION_CONV_CODE = CO.COORD_OP_CODE" +
" WHERE CO.DEPRECATED=0 AND COORD_OP_METHOD_CODE = ?";
}
- try (ResultSet result = executeQuery(key, sql, method)) {
+ final ResultSet result = executeQuery(key, sql, method);
+ try {
while (result.next()) {
for (int i=0; i<dimensions.length; i++) {
if (!differents[i]) { // Not worth to test heterogenous dimensions.
@@ -3291,6 +3403,8 @@
}
}
}
+ } finally {
+ result.close();
}
} while ((projections = !projections) == true);
return dimensions;
@@ -3314,12 +3428,12 @@
boolean changed = false;
for (int i=0; i<codes.length; i++) {
final String code = codes[i].toString();
- try (ResultSet result = executeQuery("Supersession", null, null,
+ final ResultSet result = executeQuery("Supersession", null, null,
"SELECT OBJECT_TABLE_NAME, SUPERSEDED_BY" +
" FROM [Supersession]" +
" WHERE OBJECT_CODE = ?" +
- " ORDER BY SUPERSESSION_YEAR DESC", code))
- {
+ " ORDER BY SUPERSESSION_YEAR DESC", code);
+ try {
while (result.next()) {
if (tableMatches(table, result.getString(1))) {
final String replacement = result.getString(2);
@@ -3338,6 +3452,8 @@
}
}
}
+ } finally {
+ result.close();
}
}
if (!changed) {
@@ -3420,7 +3536,6 @@
*
* @see #connection
*/
- @Override
public synchronized void close() throws FactoryException {
SQLException exception = null;
final Iterator<PreparedStatement> ip = statements.values().iterator();
@@ -3431,7 +3546,7 @@
if (exception == null) {
exception = e;
} else {
- exception.addSuppressed(e);
+ // exception.addSuppressed(e) on the JDK7 branch.
}
}
ip.remove();
@@ -3444,7 +3559,7 @@
if (exception == null) {
exception = e;
} else {
- exception.addSuppressed(e);
+ // exception.addSuppressed(e) on the JDK7 branch.
}
}
it.remove();
@@ -3455,7 +3570,7 @@
if (exception == null) {
exception = e;
} else {
- e.addSuppressed(exception); // Keep the connection thrown be Connection as the main one to report.
+ // e.addSuppressed(exception) on the JDK7 branch.
}
}
if (exception != null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
index 46bafdc..6b1b535 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
@@ -256,7 +256,7 @@
catalog = (String) properties.get("catalog");
scriptProvider = (InstallationScriptProvider) properties.get("scriptProvider");
if (locale == null) {
- locale = Locale.getDefault(Locale.Category.DISPLAY);
+ locale = Locale.getDefault();
}
this.locale = locale;
if (ds == null) try {
@@ -369,7 +369,8 @@
*/
public synchronized void install(final Connection connection) throws IOException, SQLException {
ArgumentChecks.ensureNonNull("connection", connection);
- try (EPSGInstaller installer = new EPSGInstaller(connection)) {
+ final EPSGInstaller installer = new EPSGInstaller(connection);
+ try {
final boolean ac = connection.getAutoCommit();
if (ac) {
connection.setAutoCommit(false);
@@ -395,10 +396,15 @@
connection.setAutoCommit(true);
}
}
- } catch (IOException | SQLException e) {
+ } catch (IOException e) {
+ installer.logFailure(locale, e);
+ throw e;
+ } catch (SQLException e) {
installer.logFailure(locale, e);
throw e;
}
+ } finally {
+ installer.close();
}
}
@@ -453,7 +459,7 @@
if (connection != null) try {
connection.close();
} catch (SQLException e2) {
- e.addSuppressed(e2);
+ // e.addSuppressed(e2) on the JDK7 branch.
}
exception = new UnavailableFactoryException(message(e), e);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
index 5ca7dcf..799d953 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
@@ -260,8 +260,11 @@
final String[] scripts = scriptProvider.getResourceNames(EPSG);
int numRows = 0;
for (int i=0; i<scripts.length; i++) {
- try (BufferedReader in = scriptProvider.openScript(EPSG, i)) {
+ final BufferedReader in = scriptProvider.openScript(EPSG, i);
+ try {
numRows += run(scripts[i], in);
+ } finally {
+ in.close();
}
}
time = System.nanoTime() - time;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
index 6cd4238..91761fb 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
@@ -39,10 +39,10 @@
import org.apache.sis.internal.util.Constants;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.StandardCharsets;
+import org.apache.sis.internal.jdk7.DirectoryStream;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
/**
@@ -323,7 +323,8 @@
if (Files.isDirectory(dir)) {
final String[] resources = super.resources;
final String[] found = new String[resources.length - FIRST_FILE - 1];
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "EPSG_*.sql")) {
+ DirectoryStream stream = Files.newDirectoryStream(dir, "EPSG_*.sql");
+ try {
for (final Path path : stream) {
final String name = path.getFileName().toString();
for (int i=0; i<found.length; i++) {
@@ -338,6 +339,8 @@
}
}
}
+ } finally {
+ stream.close();
}
for (int i=0; i<found.length; i++) {
final String file = found[i];
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
index 6a354e3..71bb233 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
@@ -227,7 +227,7 @@
public SQLTranslator(final DatabaseMetaData md, final String catalog, final String schema) throws SQLException {
ArgumentChecks.ensureNonNull("md", md);
quote = md.getIdentifierQuoteString().trim();
- accessToAnsi = new HashMap<>(4);
+ accessToAnsi = new HashMap<String,String>(4);
this.catalog = catalog;
this.schema = schema;
setup(md);
@@ -253,7 +253,8 @@
if (toUpperCase && i != MIXED_CASE) {
table = table.toUpperCase(Locale.US);
}
- try (ResultSet result = md.getTables(catalog, schema, table, null)) {
+ final ResultSet result = md.getTables(catalog, schema, table, null);
+ try {
if (result.next()) {
isTableFound = true;
quoteTableNames = (i == MIXED_CASE);
@@ -264,6 +265,8 @@
if (schema == null) schema = "";
break;
}
+ } finally {
+ result.close();
}
}
/*
@@ -278,8 +281,11 @@
* This column has been renamed "coord_axis_order" in DLL scripts.
* We need to check which name our current database uses.
*/
- try (ResultSet result = md.getColumns(catalog, schema, "Coordinate Axis", "ORDER")) {
+ final ResultSet result = md.getColumns(catalog, schema, "Coordinate Axis", "ORDER");
+ try {
translateColumns = !result.next();
+ } finally {
+ result.close();
}
} else {
accessToAnsi.put("Coordinate_Operation", "coordoperation");
@@ -296,7 +302,8 @@
if (md.storesLowerCaseIdentifiers()) {
deprecated = deprecated.toLowerCase(Locale.US);
}
- try (ResultSet result = md.getColumns(catalog, schema, null, deprecated)) {
+ final ResultSet result = md.getColumns(catalog, schema, null, deprecated);
+ try {
while (result.next()) {
if (CharSequences.endsWith(result.getString("TABLE_NAME"), "Datum", true)) {
final int type = result.getInt("DATA_TYPE");
@@ -304,6 +311,8 @@
break;
}
}
+ } finally {
+ result.close();
}
};
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
index 8c02b3d..7a3dabf 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
@@ -24,7 +24,6 @@
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.measure.converter.ConversionException;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.extent.Extent;
@@ -67,7 +66,7 @@
import static org.apache.sis.util.Utilities.deepEquals;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -821,7 +820,7 @@
CoordinateSystems.swapAndScaleAxes(that.getTargetCRS().getCoordinateSystem(),
this.getTargetCRS().getCoordinateSystem()));
tr2 = MathTransforms.concatenate(before, tr2, after);
- } catch (ConversionException | RuntimeException e) {
+ } catch (Exception e) { // (ConversionException | RuntimeException) on the JDK7 branch.
Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
AbstractCoordinateOperation.class, "equals", e);
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
index cee0138..995a3c4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
@@ -57,7 +57,7 @@
import static org.apache.sis.util.Utilities.deepEquals;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -469,7 +469,8 @@
* because Apache SIS infers the type from the actual parameter value. The 'merge' method
* below puts those information together.
*/
- final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4);
+ final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements =
+ new IdentityHashMap<GeneralParameterDescriptor,GeneralParameterDescriptor>(4);
final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge(
method.getParameters().descriptors(),
Parameters.getDescriptors(values),
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
index e801074..1405a8f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
@@ -26,7 +26,7 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
index 67def65..60d88e5 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
@@ -163,8 +163,8 @@
final CoordinateOperationContext context) throws FactoryException
{
super(registry, factory, context);
- identifierOfStepCRS = new HashMap<>(8);
- previousSearches = new HashMap<>(8);
+ identifierOfStepCRS = new HashMap<Identifier,Object>(8);
+ previousSearches = new HashMap<CRSPair,Boolean>(8);
useCache = (context == null) && (factory == factorySIS);
}
@@ -199,7 +199,9 @@
if (equalsIgnoreMetadata(sourceCRS, targetCRS)) try {
return createFromAffineTransform(AXIS_CHANGES, sourceCRS, targetCRS,
CoordinateSystems.swapAndScaleAxes(sourceCRS.getCoordinateSystem(), targetCRS.getCoordinateSystem()));
- } catch (IllegalArgumentException | ConversionException e) {
+ } catch (IllegalArgumentException e) {
+ throw new FactoryException(Errors.format(Errors.Keys.CanNotInstantiate_1, new CRSPair(sourceCRS, targetCRS)), e);
+ } catch (ConversionException e) {
throw new FactoryException(Errors.format(Errors.Keys.CanNotInstantiate_1, new CRSPair(sourceCRS, targetCRS)), e);
}
/*
@@ -356,7 +358,9 @@
step1 = inverse(sourceCRS.getConversionFromBase());
} catch (OperationNotFoundException exception) {
throw exception;
- } catch (FactoryException | NoninvertibleTransformException exception) {
+ } catch (FactoryException exception) {
+ throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
+ } catch (NoninvertibleTransformException exception) {
throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
}
return concatenate(step1, step2);
@@ -389,7 +393,9 @@
step1 = inverse(sourceCRS.getConversionFromBase());
} catch (OperationNotFoundException exception) {
throw exception;
- } catch (FactoryException | NoninvertibleTransformException exception) {
+ } catch (FactoryException exception) {
+ throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
+ } catch (NoninvertibleTransformException exception) {
throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
}
return concatenate(step1, step2, step3);
@@ -672,7 +678,9 @@
final Matrix matrix;
try {
matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS);
- } catch (IllegalArgumentException | ConversionException exception) {
+ } catch (IllegalArgumentException exception) {
+ throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
+ } catch (ConversionException exception) {
throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
}
return createFromAffineTransform(AXIS_CHANGES, sourceCRS, targetCRS, matrix);
@@ -718,7 +726,9 @@
final Matrix matrix;
try {
matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS);
- } catch (IllegalArgumentException | ConversionException exception) {
+ } catch (IllegalArgumentException exception) {
+ throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
+ } catch (ConversionException exception) {
throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
}
final int translationColumn = matrix.getNumCol() - 1; // Paranoiac check: should always be 1.
@@ -939,7 +949,7 @@
if (main instanceof SingleOperation) {
final SingleOperation op = (SingleOperation) main;
final MathTransform mt = factorySIS.getMathTransformFactory().createConcatenatedTransform(mt1, mt2);
- main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)),
+ main = createFromMathTransform(new HashMap<String,Object>(IdentifiedObjects.getProperties(main)),
sourceCRS, targetCRS, mt, op.getMethod(), op.getParameterValues(),
(main instanceof Transformation) ? Transformation.class :
(main instanceof Conversion) ? Conversion.class : SingleOperation.class);
@@ -959,7 +969,7 @@
break;
}
}
- main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)),
+ main = createFromMathTransform(new HashMap<String,Object>(IdentifiedObjects.getProperties(main)),
main.getSourceCRS(), main.getTargetCRS(), main.getMathTransform(), null, null, type);
}
return main;
@@ -1037,7 +1047,7 @@
identifierOfStepCRS.put(newID, oldID);
identifierOfStepCRS.put(oldID, count);
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(IdentifiedObject.NAME_KEY, newID);
properties.put(IdentifiedObject.REMARKS_KEY, Vocabulary.formatInternational(
Vocabulary.Keys.DerivedFrom_1, CRSPair.label(object)));
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
index 29a5632..0276e37 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
@@ -76,7 +76,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.JDK8;
import org.apache.sis.internal.jdk8.Predicate;
@@ -335,13 +335,16 @@
}
return operation;
}
- } catch (IllegalArgumentException | ConversionException e) {
+ } catch (IllegalArgumentException e) {
String message = Errors.format(Errors.Keys.CanNotInstantiate_1, new CRSPair(sourceCRS, targetCRS));
String details = e.getLocalizedMessage();
if (details != null) {
message = message + ' ' + details;
}
throw new FactoryException(message, e);
+ } catch (ConversionException e) {
+ throw new FactoryException(Errors.format(
+ Errors.Keys.CanNotInstantiate_1, new CRSPair(sourceCRS, targetCRS)), e);
}
}
}
@@ -402,7 +405,7 @@
return null;
}
}
- } catch (NoSuchAuthorityCodeException | MissingFactoryResourceException exception) {
+ } catch (NoSuchAuthorityCodeException exception) {
/*
* sourceCode or targetCode is unknown to the underlying authority factory.
* Ignores the exception and fallback on the generic algorithm provided by
@@ -410,6 +413,9 @@
*/
log(exception);
return null;
+ } catch (MissingFactoryResourceException exception) {
+ log(exception);
+ return null;
}
/*
* We will loop over all coordinate operations and select the one having the largest intersection
@@ -708,7 +714,7 @@
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<>(derivedFrom(operation));
+ final Map<String,Object> properties = new HashMap<String,Object>(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).
@@ -742,8 +748,11 @@
try {
method = factory.getOperationMethod(method.getName().getCode());
method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions);
- } catch (NoSuchIdentifierException | IllegalArgumentException se) {
- ex.addSuppressed(se);
+ } catch (NoSuchIdentifierException se) {
+ // ex.addSuppressed(se) on the JDK7 branch.
+ throw ex;
+ } catch (IllegalArgumentException se) {
+ // ex.addSuppressed(se) on the JDK7 branch.
throw ex;
}
}
@@ -782,7 +791,7 @@
final CoordinateOperation operation)
throws IllegalArgumentException, FactoryException
{
- final List<CoordinateOperation> operations = new ArrayList<>();
+ final List<CoordinateOperation> operations = new ArrayList<CoordinateOperation>();
if (operation instanceof ConcatenatedOperation) {
operations.addAll(((ConcatenatedOperation) operation).getOperations());
} else {
@@ -961,7 +970,7 @@
* @return a modifiable map containing the given name. Callers can put other entries in this map.
*/
static Map<String,Object> properties(final Identifier name) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(CoordinateOperation.NAME_KEY, name);
if ((name == DATUM_SHIFT) || (name == ELLIPSOID_CHANGE)) {
properties.put(CoordinateOperation.COORDINATE_OPERATION_ACCURACY_KEY, new PositionalAccuracy[] {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
index 64c810b..d62e6d0 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
@@ -42,7 +42,7 @@
import static org.apache.sis.util.Utilities.deepEquals;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -110,7 +110,7 @@
{
super(properties);
ArgumentChecks.ensureNonNull("operations", operations);
- final List<CoordinateOperation> flattened = new ArrayList<>(operations.length);
+ final List<CoordinateOperation> flattened = new ArrayList<CoordinateOperation>(operations.length);
initialize(properties, operations, flattened, mtFactory,
(coordinateOperationAccuracy == null), (domainOfValidity == null));
if (flattened.size() < 2) {
@@ -396,7 +396,7 @@
* Invoked by JAXB for setting the operations.
*/
private void setSteps(final CoordinateOperation[] steps) throws FactoryException {
- final List<CoordinateOperation> flattened = new ArrayList<>(steps.length);
+ final List<CoordinateOperation> flattened = new ArrayList<CoordinateOperation>(steps.length);
initialize(null, steps, flattened, DefaultFactories.forBuildin(MathTransformFactory.class),
(coordinateOperationAccuracy == null), (domainOfValidity == null));
operations = UnmodifiableArrayList.wrap(flattened.toArray(new CoordinateOperation[flattened.size()]));
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
index 397f2f1..3dbc5b2 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
@@ -159,7 +159,7 @@
} else {
String key = null;
Object value = null;
- properties = new HashMap<>(properties);
+ properties = new HashMap<String,Object>(properties);
/*
* Following use of properties is an undocumented feature for now. Current version documents only
* MathTransformFactory because math transforms are intimately related to coordinate operations.
@@ -178,8 +178,8 @@
if (factory != null) {
mtFactory = factory;
}
- pool = new WeakHashSet<>(IdentifiedObject.class);
- cache = new Cache<>(12, 50, true);
+ pool = new WeakHashSet<IdentifiedObject>(IdentifiedObject.class);
+ cache = new Cache<CRSPair,CoordinateOperation>(12, 50, true);
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
index 2dfbed5..4835e7f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
@@ -29,7 +29,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
index aa9bf84..73afa45 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
@@ -61,7 +61,7 @@
import static org.apache.sis.util.ArgumentChecks.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -322,7 +322,7 @@
* @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<>(IdentifiedObjects.getProperties(info));
+ final Map<String,Object> properties = new HashMap<String,Object>(IdentifiedObjects.getProperties(info));
properties.put(NAME_KEY, new NamedIdentifier(authority, info.getName().getCode()));
properties.remove(IDENTIFIERS_KEY);
return properties;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
index 97c0138..ca0738a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
@@ -39,7 +39,7 @@
import static org.apache.sis.util.Utilities.deepEquals;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java
index c114d58..09b865e 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/InverseOperationMethod.java
@@ -93,7 +93,7 @@
if (!useSameParameters) {
Identifier name = method.getName();
name = new ImmutableIdentifier(null, null, "Inverse of " + name.getCode());
- final Map<String,Object> properties = new HashMap<>(6);
+ final Map<String,Object> properties = new HashMap<String,Object>(6);
properties.put(NAME_KEY, name);
properties.put(FORMULA_KEY, method.getFormula());
properties.put(REMARKS_KEY, method.getRemarks());
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubOperationInfo.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubOperationInfo.java
index feec743..fc6a58e 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubOperationInfo.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubOperationInfo.java
@@ -127,7 +127,7 @@
if (failure == null) {
failure = exception;
} else {
- failure.addSuppressed(exception);
+ // failure.addSuppressed(exception) on the JDK7 branch.
}
continue;
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
index c6c8042..8f69d1d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
@@ -32,6 +32,9 @@
import org.apache.sis.util.Classes;
import org.apache.sis.util.Debug;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Creates a linear (usually affine) transform which will map approximatively the given source points to
@@ -223,7 +226,7 @@
}
buffer.append(']');
if (transform != null) {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
buffer.append(':').append(lineSeparator);
final TableAppender table = new TableAppender(buffer, " ");
table.setMultiLinesCells(true);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
index fd29c04..af6fb93 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
@@ -34,7 +34,8 @@
import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.JDK7;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -1133,7 +1134,7 @@
* Now append the formatted elements with the appropriate amount of spaces before each value,
* and trailling zeros after each value except ±0, ±1, NaN and infinities.
*/
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final CharSequence whiteLine = CharSequences.spaces(totalWidth);
final StringBuilder buffer = new StringBuilder((totalWidth + 2 + lineSeparator.length()) * (numRow + 2));
buffer.append('┌').append(whiteLine).append('┐').append(lineSeparator);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java
index 98fdb94..16fb4e3 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java
@@ -95,7 +95,8 @@
@SuppressWarnings("fallthrough")
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
roles.put(ParameterRole.FALSE_EASTING, EASTING_AT_FALSE_ORIGIN);
roles.put(ParameterRole.FALSE_NORTHING, NORTHING_AT_FALSE_ORIGIN);
roles.put(ParameterRole.CENTRAL_MERIDIAN, LONGITUDE_OF_FALSE_ORIGIN);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java
index ae74e73..a582e93 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java
@@ -113,7 +113,8 @@
@SuppressWarnings("fallthrough")
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
/*
* "Longitude of origin" and "scale factor" are intentionally omitted from this map because they will
* be handled in a special way. See comments in Mercator.initializer(…) method for more details.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java
index 4d6b8af..a4447ae 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java
@@ -165,7 +165,8 @@
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
final byte variant = getVariant(method);
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
/*
* "Scale factor" is not formally a "Lambert Conformal (2SP)" argument, but we accept it
* anyway for all Lambert projections since it may be used in some Well Known Text (WKT).
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
index a8fbaf7..768e3dd 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
@@ -153,7 +153,8 @@
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
final byte variant = getVariant(method);
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
/*
* "Longitude of origin" is a parameter of all Mercator projections, but is intentionally omitted from
* this map because it will be handled in a special way by the Mercator constructor. The "scale factor"
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
index 5a4b99f..e5ae046 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
@@ -55,7 +55,7 @@
import static java.lang.Math.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -175,7 +175,7 @@
* used only by {@link #getParameterDescriptors()}, which is itself invoked mostly for debugging purpose.</p>
*/
@Debug
- private static final Map<Class<?>,ParameterDescriptorGroup> DESCRIPTORS = new HashMap<>();
+ private static final Map<Class<?>,ParameterDescriptorGroup> DESCRIPTORS = new HashMap<Class<?>,ParameterDescriptorGroup>();
/**
* The parameters used for creating this projection. They are used for formatting <cite>Well Known Text</cite> (WKT)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
index 0e0f078..45d7c45 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
@@ -110,7 +110,8 @@
*/
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
roles.put(ParameterRole.CENTRAL_MERIDIAN, LONGITUDE_OF_ORIGIN);
roles.put(ParameterRole.SCALE_FACTOR, SCALE_FACTOR);
roles.put(ParameterRole.FALSE_EASTING, FALSE_EASTING);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
index f0fea68..c191d17 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
@@ -116,7 +116,8 @@
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
final byte variant = getVariant(method);
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
ParameterDescriptor<Double> falseEasting = PolarStereographicA.FALSE_EASTING;
ParameterDescriptor<Double> falseNorthing = PolarStereographicA.FALSE_NORTHING;
if (variant == C) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
index 5d54757..77df09a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
@@ -110,7 +110,8 @@
@Workaround(library="JDK", version="1.7")
private static Initializer initializer(final OperationMethod method, final Parameters parameters) {
final boolean isSouth = identMatch(method, "(?i).*\\bSouth\\b.*", TransverseMercatorSouth.IDENTIFIER);
- final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class);
+ final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
+ new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
ParameterRole xOffset = ParameterRole.FALSE_EASTING;
ParameterRole yOffset = ParameterRole.FALSE_NORTHING;
if (isSouth) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
index 8cc5ebe..98cf310 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
@@ -451,7 +451,6 @@
failure = exception; // Keep only the first failure.
blockStart = srcOff;
} else {
- failure.addSuppressed(exception);
if (Math.abs(srcOff - blockStart) > MAXIMUM_BUFFER_SIZE) {
failureCount = 0; // We started a new block of coordinates.
blockStart = srcOff;
@@ -587,8 +586,6 @@
throw exception;
} else if (failure == null) {
failure = exception; // Keep only the first exception.
- } else {
- failure.addSuppressed(exception);
}
}
for (int i=0; i<dstStop; i++) {
@@ -651,8 +648,6 @@
throw exception;
} else if (failure == null) {
failure = exception;
- } else {
- failure.addSuppressed(exception);
}
}
for (int i=0; i<dstLength; i++) {
@@ -726,8 +721,6 @@
throw exception;
} else if (failure == null) {
failure = exception;
- } else {
- failure.addSuppressed(exception);
}
}
dstOff += dstLength;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
index d6f60a1..3d7bc3c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
@@ -426,7 +426,7 @@
* @see MathTransforms#getSteps(MathTransform)
*/
public final List<MathTransform> getSteps() {
- final List<MathTransform> transforms = new ArrayList<>(5);
+ final List<MathTransform> transforms = new ArrayList<MathTransform>(5);
getSteps(transforms);
return transforms;
}
@@ -438,7 +438,7 @@
* (<var>projection</var>) elements, which does not need to be instances of {@link MathTransform}.
*/
private List<Object> getPseudoSteps() {
- final List<Object> transforms = new ArrayList<>();
+ final List<Object> transforms = new ArrayList<Object>();
getSteps(transforms);
/*
* Pre-process the transforms before to format. Some steps may be merged, or new
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
index 68b92cf..ae90388 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
@@ -21,7 +21,6 @@
import java.util.Map;
import java.util.IdentityHashMap;
import java.util.Iterator;
-import java.util.Objects;
import java.io.Serializable;
import org.opengis.util.FactoryException;
import org.opengis.parameter.GeneralParameterValue;
@@ -55,6 +54,9 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* The parameters that describe a sequence of
@@ -534,7 +536,8 @@
* Some WKT parsers other than SIS may also require the parameter values to be listed in that specific
* order. We proceed by first copying all parameters in a temporary HashMap:
*/
- final Map<ParameterDescriptor<?>, ParameterValue<?>> parameters = new IdentityHashMap<>(values.length);
+ final Map<ParameterDescriptor<?>, ParameterValue<?>> parameters =
+ new IdentityHashMap<ParameterDescriptor<?>, ParameterValue<?>>(values.length);
for (ParameterValue<?> p : values) {
if (p == null) {
break; // The first null value in the array indicates the end of sequence.
@@ -585,6 +588,7 @@
* @throws ParameterNotFoundException if there is no parameter of the given name.
*/
@Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
public synchronized ParameterValue<?> parameter(final String name) throws ParameterNotFoundException {
final GeneralParameterDescriptor desc = descriptor.descriptor(name);
if (!(desc instanceof ParameterDescriptor<?>)) {
@@ -597,7 +601,7 @@
for (int i=0; i < values.length; i++) {
ParameterValue<?> p = values[i];
if (p == null) {
- values[i] = p = new ContextualParameter<>((ParameterDescriptor<?>) desc);
+ values[i] = p = new ContextualParameter((ParameterDescriptor<?>) desc);
return p;
}
if (p.getDescriptor() == desc) { // Identity comparison should be okay here.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
index 08f84a8..c53e75f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
@@ -204,7 +204,9 @@
return factory.createConcatenatedTransform(before,
factory.createConcatenatedTransform(tr, after));
}
- } catch (IllegalArgumentException | ConversionException e) {
+ } catch (IllegalArgumentException e) {
+ cause = e;
+ } catch (ConversionException e) {
cause = e;
}
throw new OperationNotFoundException(Errors.format(Errors.Keys.CoordinateOperationNotFound_2,
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
index ff05b57..8a95527 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
@@ -31,7 +31,7 @@
import org.apache.sis.util.Debug;
// Branch-specific imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
index 98633a2..889907c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
@@ -304,11 +304,11 @@
public DefaultMathTransformFactory(final Iterable<? extends OperationMethod> methods) {
ArgumentChecks.ensureNonNull("methods", methods);
this.methods = methods;
- methodsByName = new ConcurrentHashMap<>();
- methodsByType = new IdentityHashMap<>();
- lastMethod = new ThreadLocal<>();
- pool = new WeakHashSet<>(MathTransform.class);
- parser = new AtomicReference<>();
+ methodsByName = new ConcurrentHashMap<String, OperationMethod>();
+ methodsByType = new IdentityHashMap<Class<?>, OperationMethodSet>();
+ lastMethod = new ThreadLocal<OperationMethod>();
+ pool = new WeakHashSet<MathTransform>(MathTransform.class);
+ parser = new AtomicReference<Parser>();
}
/**
@@ -662,7 +662,9 @@
} else {
return CoordinateSystems.swapAndScaleAxes(specified, normalized);
}
- } catch (IllegalArgumentException | ConversionException cause) {
+ } catch (IllegalArgumentException cause) {
+ throw new InvalidGeodeticParameterException(cause.getLocalizedMessage(), cause);
+ } catch (ConversionException cause) {
throw new InvalidGeodeticParameterException(cause.getLocalizedMessage(), cause);
}
}
@@ -796,7 +798,7 @@
mismatchedParam = bp;
mismatchedValue = b;
}
- } catch (IllegalArgumentException | IllegalStateException e) {
+ } catch (RuntimeException e) { // (IllegalArgumentException | IllegalStateException) on the JDK7 branch.
/*
* Parameter not found, or is not numeric, or unit of measurement is not linear.
* Do not touch to the parameters. We will see if createParameterizedTransform(…)
@@ -806,7 +808,7 @@
if (failure == null) {
failure = e;
} else {
- failure.addSuppressed(e);
+ // failure.addSuppressed(e) on the JDK7 branch.
}
}
final boolean isIvfDefinitive;
@@ -913,7 +915,7 @@
if (p.getValue() == null) {
p.setValue(sourceCS.getDimension());
}
- } catch (IllegalArgumentException | IllegalStateException e) {
+ } catch (RuntimeException e) { // (IllegalArgumentException | IllegalStateException e) on the JDK7 branch.
failure = e;
}
failure = setEllipsoid(getSourceEllipsoid(), "src_semi_major", "src_semi_minor", false, failure);
@@ -1006,6 +1008,8 @@
method = getOperationMethod(methodName);
Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
DefaultMathTransformFactory.class, "createParameterizedTransform", exception);
+ } catch (IllegalStateException e) {
+ failure = e;
}
if (!(method instanceof MathTransformProvider)) {
throw new NoSuchIdentifierException(Errors.format( // For now, handle like an unknown operation.
@@ -1027,7 +1031,7 @@
method = context.provider;
}
transform = ((MathTransformProvider) method).createMathTransform(this, parameters);
- } catch (IllegalArgumentException | IllegalStateException exception) {
+ } catch (RuntimeException exception) { // (IllegalArgumentException | IllegalStateException) on the JDK7 branch.
throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
/*
@@ -1043,7 +1047,7 @@
}
} catch (FactoryException e) {
if (failure != null) {
- e.addSuppressed(failure);
+ // e.addSuppressed(failure) on the JDK7 branch.
}
throw e;
} finally {
@@ -1340,7 +1344,7 @@
parserConstructor = c;
}
p = c.newInstance(this);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new FactoryException(e);
}
/*
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
index 547c9ea..c63234c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
@@ -794,6 +794,7 @@
* Creates the inverse of the enclosing transform.
*/
Inverse() {
+ EllipsoidToCentricTransform.this.super();
}
/**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
index 836d284..8050483 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
@@ -41,7 +41,7 @@
import org.apache.sis.internal.referencing.provider.DatumShiftGridFile;
// Branch-specific imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -421,6 +421,7 @@
* Creates an inverse transform.
*/
Inverse() {
+ InterpolatedTransform.this.super();
tolerance = grid.getCellPrecision();
if (!(tolerance > 0)) { // Use ! for catching NaN.
throw new IllegalArgumentException(Errors.format(
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
index 792cdc8..99ec36b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
@@ -81,7 +81,7 @@
{
this.type = type;
this.methods = methods;
- cachedMethods = new ArrayList<>();
+ cachedMethods = new ArrayList<OperationMethod>();
reset();
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java
index 427f793..259384d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java
@@ -19,9 +19,9 @@
import java.awt.Shape;
import java.awt.geom.Point2D;
import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.internal.referencing.j2d.LinearTransform2D;
/**
@@ -36,7 +36,7 @@
* @version 0.7
* @module
*/
-final class ProjectiveTransform2D extends ProjectiveTransform implements LinearTransform2D {
+final class ProjectiveTransform2D extends ProjectiveTransform implements MathTransform2D, LinearTransform {
/**
* For cross-version compatibility.
*/
@@ -90,7 +90,12 @@
* The inverse shall be linear and two-dimensional.
*/
@Override
- public LinearTransform2D inverse() throws NoninvertibleTransformException {
- return (LinearTransform2D) super.inverse();
+ public ProjectiveTransform2D inverse() throws NoninvertibleTransformException {
+ final LinearTransform inv = super.inverse();
+ if (inv instanceof ProjectiveTransform2D) {
+ return (ProjectiveTransform2D) inv;
+ } else {
+ return new ProjectiveTransform2D(inv.getMatrix());
+ }
}
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
index 773c696..4f7f3ef 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
@@ -112,10 +112,10 @@
private static DefaultParameterDescriptor<Integer> create(final String name, final String remarks,
final boolean mandatory, final Integer defaultValue)
{
- final Map<String,String> properties = new HashMap<>(4);
+ final Map<String,String> properties = new HashMap<String,String>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, name));
assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, remarks));
- return new DefaultParameterDescriptor<>(properties, mandatory ? 1 : 0, 1, Integer.class, null, null, defaultValue);
+ return new DefaultParameterDescriptor<Integer>(properties, mandatory ? 1 : 0, 1, Integer.class, null, null, defaultValue);
}
/**
@@ -186,7 +186,7 @@
@Test
@DependsOnMethod("testParameterSubstitution")
public void testGroupSubstitution() throws JAXBException {
- final Map<String,String> properties = new HashMap<>(4);
+ final Map<String,String> properties = new HashMap<String,String>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2,
unmarshal("Parameter A", null),
@@ -213,7 +213,7 @@
@Test
@DependsOnMethod({"testGroupSubstitution", "testParameterMerge"})
public void testGroupMergeBecauseDifferentProperties() throws JAXBException {
- final Map<String,String> properties = new HashMap<>(4);
+ final Map<String,String> properties = new HashMap<String,String>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2,
unmarshal("Parameter A", "Remarks A."),
@@ -254,7 +254,7 @@
@Test
@DependsOnMethod("testGroupMergeBecauseDifferentProperties")
public void testGroupMergeBecauseMissingParameter() throws JAXBException {
- final Map<String,String> properties = new HashMap<>(4);
+ final Map<String,String> properties = new HashMap<String,String>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2,
unmarshal("Parameter A", null),
@@ -296,7 +296,7 @@
@Test
@DependsOnMethod("testGroupMergeBecauseDifferentProperties")
public void testGroupMergeBecauseExtraParameter() throws JAXBException {
- final Map<String,String> properties = new HashMap<>(4);
+ final Map<String,String> properties = new HashMap<String,String>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2,
unmarshal("Parameter A", "Remarks A."),
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
index 8abbfcc..fd69ee6 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
@@ -114,7 +114,8 @@
final ParameterDescriptor<?>[] expected = create(REMARK);
final List<GeneralParameterDescriptor> fromXML = unmarshal().descriptors();
final List<GeneralParameterDescriptor> fromValues = UnmodifiableArrayList.<GeneralParameterDescriptor>wrap(expected);
- final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4);
+ final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements =
+ new IdentityHashMap<GeneralParameterDescriptor,GeneralParameterDescriptor>(4);
final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge(fromXML,
fromValues.toArray(new GeneralParameterDescriptor[fromValues.size()]), replacements);
@@ -138,7 +139,8 @@
public void testMerge() throws JAXBException {
final ParameterDescriptorGroup fromXML = unmarshal();
final ParameterDescriptor<?>[] fromValues = create(null);
- final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4);
+ final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements =
+ new IdentityHashMap<GeneralParameterDescriptor,GeneralParameterDescriptor>(4);
final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge(fromXML.descriptors(), fromValues.clone(), replacements);
assertNotSame(fromValues, merged);
/*
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
index 902e4ce..87c50ba 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
@@ -33,8 +33,8 @@
import static org.opengis.test.Assert.*;
// Branch-dependent imports
-import java.nio.file.Paths;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.Paths;
+import org.apache.sis.internal.jdk7.Path;
import org.apache.sis.internal.jdk8.JDK8;
@@ -145,8 +145,11 @@
assertNotNull("Test file \"" + TEST_FILE + "\" not found.", url);
final Path file = Paths.get(url.toURI());
final DatumShiftGridFile.Float<Angle,Length> grid;
- try (final BufferedReader in = JDK8.newBufferedReader(file)) {
+ final BufferedReader in = JDK8.newBufferedReader(file);
+ try {
grid = FranceGeocentricInterpolation.load(in, file);
+ } finally {
+ in.close();
}
assertEquals("cellPrecision", 0.005, grid.getCellPrecision(), STRICT);
assertEquals("getCellMean", 168.2587, grid.getCellMean(0), 0.0001);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
index 9650766..770d618 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
@@ -35,8 +35,8 @@
import static org.opengis.test.Assert.*;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
import org.apache.sis.internal.jdk8.JDK8;
@@ -234,7 +234,8 @@
{
Envelope envelope = new Envelope2D(null, gridX, gridY, nx - 1, ny - 1);
envelope = Envelopes.transform(grid.getCoordinateToGrid().inverse(), envelope);
- try (final BufferedWriter out = JDK8.newBufferedWriter(file)) {
+ final BufferedWriter out = JDK8.newBufferedWriter(file);
+ try {
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),
@@ -246,6 +247,8 @@
}
out.write('\n');
}
+ } finally {
+ out.close();
}
}
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
index 454a6dc..e687abd 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
@@ -19,28 +19,20 @@
import java.net.URL;
import java.net.URISyntaxException;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.WritableByteChannel;
-import java.nio.charset.StandardCharsets;
import javax.measure.unit.NonSI;
import javax.measure.quantity.Angle;
import org.opengis.geometry.Envelope;
import org.opengis.util.FactoryException;
import org.opengis.referencing.operation.TransformException;
import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.geometry.Envelope2D;
-import org.apache.sis.geometry.Envelopes;
import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.opengis.test.Assert.*;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.Files;
-import java.nio.file.StandardOpenOption;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
/**
@@ -164,98 +156,4 @@
FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE * DatumShiftGridLoader.DEGREES_TO_SECONDS);
assertSame("Grid should be cached.", grid, NTv2.getOrLoad(file));
}
-
-
-
-
- //////////////////////////////////////////////////
- //////// ////////
- //////// TEST FILE CREATION ////////
- //////// ////////
- //////////////////////////////////////////////////
-
- /**
- * Writes a sub-grid of the given grid in pseudo-NTv2 format. This method is used only for creating the test file.
- * The file created by this method is not fully NTv2 compliant (in particular, we do not write complete header),
- * but we take this opportunity for testing {@code NTv2.Loader} capability to be lenient.
- *
- * <p>This method has been executed once for creating the {@code "NTF_R93-extract.gsb"} test file and should not
- * be needed anymore, but we keep it around in case we have new test files to generate. The parameter used for
- * creating the test file are:</p>
- *
- * <ul>
- * <li>{@code gridX} = 72</li>
- * <li>{@code gridY} = 74</li>
- * <li>{@code nx} = 6</li>
- * <li>{@code ny} = 7</li>
- * </ul>
- *
- * This ensure that the grid indices (75.7432814, 78.4451225) is included in the test file.
- * Those grid indices is the location of the (2°25′32.4187″N 48°50′40.2441″W) test point to interpolate.
- *
- * <div class="section">Limitations</div>
- * This method assumes that bounding box and increments have integer values, and that any fractional part
- * is rounding errors. This is usually the case when using the {@code "SECONDS"} unit of measurement.
- * This assumption does not apply to the shift values.
- *
- * @param grid The full grid from which to extract a few values.
- * @param out Where to write the test file.
- * @param gridX Index along the longitude axis of the first cell to write.
- * @param gridY Index along the latitude axis of the first cell to write.
- * @param nx Number of cells to write along the longitude axis.
- * @param ny Number of cells to write along the latitude axis.
- * @throws TransformException if an error occurred while computing the envelope.
- * @throws IOException if an error occurred while writing the test file.
- */
- public static void writeSubGrid(final DatumShiftGridFile<Angle,Angle> grid, final Path out,
- final int gridX, final int gridY, final int nx, final int ny) throws IOException, TransformException
- {
- Envelope envelope = new Envelope2D(null, gridX, gridY, nx - 1, ny - 1);
- envelope = Envelopes.transform(grid.getCoordinateToGrid().inverse(), envelope);
- final ByteBuffer buffer = ByteBuffer.allocate(4096);
- buffer.order(ByteOrder.LITTLE_ENDIAN);
- writeString(buffer, "NUM_OREC"); buffer.putInt(5); nextRecord(buffer);
- writeString(buffer, "NUM_SREC"); buffer.putInt(7); nextRecord(buffer);
- writeString(buffer, "NUM_FILE"); buffer.putInt(1); nextRecord(buffer);
- writeString(buffer, "GS_TYPE"); writeString(buffer, "SECONDS");
- writeString(buffer, "VERSION"); writeString(buffer, "SIS_TEST"); // Last overview record.
- writeString(buffer, "S_LAT"); buffer.putDouble(Math.rint( envelope.getMinimum(1)));
- writeString(buffer, "N_LAT"); buffer.putDouble(Math.rint( envelope.getMaximum(1)));
- writeString(buffer, "E_LONG"); buffer.putDouble(Math.rint(-envelope.getMaximum(0))); // Sign reversed.
- writeString(buffer, "W_LONG"); buffer.putDouble(Math.rint(-envelope.getMinimum(0)));
- writeString(buffer, "LAT_INC"); buffer.putDouble(Math.rint( envelope.getSpan(1) / (ny - 1)));
- writeString(buffer, "LONG_INC"); buffer.putDouble(Math.rint( envelope.getSpan(0) / (nx - 1)));
- writeString(buffer, "GS_COUNT"); buffer.putInt(nx * ny); nextRecord(buffer);
- for (int y=0; y<ny; y++) {
- for (int x=0; x<nx; x++) {
- buffer.putFloat((float) grid.getCellValue(1, gridX + x, gridY + y));
- buffer.putFloat((float) grid.getCellValue(0, gridX + x, gridY + y));
- buffer.putFloat(ACCURACY);
- buffer.putFloat(ACCURACY);
- }
- }
- writeString(buffer, "END");
- nextRecord(buffer);
- try (final WritableByteChannel c = Files.newByteChannel(out, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
- buffer.flip();
- c.write(buffer);
- }
- }
-
- /**
- * Writes the given string in the given buffer. It is caller's responsibility to ensure that the
- * string does not occupy more than 8 bytes in US-ASCII encoding.
- */
- private static void writeString(final ByteBuffer buffer, final String keyword) {
- final int upper = buffer.position() + 8; // "8" is the space allowed for strings in NTv2 format.
- buffer.put(keyword.getBytes(StandardCharsets.US_ASCII));
- while (buffer.position() != upper) buffer.put((byte) ' ');
- }
-
- /**
- * Moves the buffer position to the next record.
- */
- private static void nextRecord(final ByteBuffer buffer) {
- buffer.position(((buffer.position() / 16) + 1) * 16); // "16" is the length of records in NTv2 format.
- }
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
index 31e571b..bc4e963 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
@@ -129,13 +129,13 @@
* Ensures that every parameter instance is unique. Actually this test is not strong requirement.
* This is only for sharing existing resources by avoiding unnecessary objects duplication.
*
- * @throws ReflectiveOperationException if the instantiation of a service provider failed.
+ * @throws Exception if the instantiation of a service provider failed.
*/
@Test
- public void ensureParameterUniqueness() throws ReflectiveOperationException {
- final Map<GeneralParameterDescriptor, String> groupNames = new IdentityHashMap<>();
- final Map<GeneralParameterDescriptor, GeneralParameterDescriptor> parameters = new HashMap<>();
- final Map<Object, Object> namesAndIdentifiers = new HashMap<>();
+ public void ensureParameterUniqueness() throws Exception {
+ final Map<GeneralParameterDescriptor, String> groupNames = new IdentityHashMap<GeneralParameterDescriptor, String>();
+ final Map<GeneralParameterDescriptor, GeneralParameterDescriptor> parameters = new HashMap<GeneralParameterDescriptor, GeneralParameterDescriptor>();
+ final Map<Object, Object> namesAndIdentifiers = new HashMap<Object, Object>();
for (final Class<?> c : methods()) {
final OperationMethod method = (OperationMethod) c.newInstance();
final ParameterDescriptorGroup group = method.getParameters();
@@ -184,7 +184,7 @@
*/
@Test
public void testRedimension() {
- final Map<Class<?>,Boolean> redimensionables = new HashMap<>(100);
+ final Map<Class<?>,Boolean> redimensionables = new HashMap<Class<?>,Boolean>(100);
for (final Class<?> type : methods()) {
assertNull(type.getName(), redimensionables.put(type, Boolean.FALSE));
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
index a87acdc..3ff38a5 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
@@ -61,12 +61,12 @@
public static final DefaultParameterDescriptorGroup M1_M1_O1_O2;
static {
final Class<Integer> type = Integer.class;
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
M1_M1_O1_O2 = new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"), 0, 1,
- new DefaultParameterDescriptor<>(name(properties, "Mandatory 1", "Ambiguity"), 1, 1, type, null, null, DEFAULT_VALUE),
- new DefaultParameterDescriptor<>(name(properties, "Mandatory 2", "Alias 2"), 1, 1, type, null, null, DEFAULT_VALUE),
- new DefaultParameterDescriptor<>(name(properties, "Optional 3", "Alias 3"), 0, 1, type, null, null, DEFAULT_VALUE),
- new DefaultParameterDescriptor<>(name(properties, "Optional 4", "Ambiguity"), 0, 2, type, null, null, DEFAULT_VALUE)
+ new DefaultParameterDescriptor<Integer>(name(properties, "Mandatory 1", "Ambiguity"), 1, 1, type, null, null, DEFAULT_VALUE),
+ new DefaultParameterDescriptor<Integer>(name(properties, "Mandatory 2", "Alias 2"), 1, 1, type, null, null, DEFAULT_VALUE),
+ new DefaultParameterDescriptor<Integer>(name(properties, "Optional 3", "Alias 3"), 0, 1, type, null, null, DEFAULT_VALUE),
+ new DefaultParameterDescriptor<Integer>(name(properties, "Optional 4", "Ambiguity"), 0, 2, type, null, null, DEFAULT_VALUE)
);
}
@@ -85,10 +85,10 @@
@Test
public void testConstruction() {
final Class<Integer> type = Integer.class;
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
final DefaultParameterDescriptor<Integer> p1, p2;
- p1 = new DefaultParameterDescriptor<>(name(properties, "Name", null), 1, 1, type, null, null, null);
- p2 = new DefaultParameterDescriptor<>(name(properties, " NAME ", null), 1, 1, type, null, null, null);
+ p1 = new DefaultParameterDescriptor<Integer>(name(properties, "Name", null), 1, 1, type, null, null, null);
+ p2 = new DefaultParameterDescriptor<Integer>(name(properties, " NAME ", null), 1, 1, type, null, null, null);
try {
new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"), 0, 1, p1, p2);
fail("Constructor should have detected the duplicated names.");
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
index 16d9a0d..b51a0dd 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
@@ -55,7 +55,7 @@
* @return The properties to be given to descriptor constructor.
*/
private static Map<String,Object> properties(final String name) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, name));
assertNull(properties.put(DefaultParameterDescriptor.LOCALE_KEY, Locale.US));
return properties;
@@ -69,7 +69,7 @@
* @return The parameter descriptor.
*/
static <T> DefaultParameterDescriptor<T> createSimpleOptional(final String name, final Class<T> type) {
- return new DefaultParameterDescriptor<>(properties(name), 0, 1, type, null, null, null);
+ return new DefaultParameterDescriptor<T>(properties(name), 0, 1, type, null, null, null);
}
/**
@@ -84,7 +84,7 @@
static DefaultParameterDescriptor<Integer> create(final String name,
final int minimumValue, final int maximumValue, final int defaultValue)
{
- return new DefaultParameterDescriptor<>(properties(name), 1, 1, Integer.class,
+ return new DefaultParameterDescriptor<Integer>(properties(name), 1, 1, Integer.class,
NumberRange.create(minimumValue, true, maximumValue, true), null, defaultValue);
}
@@ -101,7 +101,7 @@
static DefaultParameterDescriptor<Double> create(final String name,
final double minimumValue, final double maximumValue, final double defaultValue, final Unit<?> unit)
{
- return new DefaultParameterDescriptor<>(properties(name), 1, 1, Double.class,
+ return new DefaultParameterDescriptor<Double>(properties(name), 1, 1, Double.class,
MeasurementRange.create(minimumValue, true, maximumValue, true, unit), null,
Double.isNaN(defaultValue) ? null : defaultValue);
}
@@ -119,7 +119,7 @@
static <T> DefaultParameterDescriptor<T> create(final String name, final Class<T> type,
final T[] validValues, final T defaultValue)
{
- return new DefaultParameterDescriptor<>(properties(name), 1, 1, type, null, validValues, defaultValue);
+ return new DefaultParameterDescriptor<T>(properties(name), 1, 1, type, null, validValues, defaultValue);
}
/**
@@ -135,7 +135,7 @@
final double minimumValue, final double maximumValue, final Unit<?> unit)
{
final MeasurementRange<Double> valueDomain = MeasurementRange.create(minimumValue, true, maximumValue, true, unit);
- return new DefaultParameterDescriptor<>(properties(name), 1, 1, double[].class, valueDomain, null, null);
+ return new DefaultParameterDescriptor<double[]>(properties(name), 1, 1, double[].class, valueDomain, null, null);
}
/**
@@ -149,7 +149,7 @@
final Map<String, Object> properties = properties(name);
assertNull(properties.put(DefaultParameterDescriptor.IDENTIFIERS_KEY,
new ImmutableIdentifier(Citations.EPSG, Constants.EPSG, Short.toString(code))));
- return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, null);
+ return new DefaultParameterDescriptor<Double>(properties, 0, 1, Double.class, null, null, null);
}
/**
@@ -228,8 +228,8 @@
*/
@Test
public void testStringType() {
- final Range<String> valueDomain = new Range<>(String.class, "AAA", true, "BBB", true);
- final DefaultParameterDescriptor<String> descriptor = new DefaultParameterDescriptor<>(
+ final Range<String> valueDomain = new Range<String>(String.class, "AAA", true, "BBB", true);
+ final DefaultParameterDescriptor<String> descriptor = new DefaultParameterDescriptor<String>(
properties("String param"), 0, 1, String.class, valueDomain, null, "ABC");
assertEquals("name", "String param", descriptor.getName().getCode());
assertEquals("valueClass", String.class, descriptor.getValueClass());
@@ -299,7 +299,7 @@
* Invalid operation: wrong type of range value.
*/
try {
- DefaultParameterDescriptor<double[]> p = new DefaultParameterDescriptor<>(properties("Array param"),
+ DefaultParameterDescriptor<double[]> p = new DefaultParameterDescriptor<double[]>(properties("Array param"),
0, 1, double[].class, NumberRange.create(4, true, 9, true), null, null);
fail("Should not be allowed to create " + p);
} catch (IllegalArgumentException e) {
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
index 89a6b4f..512ed64 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
@@ -72,11 +72,12 @@
* and assigns to them an integer value in sequence with the given step. For example if {@code step} is 10,
* then this method will create parameters with values 10, 20, 30 and 40.
*/
+ @SuppressWarnings({"unchecked", "rawtypes"})
private DefaultParameterValue<?>[] createValues(final int step) {
final List<GeneralParameterDescriptor> descriptors = descriptor.descriptors();
final DefaultParameterValue<?>[] parameters = new DefaultParameterValue<?>[descriptors.size()];
for (int i=0; i<parameters.length;) {
- parameters[i] = new DefaultParameterValue<>((ParameterDescriptor<?>) descriptors.get(i));
+ parameters[i] = new DefaultParameterValue((ParameterDescriptor<?>) descriptors.get(i));
parameters[i].setValue(++i * step);
}
return parameters;
@@ -239,7 +240,8 @@
@DependsOnMethod({"testValuesAddAll", "testAddGroup", "testEqualsAndHashCode"})
public void testValuesAddAllWithSubgroups() {
final DefaultParameterDescriptorGroup group, subGroup;
- final List<GeneralParameterDescriptor> descriptors = new ArrayList<>(descriptor.descriptors());
+ final List<GeneralParameterDescriptor> descriptors =
+ new ArrayList<GeneralParameterDescriptor>(descriptor.descriptors());
subGroup = new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "theSubGroup"),
2, 4, descriptors.toArray(new GeneralParameterDescriptor[descriptors.size()]));
descriptors.add(subGroup);
@@ -264,7 +266,7 @@
g1.parameter("Mandatory 1").setValue(3);
g2.parameter( "Optional 4").setValue(7);
g3.parameter("Mandatory 2").setValue(5);
- final List<GeneralParameterValue> expected = new ArrayList<>(6);
+ final List<GeneralParameterValue> expected = new ArrayList<GeneralParameterValue>(6);
assertTrue(expected.add(v2));
assertTrue(expected.add(v3));
assertTrue(expected.add(g1));
@@ -295,7 +297,7 @@
public void testValuesAddWrongParameter() {
final DefaultParameterValueGroup group = createGroup(10);
final List<GeneralParameterValue> values = group.values();
- final ParameterValue<Integer> nonExistent = new DefaultParameterDescriptor<>(
+ final ParameterValue<Integer> nonExistent = new DefaultParameterDescriptor<Integer>(
singletonMap(NAME_KEY, "Optional 5"), 0, 1, Integer.class, null, null, null).createValue();
try {
values.add(nonExistent);
@@ -424,7 +426,7 @@
public void testEqualsIgnoreMetadata() {
final DefaultParameterValueGroup g1 = createGroup(10);
final DefaultParameterValueGroup g2 = new DefaultParameterValueGroup(g1.getDescriptor());
- final List<GeneralParameterValue> values = new ArrayList<>(g1.values());
+ final List<GeneralParameterValue> values = new ArrayList<GeneralParameterValue>(g1.values());
Collections.swap(values, 2, 3);
g2.values().addAll(values);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
index bbc6291..bd6f659 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
@@ -94,7 +94,7 @@
* @return A new parameter instance for the given name and value.
*/
private static Watcher<Integer> createOptional(final String name, final int value) {
- final Watcher<Integer> parameter = new Watcher<>(
+ final Watcher<Integer> parameter = new Watcher<Integer>(
DefaultParameterDescriptorTest.createSimpleOptional(name, Integer.class));
parameter.setValue(value, null);
return parameter;
@@ -109,7 +109,7 @@
* @return A new parameter instance for the given name and value.
*/
private static Watcher<Double> create(final String name, final double value, final Unit<?> unit) {
- final Watcher<Double> parameter = new Watcher<>(DefaultParameterDescriptorTest.create(
+ final Watcher<Double> parameter = new Watcher<Double>(DefaultParameterDescriptorTest.create(
name, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN, unit));
parameter.setValue(value, unit);
return parameter;
@@ -179,7 +179,7 @@
@Test
@DependsOnMethod("testInteger")
public void testBoundedInteger() {
- final Watcher<Integer> parameter = new Watcher<>(
+ final Watcher<Integer> parameter = new Watcher<Integer>(
DefaultParameterDescriptorTest.create("Bounded param", -30, +40, 15));
assertEquals(Integer.class, parameter.getDescriptor().getValueClass());
assertEquals( "value", Integer.valueOf(15), parameter.getValue());
@@ -299,7 +299,7 @@
@Test
@DependsOnMethod("testMeasure")
public void testBoundedDouble() {
- final Watcher<Double> parameter = new Watcher<>(
+ final Watcher<Double> parameter = new Watcher<Double>(
DefaultParameterDescriptorTest.create("Bounded param", -30.0, +40.0, 15.0, null));
assertEquals(Double.class, parameter.getDescriptor().getValueClass());
assertEquals( "value", Double.valueOf(15), parameter.getValue());
@@ -343,7 +343,7 @@
@Test
@DependsOnMethod({"testMeasure", "testBoundedDouble"})
public void testBoundedMeasure() {
- final Watcher<Double> parameter = new Watcher<>(
+ final Watcher<Double> parameter = new Watcher<Double>(
DefaultParameterDescriptorTest.create("Length measure", 4, 20, 12, SI.METRE));
assertEquals("value", Double.valueOf(12), parameter.getValue());
assertEquals("intValue", 12, parameter.intValue());
@@ -390,7 +390,7 @@
@Test
public void testArray() {
double[] values = {5, 10, 15};
- final Watcher<double[]> parameter = new Watcher<>(
+ final Watcher<double[]> parameter = new Watcher<double[]>(
DefaultParameterDescriptorTest.createForArray("myValues", 4, 4000, SI.METRE));
parameter.setValue(values);
assertArrayEquals(values, parameter.getValue(), 0);
@@ -435,7 +435,7 @@
};
final ParameterDescriptor<AxisDirection> descriptor = DefaultParameterDescriptorTest.create(
"Direction", AxisDirection.class, directions, AxisDirection.NORTH);
- final DefaultParameterValue<AxisDirection> parameter = new DefaultParameterValue<>(descriptor);
+ final DefaultParameterValue<AxisDirection> parameter = new DefaultParameterValue<AxisDirection>(descriptor);
validate(parameter);
assertEquals ("name", "Direction", descriptor.getName().getCode());
@@ -627,7 +627,7 @@
@Test
@DependsOnMethod("testWKT")
public void testIdentifiedParameterWKT() {
- final Watcher<Double> parameter = new Watcher<>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.EPSG_A0));
+ final Watcher<Double> parameter = new Watcher<Double>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.EPSG_A0));
assertWktEquals(Convention.WKT2, "PARAMETER[“A0”, null, ID[“EPSG”, 8623]]", parameter);
}
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java
index a3931ab..f913aa6 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/MapProjectionParametersTest.java
@@ -68,7 +68,7 @@
/** Creates a parameter of the given name. */
private static DefaultParameterDescriptor<?> parameter(final String name) {
- return new DefaultParameterDescriptor<>(name(name), 1, 1, Double.class, null, null, null);
+ return new DefaultParameterDescriptor<Double>(name(name), 1, 1, Double.class, null, null, null);
}
/** Returns properties map for an object of the given name. */
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
index 3d0ba3e..11d5921 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
@@ -42,7 +42,7 @@
import static org.apache.sis.test.ReferencingAssert.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -62,7 +62,7 @@
* Creates a parameter value for marshalling test.
*/
private static <T> DefaultParameterValue<T> create(final Class<T> type, final Range<?> valueDomain) {
- return new DefaultParameterValue<>(new DefaultParameterDescriptor<>(
+ return new DefaultParameterValue<T>(new DefaultParameterDescriptor<T>(
Collections.singletonMap(DefaultParameterDescriptor.NAME_KEY,
"A parameter of type " + type.getSimpleName()),
1, 1, type, valueDomain, null, null));
@@ -108,7 +108,7 @@
*/
@Test
public void testDescriptor() throws JAXBException {
- final DefaultParameterDescriptor<Double> descriptor = new DefaultParameterDescriptor<>(
+ final DefaultParameterDescriptor<Double> descriptor = new DefaultParameterDescriptor<Double>(
Collections.singletonMap(DefaultParameterDescriptor.NAME_KEY, "A descriptor"),
0, 1, Double.class, null, null, null);
final String xml = XML.marshal(descriptor);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java b/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
index 864a667..5b0dfe6 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
@@ -98,7 +98,7 @@
@SuppressWarnings("unchecked")
public TensorParametersTest() {
if (WKT1 == null) {
- WKT1 = new TensorParameters<>(Double.class, "elt_", "_",
+ WKT1 = new TensorParameters<Double>(Double.class, "elt_", "_",
TensorParameters.WKT1.getDimensionDescriptor(0),
TensorParameters.WKT1.getDimensionDescriptor(1));
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
index 216c41f..04b9efd 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
@@ -58,7 +58,7 @@
* @param identifier The value for the {@code "identifiers"} property.
*/
private static Map<String,Object> properties(final Set<Identifier> identifiers) {
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
assertNull(properties.put("name", "GRS 1980"));
assertNull(properties.put("identifiers", identifiers.toArray(new Identifier[identifiers.size()])));
assertNull(properties.put("codespace", "EPSG"));
@@ -102,7 +102,7 @@
@Test
@SuppressWarnings("ResultOfObjectAllocationIgnored")
public void testMissingName() {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(AbstractIdentifiedObject.REMARKS_KEY, "Not a name."));
try {
new AbstractIdentifiedObject(properties);
@@ -168,7 +168,7 @@
@Test
@DependsOnMethod("testWithSingleIdentifier")
public void testWithManyIdentifiers() {
- final Set<Identifier> identifiers = new LinkedHashSet<>(4);
+ final Set<Identifier> identifiers = new LinkedHashSet<Identifier>(4);
assertTrue(identifiers.add(new NamedIdentifier(EPSG, "7019")));
assertTrue(identifiers.add(new NamedIdentifier(EPSG, "IgnoreMe")));
final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties(identifiers));
@@ -204,7 +204,7 @@
@Test
@DependsOnMethod("testWithManyIdentifiers")
public void testIdentifierCollision() {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put("name", "GRS 1980"));
assertNull(properties.put("identifiers", new NamedIdentifier(EPSG, "7019")));
final AbstractIdentifiedObject o1 = new AbstractIdentifiedObject(properties);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
index d1a30de..01560af 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
@@ -53,7 +53,7 @@
*/
@Test
public void testCreateFromMap() {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
assertNull(properties.put("name", "This is a name"));
assertNull(properties.put("scope", "This is a scope"));
assertNull(properties.put("scope_fr", "Valide dans ce domaine"));
@@ -76,7 +76,7 @@
@Test
@DependsOnMethod("testCreateFromMap")
public void testSerialization() {
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
assertNull(properties.put("code", "4326"));
assertNull(properties.put("codeSpace", "EPSG"));
assertNull(properties.put("scope", "This is a scope"));
@@ -96,7 +96,7 @@
@Test
@DependsOnMethod("testCreateFromMap")
public void testWKT() {
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
assertNull(properties.put(NAME_KEY, "My “object”."));
assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
assertNull(properties.put(REMARKS_KEY, "注です。"));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java
index 4b6a1fb..9cd455a 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java
@@ -220,18 +220,14 @@
builder.onCreate(true);
for (final Map.Entry<String,?> entry : builder.properties.entrySet()) {
final Object value = entry.getValue();
- switch (entry.getKey()) {
- case Identifier.AUTHORITY_KEY: {
+ final String key = entry.getKey();
+ { // This is a switch(String) in the JDK7 branch.
+ if (key.equals(Identifier.AUTHORITY_KEY)) {
assertSame("Authority and codespace shall be unchanged.", Citations.EPSG, value);
- break;
- }
- case Identifier.CODESPACE_KEY: {
+ } else if (key.equals(Identifier.CODESPACE_KEY)) {
assertEquals("Authority and codespace shall be unchanged.", "EPSG", value);
- break;
- }
- default: {
+ } else {
assertNull("Should not contain any non-null value except the authority.", value);
- break;
}
}
}
@@ -292,7 +288,7 @@
*/
@Test
public void testCreationFromObject() {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
final Identifier id = new SimpleIdentifier(null, "An identifier", false);
assertNull(properties.put(AbstractIdentifiedObject.IDENTIFIERS_KEY, id));
assertNull(properties.put(AbstractIdentifiedObject.ALIAS_KEY, "An alias"));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
index bfb8762..c581cc7 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
@@ -73,7 +73,7 @@
*/
@Test
public void ensureNoCodeCollision() {
- final Map<Integer,Enum<?>> codes = new HashMap<>();
+ final Map<Integer,Enum<?>> codes = new HashMap<Integer,Enum<?>>();
final CommonCRS[] values = CommonCRS.values();
for (final CommonCRS crs : values) {
assertNoCodeCollision(codes, crs, crs.geographic);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
index 5797311..0305ab9 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
@@ -198,7 +198,7 @@
final CRSAuthorityFactory EPSG = (CRSAuthorityFactory) AuthorityFactories.EPSG();
try {
setEPSGFactory(EPSGFactoryFallback.INSTANCE);
- final ArrayList<String> codes = new ArrayList<>(EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CoordinateReferenceSystem.class));
+ final ArrayList<String> codes = new ArrayList<String>(EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CoordinateReferenceSystem.class));
Collections.shuffle(codes, TestUtilities.createRandomNumberGenerator());
for (final String code : codes) {
final CoordinateReferenceSystem crs = EPSGFactoryFallback.INSTANCE.createCoordinateReferenceSystem(code);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
index 551fd13..2debd04 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
@@ -251,7 +251,7 @@
* Creates a map of properties for the given name and code with world extent.
*/
private static Map<String,?> properties(final String name, final String code) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(NAME_KEY, name);
properties.put(DOMAIN_OF_VALIDITY_KEY, Extents.WORLD);
if (code != null) {
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
index b663a55..e9f9737 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
@@ -475,7 +475,7 @@
final AxisDirection direction, final Unit<?> unit, final double minimum, final double maximum,
final RangeMeaning meaning)
{
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
properties.put(DefaultCoordinateSystemAxis.NAME_KEY, name);
properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, minimum);
properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, maximum);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
index b45b880..5c8ec44 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
@@ -64,7 +64,7 @@
*/
@Test
public void testCreateAndSerialize() {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
assertNull(properties.put(DefaultEllipsoid.NAME_KEY, "Asteroid"));
final DefaultEllipsoid ellipsoid = DefaultEllipsoid.createEllipsoid(properties, 1200, 1000, SI.METRE);
@@ -127,7 +127,7 @@
@Test
@DependsOnMethod("testCreateAndSerialize")
public void testGetPositionVectorTransformation() {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
assertNull(properties.put(DefaultGeodeticDatum.NAME_KEY, "Invalid dummy datum"));
/*
* Associate two BursaWolfParameters, one valid only in a local area and the other one
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
index 4220a27..fe823c5 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
@@ -53,7 +53,7 @@
* Creates the temporal datum to use for testing purpose.
*/
private static DefaultTemporalDatum create() {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(DefaultTemporalDatum.IDENTIFIERS_KEY,
new ImmutableIdentifier(HardCodedCitations.SIS, "SIS", "MJ")));
assertNull(properties.put(DefaultTemporalDatum.NAME_KEY, "Modified Julian"));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
index 774b8f4..0bd5fbf 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
@@ -170,7 +170,7 @@
* Creates a map of properties for the given name and EPSG code.
*/
private static Map<String,?> properties(final String name, final String code, final CharSequence scope) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(NAME_KEY, name);
if (code != null) {
properties.put(IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG, code));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
index 0e0356f..eacc0a1 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
@@ -52,8 +52,9 @@
* @version 0.7
* @module
*/
+@org.apache.sis.internal.jdk7.AutoCloseable
public final strictfp class AuthorityFactoryMock extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
- CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, AutoCloseable
+ CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
{
/**
* The authority.
@@ -107,7 +108,7 @@
@Override
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) {
assertFalse("This factory has been closed.", isClosed());
- final Set<String> codes = new LinkedHashSet<>();
+ final Set<String> codes = new LinkedHashSet<String>();
if (type.isAssignableFrom(GeocentricCRS.class)) add(codes, 4979);
if (type.isAssignableFrom(GeographicCRS.class)) add(codes, 84, 4326);
if (type.isAssignableFrom(PrimeMeridian.class)) add(codes, 8901, 8903, 8914);
@@ -205,7 +206,6 @@
/**
* Flags this factory as closed.
*/
- @Override
public synchronized void close() {
closed = true;
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java
index 09f7a59..e749c04 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java
@@ -52,7 +52,7 @@
*/
private static final strictfp class Mock extends ConcurrentAuthorityFactory<AuthorityFactoryMock> {
/** All factories created by this mock, including any factories having been disposed. */
- private final Queue<AuthorityFactoryMock> allDAOs = new ConcurrentLinkedQueue<>();
+ private final Queue<AuthorityFactoryMock> allDAOs = new ConcurrentLinkedQueue<AuthorityFactoryMock>();
/** Creates a new concurrent authority factory. */
Mock() {
@@ -70,7 +70,7 @@
/** Returns a copy of the factories queue. */
final synchronized List<AuthorityFactoryMock> createdDAOs() {
- return new ArrayList<>(allDAOs);
+ return new ArrayList<AuthorityFactoryMock>(allDAOs);
}
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
index 981b3cc..17f5214 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
@@ -38,7 +38,7 @@
import org.apache.sis.internal.metadata.sql.TestDatabase;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
@@ -141,10 +141,12 @@
return;
}
final DataSource ds = TestDatabase.create("dummy");
- try (Connection c = ds.getConnection()) {
+ final Connection c = ds.getConnection();
+ try {
final EPSGDataFormatter f = new EPSGDataFormatter(c);
f.run(new File(arguments[0]), new File(arguments[1]));
} finally {
+ c.close();
TestDatabase.drop(ds);
}
}
@@ -195,7 +197,7 @@
*/
private EPSGDataFormatter(final Connection c) throws SQLException {
super(c, Integer.MAX_VALUE);
- final Map<String,int[]> m = new HashMap<>();
+ final Map<String,int[]> m = new HashMap<String,int[]>();
m.put("epsg_alias", new int[] { });
m.put("epsg_area", new int[] {0 });
m.put("epsg_change", new int[] { });
@@ -245,9 +247,8 @@
throw new IllegalArgumentException("Input and output files are the same.");
}
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.ISO_8859_1));
- try (final LineNumberReader in = new LineNumberReader(
- new InputStreamReader(new FileInputStream(inputFile), StandardCharsets.ISO_8859_1)))
- {
+ final LineNumberReader in = new LineNumberReader(new InputStreamReader(new FileInputStream(inputFile), StandardCharsets.ISO_8859_1));
+ try {
out.write("---\n" +
"--- Copyright International Association of Oil and Gas Producers (IOGP)\n" +
"--- See http://www.epsg.org/TermsOfUse (a copy is in ./LICENSE.txt).\n" +
@@ -258,6 +259,7 @@
"\n");
run(inputFile.getName(), in);
} finally {
+ in.close();
out.close();
out = null;
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
index 9eea71e..21b2172 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
@@ -105,7 +105,7 @@
@BeforeClass
public static void createFactory() throws FactoryException {
final GeodeticObjectFactory f = new GeodeticObjectFactory();
- final Map<String,Object> properties = new HashMap<>(6);
+ final Map<String,Object> properties = new HashMap<String,Object>(6);
assertNull(properties.put("datumFactory", f));
assertNull(properties.put("csFactory", f));
assertNull(properties.put("crsFactory", f));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
index 7e7d928..7b69c8d 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
@@ -158,8 +158,11 @@
try {
createAndTest(ds, scripts);
} finally {
- try (Connection c = ds.getConnection(); Statement s = c.createStatement()) {
+ final Connection c = ds.getConnection(); Statement s = c.createStatement();
+ try {
s.execute("SHUTDOWN");
+ } finally {
+ c.close();
}
}
loggings.assertNextLogContains("EPSG", "jdbc:hsqldb:mem:test");
@@ -173,13 +176,14 @@
private void createAndTest(final DataSource ds, final InstallationScriptProvider scriptProvider)
throws SQLException, FactoryException
{
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
assertNull(properties.put("dataSource", ds));
assertNull(properties.put("scriptProvider", scriptProvider));
assertEquals("Should not contain EPSG tables before we created them.", 0, countCRSTables(ds));
loggings.assertNoUnexpectedLog(); // Should not yet have logged anything at this point.
- try (EPSGFactory factory = new EPSGFactory(properties)) {
+ final EPSGFactory factory = new EPSGFactory(properties);
+ try {
/*
* Fetch the "WGS 84" coordinate reference system.
*/
@@ -204,9 +208,11 @@
* should not be included. The intend is to verify that the fields
* of type BOOLEAN have been properly handled.
*/
- codes = new HashSet<>(codes);
+ codes = new HashSet<String>(codes);
assertTrue ("4979", codes.contains("4979"));
assertFalse("4329", codes.contains("4329"));
+ } finally {
+ factory.close();
}
assertEquals("Should contain EPSG tables after we created them.", 1, countCRSTables(ds));
}
@@ -217,14 +223,20 @@
*/
private static int countCRSTables(final DataSource ds) throws SQLException {
int count = 0;
- try (Connection c = ds.getConnection()) {
- try (ResultSet r = c.getMetaData().getTables(null, null, "Coordinate Reference System", null)) {
+ final Connection c = ds.getConnection();
+ try {
+ final ResultSet r = c.getMetaData().getTables(null, null, "Coordinate Reference System", null);
+ try {
while (r.next()) {
final String schema = r.getString("TABLE_SCHEM");
assertTrue(schema, "EPSG".equalsIgnoreCase(schema));
count++;
}
+ } finally {
+ r.close();
}
+ } finally {
+ c.close();
}
return count;
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
index eec6da2..de9c165 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
@@ -829,7 +829,7 @@
@Test
@DependsOnMethod("testProjected4D_to_2D")
public void testSpatioTemporalToDerived() throws FactoryException, TransformException {
- final Map<String,Object> properties = new HashMap<>();
+ final Map<String,Object> properties = new HashMap<String,Object>();
properties.put(DerivedCRS.NAME_KEY, "Display");
properties.put("conversion.name", "Display to WGS84");
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
index 2417b6a..7f745f8 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
@@ -157,7 +157,7 @@
* did not bothered to define a specialized MathTransform class for our case. So we will help
* a little bit DefaultConversion by telling it the parameters that we used.
*/
- final Map<String, Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(DefaultTransformation.NAME_KEY, "Paris to Greenwich");
properties.put(ReferencingServices.PARAMETERS_KEY, pg);
return new DefaultConversion(properties, sourceCRS, targetCRS, interpolationCRS,
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
index e119d1f..d465be0 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
@@ -63,7 +63,7 @@
static DefaultOperationMethod create(final String method, final String identifier, final String formula,
final Integer dimension, final ParameterDescriptor<?>... parameters)
{
- final Map<String,Object> properties = new HashMap<>(8);
+ final Map<String,Object> properties = new HashMap<String,Object>(8);
assertNull(properties.put(OperationMethod.NAME_KEY, method));
assertNull(properties.put(Identifier.CODESPACE_KEY, "EPSG"));
assertNull(properties.put(Identifier.AUTHORITY_KEY, Citations.EPSG));
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
index 8b46c36..588e9a0 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
@@ -59,7 +59,7 @@
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<>(properties);
+ final Map<String,Object> copy = new HashMap<String,Object>(properties);
copy.put(DefaultGeocentricCRS.NAME_KEY, name);
properties = copy;
}
@@ -93,7 +93,7 @@
* did not bothered to define a specialized MathTransform class for our case. So we will help
* a little bit DefaultTransformation by telling it the parameters that we used.
*/
- final Map<String, Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(DefaultTransformation.NAME_KEY, "Tokyo to JGD2000 (GSI)");
properties.put(ReferencingServices.PARAMETERS_KEY, pg);
return new DefaultTransformation(properties,
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
index 8928de9..4989d4d 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java
@@ -77,7 +77,7 @@
};
builder.addName(null, "Mercator (1SP)");
final ParameterDescriptorGroup descriptor = builder.createGroup(parameters);
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
properties.put(DefaultOperationMethod.NAME_KEY, descriptor.getName());
properties.put(DefaultOperationMethod.FORMULA_KEY, new DefaultFormula("See EPSG guide."));
return new DefaultOperationMethod(properties, 2, 2, descriptor);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/InitializerTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/InitializerTest.java
index abde794..5b956c4 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/InitializerTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/InitializerTest.java
@@ -72,7 +72,7 @@
* to do that since this map is provided by the ObliqueStereographic class itself.
*/
final EnumMap<NormalizedProjection.ParameterRole, ParameterDescriptor<Double>> roles =
- new EnumMap<>(NormalizedProjection.ParameterRole.class);
+ new EnumMap<NormalizedProjection.ParameterRole, ParameterDescriptor<Double>>(NormalizedProjection.ParameterRole.class);
roles.put(NormalizedProjection.ParameterRole.CENTRAL_MERIDIAN, ObliqueStereographic.LONGITUDE_OF_ORIGIN);
roles.put(NormalizedProjection.ParameterRole.SCALE_FACTOR, ObliqueStereographic.SCALE_FACTOR);
roles.put(NormalizedProjection.ParameterRole.FALSE_EASTING, ObliqueStereographic.FALSE_EASTING);
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java
index f726494..e7f8085 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java
@@ -113,7 +113,7 @@
final Object elliptical;
try {
elliptical = ellipticalClass.getDeclaredConstructor(ellipticalClass).newInstance(spherical);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // ReflectiveOperationException on the JDK7 branch.
throw new AssertionError(e); // Considered as a test failure.
}
/*
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
index 2061d5f..de642d5 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
@@ -158,7 +158,7 @@
derivativeDeltas = new double[] {delta, delta, 100};
tolerance = Formulas.LINEAR_TOLERANCE;
toleranceModifier = ToleranceModifier.PROJECTION;
- verifyInverse(40, 30, 10000);
+ verifyInverse(new double[] {40, 30, 10000});
}
/**
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
index 7450045..6c890af 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
@@ -209,7 +209,8 @@
" Parameter[“tgt_semi_major”, 6378137.0],\n" +
" Parameter[“tgt_semi_minor”, 6356752.314140356],\n" +
" ParameterFile[“Geocentric translation file”, “\\E.*\\W\\Q" +
- FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727]]],\n" +
+ FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727],\n" +
+ " Remark[“\\E.*\\Q”]]],\n" +
" Param_MT[“Affine parametric transformation”,\n" +
" Parameter[“A0”, 57.29577951308232, Id[“EPSG”, 8623]],\n" + // Radians to degrees conversion
" Parameter[“B1”, 57.29577951308232, Id[“EPSG”, 8640]]]]\\E");
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java
index ec91d2b..bbb0cdb 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java
@@ -118,7 +118,8 @@
" Parameter[“Semi-major axis length difference”, -112.2, Id[“EPSG”, 8654]],\n" +
" Parameter[“Flattening difference”, -5.4738838833299144E-5, Id[“EPSG”, 8655]],\n" +
" ParameterFile[“Geocentric translation file”, “\\E.*\\W\\Q" +
- FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727]],\n" +
+ FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727],\n" +
+ " Remark[“\\E.*\\Q”]],\n" +
" Parameter[“dim”, 2]],\n" +
" Param_MT[“Affine parametric transformation”,\n" +
" Parameter[“A0”, 57.29577951308232, Id[“EPSG”, 8623]],\n" + // Radians to degrees conversion
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
index 5826e5c..5075ec4 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
@@ -29,7 +29,7 @@
import org.apache.sis.io.wkt.UnformattableObjectException;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RandomFailureTransform.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RandomFailureTransform.java
index 7acb97d..479af27 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RandomFailureTransform.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/RandomFailureTransform.java
@@ -71,7 +71,7 @@
super(4,3);
this.denominator = denominator;
random = new Random(891914828L * denominator);
- failures = new HashSet<>();
+ failures = new HashSet<Integer>();
}
/**
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java
index 07b3c46..e5d2975 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateOperationMethods.java
@@ -78,7 +78,7 @@
*/
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));
+ final List<OperationMethod> methods = new ArrayList<OperationMethod>(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");
@@ -95,11 +95,14 @@
return c;
}
});
- try (final CoordinateOperationMethods writer = new CoordinateOperationMethods()) {
+ final CoordinateOperationMethods writer = new CoordinateOperationMethods();
+ try {
writer.writeIndex(methods);
for (final OperationMethod method : methods) {
writer.write(method);
}
+ } finally {
+ writer.close();
}
}
@@ -326,7 +329,7 @@
println("th class=\"sep\"", "Remarks");
println("th class=\"sep\" colspan=\"3\"", "Value domain");
println("th class=\"sep\"", "Default");
- final Map<String, Integer> footnotes = new LinkedHashMap<>();
+ final Map<String,Integer> footnotes = new LinkedHashMap<String,Integer>();
for (final GeneralParameterDescriptor gp : group.descriptors()) {
if (isDeprecated(gp)) {
continue; // Hide deprecated parameters.
@@ -416,7 +419,7 @@
public static Map<String, DefaultGeographicBoundingBox> computeUnionOfAllDomainOfValidity(
final CRSAuthorityFactory factory) throws FactoryException
{
- final Map<String, DefaultGeographicBoundingBox> domainOfValidity = new HashMap<>();
+ final Map<String, DefaultGeographicBoundingBox> domainOfValidity = new HashMap<String, DefaultGeographicBoundingBox>();
for (final String code : factory.getAuthorityCodes(GeneralDerivedCRS.class)) {
final CoordinateReferenceSystem crs;
try {
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
index c78d2f6..41f6b8b 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
@@ -97,7 +97,7 @@
* <p>The decision to merge or not is arbitrary. Generally, we try to avoid small sections (less that 5 CRS)
* but without merging together unrelated datums.</p>
*/
- private static final Map<String,String> SECTION_TITLES = new HashMap<>();
+ private static final Map<String,String> SECTION_TITLES = new HashMap<String,String>();
static {
rd("American Samoa 1962", "American Samoa");
rd("American Samoa Vertical Datum of 2002", "American Samoa");
@@ -364,7 +364,7 @@
* The datums from the above list which are deprecated, but that we do not want to replace by the non-deprecated
* datum. We disable some replacements when they allow better sorting of deprecated CRS.
*/
- private static final Set<String> KEEP_DEPRECATED_DATUM = new HashSet<>(Arrays.asList(
+ private static final Set<String> KEEP_DEPRECATED_DATUM = new HashSet<String>(Arrays.asList(
"Dealul Piscului 1970")); // Datum does not exist but is an alias for S-42 in Romania.
/**
@@ -378,7 +378,7 @@
/**
* Words to ignore in a datum name in order to detect if a CRS name is the acronym of the datum name.
*/
- private static final Set<String> DATUM_WORDS_TO_IGNORE = new HashSet<>(Arrays.asList(
+ private static final Set<String> DATUM_WORDS_TO_IGNORE = new HashSet<String>(Arrays.asList(
"of", // VIVD: Virgin Islands Vertical Datum of 2009
"de", // RRAF: Reseau de Reference des Antilles Francaises
"des", // RGAF: Reseau Geodesique des Antilles Francaises
@@ -449,7 +449,7 @@
*/
private CoordinateReferenceSystems() throws FactoryException {
super(null);
- unusedDatumMapping = new HashSet<>(SECTION_TITLES.keySet());
+ unusedDatumMapping = new HashSet<String>(SECTION_TITLES.keySet());
properties.setProperty("TITLE", "Apache SIS™ Coordinate Reference System (CRS) codes");
properties.setProperty("PRODUCT.NAME", "Apache SIS™");
properties.setProperty("PRODUCT.VERSION", getVersion());
@@ -860,7 +860,7 @@
super.sortRows();
@SuppressWarnings("SuspiciousToArrayCall")
final ByName[] data = rows.toArray(new ByName[rows.size()]);
- final Map<String,String> sections = new TreeMap<>();
+ final Map<String,String> sections = new TreeMap<String,String>();
for (final ByName row : data) {
final String section = row.section;
if (section != null) {
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
index 9ed80b4..853088f 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
@@ -93,7 +93,7 @@
if (file.exists()) {
throw new IOException("File " + file.getAbsolutePath() + " already exists.");
}
- openedTags = new ArrayDeque<>();
+ openedTags = new ArrayDeque<String>();
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), ENCODING));
out.write("<!DOCTYPE html>");
out.newLine();
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java b/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
new file mode 100644
index 0000000..7011a9f
--- /dev/null
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
@@ -0,0 +1,274 @@
+/*
+ * 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.test;
+
+import java.util.Deque;
+import java.util.ArrayDeque;
+import java.util.Locale;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.Closeable;
+import org.opengis.util.InternationalString;
+import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Deprecable;
+
+
+/**
+ * Base class of all classes used to generate HTML pages to be published on
+ * the <a href="http://sis.apache.org/">http://sis.apache.org/</a> web site.
+ *
+ * <p>This class creates files in the current default directory. It is user's responsibility
+ * to move the files to the appropriate Apache SIS {@code "content/"} site directory.</p>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+public abstract class HTMLGenerator implements Closeable {
+ /**
+ * The encoding of the files to generate.
+ */
+ private static final String ENCODING = "UTF-8";
+
+ /**
+ * The language to use for the reports to generate.
+ *
+ * @see #toLocalizedString(InternationalString)
+ */
+ protected static final Locale LOCALE = Locale.US;
+
+ /**
+ * The number of space to add or remove in the {@linkplain #margin}
+ * when new HTML elements are opened or closed.
+ */
+ private static final int INDENTATION = 2;
+
+ /**
+ * Where to write the HTML page.
+ */
+ private final BufferedWriter out;
+
+ /**
+ * The spaces to write in the margin before every new line.
+ * The number of spaces will increase by the indentation amount when new elements are opened.
+ *
+ * @see #INDENTATION
+ */
+ private String margin = "";
+
+ /**
+ * HTML tags currently opened.
+ */
+ private final Deque<String> openedTags;
+
+ /**
+ * Creates a new instance which will write in the given file.
+ * This constructor immediately writes the HTML header up to the {@code <body>} line, inclusive.
+ *
+ * @param filename The name of the file where to write.
+ * @param title The document title.
+ * @throws IOException if the file can not be created (e.g. because it already exists).
+ */
+ protected HTMLGenerator(final String filename, final String title) throws IOException {
+ final File file = new File(filename);
+ if (file.exists()) {
+ throw new IOException("File " + file.getAbsolutePath() + " already exists.");
+ }
+ openedTags = new ArrayDeque<String>();
+ out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), ENCODING));
+ out.write("<!DOCTYPE html>");
+ out.newLine();
+ out.write("<!--");
+ out.newLine();
+ out.write(" This page is automatically generated by the following class in the test directory:");
+ out.newLine();
+ out.write(" ");
+ out.write(getClass().getCanonicalName());
+ out.newLine();
+ out.write("-->");
+ out.newLine();
+ openTag("html");
+ final int head = openTag("head");
+ out.write(margin);
+ out.write("<meta charset=\"" + ENCODING + "\"/>");
+ out.newLine();
+ println("title", title);
+ openTag("style type=\"text/css\" media=\"all\"");
+ println("@import url(\"./reports.css\");");
+ closeTags(head);
+ openTag("body");
+ }
+
+ /**
+ * Escapes the {@code &}, {@code <} and {@code >} characters.
+ *
+ * @param text The text to escape, or {@code null}.
+ * @return The escaped text, or {@code null} if the given text was null.
+ */
+ protected static CharSequence escape(CharSequence text) {
+ text = CharSequences.replace(text, "&", "&");
+ text = CharSequences.replace(text, "<", "<");
+ text = CharSequences.replace(text, ">", ">");
+ return text;
+ }
+
+ /**
+ * Return the given HTML tag without the attributes. For example if {@code tag} is
+ * {@code "table class='param'"}, then this method returns only {@code "table"}.
+ */
+ private static String omitAttributes(String tag) {
+ final int s = tag.indexOf(' ');
+ if (s >= 0) {
+ tag = tag.substring(0, s);
+ }
+ return tag;
+ }
+
+ /**
+ * Opens a new HTML tag and increase the indentation.
+ *
+ * @param tag The HTML tag without brackets (e.g. {@code "h2"}).
+ * @return The value to give to {@link #closeTags(int)} for closing the tags.
+ * @throws IOException if an error occurred while writing to the file.
+ */
+ protected final int openTag(final String tag) throws IOException {
+ out.write(margin);
+ out.write('<');
+ out.write(tag);
+ out.write('>');
+ out.newLine();
+ margin = CharSequences.spaces(margin.length() + INDENTATION).toString();
+ final int openedTag = openedTags.size();
+ openedTags.add(omitAttributes(tag));
+ return openedTag;
+ }
+
+ /**
+ * Closes the last HTML tag if it is equals to the given element, and opens a new tag on the same line.
+ *
+ * @param tag The HTML tag without brackets (e.g. {@code "h2"}).
+ * @throws IOException if an error occurred while writing to the file.
+ */
+ protected final void reopenTag(final String tag) throws IOException {
+ final String tagWithoutAttributes = omitAttributes(tag);
+ if (openedTags.getLast().equals(tagWithoutAttributes)) {
+ out.write(CharSequences.spaces(margin.length() - INDENTATION).toString());
+ out.write("</");
+ out.write(tagWithoutAttributes);
+ out.write("><");
+ out.write(tag);
+ out.write('>');
+ out.newLine();
+ } else {
+ openTag(tag);
+ }
+ }
+
+ /**
+ * Closes the HTML tag identified by the given number, together will all child tags.
+ *
+ * @param openedTag The value returned by the {@link #openTag(String)} matching the tag to close.
+ * @throws IOException if an error occurred while writing to the file.
+ */
+ protected final void closeTags(final int openedTag) throws IOException {
+ while (openedTags.size() != openedTag) {
+ margin = CharSequences.spaces(margin.length() - INDENTATION).toString();
+ out.write(margin);
+ out.write("</");
+ out.write(openedTags.removeLast());
+ out.write('>');
+ out.newLine();
+ }
+ }
+
+ /**
+ * Writes the given text in the given HTML element.
+ * The {@code &}, {@code <} and {@code >} characters are <strong>not</strong> escaped.
+ * For escaping those characters, invoke <code>println(tag, {@linkplain #escape(CharSequence) escape}(value))</code>.
+ *
+ * @param tag The HTML tag without brackets (e.g. {@code "h1"}).
+ * @param value The text to write, or {@code null} for none.
+ * @throws IOException if an error occurred while writing to the file.
+ */
+ protected final void println(final String tag, final CharSequence value) throws IOException {
+ out.write(margin);
+ out.write('<');
+ out.write(tag);
+ out.write('>');
+ if (value != null) {
+ out.write(value.toString());
+ }
+ out.write("</");
+ final int s = tag.indexOf(' ');
+ out.write(tag, 0, (s >= 0) ? s : tag.length());
+ out.write('>');
+ out.newLine();
+ }
+
+ /**
+ * Writes the given text on its own line, then write EOL sequence.
+ * The {@code &}, {@code <} and {@code >} characters are <strong>not</strong> escaped.
+ * For escaping those characters, invoke <code>println({@linkplain #escape(CharSequence) escape}(value))</code>.
+ *
+ * @param value The text to write, or {@code null} if none.
+ * @throws IOException if an error occurred while writing to the file.
+ */
+ protected final void println(final CharSequence value) throws IOException {
+ if (value != null) {
+ out.write(margin);
+ out.write(value.toString());
+ out.newLine();
+ }
+ }
+
+ /**
+ * Closes the HTML generator.
+ *
+ * @throws IOException if an error occurred while closing the output file.
+ */
+ @Override
+ public void close() throws IOException {
+ closeTags(0);
+ out.close();
+ }
+
+ /**
+ * Returns the localized version of the given string, or {@code null} if none.
+ *
+ * @param text The text to localize, or {@code null}.
+ * @return The localized test, or {@code null}.
+ *
+ * @see #LOCALE
+ */
+ protected static String toLocalizedString(final InternationalString text) {
+ return (text != null) ? text.toString(LOCALE) : null;
+ }
+
+ /**
+ * Returns {@code true} if the given object is deprecated.
+ *
+ * @param object The object to test.
+ * @return {@code true} if the given object is deprecated.
+ */
+ protected static boolean isDeprecated(final Object object) {
+ return (object instanceof Deprecable) && ((Deprecable) object).isDeprecated();
+ }
+}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
index d35e939..6ad3acb 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
@@ -62,7 +62,7 @@
/**
* Codes to exclude for now.
*/
- private static final Set<String> EXCLUDES = new HashSet<>(Arrays.asList(
+ private static final Set<String> EXCLUDES = new HashSet<String>(Arrays.asList(
"CRS:1", // Computer display
"EPSG:5819" // EPSG topocentric example A
));
@@ -97,7 +97,10 @@
final CoordinateReferenceSystem crs;
try {
crs = CRS.forCode(code);
- } catch (NoSuchIdentifierException | FactoryDataException e) {
+ } catch (NoSuchIdentifierException e) {
+ print(code, "WARNING", e.getLocalizedMessage());
+ continue;
+ } catch (FactoryDataException e) {
print(code, "WARNING", e.getLocalizedMessage());
continue;
}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DatumShiftTest.java b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DatumShiftTest.java
index cb903ba..6226716 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DatumShiftTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DatumShiftTest.java
@@ -30,7 +30,7 @@
import static org.apache.sis.test.Assume.*;
// Branch-specific imports
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.Path;
/**
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
index 3f7a0a7..3a85d2d 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
@@ -87,7 +87,7 @@
import static org.apache.sis.test.TestUtilities.getSingleton;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
diff --git a/core/sis-utility/pom.xml b/core/sis-utility/pom.xml
index 7a7f8f3..b6a9283 100644
--- a/core/sis-utility/pom.xml
+++ b/core/sis-utility/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>core</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
index b4a7617..6cc0e0d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
@@ -86,10 +86,10 @@
*
* @return A key for the parent source, or {@code null}.
*/
+ @SuppressWarnings({"unchecked","rawtypes"})
final ClassPair<? super S, T> parentSource() {
final Class<? super S> source;
if (sourceClass.isInterface()) {
- @SuppressWarnings({"unchecked","rawtypes"})
final Class<? super S>[] interfaces = (Class[]) sourceClass.getInterfaces();
if (interfaces.length == 0) {
return null;
@@ -101,7 +101,7 @@
return null;
}
}
- return new ClassPair<>(source, targetClass);
+ return new ClassPair(source, targetClass); // Checked in JDK7 branch.
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
index f6ea8f9..1785313 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
@@ -71,6 +71,7 @@
}
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
public java.util.List<?> apply(final Collection<?> source) {
if (source == null) {
return null;
@@ -78,7 +79,7 @@
if (source instanceof java.util.List<?>) {
return (java.util.List<?>) source;
}
- return new ArrayList<>(source);
+ return new ArrayList(source); // Checked in JDK7 branch.
}
}
@@ -95,6 +96,7 @@
}
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
public java.util.Set<?> apply(final Collection<?> source) {
if (source == null) {
return null;
@@ -102,7 +104,7 @@
if (source instanceof java.util.Set<?>) {
return (java.util.Set<?>) source;
}
- return new LinkedHashSet<>(source);
+ return new LinkedHashSet(source); // Checked in JDK7 branch.
}
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
index c3f4d9f..60d051a 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
@@ -84,7 +84,7 @@
* Creates an initially empty set of object converters.
*/
public ConverterRegistry() {
- converters = new LinkedHashMap<>();
+ converters = new LinkedHashMap<ClassPair<?,?>, ObjectConverter<?,?>>();
}
/**
@@ -243,6 +243,7 @@
* @param <T> The class of target (converted) values.
* @param converter The converter to register.
*/
+ @SuppressWarnings({"unchecked","rawtypes"})
public <S,T> void register(final ObjectConverter<S,T> converter) {
ArgumentChecks.ensureNonNull("converter", converter);
/*
@@ -273,7 +274,7 @@
initialize();
}
for (Class<? super T> i=targetClass; i!=null && i!=stopAt; i=i.getSuperclass()) {
- register(new ClassPair<>(sourceClass, i), converter);
+ register(new ClassPair(sourceClass, i), converter); // Checked in the JDK7 branch.
}
/*
* At this point, the given class and parent classes have been registered.
@@ -317,7 +318,7 @@
continue;
}
if (!i.isAssignableFrom(sourceClass)) {
- register(new ClassPair<>(sourceClass, i), converter);
+ register(new ClassPair(sourceClass, i), converter); // Checked in the JDK7 branch.
}
}
}
@@ -438,7 +439,7 @@
public <S,T> ObjectConverter<? super S, ? extends T> find(final Class<S> sourceClass, final Class<T> targetClass)
throws UnconvertibleObjectException
{
- final ClassPair<S,T> key = new ClassPair<>(sourceClass, targetClass);
+ final ClassPair<S,T> key = new ClassPair<S,T>(sourceClass, targetClass);
synchronized (converters) {
ObjectConverter<? super S, ? extends T> converter = get(key);
if (converter != null) {
@@ -489,7 +490,7 @@
if (sourceComponent != null) {
final Class<?> targetComponent = targetClass.getComponentType();
if (targetComponent != null) {
- converter = new ArrayConverter<>(sourceClass, targetClass, find(
+ converter = new ArrayConverter<S,T>(sourceClass, targetClass, find(
Numbers.primitiveToWrapper(sourceComponent),
Numbers.primitiveToWrapper(targetComponent)));
put(key, converter);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
index 3bddb9c..09d9c69 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
@@ -141,7 +141,7 @@
public SQL() { // Instantiated by ServiceLoader.
super(java.sql.Date.class);
- inverse = new IdentityConverter<>(targetClass, Date.class, this);
+ inverse = new IdentityConverter<Date, java.sql.Date>(targetClass, Date.class, this); // <T,S> in reverse order.
}
@Override public java.sql.Date apply(final Date source) {
@@ -161,7 +161,7 @@
public Timestamp() { // Instantiated by ServiceLoader.
super(java.sql.Timestamp.class);
- inverse = new IdentityConverter<>(targetClass, Date.class, this);
+ inverse = new IdentityConverter<Date, java.sql.Timestamp>(targetClass, Date.class, this); // <T,S> in reverse order.
}
@Override public java.sql.Timestamp apply(final Date source) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java
index 0af7a07..c7986eb 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java
@@ -248,7 +248,7 @@
/*
* Both 'branch' and 'checked' are ordinary converters (not FallbackConverter).
*/
- return new FallbackConverter<>(branch.getSourceClass(), targetClass, branch, checked);
+ return new FallbackConverter<S,T>(branch.getSourceClass(), targetClass, branch, checked);
}
}
@@ -291,7 +291,7 @@
return null;
}
}
- return new FallbackConverter<>(sourceClass, targetClass, newPrimary, newFallback);
+ return new FallbackConverter<S,T>(sourceClass, targetClass, newPrimary, newFallback);
}
/**
@@ -320,7 +320,7 @@
try {
return fallback.apply(source);
} catch (UnconvertibleObjectException failure) {
- exception.addSuppressed(failure);
+ // addSuppressed(failure) on the JDK7 branch.
throw exception;
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/IdentityConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/IdentityConverter.java
index ecad18c..9498b98 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/IdentityConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/IdentityConverter.java
@@ -38,7 +38,10 @@
*
* @see org.apache.sis.util.ObjectConverters#identity(Class)
*/
-public final class IdentityConverter<S extends T, T> extends SystemConverter<S,T> {
+public final class IdentityConverter<T, S extends T> extends SystemConverter<S,T> {
+ // JDK6 NOTE: Order of above <T> and <S> parameters is reversed compared to the
+ // JDK7 branch, because the JDK6 compiler does not supports forward reference.
+
/**
* For cross-version compatibility.
*/
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/PathConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/PathConverter.java
index 08ac168..77ad896 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/PathConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/PathConverter.java
@@ -27,10 +27,6 @@
import org.apache.sis.util.ObjectConverter;
import org.apache.sis.util.UnconvertibleObjectException;
-// Branch-specific import
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
/**
* Handles conversions between {@link Path}, {@link File}, {@link URI} and {@link URL} objects.
@@ -96,66 +92,6 @@
abstract T doConvert(S source) throws Exception;
/**
- * Converter from {@link Path} to {@link URI}.
- */
- public static final class PathURI extends PathConverter<Path,URI> {
- private static final long serialVersionUID = 740202123888081482L;
- static final PathURI INSTANCE = new PathURI();
- public PathURI() {super(Path.class, URI.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<Path,URI> unique() {return INSTANCE;}
- @Override public ObjectConverter<URI,Path> inverse() {return URIPath.INSTANCE;}
- @Override public URI doConvert(final Path source) {
- return source.toUri();
- }
- }
-
- /**
- * Converter from {@link Path} to {@link URL}.
- */
- public static final class PathURL extends PathConverter<Path,URL> {
- private static final long serialVersionUID = -289518201451769080L;
- static final PathURL INSTANCE = new PathURL();
- public PathURL() {super(Path.class, URL.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<Path,URL> unique() {return INSTANCE;}
- @Override public ObjectConverter<URL,Path> inverse() {return URLPath.INSTANCE;}
- @Override public URL doConvert(final Path source) throws MalformedURLException {
- return source.toUri().toURL();
- }
- }
-
- /**
- * Converter from {@link Path} to {@link File}.
- */
- public static final class PathFile extends PathConverter<Path,File> {
- private static final long serialVersionUID = 452241851474627778L;
- static final PathFile INSTANCE = new PathFile();
- public PathFile() {super(Path.class, File.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<Path,File> unique() {return INSTANCE;}
- @Override public ObjectConverter<File,Path> inverse() {return FilePath.INSTANCE;}
- @Override public File doConvert(final Path source) throws UnsupportedOperationException {
- return source.toFile();
- }
- }
-
- /**
- * Converter from {@link File} to {@link Path}.
- */
- public static final class FilePath extends PathConverter<File,Path> {
- private static final long serialVersionUID = 6420947028493989549L;
- static final FilePath INSTANCE = new FilePath();
- public FilePath() {super(File.class, Path.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<File,Path> unique() {return INSTANCE;}
- @Override public ObjectConverter<Path,File> inverse() {return PathFile.INSTANCE;}
- @Override public Path doConvert(final File source) {
- return source.toPath();
- }
- }
-
- /**
* Converter from {@link File} to {@link URI}.
* This converter changes relative paths to absolute paths.
*/
@@ -187,36 +123,6 @@
}
/**
- * Converter from {@link URL} to {@link Path}.
- */
- public static final class URLPath extends PathConverter<URL,Path> {
- private static final long serialVersionUID = 4030502499990629230L;
- static final URLPath INSTANCE = new URLPath();
- public URLPath() {super(URL.class, Path.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<URL,Path> unique() {return INSTANCE;}
- @Override public ObjectConverter<Path,URL> inverse() {return PathURL.INSTANCE;}
- @Override public Path doConvert(final URL source) throws URISyntaxException {
- return Paths.get(source.toURI());
- }
- }
-
- /**
- * Converter from {@link URI} to {@link Path}.
- */
- public static final class URIPath extends PathConverter<URI,Path> {
- private static final long serialVersionUID = 5935532794533554151L;
- static final URIPath INSTANCE = new URIPath();
- public URIPath() {super(URI.class, Path.class);} // Instantiated by ServiceLoader.
-
- @Override public ObjectConverter<URI,Path> unique() {return INSTANCE;}
- @Override public ObjectConverter<Path,URI> inverse() {return PathURI.INSTANCE;}
- @Override public Path doConvert(final URI source) throws IllegalArgumentException {
- return Paths.get(source);
- }
- }
-
- /**
* Converter from {@link URL} to {@link File}.
*/
public static final class URLFile extends PathConverter<URL,File> {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
index cd28fac..ac04935 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
@@ -18,11 +18,9 @@
import java.util.Set;
import java.util.EnumSet;
-import java.util.IllformedLocaleException;
import java.nio.charset.UnsupportedCharsetException;
import java.net.URISyntaxException;
import java.net.MalformedURLException;
-import java.nio.file.InvalidPathException;
import org.apache.sis.math.FunctionProperty;
import org.apache.sis.util.Locales;
import org.apache.sis.util.Numbers;
@@ -96,7 +94,7 @@
* To be overridden by classes which need a specialized instance.
*/
ObjectConverter<T, String> createInverse() {
- return new ObjectToString<>(targetClass, this);
+ return new ObjectToString<T>(targetClass, this);
}
/**
@@ -240,10 +238,10 @@
/** See {@link StringConverter} for the conversion table. */
@Override java.lang.Boolean doConvert(final String source) throws UnconvertibleObjectException {
- switch (source.toLowerCase(java.util.Locale.ROOT)) {
- case "true": case "yes": case "on": case "1": return java.lang.Boolean.TRUE;
- case "false": case "no": case "off": case "0": return java.lang.Boolean.FALSE;
- }
+ // "String in switch" in the JDK7 branch.
+ final String lower = source.toLowerCase(java.util.Locale.US);
+ if (lower.equals("true") || lower.equals("yes") || lower.equals("on") || lower.equals("1")) return java.lang.Boolean.TRUE;
+ if (lower.equals("false") || lower.equals("no") || lower.equals("off") || lower.equals("0")) return java.lang.Boolean.FALSE;
throw new UnconvertibleObjectException(formatErrorMessage(source));
}
}
@@ -252,7 +250,7 @@
private static final long serialVersionUID = -794933131690043494L;
public Locale() {super(java.util.Locale.class);} // Instantiated by ServiceLoader.
- @Override java.util.Locale doConvert(String source) throws IllformedLocaleException {
+ @Override java.util.Locale doConvert(String source) {
return Locales.parse(source);
}
}
@@ -275,15 +273,6 @@
}
}
- public static final class Path extends StringConverter<java.nio.file.Path> {
- private static final long serialVersionUID = -1737315635965906042L;
- public Path() {super(java.nio.file.Path.class);} // Instantiated by ServiceLoader.
-
- @Override java.nio.file.Path doConvert(String source) throws InvalidPathException {
- return java.nio.file.Paths.get(source);
- }
- }
-
public static final class URI extends StringConverter<java.net.URI> {
private static final long serialVersionUID = 7266486748714603336L;
public URI() {super(java.net.URI.class);} // Instantiated by ServiceLoader.
@@ -363,7 +352,7 @@
/** Invoked by the constructor for creating the inverse converter. */
@Override ObjectConverter<T, String> createInverse() {
- return new ObjectToString.CodeList<>(targetClass, this);
+ return new ObjectToString.CodeList<T>(targetClass, this);
}
}
@@ -395,7 +384,7 @@
/** Invoked by the constructor for creating the inverse converter. */
@Override ObjectConverter<T, String> createInverse() {
- return new ObjectToString.Enum<>(targetClass, this);
+ return new ObjectToString.Enum<T>(targetClass, this);
}
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java
index 9e7f882..b14681d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java
@@ -180,7 +180,7 @@
* CharSequence or Object), otherwise this converter would apply useless toString().
*/
if (sourceClass == CharSequence.class) {
- return (ObjectConverter<S,T>) new CharSequenceConverter<>(
+ return (ObjectConverter<S,T>) new CharSequenceConverter<T>( // More checks in JDK7 branch.
targetClass, find(String.class, targetClass));
}
/*
@@ -188,11 +188,11 @@
*/
if (sourceClass == String.class) {
if (CodeList.class.isAssignableFrom(targetClass)) {
- return (ObjectConverter<S,T>) new StringConverter.CodeList<>(
+ return (ObjectConverter<S,T>) new StringConverter.CodeList( // More checks in JDK7 branch.
targetClass.asSubclass(CodeList.class));
}
if (targetClass.isEnum()) {
- return (ObjectConverter<S,T>) new StringConverter.Enum<>(
+ return (ObjectConverter<S,T>) new StringConverter.Enum( // More checks in JDK7 branch.
targetClass.asSubclass(Enum.class));
}
}
@@ -201,12 +201,12 @@
*/
if (sourceClass == Number.class || isSupportedNumber(sourceClass)) {
if (isSupportedNumber(targetClass)) {
- return (ObjectConverter<S,T>) new NumberConverter<>(
+ return (ObjectConverter<S,T>) new NumberConverter( // More checks in JDK7 branch.
sourceClass.asSubclass(Number.class),
targetClass.asSubclass(Number.class));
}
if (targetClass == Comparable.class) {
- return (ObjectConverter<S,T>) new NumberConverter.Comparable<>(
+ return (ObjectConverter<S,T>) new NumberConverter.Comparable( // More checks in JDK7 branch.
sourceClass.asSubclass(Number.class));
}
}
@@ -214,7 +214,7 @@
* From various objects to String.
*/
if (targetClass == String.class) {
- return (ObjectConverter<S,T>) new ObjectToString<>(sourceClass, null);
+ return (ObjectConverter<S,T>) new ObjectToString<S>(sourceClass, null);
}
return null;
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
index be8c01b..678a0e3 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
@@ -102,7 +102,7 @@
* {@code finally} block by the {@link #finish()} method. This {@code ThreadLocal} shall
* not contain any value when no (un)marshalling is in progress.
*/
- private static final ThreadLocal<Context> CURRENT = new ThreadLocal<>();
+ private static final ThreadLocal<Context> CURRENT = new ThreadLocal<Context>();
/**
* The logger to use for warnings that are specific to XML.
@@ -218,15 +218,15 @@
final WarningListener<?> warningListener)
{
this.bitMasks = bitMasks;
- this.locales = new LinkedList<>();
+ this.locales = new LinkedList<Locale>();
this.timezone = timezone;
this.schemas = schemas; // No clone, because this class is internal.
this.versionGML = versionGML;
this.resolver = resolver;
this.converter = converter;
this.warningListener = warningListener;
- this.identifiers = new HashMap<>();
- this.identifiedObjects = new IdentityHashMap<>();
+ this.identifiers = new HashMap<String,Object>();
+ this.identifiedObjects = new IdentityHashMap<Object,String>();
if ((bitMasks & MARSHALLING) != 0) {
if (!Semaphores.queryAndSet(Semaphores.NULL_COLLECTION)) {
this.bitMasks |= CLEAR_SEMAPHORE;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
index a20feb5..9dc2c24 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
@@ -37,7 +37,7 @@
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -192,7 +192,7 @@
*/
@Override
public final int size() {
- final HashSet<Citation> done = new HashSet<>(hashMapCapacity(identifiers.size()));
+ final HashSet<Citation> done = new HashSet<Citation>(hashMapCapacity(identifiers.size()));
for (final Identifier identifier : identifiers) {
if (identifier != null) {
done.add(identifier.getAuthority());
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMap.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMap.java
index f4565e6..0dff306 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMap.java
@@ -28,7 +28,7 @@
import org.apache.sis.xml.XLink;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -271,7 +271,7 @@
}
}
if (value != null) {
- identifiers.add(new SpecializedIdentifier<>(authority, value));
+ identifiers.add(new SpecializedIdentifier<T>(authority, value));
}
return old;
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
index c1f3d28..ed1c7b3 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
@@ -218,7 +218,7 @@
for (final Identifier id : identifiers) {
if (id != null && id.getAuthority() instanceof NonMarshalledAuthority<?>) {
if (toPreserve == null) {
- toPreserve = new ArrayList<>(remaining);
+ toPreserve = new ArrayList<Identifier>(remaining);
}
toPreserve.add(id);
}
@@ -231,8 +231,8 @@
* We find at least one identifier that may need to be preserved.
* We need to create a combination of the two collections.
*/
- final Map<Citation,Identifier> authorities = new IdentityHashMap<>(4);
- final List<Identifier> merged = new ArrayList<>(newValues.size());
+ final Map<Citation,Identifier> authorities = new IdentityHashMap<Citation,Identifier>(4);
+ final List<Identifier> merged = new ArrayList<Identifier>(newValues.size());
for (final Identifier id : newValues) {
merged.add(id);
if (id != null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/PrimitiveTypeProperties.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/PrimitiveTypeProperties.java
index 0917b89..ae56107 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/PrimitiveTypeProperties.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/PrimitiveTypeProperties.java
@@ -59,7 +59,7 @@
* <div class="section">Synchronization</div>
* All accesses to this map shall be synchronized on the map object.
*/
- private static final Map<Object,Object> SENTINEL_VALUES = new IdentityHashMap<>();
+ private static final Map<Object,Object> SENTINEL_VALUES = new IdentityHashMap<Object,Object>();
/**
* Do not allow instantiation of this class.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
index 13daf2a..e4e83ed 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
@@ -33,7 +33,7 @@
import org.apache.sis.internal.util.Citations;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -102,13 +102,13 @@
final int ordinal = ((NonMarshalledAuthority) authority).ordinal;
switch (ordinal) {
case NonMarshalledAuthority.ID: {
- return new SpecializedIdentifier<>(IdentifierSpace.ID, code);
+ return new SpecializedIdentifier<String>(IdentifierSpace.ID, code);
}
case NonMarshalledAuthority.UUID: {
final Context context = Context.current();
final ValueConverter converter = Context.converter(context);
try {
- return new SpecializedIdentifier<>(IdentifierSpace.UUID, converter.toUUID(context, code));
+ return new SpecializedIdentifier<UUID>(IdentifierSpace.UUID, converter.toUUID(context, code));
} catch (IllegalArgumentException e) {
parseFailure(context, code, UUID.class, e);
break;
@@ -126,11 +126,11 @@
break;
}
if (ordinal == NonMarshalledAuthority.HREF) {
- return new SpecializedIdentifier<>(IdentifierSpace.HREF, href);
+ return new SpecializedIdentifier<URI>(IdentifierSpace.HREF, href);
}
final XLink xlink = new XLink();
xlink.setHRef(href);
- return new SpecializedIdentifier<>(IdentifierSpace.XLINK, xlink);
+ return new SpecializedIdentifier<XLink>(IdentifierSpace.XLINK, xlink);
}
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
index fbf7673..09a20c8 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
@@ -91,7 +91,7 @@
* 1) It would cache the TypeRegistration instances, which are not needed after this method call.
* 2) The ClassLoader between different invocations may be different in an OSGi context.
*/
- final ArrayList<Class<?>> types = new ArrayList<>();
+ final ArrayList<Class<?>> types = new ArrayList<Class<?>>();
for (final TypeRegistration t : DefaultFactories.createServiceLoader(TypeRegistration.class)) {
t.getTypes(types);
}
@@ -115,7 +115,7 @@
}
}
final JAXBContext instance = JAXBContext.newInstance(defaultClassesToBeBound());
- context = new WeakReference<>(instance);
+ context = new WeakReference<JAXBContext>(instance);
return instance;
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
index 65d9a82..0dbcdc6 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
@@ -262,7 +262,7 @@
} else {
namespace = XMLConstants.NULL_NS_URI;
}
- return new JAXBElement<>(new QName(namespace, name), CodeListUID.class,
+ return new JAXBElement<CodeListUID>(new QName(namespace, name), CodeListUID.class,
new CodeListUID(Context.current(), code));
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
index aed5441..e5178dd 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
@@ -103,8 +103,8 @@
// Creates an empty instance with the identifiers.
int count = 0;
SpecializedIdentifier<?>[] identifiers = new SpecializedIdentifier<?>[2];
- if (uuid != null) identifiers[count++] = new SpecializedIdentifier<>(IdentifierSpace.UUID, uuid);
- if (xlink != null) identifiers[count++] = new SpecializedIdentifier<>(IdentifierSpace.XLINK, xlink);
+ if (uuid != null) identifiers[count++] = new SpecializedIdentifier<UUID> (IdentifierSpace.UUID, uuid);
+ if (xlink != null) identifiers[count++] = new SpecializedIdentifier<XLink>(IdentifierSpace.XLINK, xlink);
identifiers = ArraysExt.resize(identifiers, count);
metadata = resolver.newIdentifiedObject(context, type, identifiers);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
index 902cdc7..6806654 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
@@ -125,7 +125,7 @@
return marshalLocale;
}
}
- return Locale.getDefault(Locale.Category.DISPLAY);
+ return Locale.getDefault();
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
index 68a9017..c6b0d2d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
@@ -23,7 +23,7 @@
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
index 77868a5..7866bcd 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
@@ -20,6 +20,9 @@
import javax.xml.bind.annotation.XmlElement;
import org.apache.sis.util.Debug;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* A set of strings localized in different languages. This adapter represents the
@@ -124,7 +127,7 @@
@Debug
@Override
public String toString() {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(160).append(getClass().getSimpleName()).append(lineSeparator);
if (localized != null) {
int corner = 0;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
index 8864c56..6bf3596 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
@@ -24,7 +24,7 @@
import org.apache.sis.xml.XLink;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AccessDeniedException.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AccessDeniedException.java
new file mode 100644
index 0000000..8434aae
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AccessDeniedException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.internal.jdk7;
+
+import java.io.IOException;
+
+
+/**
+ * Placeholder for the {@link java.nio.file.AccessDeniedException} class.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+@SuppressWarnings("serial")
+public class AccessDeniedException extends IOException {
+ /**
+ * Creates an exception.
+ *
+ * @param file The filename, or {@code null} if unknown.
+ */
+ public AccessDeniedException(String file) {
+ super(file);
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AutoCloseable.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AutoCloseable.java
new file mode 100644
index 0000000..4c3ee04
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/AutoCloseable.java
@@ -0,0 +1,39 @@
+/*
+ * 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.internal.jdk7;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Placeholder for the {@link java.lang.AutoCloseable} interface.
+ * Class annotated by this annotation must have a public {@code close()} method.
+ * {@code instanceof} checks and calls to {@code ((AutoCloseable) object).close()} need to be replaced
+ * by calls to {@link JDK7#isAutoCloseable(Object)} and {@link JDK7#close(Object)} respectively.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 0.7
+ * @module
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AutoCloseable {
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/DirectoryStream.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/DirectoryStream.java
new file mode 100644
index 0000000..7394ca8
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/DirectoryStream.java
@@ -0,0 +1,86 @@
+/*
+ * 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.internal.jdk7;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
+
+/**
+ * Place holder for {@link java.nio.file.DirectoryStream}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public final class DirectoryStream implements Closeable, Iterable<Path>, FileFilter {
+ /**
+ * The directory of files to be returned by the iterator.
+ */
+ private final File directory;
+
+ /**
+ * The pattern to match.
+ */
+ private final Pattern pattern;
+
+ /**
+ * Creates a new stream for the given directory.
+ */
+ DirectoryStream(final File directory, String glob) {
+ this.directory = directory;
+ glob = glob.replace(".", "\\.");
+ glob = glob.replace("?", ".");
+ glob = glob.replace("*", ".*");
+ pattern = Pattern.compile(glob);
+ }
+
+ /**
+ * Returns an iterator over the files in the directory.
+ */
+ @Override
+ public Iterator<Path> iterator() {
+ final File[] files = directory.listFiles(this);
+ final Path[] paths = new Path[files.length];
+ for (int i=0; i<files.length; i++) {
+ paths[i] = Path.castOrCopy(files[i]);
+ }
+ return Arrays.asList(paths).iterator();
+ }
+
+ /**
+ * Public as a side effect.
+ */
+ @Override
+ public boolean accept(final File pathname) {
+ return pattern.matcher(pathname.getName()).matches();
+ }
+
+ /**
+ * No-op.
+ */
+ @Override
+ public void close() throws IOException {
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Files.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Files.java
new file mode 100644
index 0000000..1084fd1
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Files.java
@@ -0,0 +1,213 @@
+/*
+ * 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.internal.jdk7;
+
+import java.util.Set;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.nio.channels.ByteChannel;
+import java.nio.charset.Charset;
+
+
+/**
+ * Place holder for {@link java.nio.file.Files}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.4
+ * @version 0.7
+ * @module
+ */
+public final class Files {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private Files() {
+ }
+
+ /**
+ * Creates the directory at the given path.
+ * This method does not create parent directories.
+ *
+ * @param dir The directory to create.
+ * @return The given path.
+ * @throws IOException if the directory can not be created.
+ *
+ * @since 0.7
+ */
+ public static Path createDirectory(final Path dir) throws IOException {
+ if (!dir.mkdir()) {
+ throw new IOException("Can not create directory: " + dir);
+ }
+ return dir;
+ }
+
+ /**
+ * Returns {@code true} if the given path is a directory.
+ *
+ * @param path The path to test.
+ * @return {@code true} if the path is a directory.
+ *
+ * @since 0.7
+ */
+ public static boolean isDirectory(final Path path) {
+ return path.isDirectory();
+ }
+
+ /**
+ * Returns {@code true} if the given path is an ordinary file.
+ *
+ * @param path The path to test.
+ * @return {@code true} if the path is a file.
+ *
+ * @since 0.7
+ */
+ public static boolean isRegularFile(final Path path) {
+ return path.isFile();
+ }
+
+ /**
+ * Returns {@code true} if the file at the given path can be read.
+ *
+ * @param path The path to test.
+ * @return {@code true} if file at the given path can be read.
+ *
+ * @since 0.7
+ */
+ public static boolean isReadable(final Path path) {
+ return path.canRead();
+ }
+
+ /**
+ * Returns {@code true} if the file at the given path can be written.
+ *
+ * @param path The path to test.
+ * @return {@code true} if file at the given path can be written.
+ *
+ * @since 0.7
+ */
+ public static boolean isWritable(final Path path) {
+ return path.canWrite();
+ }
+
+ /**
+ * Returns {@code true} if the given file or directory exits.
+ *
+ * @param path The path to test.
+ * @return {@code true} if file or directory exists.
+ *
+ * @since 0.7
+ */
+ public static boolean exists(final Path path) {
+ return path.exists();
+ }
+
+ /**
+ * Returns an iterable over the content of the given directory.
+ *
+ * @param dir The directory.
+ * @param glob The pattern to match.
+ * @return Iterable over the given directory.
+ * @throws IOException if an error occurred while creating the iterable.
+ */
+ public static DirectoryStream newDirectoryStream(Path dir, String glob) throws IOException {
+ return new DirectoryStream(dir, glob);
+ }
+
+ /**
+ * Creates a new input stream. The input stream is intentionally not buffered;
+ * it is caller's responsibility to provide buffering.
+ *
+ * @param path The path of the file to read.
+ * @return The input stream.
+ * @throws IOException if an error occurred while creating the input stream.
+ *
+ * @since 0.7
+ */
+ public static InputStream newInputStream(final Path path) throws IOException {
+ return new FileInputStream(path);
+ }
+
+ /**
+ * Creates a new buffered reader for the given character encoding.
+ *
+ * @param path The path of the file to read.
+ * @param cs The character encoding to use.
+ * @return The reader.
+ * @throws IOException if an error occurred while creating the reader.
+ *
+ * @since 0.7
+ */
+ public static BufferedReader newBufferedReader(final Path path, final Charset cs) throws IOException {
+ return new BufferedReader(new InputStreamReader(new FileInputStream(path), cs.newDecoder()));
+ }
+
+ /**
+ * Creates a new buffered writer for the given character encoding.
+ *
+ * @param path The path of the file to write.
+ * @param cs The character encoding to use.
+ * @return The writer.
+ * @throws IOException if an error occurred while creating the writer.
+ *
+ * @since 0.7
+ */
+ public static BufferedWriter newBufferedWriter(final Path path, final Charset cs) throws IOException {
+ return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), cs.newEncoder()));
+ }
+
+ /**
+ * Simulates {@link java.nio.file.Files#newByteChannel(java.nio.file.Path, java.nio.file.OpenOption[])}.
+ *
+ * @param file The file to open.
+ * @param options The name of {@code OpenOption} values.
+ * @return The channel.
+ * @throws IOException If an error occurred while opening the channel.
+ */
+ public static ByteChannel newByteChannel(final File file, final Set<?> options) throws IOException {
+ String mode = "r";
+ if (options != null) {
+ if (options.contains(StandardOpenOption.DSYNC)) {
+ mode = "rwd";
+ } else if (options.contains(StandardOpenOption.SYNC)) {
+ mode = "rws";
+ } else if (options.contains(StandardOpenOption.WRITE)) {
+ mode = "rw";
+ }
+ }
+ return new RandomAccessFile(file, mode).getChannel();
+ }
+
+ /**
+ * Creates a new byte channel.
+ *
+ * @param path The file to open.
+ * @return The channel.
+ * @throws IOException If an error occurred while opening the channel.
+ */
+ public static ByteChannel newByteChannel(final Path path) throws IOException {
+ return newByteChannel(path, null);
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/InvalidPathException.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/InvalidPathException.java
new file mode 100644
index 0000000..40352c9
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/InvalidPathException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.internal.jdk7;
+
+
+/**
+ * Place holder for {@link java.nio.file.Path}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+@SuppressWarnings("serial")
+public class InvalidPathException extends IllegalArgumentException {
+ /**
+ * Creates a new exception.
+ */
+ InvalidPathException(final RuntimeException cause) {
+ super(cause);
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java
new file mode 100644
index 0000000..92fae3e
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java
@@ -0,0 +1,144 @@
+/*
+ * 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.internal.jdk7;
+
+import java.io.Closeable;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import javax.imageio.stream.ImageInputStream;
+import java.lang.reflect.InvocationTargetException;
+
+
+/**
+ * Place holder for methods defined only in JDK7. Those methods are defined in existing classes,
+ * so we can not creates a new class of the same name like we did for {@link Objects}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from GeoAPI)
+ * @version 0.7
+ * @module
+ */
+public final class JDK7 {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private JDK7() {
+ }
+
+ /**
+ * Returns the platform specific line-separator.
+ *
+ * @return The platform-specific line separator.
+ *
+ * @see System#lineSeparator()
+ */
+ public static String lineSeparator() {
+ return System.getProperty("line.separator", "\n");
+ }
+
+ /**
+ * Returns {@code true} if the given code point is in the BMP plane.
+ *
+ * @param c The code point.
+ * @return {@code true} if the given code point is in the BMP plane.
+ *
+ * @see Character#isBmpCodePoint(int)
+ */
+ public static boolean isBmpCodePoint(final int c) {
+ return c >= Character.MIN_VALUE &&
+ c <= Character.MAX_VALUE;
+ }
+
+ /**
+ * Returns the leading surrogate for the given code point.
+ *
+ * @param c The code point.
+ * @return The leading surrogate.
+ *
+ * @see Character#highSurrogate(int)
+ */
+ public static char highSurrogate(int c) {
+ c -= Character.MIN_SUPPLEMENTARY_CODE_POINT;
+ c >>>= 10;
+ c += Character.MIN_HIGH_SURROGATE;
+ return (char) c;
+ }
+
+ /**
+ * Returns the trailing surrogate for the given code point.
+ *
+ * @param c The code point.
+ * @return The trailing surrogate.
+ *
+ * @see Character#lowSurrogate(int)
+ */
+ public static char lowSurrogate(int c) {
+ c &= 0x3FF;
+ c += Character.MIN_LOW_SURROGATE;
+ return (char) c;
+ }
+
+ /**
+ * Compares to integer values.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ * @return Comparison result.
+ */
+ public static int compare(final int x, final int y) {
+ return (x < y) ? -1 : (x == y) ? 0 : 1;
+ }
+
+ /**
+ * Simulates the {@code object instanceof AutoCloseable} code.
+ *
+ * @param object The object to check, or {@code null}.
+ * @return {@code true} if the given object is closeable.
+ */
+ public static boolean isAutoCloseable(final Object object) {
+ return (object instanceof Closeable) || (object instanceof ImageInputStream) ||
+ (object instanceof Connection) || (object instanceof Statement) || (object instanceof ResultSet) ||
+ (object != null && object.getClass().isAnnotationPresent(AutoCloseable.class));
+ }
+
+ /**
+ * Simulates the {@code ((AutoCloseable) object).close()} method call.
+ * The given object shall be an instance of which {@link #isAutoCloseable(Object)}
+ * returned {@code true}, otherwise a {@link ClassCastException} will be thrown.
+ *
+ * @param object The object to close.
+ * @throws Exception If an error occurred while closing the object.
+ */
+ public static void close(final Object object) throws Exception {
+ if (object instanceof Closeable) ((Closeable) object).close();
+ else if (object instanceof ImageInputStream) ((ImageInputStream) object).close();
+ else if (object instanceof Connection) ((Connection) object).close();
+ else if (object instanceof Statement) ((Statement) object).close();
+ else if (object instanceof ResultSet) ((ResultSet) object).close();
+ else try {
+ object.getClass().getMethod("close", (Class<?>[]) null).invoke(object, (Object[]) null);
+ } catch (InvocationTargetException e) {
+ final Throwable cause = e.getTargetException();
+ if (cause instanceof Exception) {
+ throw (Exception) cause;
+ } else {
+ throw e;
+ }
+ }
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Objects.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Objects.java
new file mode 100644
index 0000000..fab1840
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Objects.java
@@ -0,0 +1,202 @@
+/*
+ * 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.internal.jdk7;
+
+import java.util.Arrays;
+
+
+/**
+ * Place holder for {@link java.util.Objects}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from GeoAPI)
+ * @version 0.3
+ * @module
+ */
+public final class Objects {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private Objects() {
+ }
+
+ /**
+ * See JDK7 javadoc.
+ *
+ * @param <T> The type of the value to check.
+ * @param value Reference to check against null value.
+ * @return The given {@code value}, guaranteed to be non null.
+ */
+ public static <T> T requireNonNull(final T value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ return value;
+ }
+
+ /**
+ * See JDK7 javadoc.
+ *
+ * @param <T> The type of the value to check.
+ * @param value Reference to check against null value.
+ * @param message Exception message.
+ * @return The given {@code value}, guaranteed to be non null.
+ */
+ public static <T> T requireNonNull(final T value, final String message) {
+ if (value == null) {
+ throw new NullPointerException(message);
+ }
+ return value;
+ }
+
+ /**
+ * Convenience method for testing two objects for equality. One or both objects may be null.
+ * This method do <strong>not</strong> iterates recursively in array elements. If array needs
+ * to be compared, use one of {@link Arrays} method or {@link #deepEquals deepEquals} instead.
+ * <p>
+ * <b>Note on assertions:</b> There is no way to ensure at compile time that this method
+ * is not invoked with array arguments, while doing so would usually be a program error.
+ * Performing a systematic argument check would impose a useless overhead for correctly
+ * implemented {@link Object#equals} methods. As a compromise we perform this check at runtime
+ * only if assertions are enabled. Using assertions for argument check in a public API is
+ * usually a deprecated practice, but this particular method is for internal use only.
+ * <p>
+ * <strong>WARNING: This method will be removed when SIS will switch to JDK7.
+ * This method will be replaced by the new {@code java.util.Objects.equals} method.
+ * Developers who are already on JDK7 should use that JDK method instead.</strong>
+ *
+ * @param o1 First object to compare.
+ * @param o2 Second object to compare.
+ * @return {@code true} if both objects are equal.
+ * @throws AssertionError If assertions are enabled and at least one argument is an array.
+ */
+ public static boolean equals(final Object o1, final Object o2) {
+ assert o1 == null || !o1.getClass().isArray() : o1;
+ assert o2 == null || !o2.getClass().isArray() : o2;
+ return (o1 == o2) || (o1 != null && o1.equals(o2));
+ }
+
+ /**
+ * Convenience method for testing two objects for equality. One or both objects may be null.
+ * If both are non-null and are arrays, then every array elements will be compared.
+ * <p>
+ * This method may be useful when the objects may or may not be array. If they are known
+ * to be arrays, consider using {@link Arrays#deepEquals(Object[],Object[])} or one of its
+ * primitive counter-part instead.
+ * <p>
+ * <strong>Rules for choosing an {@code equals} or {@code deepEquals} method</strong>
+ * <ul>
+ * <li>If <em>both</em> objects are declared as {@code Object[]} (not anything else like
+ * {@code String[]}), consider using {@link Arrays#deepEquals(Object[],Object[])} except
+ * if it is known that the array elements can never be other arrays.</li>
+ *
+ * <li>Otherwise if both objects are arrays (e.g. {@code Expression[]}, {@code String[]},
+ * {@code int[]}, <i>etc.</i>), use {@link Arrays#equals(Object[],Object[])}. This
+ * rule is applicable to arrays of primitive type too, since {@code Arrays.equals} is
+ * overridden with primitive counter-parts.</li>
+ *
+ * <li>Otherwise if at least one object is anything else than {@code Object} (e.g.
+ * {@code String}, {@code Expression}, <i>etc.</i>), use {@link #equals(Object,Object)}.
+ * Using this {@code deepEquals} method would be an overkill since there is no chance that
+ * {@code String} or {@code Expression} could be an array.</li>
+ *
+ * <li>Otherwise if <em>both</em> objects are declared exactly as {@code Object} type and
+ * it is known that they could be arrays, only then invoke this {@code deepEquals} method.
+ * In such case, make sure that the hash code is computed using {@link #deepHashCode(Object)}
+ * for consistency.</li>
+ * </ul>
+ * <p>
+ * <strong>WARNING: This method will be removed when SIS will switch to JDK7.
+ * This method will be replaced by the new {@code java.util.Objects.deepEquals} method.
+ * Developers who are already on JDK7 should use that JDK method instead.</strong>
+ *
+ * @param object1 The first object to compare, or {@code null}.
+ * @param object2 The second object to compare, or {@code null}.
+ * @return {@code true} if both objects are equal.
+ */
+ public static boolean deepEquals(final Object object1, final Object object2) {
+ if (object1 == object2) {
+ return true;
+ }
+ if (object1 == null || object2 == null) {
+ return false;
+ }
+ if (object1 instanceof Object[]) {
+ return (object2 instanceof Object[]) &&
+ Arrays.deepEquals((Object[]) object1, (Object[]) object2);
+ }
+ if (object1 instanceof double[]) {
+ return (object2 instanceof double[]) &&
+ Arrays.equals((double[]) object1, (double[]) object2);
+ }
+ if (object1 instanceof float[]) {
+ return (object2 instanceof float[]) &&
+ Arrays.equals((float[]) object1, (float[]) object2);
+ }
+ if (object1 instanceof long[]) {
+ return (object2 instanceof long[]) &&
+ Arrays.equals((long[]) object1, (long[]) object2);
+ }
+ if (object1 instanceof int[]) {
+ return (object2 instanceof int[]) &&
+ Arrays.equals((int[]) object1, (int[]) object2);
+ }
+ if (object1 instanceof short[]) {
+ return (object2 instanceof short[]) &&
+ Arrays.equals((short[]) object1, (short[]) object2);
+ }
+ if (object1 instanceof byte[]) {
+ return (object2 instanceof byte[]) &&
+ Arrays.equals((byte[]) object1, (byte[]) object2);
+ }
+ if (object1 instanceof char[]) {
+ return (object2 instanceof char[]) &&
+ Arrays.equals((char[]) object1, (char[]) object2);
+ }
+ if (object1 instanceof boolean[]) {
+ return (object2 instanceof boolean[]) &&
+ Arrays.equals((boolean[]) object1, (boolean[]) object2);
+ }
+ return object1.equals(object2);
+ }
+
+ /**
+ * Delegates to {@link Arrays#hashCode(Object[])}.
+ *
+ * @param values The object for which to compute hash code values.
+ * @return The hash code value for the given objects.
+ */
+ public static int hash(Object... values) {
+ return Arrays.hashCode(values);
+ }
+
+ /**
+ * Returns the hash code of the given object, or 0 if the object is {@code null}.
+ * If non-null, then the given object is not allowed to be an array.
+ *
+ * @param object The object for which to compute the hash code.
+ * @return The hash code of the given object.
+ */
+ public static int hashCode(final Object object) {
+ if (object == null) {
+ return 0;
+ }
+ assert !object.getClass().isArray() : object;
+ return object.hashCode();
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java
new file mode 100644
index 0000000..72b4af5
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java
@@ -0,0 +1,165 @@
+/*
+ * 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.internal.jdk7;
+
+import java.io.File;
+import java.net.URI;
+
+
+/**
+ * Place holder for {@link java.nio.file.Path}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+@SuppressWarnings("serial")
+public final class Path extends File {
+ /**
+ * Creates a path for the given file.
+ */
+ Path(final String path) {
+ super(path);
+ }
+
+ /**
+ * Creates a path for the given URI.
+ */
+ Path(final URI path) throws IllegalArgumentException {
+ super(path);
+ }
+
+ /**
+ * For {@link #resolve(String)} implementation.
+ */
+ Path(final File path, final String other) {
+ super(path, other);
+ }
+
+ /**
+ * For inter-operability.
+ *
+ * @param file The file to cast or copy.
+ * @return The given file as a path.
+ */
+ public static Path castOrCopy(final File file) {
+ return (file == null || file instanceof Path) ? (Path) file : new Path(file.getPath());
+ }
+
+ /**
+ * Returns the last element in the path.
+ *
+ * @return Last element in the path.
+ */
+ public Path getFileName() {
+ return new Path(getName());
+ }
+
+ /**
+ * Unimplemented.
+ *
+ * @return this.
+ */
+ public Path normalize() {
+ return this;
+ }
+
+ /**
+ * Returns a sub-directory of this path, or the given path if it is absolute.
+ *
+ * @param other The sub-directory name.
+ * @return The path with the sub-directory.
+ */
+ public Path resolve(final Path other) {
+ if (other.isAbsolute()) {
+ return other;
+ }
+ return new Path(this, other.toString());
+ }
+
+ /**
+ * Returns a sub-directory of this path, provided that the given path is not absolute.
+ *
+ * @param other The sub-directory name.
+ * @return The path with the sub-directory.
+ */
+ public Path resolve(final String other) {
+ return resolve(new Path(other));
+ }
+
+ /**
+ * Resolves the given path against the parent of this path.
+ *
+ * @param other The sub-directory name.
+ * @return The path with the sub-directory.
+ */
+ public Path resolveSibling(final Path other) {
+ if (other.isAbsolute()) {
+ return other;
+ }
+ return new Path(getParentFile(), other.toString());
+ }
+
+ /**
+ * Resolves the given path against the parent of this path.
+ *
+ * @param other The sub-directory name.
+ * @return The path with the sub-directory.
+ */
+ public Path resolveSibling(final String other) {
+ return resolveSibling(new Path(other));
+ }
+
+ /**
+ * Returns the given path relative to this path.
+ *
+ * @param other The path to make relative to this path.
+ * @return The relative path (if possible).
+ */
+ public Path relativize(final Path other) {
+ final String start = getAbsolutePath();
+ final String full = other.getAbsolutePath();
+ if (full.startsWith(start)) {
+ final int length = start.length();
+ if (full.length() > length && full.charAt(length) == separatorChar) {
+ return new Path(full.substring(length + 1));
+ }
+ }
+ return other;
+ }
+
+
+ /**
+ * Returns this path as a URI.
+ *
+ * @return The URI for this path.
+ */
+ public URI toUri() {
+ return toURI();
+ }
+
+ /**
+ * Returns the path as an absolute path.
+ *
+ * @return The absolute path.
+ */
+ public Path toAbsolutePath() {
+ return isAbsolute() ? this : new Path(getAbsolutePath());
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java
new file mode 100644
index 0000000..a449d1e
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java
@@ -0,0 +1,68 @@
+/*
+ * 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.internal.jdk7;
+
+import java.net.URI;
+
+
+/**
+ * Place holder for {@link java.nio.file.Paths}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public final class Paths {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private Paths() {
+ }
+
+ /**
+ * Creates a path.
+ *
+ * @param first First element of the path.
+ * @param more Additional element of the path.
+ * @return The path.
+ * @throws InvalidPathException if the path can not be created.
+ */
+ public static Path get(final String first, final String... more) throws InvalidPathException {
+ try {
+ Path path = new Path(first);
+ for (final String other : more) {
+ path = new Path(path, other);
+ }
+ return path;
+ } catch (RuntimeException e) {
+ throw new InvalidPathException(e);
+ }
+ }
+
+ /**
+ * Returns a path for the given URI.
+ *
+ * @param uri The URI
+ * @return The path.
+ * @throws IllegalArgumentException if the path can not be created.
+ */
+ public static Path get(final URI uri) throws IllegalArgumentException {
+ return new Path(uri);
+ }
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardCharsets.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardCharsets.java
new file mode 100644
index 0000000..66535f0
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardCharsets.java
@@ -0,0 +1,57 @@
+/*
+ * 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.internal.jdk7;
+
+import java.nio.charset.Charset;
+
+
+/**
+ * Place holder for {@link java.nio.charset.StandardCharsets}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from GeoAPI)
+ * @version 0.5
+ * @module
+ */
+public final class StandardCharsets {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private StandardCharsets() {
+ }
+
+ /**
+ * Eight-bit UCS Transformation Format.
+ */
+ public static final Charset UTF_8 = Charset.forName("UTF-8");
+
+ /**
+ * Sixteen-bit UCS Transformation Format.
+ */
+ public static final Charset UTF_16 = Charset.forName("UTF-16");
+
+ /**
+ * ISO/IEC 8859-1, Information technology - 8-bit single byte coded graphic character sets - Part 1 : Latin alphabet No.1.
+ */
+ public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
+
+ /**
+ * Seven-bit ASCII, a.k.a. ISO646-US.
+ */
+ public static final Charset US_ASCII = Charset.forName("US-ASCII");
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardOpenOption.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardOpenOption.java
new file mode 100644
index 0000000..9edefdf
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/StandardOpenOption.java
@@ -0,0 +1,59 @@
+/*
+ * 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.internal.jdk7;
+
+
+/**
+ * Place holder for {@link java.nio.file.StandardOpenOption}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * We simulate the enum by {@link String} values.
+ * This allow us to avoid putting a non-standard enum in public API.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.4
+ * @version 0.4
+ * @module
+ */
+public final class StandardOpenOption {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private StandardOpenOption() {
+ }
+
+ /** See {@link java.nio.file.StandardOpenOption#READ}. */
+ public static final String READ = "READ";
+
+ /** See {@link java.nio.file.StandardOpenOption#WRITE}. */
+ public static final String WRITE = "WRITE";
+
+ /** See {@link java.nio.file.StandardOpenOption#APPEND}. */
+ public static final String APPEND = "APPEND";
+
+ /** See {@link java.nio.file.StandardOpenOption#TRUNCATE_EXISTING}. */
+ public static final String TRUNCATE_EXISTING = "TRUNCATE_EXISTING";
+
+ /** See {@link java.nio.file.StandardOpenOption#DELETE_ON_CLOSE}. */
+ public static final String DELETE_ON_CLOSE = "DELETE_ON_CLOSE";
+
+ /** See {@link java.nio.file.StandardOpenOption#SYNC}. */
+ public static final String SYNC = "SYNC";
+
+ /** See {@link java.nio.file.StandardOpenOption#DSYNC}. */
+ public static final String DSYNC = "DSYNC";
+}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/package-info.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/package-info.java
new file mode 100644
index 0000000..e48ae9c
--- /dev/null
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/**
+ * Place-holder for JDK7 classes that do not exist in JDK6.
+ *
+ * <STRONG>Do not use!</STRONG>
+ *
+ * This package is for internal use by SIS only. Classes in this package
+ * may change in incompatible ways in any future version without notice.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3
+ * @version 0.3
+ * @module
+ */
+package org.apache.sis.internal.jdk7;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
index d690091..5f43cd9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
@@ -29,13 +29,14 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import javax.xml.bind.DatatypeConverter;
// Branch-dependent imports
-import java.util.Objects;
-import java.nio.file.Files;
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.JDK7;
+import org.apache.sis.internal.jdk7.Objects;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
@@ -53,7 +54,7 @@
* We share a single instance instead than using {@link ThreadLocal} instances
* on the assumption that usages of this calendar will be relatively rare.
*/
- private static final AtomicReference<Calendar> CALENDAR = new AtomicReference<>();
+ private static final AtomicReference<Calendar> CALENDAR = new AtomicReference<Calendar>();
/**
* Do not allow instantiation of this class.
@@ -71,7 +72,7 @@
* @since 0.7
*/
public static int compareUnsigned(final int x, final int y) {
- return Integer.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
+ return JDK7.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
index 8bcef96..52af8d5 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
@@ -33,7 +33,7 @@
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
index fb37ba2..540e6e8 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
@@ -34,7 +34,7 @@
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
index 3e181b7..67a1061 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
@@ -29,7 +29,7 @@
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java
index c2a93dd..3cef8ee 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java
@@ -165,7 +165,7 @@
while (thread != null) {
if (!thread.isAlive() || thread.isStalled()) {
if (list == null) {
- list = new ArrayList<>();
+ list = new ArrayList<Thread>();
}
list.add(thread);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
index dcec19f..1e6bbc0 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
@@ -25,10 +25,10 @@
import org.apache.sis.util.resources.Messages;
// Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.InvalidPathException;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
+import org.apache.sis.internal.jdk7.InvalidPathException;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
index e438b64..3d16016 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
@@ -42,7 +42,7 @@
/**
* Cache of factories which are found by {@code META-INF/services}.
*/
- private static final Map<Class<?>, Object> FACTORIES = new IdentityHashMap<>(4);
+ private static final Map<Class<?>, Object> FACTORIES = new IdentityHashMap<Class<?>, Object>(4);
static {
SystemListener.add(new DefaultFactories());
}
@@ -205,7 +205,7 @@
private static ClassLoader getContextClassLoader() throws SecurityException {
final Thread thread = Thread.currentThread();
ClassLoader loader = thread.getContextClassLoader();
- final Set<ClassLoader> parents = new HashSet<>();
+ final Set<ClassLoader> parents = new HashSet<ClassLoader>();
for (ClassLoader c = loader; c != null; c = c.getParent()) {
parents.add(c);
}
@@ -222,7 +222,7 @@
c = c.getParent();
}
}
- } catch (SecurityException | ClassNotFoundException e) {
+ } catch (Exception e) { // This is (SecurityException | ClassNotFoundException) on the JDK7 branch.
if (!warnings) {
warnings = true;
Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
index 5ca9bdf..9b476c6 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
@@ -73,7 +73,7 @@
/**
* List of delayed tasks to execute.
*/
- private static final BlockingQueue<DelayedRunnable> QUEUE = new DelayQueue<>();
+ private static final BlockingQueue<DelayedRunnable> QUEUE = new DelayQueue<DelayedRunnable>();
/**
* Creates the singleton instance of the {@code DelayedExecutor} thread.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
index 1ac4479..d4e456f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
@@ -116,7 +116,7 @@
* @return The effective logging levels of SIS loggers.
*/
public static SortedMap<String,Level> getEffectiveLevels() {
- final SortedMap<String,Level> levels = new TreeMap<>();
+ final SortedMap<String,Level> levels = new TreeMap<String,Level>();
for (final Field field : Loggers.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == String.class) try {
levels.put((String) field.get(null), null);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
index 8aab8ea..aca27c1 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
@@ -93,7 +93,7 @@
record.setLoggerName(module);
Logging.log(type, "getInstance", record);
return null;
- } catch (ReflectiveOperationException exception) {
+ } catch (Exception exception) { // (ReflectiveOperationException) on JDK7 branch.
// Should never happen if we didn't broke our helper class.
throw new AssertionError(exception);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java
index 239e6e3..c2ac450 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java
@@ -56,7 +56,7 @@
* {@link Reference} constructors as documented in the class javadoc. Those {@code Reference}
* sub-classes <strong>must</strong> implement the {@link Disposable} interface.
*/
- public static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<>();
+ public static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
/**
* Creates the singleton instance of the {@code ReferenceQueueConsumer} thread.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
index f88bfef..1951611 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
@@ -68,7 +68,7 @@
/**
* The flags per running thread.
*/
- private static final ThreadLocal<Semaphores> FLAGS = new ThreadLocal<>();
+ private static final ThreadLocal<Semaphores> FLAGS = new ThreadLocal<Semaphores>();
/**
* The bit flags.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
index 387d770..2855e74 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
@@ -22,7 +22,7 @@
import org.apache.sis.util.logging.Logging;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -49,7 +49,7 @@
/**
* The resources to dispose. Most recently added resources are last.
*/
- private static final List<Callable<?>> resources = new ArrayList<>();
+ private static final List<Callable<?>> resources = new ArrayList<Callable<?>>();
/**
* Creates the thread to be executed at shutdown time.
@@ -184,9 +184,6 @@
while ((i = resources.size()) != 0) try { // In case run() modifies the resources list.
resources.remove(i - 1).call(); // Dispose most recently added resources first.
} catch (Exception e) {
- if (exception != null) {
- e.addSuppressed(exception);
- }
exception = e;
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
index ebcdccb..a5f0496 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
@@ -193,7 +193,7 @@
*/
private String getDescription(final String resourceKey) {
return ResourceBundle.getBundle("org.apache.sis.internal.system.Descriptions",
- Locale.getDefault(Locale.Category.DISPLAY),
+ Locale.getDefault(),
Supervisor.class.getClassLoader()).getString(resourceKey);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
index 028bfa0..f8abcad 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
@@ -27,7 +27,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -119,7 +119,7 @@
* @return The entry at the current iterator position.
*/
protected Entry<K,V> getEntry() {
- return new java.util.AbstractMap.SimpleImmutableEntry<>(getKey(), getValue());
+ return new java.util.AbstractMap.SimpleImmutableEntry<K,V>(getKey(), getValue());
}
/**
@@ -371,7 +371,7 @@
@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<K,V>(it) : Collections.<K>emptySet().iterator();
}
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */
@@ -418,7 +418,7 @@
@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<K,V>(it) : Collections.<V>emptySet().iterator();
}
};
}
@@ -453,7 +453,7 @@
/** 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<K,V>(it) : Collections.<Entry<K,V>>emptySet().iterator();
}
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java
index 6b8a4fc..6d3d6da 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java
@@ -22,7 +22,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
index c64b6a3..583878d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
@@ -108,7 +108,7 @@
if (collection instanceof CheckedArrayList<?> && ((CheckedArrayList<?>) collection).type == type) {
return (CheckedArrayList<E>) collection;
} else {
- final CheckedArrayList<E> list = new CheckedArrayList<>(type, collection.size());
+ final CheckedArrayList<E> list = new CheckedArrayList<E>(type, collection.size());
list.addAll((Collection) collection); // addAll will perform the type checks.
return list;
}
@@ -215,7 +215,7 @@
}
// Not-so-unsafe cast: we verified in the above loop that all elements are instance of E.
// The array itself may not be an instance of E[], but this is not important for Mediator.
- return new Mediator<>(ArraysExt.resize((E[]) array, count));
+ return new Mediator<E>(ArraysExt.resize((E[]) array, count));
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
index 8724de6..45ca7e6 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
@@ -31,7 +31,7 @@
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
index 3ae231e..c2fc70c 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
@@ -118,9 +118,7 @@
method = null;
type = valueType;
} catch (IllegalAccessException e) {
- if (security != null) {
- e.addSuppressed(security);
- }
+ // JDK7 branch has the following: e.addSuppressed(security);
throw fail(e, valueType);
} catch (InvocationTargetException e) {
rethrow(e.getCause());
@@ -182,12 +180,14 @@
if (Modifier.isPublic(m.getModifiers())) {
return m.invoke(object, (Object[]) null);
}
- } catch (NoSuchMethodException | IllegalAccessException e) {
+ } catch (NoSuchMethodException e) {
/*
* Should never happen because all objects have a clone() method
* and we verified that the method is public.
*/
throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError(e);
} catch (InvocationTargetException e) {
rethrow(e.getCause());
throw fail(e, type);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
index 4f1e5a3..a8e9f33 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
@@ -28,6 +28,7 @@
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.Function;
@@ -135,7 +136,6 @@
*
* @since 0.6
*/
- @SafeVarargs
public static <T> Set<T> nonEmptySet(final T... elements) {
final Set<T> asSet = immutableSet(true, elements);
return (asSet != null && asSet.isEmpty()) ? null : asSet;
@@ -234,7 +234,7 @@
final Class<?> valueType = value.getClass();
if (valueType.isArray()) {
if (type.isAssignableFrom(valueType)) {
- final Set<E> set = new LinkedHashSet<>(Arrays.asList((E[]) value));
+ final Set<E> set = new LinkedHashSet<E>(Arrays.asList((E[]) value));
set.remove(null);
return set.toArray(emptyArray);
}
@@ -266,7 +266,7 @@
if (Enum.class.isAssignableFrom(type)) {
return EnumSet.noneOf((Class) type);
}
- return new LinkedHashSet<>(hashMapCapacity(count));
+ return new LinkedHashSet<E>(hashMapCapacity(count));
}
/**
@@ -282,7 +282,6 @@
*
* @see Collections#unmodifiableSet(Set)
*/
- @SafeVarargs
@SuppressWarnings("fallthrough")
public static <E> Set<E> immutableSet(final boolean excludeNull, final E... array) {
if (array == null) {
@@ -300,7 +299,7 @@
return Collections.emptySet();
}
default: {
- final Set<E> set = new LinkedHashSet<>(Arrays.asList(array));
+ final Set<E> set = new LinkedHashSet<E>(Arrays.asList(array));
if (excludeNull) {
set.remove(null);
}
@@ -419,7 +418,7 @@
if (type == TreeSet.class) {
return (Collection<E>) ((TreeSet<E>) collection).clone();
}
- return new TreeSet<>(collection);
+ return new TreeSet<E>(collection);
}
if (type == HashSet.class || type == LinkedHashSet.class) {
return (Collection<E>) ((HashSet<E>) collection).clone();
@@ -430,18 +429,18 @@
if (collection instanceof CodeListSet<?>) {
return ((CodeListSet) collection).clone();
}
- return new LinkedHashSet<>(collection);
+ return new LinkedHashSet<E>(collection);
}
if (collection instanceof Queue<?>) {
if (type == LinkedList.class) {
return (Collection<E>) ((LinkedList<E>) collection).clone();
}
- return new LinkedList<>(collection);
+ return new LinkedList<E>(collection);
}
if (type == ArrayList.class) {
return (Collection<E>) ((ArrayList<E>) collection).clone();
}
- return new ArrayList<>(collection);
+ return new ArrayList<E>(collection);
}
/**
@@ -476,12 +475,12 @@
if (type == TreeMap.class) {
return (Map<K,V>) ((TreeMap<K,V>) map).clone();
}
- return new TreeMap<>(map);
+ return new TreeMap<K,V>(map);
}
if (type == HashMap.class || type == LinkedHashMap.class) {
return (Map<K,V>) ((HashMap<K,V>) map).clone();
}
- return new LinkedHashMap<>(map);
+ return new LinkedHashMap<K,V>(map);
}
/**
@@ -562,7 +561,7 @@
return Arrays.asList((Object[]) value);
}
if (value instanceof Iterable<?>) {
- final List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<Object>();
for (final Object element : (Iterable<?>) value) {
list.add(element);
}
@@ -570,7 +569,7 @@
}
if (value instanceof Iterator<?>) {
final Iterator<?> it = (Iterator<?>) value;
- final List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<Object>();
while (it.hasNext()) {
list.add(it.next());
}
@@ -606,7 +605,7 @@
if (collection instanceof List<?>) {
return (List<T>) collection;
}
- return new ArrayList<>(collection);
+ return new ArrayList<T>(collection);
}
/**
@@ -648,7 +647,7 @@
return singleton;
}
if (values.size() <= 1) {
- values = new ArrayList<>(values);
+ values = new ArrayList<V>(values);
if (map.put(key, values) != singleton) {
throw new ConcurrentModificationException();
}
@@ -678,7 +677,7 @@
if (elements == null) {
return Collections.emptyMap();
}
- final Map<String,E> map = new HashMap<>(hashMapCapacity(elements.size()));
+ final Map<String,E> map = new HashMap<String,E>(hashMapCapacity(elements.size()));
Set<String> excludes = null;
for (final E e : elements) {
final String name = nameFunction.apply(e);
@@ -716,7 +715,7 @@
*/
map.remove(lower);
if (excludes == null) {
- excludes = new HashSet<>();
+ excludes = new HashSet<String>();
}
excludes.add(lower);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
index b78078b..74f560d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
@@ -25,7 +25,7 @@
import org.apache.sis.internal.system.DefaultFactories;
// Branch-specific imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
index 0d4d789..ced6617 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
@@ -42,7 +42,7 @@
* Some frequently used {@link Double} values. As of Java 7, those values do not
* seem to be cached by {@link Double#valueOf(double)} like JDK does for integers.
*/
- private static final Map<Object,Object> CACHE = new HashMap<>(32);
+ private static final Map<Object,Object> CACHE = new HashMap<Object,Object>(32);
static {
cache( 0);
cache( 1);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
index e2ebc59..15c80d0 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
@@ -63,7 +63,7 @@
* @param entries The (unit, symbol) pairs.
*/
public static void init(final Object... entries) {
- final Map<Unit<?>,String> symbols = new HashMap<>(8);
+ final Map<Unit<?>,String> symbols = new HashMap<Unit<?>,String>(8);
for (int i=0; i<entries.length; i++) {
final String uom;
if (symbols.put((Unit<?>) entries[i], uom = (String) entries[++i]) != null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java
index 0b3d2ef..1db7951 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.util;
+import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -45,8 +46,12 @@
/**
* The pattern of dates.
+ *
+ * The JDK7 branch has a 'X' pattern at the end of this format. But JDK6 does not support that pattern.
+ * As a workaround, code using this pattern will append a hard-coded {@code "'Z'"} if the timezone is
+ * known to be UTC.
*/
- public static final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SX";
+ public static final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.S";
/**
* Short version of {@link #PATTERN}, to be used when formatting temporal extents
@@ -80,7 +85,7 @@
* @param timezone The timezone.
*/
public StandardDateFormat(final Locale locale, final TimeZone timezone) {
- super(PATTERN, locale);
+ super("UTC".equals(timezone.getID()) ? PATTERN + "'Z'" : PATTERN, locale);
setTimeZone(timezone);
}
@@ -113,6 +118,35 @@
position.setErrorIndex(errorIndex); // Reset original error index.
}
}
+ } else {
+ /*
+ * Following is a workaround specific to the JDK6 branch. Since JDK6 does not understand the 'Z' suffix,
+ * we handle it in this method. The Apache SIS branch for JDK7 does not need this hack since JDK7 supports
+ * parsing the 'Z' suffix.
+ */
+ final int p = position.getIndex();
+ if (p < text.length() && text.charAt(p) == 'Z') {
+ position.setIndex(p + 1);
+ final Calendar cal = calendar;
+ final int year = cal.get(Calendar.YEAR);
+ final int month = cal.get(Calendar.MONTH);
+ final int day = cal.get(Calendar.DAY_OF_MONTH);
+ final int hour = cal.get(Calendar.HOUR_OF_DAY);
+ final int minute = cal.get(Calendar.MINUTE);
+ final int second = cal.get(Calendar.SECOND);
+ final int millis = cal.get(Calendar.MILLISECOND);
+ final TimeZone timezone = cal.getTimeZone();
+ final long time;
+ try {
+ cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ cal.set(year, month, day, hour, minute, second);
+ cal.set(Calendar.MILLISECOND, millis);
+ time = cal.getTimeInMillis();
+ } finally {
+ cal.setTimeZone(timezone);
+ }
+ date.setTime(time);
+ }
}
return date;
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
index d39b036..0149984 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
@@ -24,7 +24,7 @@
import org.apache.sis.util.collection.CheckedContainer;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -116,7 +116,7 @@
* array was null.
*/
public static <E> UnmodifiableArrayList<E> wrap(final E[] array) { // NOT "E..." - see javadoc.
- return (array != null) ? new UnmodifiableArrayList<>(array) : null;
+ return (array != null) ? new UnmodifiableArrayList<E>(array) : null;
}
/**
@@ -142,9 +142,9 @@
*/
public static <E> UnmodifiableArrayList<E> wrap(final E[] array, final int lower, final int upper) {
if (lower == 0 && upper == array.length) {
- return new UnmodifiableArrayList<>(array);
+ return new UnmodifiableArrayList<E>(array);
}
- return new UnmodifiableArrayList.SubList<>(array, lower, upper - lower);
+ return new UnmodifiableArrayList.SubList<E>(array, lower, upper - lower);
}
/**
@@ -301,7 +301,7 @@
throws IndexOutOfBoundsException
{
ArgumentChecks.ensureValidIndexRange(size(), lower, upper);
- return new SubList<>(array, lower + lower(), upper - lower);
+ return new SubList<E>(array, lower + lower(), upper - lower);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java b/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java
index c86651c..e38f13b 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java
@@ -22,6 +22,9 @@
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Base class for writing filtered characters to another {@link Appendable}.
@@ -157,11 +160,11 @@
* @throws IOException If an error occurred while appending the code point.
*/
final void appendCodePoint(final int c) throws IOException {
- if (Character.isBmpCodePoint(c)) {
+ if (JDK7.isBmpCodePoint(c)) {
out.append((char) c);
} else if (Character.isSupplementaryCodePoint(c)) {
- out.append(Character.highSurrogate(c))
- .append(Character. lowSurrogate(c));
+ out.append(JDK7.highSurrogate(c))
+ .append(JDK7. lowSurrogate(c));
} else {
throw new CharConversionException();
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java b/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
index f75ac76..8ec59ae 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
@@ -136,34 +136,6 @@
}
/**
- * Returns the locale for the given category. Subclasses may override this method in order to assign
- * different roles to the different locale categories. A typical (but not mandatory) mapping is:
- *
- * <ul>
- * <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for numbers, dates and angles formatting.</li>
- * <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for {@link org.opengis.util.CodeList} labels
- * and {@link org.opengis.util.InternationalString} contents.</li>
- * </ul>
- *
- * <div class="note"><b>Example:</b>
- * The ISO 19162 (<cite>Well Known Text</cite>) standard requires a number format similar to the one defined by
- * {@code Locale.ROOT} while it allows informative texts (remarks, <i>etc.</i>) to be formatted according the
- * user's locale. Consequently {@code WKTFormat} fixes (usually) the locale for {@code Category.FORMAT} to
- * {@code Locale.ROOT} and let {@code Category.DISPLAY} be any locale.</div>
- *
- * For subclasses that do not override this method, the default implementation returns {@link #getLocale()}.
- *
- * @param category The category for which a locale is desired.
- * @return The locale for the given category (never {@code null}).
- *
- * @since 0.4
- */
- public Locale getLocale(final Locale.Category category) {
- ArgumentChecks.ensureNonNull("category", category);
- return getLocale();
- }
-
- /**
* Returns the timezone used by this format.
*
* @return The timezone used for this format, or UTC for unlocalized format.
@@ -298,7 +270,7 @@
} while (Character.isSpaceChar(c) || Character.isISOControl(c));
pos.setErrorIndex(i);
}
- throw new LocalizedParseException(getLocale(Locale.Category.DISPLAY), getValueType(), text, pos);
+ throw new LocalizedParseException(getLocale(), getValueType(), text, pos);
}
/**
@@ -378,7 +350,7 @@
format = createFormat(type);
if (format != null) {
if (formats == null) {
- this.formats = formats = new IdentityHashMap<>(4);
+ this.formats = formats = new IdentityHashMap<Class<?>,Format>(4);
}
formats.put(type, format);
break;
@@ -424,7 +396,7 @@
* documented in this method javadoc. But actually it is not, since the call to
* DefaultFormat.getInstance(…) will indirectly perform this kind of comparison.
*/
- final Locale locale = getLocale(Locale.Category.FORMAT);
+ final Locale locale = getLocale();
if (Number.class.isAssignableFrom(valueType)) {
if (Locale.ROOT.equals(locale)) {
return DefaultFormat.getInstance(valueType);
@@ -467,7 +439,7 @@
@SuppressWarnings("unchecked")
final CompoundFormat<T> clone = (CompoundFormat<T>) super.clone();
if (clone.formats != null) {
- clone.formats = new IdentityHashMap<>(clone.formats);
+ clone.formats = new IdentityHashMap<Class<?>,Format>(clone.formats);
for (final Map.Entry<Class<?>,Format> entry : clone.formats.entrySet()) {
entry.setValue((Format) entry.getValue().clone());
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java b/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java
index 1a9370a..0fe557b 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java
@@ -23,6 +23,9 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.internal.util.X364;
+// Related to JK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* An {@link Appendable} which can apply different kinds of reformatting that depend on the
@@ -297,7 +300,7 @@
*/
private void writeLineSeparator() throws IOException {
if (lineSeparator == null) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
out.append(lineSeparator);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java b/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
index 9e62379..31a4298 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
@@ -29,6 +29,9 @@
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
+// Related to JK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* An {@link Appendable} which formats the text as a table suitable for displaying in devices using
@@ -141,7 +144,7 @@
* <code>{@linkplain Cell#text} == null</code> means that we need to move
* to the next line.
*/
- private final List<Cell> cells = new ArrayList<>();
+ private final List<Cell> cells = new ArrayList<Cell>();
/**
* Alignment for current and next cells.
@@ -797,7 +800,7 @@
out.append(isLastColumn ? rightBorder : columnSeparator);
}
if (lineSeparator == null) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
out.append(lineSeparator);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java b/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java
index cc8077a..63879a7 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java
@@ -25,6 +25,9 @@
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
+// Related to JK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Base class for parser and formatter of tabular data, providing control on line and column separators.
@@ -137,7 +140,7 @@
beforeFill = "";
fillCharacter = ' ';
columnSeparator = " ";
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java b/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
index 941792b..6bf661f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
@@ -27,7 +27,7 @@
import static java.lang.Double.doubleToLongBits;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.LongConsumer;
import org.apache.sis.internal.jdk8.DoubleConsumer;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java b/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
index 24447aa..7dacfc4 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
@@ -93,9 +93,7 @@
* @return A statistics format instance for the current default locale.
*/
public static StatisticsFormat getInstance() {
- return new StatisticsFormat(
- Locale.getDefault(Locale.Category.FORMAT),
- Locale.getDefault(Locale.Category.DISPLAY), null);
+ return getInstance(Locale.getDefault());
}
/**
@@ -123,28 +121,6 @@
}
/**
- * Returns the locale for the given category. This method implements the following mapping:
- *
- * <ul>
- * <li>{@link java.util.Locale.Category#DISPLAY} — the {@code headerLocale} given at construction time.</li>
- * <li>{@link java.util.Locale.Category#FORMAT} — the {@code locale} given at construction time,
- * used for all values below the header row.</li>
- * </ul>
- *
- * @param category The category for which a locale is desired.
- * @return The locale for the given category (never {@code null}).
- *
- * @since 0.4
- */
- @Override
- public Locale getLocale(final Locale.Category category) {
- if (category == Locale.Category.DISPLAY) {
- return headerLocale;
- }
- return super.getLocale(category);
- }
-
- /**
* Returns the type of objects formatted by this class.
*
* @return {@code Statistics.class}
@@ -257,7 +233,7 @@
*/
@Override
public void format(Statistics stats, final Appendable toAppendTo) throws IOException {
- final List<Statistics> list = new ArrayList<>(3);
+ final List<Statistics> list = new ArrayList<Statistics>(3);
while (stats != null) {
list.add(stats);
stats = stats.differences();
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java b/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
index 1bf99bc..4437c42 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
@@ -42,7 +42,7 @@
import static org.apache.sis.math.DecimalFunctions.fractionDigitsForDelta;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.JDK8;
@@ -398,7 +398,7 @@
* Constructs a new {@code AngleFormat} for the default pattern and the current default locale.
*/
public AngleFormat() {
- this(Locale.getDefault(Locale.Category.FORMAT));
+ this(Locale.getDefault());
}
/**
@@ -429,7 +429,7 @@
* @throws IllegalArgumentException If the specified pattern is illegal.
*/
public AngleFormat(final String pattern) throws IllegalArgumentException {
- this(pattern, Locale.getDefault(Locale.Category.FORMAT));
+ this(pattern, Locale.getDefault());
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java b/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
index 7afa839..03f69d5 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
@@ -155,7 +155,7 @@
*/
FormattedCharacterIterator(final CharSequence text) {
super(text);
- attributes = new IdentityHashMap<>(8);
+ attributes = new IdentityHashMap<Attribute,Entry>(8);
}
/**
@@ -314,7 +314,7 @@
* {@code getRunStart(Set)} and {@code getRunLimit(Set)} methods.
*/
private Collection<Entry> entries(final Set<? extends Attribute> requested) {
- final Collection<Entry> entries = new ArrayList<>(requested.size());
+ final Collection<Entry> entries = new ArrayList<Entry>(requested.size());
for (final Attribute r : requested) {
final Entry e = attributes.get(r);
if (e != null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java b/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
index 8e6d4d6..e23a448 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
@@ -23,7 +23,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -84,7 +84,7 @@
public static MeasurementRange<Float> create(float minValue, boolean isMinIncluded,
float maxValue, boolean isMaxIncluded, Unit<?> unit)
{
- return unique(new MeasurementRange<>(Float.class,
+ return unique(new MeasurementRange<Float>(Float.class,
valueOf("minValue", minValue, Float.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded, unit));
}
@@ -103,7 +103,7 @@
public static MeasurementRange<Double> create(double minValue, boolean isMinIncluded,
double maxValue, boolean isMaxIncluded, Unit<?> unit)
{
- return unique(new MeasurementRange<>(Double.class,
+ return unique(new MeasurementRange<Double>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded, unit));
}
@@ -120,7 +120,7 @@
* @since 0.6
*/
public static MeasurementRange<Double> createGreaterThan(final double minValue, final Unit<?> unit) {
- return unique(new MeasurementRange<>(Double.class,
+ return unique(new MeasurementRange<Double>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), false, null, false, unit));
}
@@ -225,7 +225,7 @@
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new MeasurementRange<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded, unit);
+ return new MeasurementRange<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded, unit);
}
/**
@@ -263,7 +263,7 @@
if (elementType == type) {
return (MeasurementRange<N>) this;
} else {
- return new MeasurementRange<>(type, this, unit);
+ return new MeasurementRange<N>(type, this, unit);
}
}
@@ -306,7 +306,7 @@
throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
((MeasurementRange<?>) range).unit, unit), e);
}
- return new MeasurementRange<>(type, range, unit);
+ return new MeasurementRange<N>(type, range, unit);
}
/**
@@ -345,12 +345,12 @@
minInc &= (minimum == (minimum = Math.floor(minimum)));
maxInc &= (maximum == (maximum = Math.ceil (maximum)));
}
- return new MeasurementRange<>(type,
+ return new MeasurementRange<N>(type,
Numbers.cast(minimum, type), minInc,
Numbers.cast(maximum, type), maxInc, targetUnit);
}
}
- return new MeasurementRange<>(type, this, targetUnit);
+ return new MeasurementRange<N>(type, this, targetUnit);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java b/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
index 52f8da6..e770723 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
@@ -98,7 +98,7 @@
* The pool of ranges created by the {@code create(…)} methods.
*/
@SuppressWarnings("unchecked")
- private static final WeakHashSet<NumberRange<?>> POOL = new WeakHashSet<>((Class) NumberRange.class);
+ private static final WeakHashSet<NumberRange<?>> POOL = new WeakHashSet<NumberRange<?>>((Class) NumberRange.class);
/**
* Returns a unique instance of the given range, except if the range is empty.
@@ -129,7 +129,7 @@
public static NumberRange<Byte> create(final byte minValue, final boolean isMinIncluded,
final byte maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Byte.class,
+ return unique(new NumberRange<Byte>(Byte.class,
Byte.valueOf(minValue), isMinIncluded,
Byte.valueOf(maxValue), isMaxIncluded));
}
@@ -147,7 +147,7 @@
public static NumberRange<Short> create(final short minValue, final boolean isMinIncluded,
final short maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Short.class,
+ return unique(new NumberRange<Short>(Short.class,
Short.valueOf(minValue), isMinIncluded,
Short.valueOf(maxValue), isMaxIncluded));
}
@@ -167,7 +167,7 @@
public static NumberRange<Integer> create(final int minValue, final boolean isMinIncluded,
final int maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Integer.class,
+ return unique(new NumberRange<Integer>(Integer.class,
Integer.valueOf(minValue), isMinIncluded,
Integer.valueOf(maxValue), isMaxIncluded));
}
@@ -185,7 +185,7 @@
public static NumberRange<Long> create(final long minValue, final boolean isMinIncluded,
final long maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Long.class,
+ return unique(new NumberRange<Long>(Long.class,
Long.valueOf(minValue), isMinIncluded,
Long.valueOf(maxValue), isMaxIncluded));
}
@@ -204,7 +204,7 @@
public static NumberRange<Float> create(final float minValue, final boolean isMinIncluded,
final float maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Float.class,
+ return unique(new NumberRange<Float>(Float.class,
valueOf("minValue", minValue, Float.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded));
}
@@ -234,7 +234,7 @@
public static NumberRange<Double> create(final double minValue, final boolean isMinIncluded,
final double maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<>(Double.class,
+ return unique(new NumberRange<Double>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded));
}
@@ -268,7 +268,7 @@
* @since 0.5
*/
public static NumberRange<Integer> createLeftBounded(final int minValue, final boolean isMinIncluded) {
- return unique(new NumberRange<>(Integer.class, Integer.valueOf(minValue), isMinIncluded, null, false));
+ return unique(new NumberRange<Integer>(Integer.class, Integer.valueOf(minValue), isMinIncluded, null, false));
}
/**
@@ -324,7 +324,7 @@
}
// The constructor will ensure that the range element type is a subclass of Number.
// Do not invoke unique(NumberRange) because the returned range is often temporary.
- return new NumberRange<>(range);
+ return new NumberRange<N>(range);
}
/**
@@ -397,7 +397,7 @@
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new NumberRange<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
+ return new NumberRange<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
}
/**
@@ -420,7 +420,7 @@
if (range.elementType == type) {
return (NumberRange<N>) range;
}
- return new NumberRange<>(type, range);
+ return new NumberRange<N>(type, range);
}
/**
@@ -442,7 +442,7 @@
if (elementType == type) {
return (NumberRange<N>) this;
}
- return new NumberRange<>(type, this);
+ return new NumberRange<N>(type, this);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java b/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
index b2ed239..a094d85 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
@@ -29,7 +29,7 @@
import org.apache.sis.util.Numbers;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -174,7 +174,7 @@
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new Range<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
+ return new Range<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
}
/**
@@ -616,6 +616,7 @@
* only one digit. This method assumes that we have verified that the element type
* is an integer type before to invoke this method.
*/
+ @SuppressWarnings("unchecked")
private static boolean isCompact(final Comparable<?> value, final boolean ifNull) {
if (value == null) {
return ifNull;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java b/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
index ba8b39f..b69fe89 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
@@ -302,7 +302,7 @@
* using the {@linkplain Locale#getDefault() default locale}.
*/
public RangeFormat() {
- this(Locale.getDefault(Locale.Category.FORMAT));
+ this(Locale.getDefault());
}
/**
@@ -475,7 +475,7 @@
*/
private boolean insertSpaceBeforeUnit(final Unit<?> unit) {
if (insertSpaceBeforeUnit == null) {
- insertSpaceBeforeUnit = new HashMap<>();
+ insertSpaceBeforeUnit = new HashMap<Unit<?>,Boolean>();
}
Boolean value = insertSpaceBeforeUnit.get(unit);
if (value == null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
index 8ead0eb..2cf0900 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
@@ -58,7 +58,7 @@
* avoid loading the {@code SexagesimalConverter} class before needed, since their
* constants appear in this map.
*/
- static final Map<Unit<?>,Integer> EPSG_CODES = new HashMap<>(20);
+ static final Map<Unit<?>,Integer> EPSG_CODES = new HashMap<Unit<?>,Integer>(20);
static {
final byte[] codes = {1, 2, 30, 36, 101, 102, 103, 104, 105, 108, 109, 111, 110, (byte) 201, (byte) 202};
for (final byte c : codes) {
@@ -70,7 +70,7 @@
/**
* A few units commonly used in GIS.
*/
- private static final Map<Unit<?>,Unit<?>> COMMONS = new HashMap<>(48);
+ private static final Map<Unit<?>,Unit<?>> COMMONS = new HashMap<Unit<?>,Unit<?>>(48);
static {
COMMONS.put(MILLISECOND, MILLISECOND);
boolean nonSI = false;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
index 02fd873..3ce2d7e 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
@@ -62,7 +62,7 @@
import static org.apache.sis.util.collection.TableColumn.VALUE_AS_TEXT;
// Branch-dependent imports
-import java.nio.file.Path;
+import org.apache.sis.internal.jdk7.Path;
/**
@@ -183,8 +183,8 @@
if (locale != null) {
formatLocale = locale;
} else {
- locale = Locale.getDefault(Locale.Category.DISPLAY);
- formatLocale = Locale.getDefault(Locale.Category.FORMAT);
+ locale = Locale.getDefault();
+ formatLocale = locale; // On the JDK7 branch, this is not necessarily the same.
}
String userHome = null;
String javaHome = null;
@@ -507,7 +507,7 @@
* @return The paths, or {@code null} if none.
*/
private static Map<File,CharSequence> classpath(final String paths, final boolean asDirectories) {
- final Map<File,CharSequence> files = new LinkedHashMap<>();
+ final Map<File,CharSequence> files = new LinkedHashMap<File,CharSequence>();
return classpath(paths, null, asDirectories, files) ? files : null;
}
@@ -576,7 +576,8 @@
}
final File file = entry.getKey();
if (file.isFile() && file.canRead()) {
- try (final JarFile jar = new JarFile(file)) {
+ try {
+ final JarFile jar = new JarFile(file);
final Manifest manifest = jar.getManifest();
if (manifest != null) {
final Attributes attributes = manifest.getMainAttributes();
@@ -600,11 +601,12 @@
}
}
}
+ jar.close();
} catch (IOException e) {
if (error == null) {
error = e;
} else {
- error.addSuppressed(e);
+ // error.addSuppressed(e) on JDK7 branch.
}
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
index a394861..392efa5 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
@@ -25,10 +25,6 @@
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Modules;
-// Branch-dependent imports
-import java.nio.file.OpenOption;
-import java.nio.file.StandardOpenOption;
-
/**
* Keys in a map of options for configuring various services
@@ -83,7 +79,7 @@
*
* @since 0.4
*/
- public static final OptionKey<Charset> ENCODING = new OptionKey<>("ENCODING", Charset.class);
+ public static final OptionKey<Charset> ENCODING = new OptionKey<Charset>("ENCODING", Charset.class);
/**
* The encoding of a URL (<strong>not</strong> the encoding of the document content).
@@ -115,7 +111,7 @@
*
* @see java.net.URLDecoder
*/
- public static final OptionKey<String> URL_ENCODING = new OptionKey<>("URL_ENCODING", String.class);
+ public static final OptionKey<String> URL_ENCODING = new OptionKey<String>("URL_ENCODING", String.class);
/**
* Whether a storage object (e.g. a {@link org.apache.sis.storage.DataStore}) shall be opened in read,
@@ -124,13 +120,18 @@
* <table class="sis">
* <caption>Supported open options</caption>
* <tr><th>Value</th> <th>Meaning</th></tr>
- * <tr><td>{@link StandardOpenOption#READ}</td> <td>Open for reading data from the storage object.</td></tr>
- * <tr><td>{@link StandardOpenOption#WRITE}</td> <td>Open for modifying existing data in the storage object.</td></tr>
- * <tr><td>{@link StandardOpenOption#APPEND}</td> <td>Open for appending new data in the storage object.</td></tr>
- * <tr><td>{@link StandardOpenOption#CREATE}</td> <td>Creates a new storage object (file or database) if it does not exist.</td></tr>
+ * <tr><td>{@code "READ"}</td> <td>Open for reading data from the storage object.</td></tr>
+ * <tr><td>{@code "WRITE"}</td> <td>Open for modifying existing data in the storage object.</td></tr>
+ * <tr><td>{@code "APPEND"}</td> <td>Open for appending new data in the storage object.</td></tr>
+ * <tr><td>{@code "CREATE"}</td> <td>Creates a new storage object (file or database) if it does not exist.</td></tr>
* </table>
+ *
+ * {@section Differences between the JDK6 and JDK7 branches of SIS}
+ * In the JDK7 branch of SIS, the array type for this key is {@code java.nio.file.OpenOption[]} instead than
+ * {@code Object[]} and the constants listed in the above table are {@code java.nio.file.StandardOpenOption}
+ * enumeration values.
*/
- public static final OptionKey<OpenOption[]> OPEN_OPTIONS = new OptionKey<>("OPEN_OPTIONS", OpenOption[].class);
+ public static final OptionKey<Object[]> OPEN_OPTIONS = new OptionKey<Object[]>("OPEN_OPTIONS", Object[].class);
/**
* The byte buffer to use for input/output operations. Some {@link org.apache.sis.storage.DataStore}
@@ -144,7 +145,7 @@
* <li>The same buffer is not used concurrently by two different {@code DataStore} instances.</li>
* </ul>
*/
- public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<>("BYTE_BUFFER", ByteBuffer.class);
+ public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<ByteBuffer>("BYTE_BUFFER", ByteBuffer.class);
/**
* The name of this key. For {@code OptionKey} instances, it shall be the name of the static constants.
@@ -225,7 +226,7 @@
public Map<OptionKey<?>,Object> setValueInto(Map<OptionKey<?>,Object> options, final T value) {
if (value != null) {
if (options == null) {
- options = new HashMap<>();
+ options = new HashMap<OptionKey<?>,Object>();
}
options.put(this, value);
} else if (options != null) {
@@ -277,7 +278,7 @@
private Object readResolve() {
try {
return OptionKey.class.getField(name).get(null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
/*
* This may happen if we are deserializing a stream produced by a more recent SIS library
* than the one running in this JVM. This class should be robust to this situation, since
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java b/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
index 15e20d9..77350a9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
@@ -21,7 +21,7 @@
import java.lang.reflect.Array;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -2024,7 +2024,6 @@
* @see #append(Object[], Object)
* @see #unionOfSorted(int[], int[])
*/
- @SafeVarargs
public static <T> T[] concatenate(final T[]... arrays) {
T[] result = null;
if (arrays != null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java b/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
index 681bda9..f474c72 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
@@ -23,6 +23,10 @@
import static java.lang.Character.*;
+// Related to JDK7
+import static org.apache.sis.internal.jdk7.JDK7.lowSurrogate;
+import static org.apache.sis.internal.jdk7.JDK7.highSurrogate;
+
/**
* Static methods working with {@link CharSequence} instances. Some methods defined in this
@@ -2079,8 +2083,8 @@
((StringBuilder) src).getChars(srcOffset, srcOffset + length, dst, dstOffset);
} else if (src instanceof StringBuffer) {
((StringBuffer) src).getChars(srcOffset, srcOffset + length, dst, dstOffset);
- } else if (src instanceof CharBuffer) {
- ((CharBuffer) src).subSequence(srcOffset, srcOffset + length).get(dst, dstOffset, length);
+// } else if (src instanceof CharBuffer) {
+// JDK7 ((CharBuffer) src).subSequence(srcOffset, srcOffset + length).get(dst, dstOffset, length);
} else {
// An other candidate could be javax.swing.text.Segment, but it
// is probably not worth to introduce a Swing dependency for it.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java b/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
index 7ef836f..b20a55d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
@@ -264,7 +264,7 @@
* @return The set of classes of all objects in the given collection.
*/
private static <T> Set<Class<? extends T>> getClasses(final Iterable<? extends T> objects) {
- final Set<Class<? extends T>> types = new LinkedHashSet<>();
+ final Set<Class<? extends T>> types = new LinkedHashSet<Class<? extends T>>();
for (final T object : objects) {
types.add(getClass(object));
}
@@ -329,7 +329,7 @@
final Class<?>[] interfaces = type.getInterfaces();
for (final Class<?> candidate : interfaces) {
if (addTo == null) {
- addTo = new LinkedHashSet<>(hashMapCapacity(interfaces.length));
+ addTo = new LinkedHashSet<Class<?>>(hashMapCapacity(interfaces.length));
}
if (addTo.add(candidate)) {
getInterfaceSet(candidate, addTo);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java b/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
index 920e8fb..ca3eb72 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
@@ -25,6 +25,9 @@
import org.apache.sis.util.resources.Vocabulary;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Static methods working with {@link Exception} instances.
@@ -99,7 +102,7 @@
final Throwable ne;
try {
ne = exception.getClass().getConstructor(String.class).newInstance(message);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // Too many exception for listing them all.
return exception;
}
ne.setStackTrace(exception.getStackTrace());
@@ -125,8 +128,8 @@
* and no exception provide a message.
*/
public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
- final List<String> previousLines = new ArrayList<>();
- final String lineSeparator = System.lineSeparator();
+ final List<String> previousLines = new ArrayList<String>();
+ final String lineSeparator = JDK7.lineSeparator();
StringBuilder buffer = null;
Vocabulary resources = null;
while (cause != null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java b/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
index df52ad5..dc1278f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
@@ -24,10 +24,10 @@
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.MissingResourceException;
-import java.util.IllformedLocaleException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.system.Loggers;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
@@ -58,7 +58,7 @@
private static final Map<Locale,Locale> POOL;
static {
final Locale[] locales = Locale.getAvailableLocales();
- POOL = new HashMap<>(hashMapCapacity(locales.length));
+ POOL = new HashMap<Locale,Locale>(hashMapCapacity(locales.length));
for (final Locale lc : locales) {
POOL.put(lc, lc);
}
@@ -104,7 +104,7 @@
private static final short[] ISO3, ISO2;
static {
final Short CONFLICT = 0; // Sentinal value for conflicts (paranoiac safety).
- final Map<Short,Short> map = new TreeMap<>();
+ final Map<Short,Short> map = new TreeMap<Short,Short>();
for (final Locale locale : POOL.values()) {
short type = LANGUAGE; // 0 for language, or leftmost bit set for country.
do { // Executed exactly twice: once for language, than once for country.
@@ -211,7 +211,7 @@
* @return The languages, without country or variant information.
*/
private static Locale[] getLanguages(final Locale... locales) {
- final Set<String> codes = new LinkedHashSet<>(hashMapCapacity(locales.length));
+ final Set<String> codes = new LinkedHashSet<String>(hashMapCapacity(locales.length));
for (final Locale locale : locales) {
codes.add(locale.getLanguage());
}
@@ -234,11 +234,11 @@
*
* @param code The language code, optionally followed by country code and variant.
* @return The language for the given code (never {@code null}).
- * @throws IllformedLocaleException If the given code is not valid.
+ * @throws RuntimeException If the given code is not valid ({@code IllformedLocaleException} on the JDK7 branch).
*
* @see Locale#forLanguageTag(String)
*/
- public static Locale parse(final String code) throws IllformedLocaleException {
+ public static Locale parse(final String code) {
return parse(code, 0);
}
@@ -256,24 +256,22 @@
* @param code The language code, which may be followed by country code.
* @param fromIndex Index of the first character to parse.
* @return The language for the given code (never {@code null}).
- * @throws IllformedLocaleException If the given code is not valid.
+ * @throws RuntimeException If the given code is not valid ({@code IllformedLocaleException} on the JDK7 branch).
*
* @see Locale#forLanguageTag(String)
* @see org.apache.sis.util.iso.Types#toInternationalString(Map, String)
*/
- public static Locale parse(final String code, final int fromIndex) throws IllformedLocaleException {
+ public static Locale parse(final String code, final int fromIndex) {
ArgumentChecks.ensureNonNull("code", code);
ArgumentChecks.ensurePositive("fromIndex", fromIndex);
int p1 = code.indexOf('_', fromIndex);
- int i = code.indexOf('-', fromIndex);
- if (i >= 0 && (p1 < 0 || i < p1)) {
+ // JDK7 branch contains a code here with the following comment:
/*
* IETF BCP 47 language tag string. This syntax uses the '-' separator instead of '_'.
* Note that the '_' character is illegal for the language code, but is legal for the
* variant. Consequently we require the '-' character to appear before the first '_'.
*/
- return unique(new Locale.Builder().setLanguageTag(code).build());
- }
+ // End of JDK7-specific.
/*
* Old syntax (e.g. "en_US"). Split in (language, country, variant) components,
* then convert the 3-letters codes to the 2-letters ones.
@@ -294,7 +292,29 @@
language = (String) trimWhitespaces(code, fromIndex, p1);
language = toISO2(language, LANGUAGE);
country = toISO2(country, COUNTRY);
- return unique(new Locale.Builder().setLanguage(language).setRegion(country).setVariant(variant).build());
+ if (language.length() > 8 || !isAlphaNumeric(language) ||
+ country.length() > 3 || !isAlphaNumeric(country))
+ {
+ throw new RuntimeException( // IllformedLocaleException (indirectly) on the JDK7 branch.
+ Errors.format(Errors.Keys.IllegalLanguageCode_1, code.substring(fromIndex)));
+ }
+ return unique(new Locale(language, country, variant));
+ }
+
+ /**
+ * Returns {@code true} if the given text contains only Latin alphabetic or numeric characters.
+ * We use this method for simulating the check performed by {@code Locale.Builder} on JDK7. Our
+ * test is not as accurate as the JDK7 one however - we are more permissive. But it is not our
+ * intend to reproduce all the JDK7 syntax checks here.
+ */
+ private static boolean isAlphaNumeric(final String text) {
+ for (int i=text.length(); --i>=0;) {
+ final char c = text.charAt(i);
+ if (!(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9')) {
+ return false;
+ }
+ }
+ return true;
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java b/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
index 2af0bc5..84c77fa 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
@@ -65,7 +65,7 @@
* But maybe the most interesting property is that it allocates less objects since {@code IdentityHashMap}
* implementation doesn't need the chain of objects created by {@code HashMap}.</div>
*/
- private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<>(11);
+ private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(11);
static {
new Numbers(BigDecimal.class, true, false, BIG_DECIMAL);
new Numbers(BigInteger.class, false, true, BIG_INTEGER);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java b/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
index 0545a7a..b5f1bda 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
@@ -81,7 +81,7 @@
*/
public static <T> ObjectConverter<T,T> identity(final Class<T> type) {
ArgumentChecks.ensureNonNull("type", type);
- return new IdentityConverter<>(type, type, null).unique();
+ return new IdentityConverter<T,T>(type, type, null).unique();
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java b/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
index 1417265..ebdee82 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
@@ -25,7 +25,7 @@
import org.apache.sis.util.collection.CheckedContainer;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -250,7 +250,7 @@
* compared up to this point.
*/
// Creates a copy of REMAINING elements in the first collection.
- final LinkedList<Object> copy = new LinkedList<>();
+ final LinkedList<Object> copy = new LinkedList<Object>();
copy.add(element1);
while (it1.hasNext()) {
copy.add(it1.next());
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
index 44dd729..326094f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
@@ -67,7 +67,9 @@
* return createMyObject(key);
* }
* });
- * } catch (MyCheckedException | RuntimeException e) {
+ * } catch (MyCheckedException e) {
+ * throw e;
+ * } catch (RuntimeException e) {
* throw e;
* } catch (Exception e) {
* throw new UndeclaredThrowableException(e);
@@ -212,8 +214,8 @@
ArgumentChecks.ensureStrictlyPositive("initialCapacity", initialCapacity);
ArgumentChecks.ensurePositive("costLimit", costLimit);
initialCapacity = Containers.hashMapCapacity(initialCapacity);
- this.map = new ConcurrentHashMap<>(initialCapacity);
- this.costs = new LinkedHashMap<>((int) Math.min(initialCapacity, costLimit), 0.75f, true);
+ this.map = new ConcurrentHashMap<K,Object>(initialCapacity);
+ this.costs = new LinkedHashMap<K,Integer>((int) Math.min(initialCapacity, costLimit), 0.75f, true);
this.costLimit = costLimit;
this.soft = soft;
}
@@ -478,7 +480,7 @@
ref.clear(); // Prevents the reference from being enqueued.
DelayedExecutor.schedule(new Strong(key, result));
}
- return new Simple<>(result);
+ return new Simple<V>(result);
}
/*
* The weak reference is invalid but not yet discarded (it looks like that this
@@ -520,7 +522,7 @@
* not be cached. This is okay since the value that we really want to cache is
* CoordinateOperation, which is associated to the first occurrence of that key.
*/
- return new Simple<>(null);
+ return new Simple<V>(null);
}
throw new IllegalStateException(Errors.format(Errors.Keys.RecursiveCreateCallForKey_1, key));
}
@@ -533,7 +535,7 @@
assert !isReservedType(value) : value;
@SuppressWarnings("unchecked")
final V result = (V) value;
- return new Simple<>(result);
+ return new Simple<V>(result);
}
/**
@@ -784,8 +786,8 @@
final Object oldValue = map.get(oldKey);
if (oldValue != null && !isReservedType(oldValue)) {
@SuppressWarnings("unchecked")
- final Reference<V> ref = soft ? new Soft<>(map, oldKey, (V) oldValue)
- : new Weak<>(map, oldKey, (V) oldValue);
+ final Reference<V> ref = soft ? new Soft<K,V>(map, oldKey, (V) oldValue)
+ : new Weak<K,V>(map, oldKey, (V) oldValue);
if (!map.replace(oldKey, oldValue, ref)) {
ref.clear(); // Prevents the reference to be enqueued.
}
@@ -867,7 +869,7 @@
@Override
public Set<Entry<K,V>> entrySet() {
final Set<Entry<K,V>> es = entries;
- return (es != null) ? es : (entries = new CacheEntries<>(map.entrySet()));
+ return (es != null) ? es : (entries = new CacheEntries<K,V>(map.entrySet()));
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java
index dce0b7c..cd35e1f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/CacheEntries.java
@@ -80,7 +80,7 @@
*/
@Override
public Iterator<Map.Entry<K,V>> iterator() {
- return new Iter<>(entries.iterator());
+ return new Iter<K,V>(entries.iterator());
}
/**
@@ -123,7 +123,7 @@
continue;
}
}
- next = new SimpleEntry<>(entry.getKey(), (V) value);
+ next = new SimpleEntry<K,V>(entry.getKey(), (V) value);
return;
}
next = null;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
index 14082de..1e668f7 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
@@ -72,7 +72,7 @@
* same code list type, this allows those instances to share the same arrays.
*/
@SuppressWarnings("rawtypes")
- private static final WeakHashSet<CodeList[]> POOL = new WeakHashSet<>(CodeList[].class);
+ private static final WeakHashSet<CodeList[]> POOL = new WeakHashSet<CodeList[]>(CodeList[].class);
/**
* The type of code list elements.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
index dabe9a0..5e802a8 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
@@ -93,7 +93,6 @@
*
* @see java.util.Arrays#asList(Object[])
*/
- @SafeVarargs
public static <E> List<? extends E> unmodifiableList(final E... array) {
return UnmodifiableArrayList.wrap(array);
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
index 5c44c80..2af3536 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
@@ -33,7 +33,7 @@
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -157,7 +157,7 @@
switch (columns.length) {
case 0: map = Collections.emptyMap(); break;
case 1: map = null; break; // Will be created inside the loop (common case).
- default: map = new LinkedHashMap<>(hashMapCapacity(columns.length)); break;
+ default: map = new LinkedHashMap<TableColumn<?>,Integer>(hashMapCapacity(columns.length)); break;
}
for (int i=0; i<columns.length; i++) {
final TableColumn<?> column = columns[i];
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java
index 0a404ec..8a31fb2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedMap.java
@@ -117,14 +117,14 @@
final Set<FunctionProperty> vp = valueConverter.properties();
if (kp.contains(FunctionProperty.INVERTIBLE)) {
if (vp.contains(FunctionProperty.INVERTIBLE)) {
- return new Invertible<>(storage, keyConverter, valueConverter);
+ return new Invertible<SK,SV,K,V>(storage, keyConverter, valueConverter);
}
- return new InvertibleKey<>(storage, keyConverter, valueConverter);
+ return new InvertibleKey<SK,SV,K,V>(storage, keyConverter, valueConverter);
}
if (vp.contains(FunctionProperty.INVERTIBLE)) {
- return new InvertibleValue<>(storage, keyConverter, valueConverter);
+ return new InvertibleValue<SK,SV,K,V>(storage, keyConverter, valueConverter);
}
- return new DerivedMap<>(storage, keyConverter, valueConverter);
+ return new DerivedMap<SK,SV,K,V>(storage, keyConverter, valueConverter);
}
/**
@@ -293,7 +293,7 @@
@Override
public ObjectConverter<Entry<K,V>, Entry<SK,SV>> inverse() {
if (inverse == null) {
- inverse = new DerivedMap<>(null, keyInverse, valueInverse);
+ inverse = new DerivedMap<K,V,SK,SV>(null, keyInverse, valueInverse);
}
return inverse;
}
@@ -363,7 +363,7 @@
public final Entry<K,V> apply(final Entry<SK,SV> entry) {
final K key = keyConverter.apply(entry.getKey());
final V value = valueConverter.apply(entry.getValue());
- return (key != null) ? new SimpleEntry<>(key, value) : null;
+ return (key != null) ? new SimpleEntry<K,V>(key, value) : null;
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java
index 911b4d3..fe3984d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java
@@ -87,11 +87,11 @@
final Set<FunctionProperty> properties = converter.properties();
if (properties.contains(FunctionProperty.INVERTIBLE)) {
if (FunctionProperty.isBijective(properties)) {
- return new Bijective<>(storage, converter);
+ return new Bijective<S,E>(storage, converter);
}
- return new Invertible<>(storage, converter);
+ return new Invertible<S,E>(storage, converter);
}
- return new DerivedSet<>(storage, converter);
+ return new DerivedSet<S,E>(storage, converter);
}
/**
@@ -121,7 +121,7 @@
*/
@Override
public final Iterator<E> iterator() {
- return new DerivedIterator<>(storage.iterator(), converter);
+ return new DerivedIterator<S,E>(storage.iterator(), converter);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
index 762ae6e..8c69091 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
@@ -292,7 +292,7 @@
if (Number.class.isAssignableFrom(elementType)) {
return new Numeric(elementType, isMinIncluded, isMaxIncluded);
}
- return new RangeSet<>(elementType, isMinIncluded, isMaxIncluded);
+ return new RangeSet<E>(elementType, isMinIncluded, isMaxIncluded);
}
/**
@@ -434,13 +434,14 @@
*/
final int binarySearch(final E value, final int lower, final int upper) {
switch (elementCode) {
- case DOUBLE: return Arrays.binarySearch((double[]) array, lower, upper, (Double) value);
- case FLOAT: return Arrays.binarySearch((float []) array, lower, upper, (Float) value);
- case LONG: return Arrays.binarySearch((long []) array, lower, upper, (Long) value);
- case INTEGER: return Arrays.binarySearch((int []) array, lower, upper, (Integer) value);
- case SHORT: return Arrays.binarySearch((short []) array, lower, upper, (Short) value);
- case BYTE: return Arrays.binarySearch((byte []) array, lower, upper, (Byte) value);
- case CHARACTER: return Arrays.binarySearch((char []) array, lower, upper, (Character) value);
+ // The convolved casts below are for working around a JDK6 compiler error which does not occur with the JDK7 compiler.
+ case DOUBLE: return Arrays.binarySearch((double[]) array, lower, upper, ((Double) ((Comparable) value)).doubleValue());
+ case FLOAT: return Arrays.binarySearch((float []) array, lower, upper, ((Float) ((Comparable) value)).floatValue ());
+ case LONG: return Arrays.binarySearch((long []) array, lower, upper, ((Long) ((Comparable) value)).longValue ());
+ case INTEGER: return Arrays.binarySearch((int []) array, lower, upper, ((Integer) ((Comparable) value)).intValue ());
+ case SHORT: return Arrays.binarySearch((short []) array, lower, upper, ((Short) ((Comparable) value)).shortValue ());
+ case BYTE: return Arrays.binarySearch((byte []) array, lower, upper, ((Byte) ((Comparable) value)).byteValue ());
+ case CHARACTER: return Arrays.binarySearch((char []) array, lower, upper, ((Character) ((Comparable) value)).charValue ());
default: return Arrays.binarySearch((Object[]) array, lower, upper, value);
}
}
@@ -930,7 +931,7 @@
throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentValue_2, "upper", upper));
}
- return intersect(new Range<>(elementType,
+ return intersect(new Range<E>(elementType,
lower.getMinValue(), lower.isMinIncluded(),
maxValue, !upper.isMinIncluded()));
}
@@ -955,7 +956,7 @@
throw new IllegalArgumentException(Errors.format(
Errors.Keys.IllegalArgumentValue_2, "upper", upper));
}
- return intersect(new Range<>(elementType, null, false, maxValue, !upper.isMinIncluded()));
+ return intersect(new Range<E>(elementType, null, false, maxValue, !upper.isMinIncluded()));
}
/**
@@ -973,7 +974,7 @@
@Override
public SortedSet<Range<E>> tailSet(final Range<E> lower) {
ArgumentChecks.ensureNonNull("lower", lower);
- return intersect(new Range<>(elementType, lower.getMinValue(), lower.isMinIncluded(), null, false));
+ return intersect(new Range<E>(elementType, lower.getMinValue(), lower.isMinIncluded(), null, false));
}
/**
@@ -1507,7 +1508,7 @@
* @return The new range for the given values.
*/
protected Range<E> newRange(final E lower, final E upper) {
- return new Range<>(elementType, lower, isMinIncluded, upper, isMaxIncluded);
+ return new Range<E>(elementType, lower, isMinIncluded, upper, isMaxIncluded);
}
/**
@@ -1524,7 +1525,7 @@
@Override
protected Range<E> newRange(final E lower, final E upper) {
- return new NumberRange<>(elementType, lower, isMinIncluded, upper, isMaxIncluded);
+ return new NumberRange<E>(elementType, lower, isMinIncluded, upper, isMaxIncluded);
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
index f78d8e3..85559e6 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
@@ -104,7 +104,7 @@
* the column elements are typically instances of {@link String} or {@link InternationalString},
* depending on whether the data provide localization support or not.
*/
- public static final TableColumn<CharSequence> NAME = new Constant<>("NAME",
+ public static final TableColumn<CharSequence> NAME = new Constant<CharSequence>("NAME",
CharSequence.class, Vocabulary.Keys.Name);
/**
@@ -112,7 +112,7 @@
* The column {@linkplain #getHeader() header} is <cite>"Identifier"</cite> (eventually localized)
* and the column elements are instances of {@link String}.
*/
- public static final TableColumn<String> IDENTIFIER = new Constant<>("IDENTIFIER",
+ public static final TableColumn<String> IDENTIFIER = new Constant<String>("IDENTIFIER",
String.class, Vocabulary.Keys.Identifier);
/**
@@ -120,7 +120,7 @@
* The column {@linkplain #getHeader() header} is <cite>"Index"</cite> (eventually localized)
* and the column elements are instances of {@link Integer}.
*/
- public static final TableColumn<Integer> INDEX = new Constant<>("INDEX",
+ public static final TableColumn<Integer> INDEX = new Constant<Integer>("INDEX",
Integer.class, Vocabulary.Keys.Index);
/**
@@ -128,7 +128,7 @@
* The column {@linkplain #getHeader() header} is <cite>"Type"</cite> (eventually localized).
*/
@SuppressWarnings("unchecked")
- public static final TableColumn<Class<?>> TYPE = new Constant<>("TYPE",
+ public static final TableColumn<Class<?>> TYPE = new Constant<Class<?>>("TYPE",
(Class) Class.class, Vocabulary.Keys.Type);
/**
@@ -139,7 +139,7 @@
* @see #VALUE_AS_TEXT
* @see #VALUE_AS_NUMBER
*/
- public static final TableColumn<Object> VALUE = new Constant<>("VALUE",
+ public static final TableColumn<Object> VALUE = new Constant<Object>("VALUE",
Object.class, Vocabulary.Keys.Value);
/**
@@ -148,14 +148,14 @@
* the column elements are typically instances of {@link String} or {@link InternationalString},
* depending on whether the data provide localization support or not.
*/
- public static final TableColumn<CharSequence> VALUE_AS_TEXT = new Constant<>("VALUE_AS_TEXT",
+ public static final TableColumn<CharSequence> VALUE_AS_TEXT = new Constant<CharSequence>("VALUE_AS_TEXT",
CharSequence.class, Vocabulary.Keys.Value);
/**
* Frequently-used constant for a column of object numerical values.
* The column {@linkplain #getHeader() header} is <cite>"Value"</cite> (eventually localized).
*/
- public static final TableColumn<Number> VALUE_AS_NUMBER = new Constant<>("VALUE_AS_NUMBER",
+ public static final TableColumn<Number> VALUE_AS_NUMBER = new Constant<Number>("VALUE_AS_NUMBER",
Number.class, Vocabulary.Keys.Value);
/**
@@ -237,7 +237,7 @@
private Object readResolve() throws InvalidObjectException {
try {
return TableColumn.class.getField(field).get(null);
- } catch (ReflectiveOperationException cause) {
+ } catch (Exception cause) { // (ReflectiveOperationException) on JDK7 branch.
InvalidObjectException e = new InvalidObjectException(cause.toString());
e.initCause(cause);
throw e;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
index 3937f1a..e06e12f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
-import java.util.Currency;
import java.io.IOException;
import java.text.Format;
import java.text.ParsePosition;
@@ -292,7 +291,7 @@
* Returns the locale to use for code lists, international strings and exception messages.
*/
final Locale getDisplayLocale() {
- return getLocale(Locale.Category.DISPLAY);
+ return getLocale(); // Implemented as getLocale(Locale.Category.DISPLAY) on the JDK7 branch.
}
/**
@@ -678,9 +677,6 @@
} else if (value instanceof Charset) {
final Locale locale = getDisplayLocale();
text = (locale != Locale.ROOT) ? ((Charset) value).displayName(locale) : ((Charset) value).name();
- } else if (value instanceof Currency) {
- final Locale locale = getDisplayLocale();
- text = (locale != Locale.ROOT) ? ((Currency) value).getDisplayName(locale) : value.toString();
} else if (value instanceof Record) {
formatCollection(((Record) value).getAttributes().values(), recursive);
return;
@@ -832,7 +828,7 @@
columns = c.toArray(new TableColumn<?>[c.size()]);
}
if (parentObjects == null) {
- parentObjects = new IdentityHashMap<>();
+ parentObjects = new IdentityHashMap<Object,Object>();
}
try {
final Writer out = new Writer(toAppendTo, columns, parentObjects);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
index a03ccc6..bbf5f28 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
@@ -21,7 +21,6 @@
import java.util.Map;
import java.util.Locale;
import java.io.File;
-import java.nio.file.Path;
import java.text.ParseException;
import org.opengis.util.InternationalString;
import org.apache.sis.util.Static;
@@ -133,38 +132,6 @@
*
* @param from The root node from which to start the search.
* @param column The column containing the file name.
- * @param path The path for which to find or create a node.
- * @return The node for the given path, either as an existing node or a new node.
- */
- public static TreeTable.Node nodeForPath(TreeTable.Node from,
- final TableColumn<? super String> column, final Path path)
- {
- final Path parent = path.getParent();
- if (parent != null) {
- from = nodeForPath(from, column, parent);
- }
- Path filename = path.getFileName();
- if (filename == null) {
- filename = path.getRoot();
- }
- final String name = filename.toString();
- for (final TreeTable.Node child : from.getChildren()) {
- if (name.equals(child.getValue(column))) {
- return child;
- }
- }
- from = from.newChild();
- from.setValue(column, name);
- return from;
- }
-
- /**
- * Finds the node for the given file, or creates a new node if none exists.
- * This method performs the same work than the above variant, but working on
- * {@code File} instances rather than {@code Path}.
- *
- * @param from The root node from which to start the search.
- * @param column The column containing the file name.
* @param path The file for which to find or create a node.
* @return The node for the given file, either as an existing node or a new node.
*/
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
index 71bda76..1df28a2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
@@ -30,7 +30,7 @@
import static org.apache.sis.util.collection.WeakEntry.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
index 500dcaa..62becb3 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
@@ -34,7 +34,7 @@
import static org.apache.sis.util.collection.WeakEntry.*;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -541,7 +541,7 @@
final Entry[] table = WeakValueHashMap.this.table;
for (Entry el : table) {
while (el != null) {
- final Map.Entry<K,V> entry = new SimpleEntry<>(el);
+ final Map.Entry<K,V> entry = new SimpleEntry<K,V>(el);
if (entry.getValue() != null) {
elements[index++] = entry;
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
index d3b062f..7f0a798 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
@@ -32,7 +32,7 @@
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
index 185e76a..55ed79b 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
@@ -38,7 +38,7 @@
import org.apache.sis.internal.system.Modules;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -118,7 +118,7 @@
if (!it.hasNext()) {
localeMap = Collections.singletonMap(entry.getKey(), entry.getValue());
} else {
- localeMap = new LinkedHashMap<>(strings);
+ localeMap = new LinkedHashMap<Locale,String>(strings);
// If HashMap is replaced by an other type, please revisit 'getLocales()'.
}
}
@@ -148,7 +148,7 @@
}
case 1: {
// If HashMap is replaced by an other type, please revisit 'getLocales()'.
- localeMap = new LinkedHashMap<>(localeMap);
+ localeMap = new LinkedHashMap<Locale,String>(localeMap);
localeSet = null;
break;
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
index 2c03e6c..3e07556 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
@@ -33,7 +33,7 @@
import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java
index c7b3950..13fca9c 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java
@@ -26,7 +26,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
index 00d665c..eca7d4a 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
@@ -105,7 +105,7 @@
* Creates a new factory.
*/
public DefaultNameFactory() {
- pool = new WeakHashSet<>(GenericName.class);
+ pool = new WeakHashSet<GenericName>(GenericName.class);
}
/**
@@ -300,7 +300,7 @@
separator = DEFAULT_SEPARATOR_STRING;
}
final int s = separator.length();
- final List<String> names = new ArrayList<>();
+ final List<String> names = new ArrayList<String>();
int lower = 0;
final String string = name.toString();
while (true) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
index febed77..5346ce8 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
@@ -33,7 +33,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -175,7 +175,7 @@
* Initializes the transient fields.
*/
private void init() {
- childs = new WeakValueHashMap<>(String.class);
+ childs = new WeakValueHashMap<String,Object>(String.class);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
index 925624b..b1ceaa7 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
@@ -34,7 +34,7 @@
import org.apache.sis.internal.util.AbstractMapEntry;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
index 41c2168..170699e 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
@@ -133,8 +133,8 @@
this.nameFactory = nameFactory;
this.typeFactory = (nameFactory instanceof DefaultNameFactory) ? null : new TypeNames(nameFactory);
this.namespace = nameFactory.createNameSpace(nameFactory.createLocalName(parent, schemaName), null);
- this.description = new WeakValueHashMap<>(TypeName.class);
- this.attributeTypes = new ConcurrentHashMap<>();
+ this.description = new WeakValueHashMap<TypeName,RecordType>(TypeName.class);
+ this.attributeTypes = new ConcurrentHashMap<Class<?>,Type>();
}
/**
@@ -202,6 +202,7 @@
* @param valueClass The value class to represent as an attribute type.
* @return Attribute type for the given value class.
*/
+ @SuppressWarnings({"unchecked", "rawtypes"})
final Type toAttributeType(final Class<?> valueClass) {
if (!TypeNames.isValid(valueClass)) {
return null;
@@ -217,7 +218,7 @@
} else {
name = typeFactory.toTypeName(nameFactory, valueClass);
}
- type = new SimpleAttributeType<>(name, valueClass);
+ type = new SimpleAttributeType(name, valueClass);
final Type old = attributeTypes.putIfAbsent(valueClass, type);
if (old != null) { // May happen if the type has been computed concurrently.
return old;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
index 459163d..2a2cfe1 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
@@ -43,7 +43,7 @@
import org.apache.sis.internal.converter.SurjectiveConverter;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -198,7 +198,7 @@
this.typeName = typeName;
this.container = container;
final NameSpace namespace = nameFactory.createNameSpace(typeName, null);
- final Map<MemberName,Type> memberTypes = new LinkedHashMap<>(Containers.hashMapCapacity(members.size()));
+ final Map<MemberName,Type> memberTypes = new LinkedHashMap<MemberName,Type>(Containers.hashMapCapacity(members.size()));
for (final Map.Entry<? extends CharSequence, ? extends Type> entry : members.entrySet()) {
final Type type = entry.getValue();
final CharSequence name = entry.getKey();
@@ -221,7 +221,7 @@
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
final int size = in.readInt();
- final Map<MemberName,Type> members = new LinkedHashMap<>(Containers.hashMapCapacity(size));
+ final Map<MemberName,Type> members = new LinkedHashMap<MemberName,Type>(Containers.hashMapCapacity(size));
for (int i=0; i<size; i++) {
final MemberName member = (MemberName) in.readObject();
final Type type = (Type) in.readObject();
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/RecordDefinition.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
index 162dca4..653acde 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
@@ -34,6 +34,9 @@
import org.apache.sis.util.collection.Containers;
import org.apache.sis.internal.util.CollectionsExt;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Holds a {@code Record} definition in a way more convenient for Apache SIS than
@@ -148,7 +151,7 @@
final Type[] computeTransientFields(final Map<? extends MemberName, ? extends Type> memberTypes) {
final int size = memberTypes.size();
members = new MemberName[size];
- memberIndices = new LinkedHashMap<>(Containers.hashMapCapacity(size));
+ memberIndices = new LinkedHashMap<MemberName,Integer>(Containers.hashMapCapacity(size));
final Type[] types = new Type[size];
int i = 0;
for (final Map.Entry<? extends MemberName, ? extends Type> entry : memberTypes.entrySet()) {
@@ -239,7 +242,7 @@
*/
final String toString(final String head, final Object values) {
final StringBuilder buffer = new StringBuilder(250);
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final String[] names = new String[size()];
int width = 0;
buffer.append(head).append("[“").append(getRecordType().getTypeName()).append("”] {").append(lineSeparator);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java
index a19f700..f5cde8c 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java
@@ -24,7 +24,7 @@
import org.apache.sis.util.ArgumentChecks;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
index b3f491c..82ecfbe 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
@@ -51,7 +51,7 @@
*
* <p>This map shall not be modified after construction.</p>
*/
- private static final Map<String,Class<?>> MAPPING = new LinkedHashMap<>(16);
+ private static final Map<String,Class<?>> MAPPING = new LinkedHashMap<String,Class<?>>(16);
static {
final Map<String,Class<?>> m = MAPPING;
m.put("URI", URI.class);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java b/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
index b0ad56f..66c9306 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
@@ -23,7 +23,6 @@
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
-import java.util.IllformedLocaleException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
@@ -501,7 +500,9 @@
throw (Error) cause;
}
throw new UndeclaredThrowableException(cause);
- } catch (NoSuchMethodException | IllegalAccessException e) {
+ } catch (NoSuchMethodException e) {
+ values = Array.newInstance(codeType, 0);
+ } catch (IllegalAccessException e) {
values = Array.newInstance(codeType, 0);
}
return (T[]) values;
@@ -539,10 +540,12 @@
try {
props.load(in);
in.close();
- } catch (IOException | IllegalArgumentException e) {
+ } catch (IOException e) {
+ throw new BackingStoreException(e);
+ } catch (IllegalArgumentException e) {
throw new BackingStoreException(e);
}
- typeForNames = new HashMap<>(props);
+ typeForNames = new HashMap<Object,Object>(props);
JDK8.putIfAbsent(typeForNames, "MI_SensorTypeCode", "org.apache.sis.internal.metadata.SensorType");
}
final Object value = typeForNames.get(identifier);
@@ -745,7 +748,7 @@
final int s = offset + 1;
try {
locale = Locales.parse(key, s);
- } catch (IllformedLocaleException e) {
+ } catch (RuntimeException e) { // IllformedLocaleException on the JDK7 branch.
throw new IllegalArgumentException(Errors.getResources(properties).getString(
Errors.Keys.IllegalLanguageCode_1, '(' + key.substring(0, s) + ')' + key.substring(s), e));
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
index d0ba836..a7dc5aa 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
@@ -72,7 +72,7 @@
*/
protected LoggerFactory(final Class<L> loggerClass) {
this.loggerClass = loggerClass;
- loggers = new WeakValueHashMap<>(String.class);
+ loggers = new WeakValueHashMap<String,Logger>(String.class);
}
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
index 59c32ad..0965e67 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
@@ -41,6 +41,9 @@
import org.apache.sis.util.Configuration;
import org.apache.sis.util.Debug;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* A formatter writing log messages on a single line. Compared to the JDK {@link SimpleFormatter},
@@ -321,7 +324,7 @@
* The default (8 characters) is a little bit too wide...
*/
final StringWriter str = new StringWriter();
- writer = new LineAppender(str, System.lineSeparator(), true);
+ writer = new LineAppender(str, JDK7.lineSeparator(), true);
buffer = str.getBuffer().append(header);
printer = new PrintWriter(IO.asWriter(writer));
writer.setTabulationWidth(4);
@@ -548,7 +551,7 @@
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private SortedMap<Level,X364> colors() {
if (colors == null) {
- colors = new TreeMap<>(COMPARATOR);
+ colors = new TreeMap<Level,X364>(COMPARATOR);
}
return colors;
}
@@ -696,7 +699,7 @@
* amount of spaces in order to align message body on the column after the level name.
*/
String bodyLineSeparator = writer.getLineSeparator();
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
if (bodyLineSeparator.length() != lineSeparator.length() + margin + 1) {
bodyLineSeparator = lineSeparator + levelColor + CharSequences.spaces(margin) + levelReset + ' ';
writer.setLineSeparator(bodyLineSeparator);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
index 0bfaa9e..be15119 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
@@ -44,6 +44,9 @@
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.util.PatchedUnitFormat;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* {@link ResourceBundle} implementation accepting integers instead of strings for resource keys.
@@ -237,7 +240,7 @@
keyLength = Math.max(keyLength, key.length());
}
}
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final String[] values = ensureLoaded(null);
for (int i=0; i<values.length; i++) {
final String key = keys [i];
@@ -295,7 +298,8 @@
/*
* Loads resources from the UTF file.
*/
- try (DataInputStream input = new DataInputStream(new BufferedInputStream(resources.openStream()))) {
+ try {
+ DataInputStream input = new DataInputStream(new BufferedInputStream(resources.openStream()));
values = new String[input.readInt()];
for (int i=0; i<values.length; i++) {
values[i] = input.readUTF();
@@ -303,6 +307,7 @@
values[i] = null;
}
}
+ input.close();
} catch (IOException exception) {
record.setLevel (Level.WARNING);
record.setMessage(exception.getMessage()); // For administrator, use system locale.
@@ -360,8 +365,7 @@
*/
try {
keyID = getKeyConstants().getKeyValue(key);
- } catch (ReflectiveOperationException e) {
- e.addSuppressed(exception);
+ } catch (Exception e) {
Logging.recoverableException(Logging.getLogger(Loggers.LOCALIZATION), getClass(), "handleGetObject", e);
return null; // This is okay as of 'handleGetObject' contract.
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java
index ba8257a..1328c58 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java
@@ -116,7 +116,7 @@
*/
try {
return (ResourceBundle) classe.getDeclaredConstructor(URL.class).newInstance(resources);
- } catch (NoSuchMethodException | InvocationTargetException e) {
+ } catch (Exception e) { // The JDK7 branch uses multi-catches here.
InstantiationException exception = new InstantiationException(Exceptions.getLocalizedMessage(e, locale));
exception.initCause(e);
throw exception;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
index 6b5ab9e..bab948a 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
@@ -27,7 +27,7 @@
import org.apache.sis.util.iso.AbstractInternationalString;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -168,7 +168,7 @@
in.defaultReadObject();
try {
key = getKeyConstants().getKeyValue(in.readUTF());
- } catch (ReflectiveOperationException cause) {
+ } catch (Exception cause) { // (ReflectiveOperationException) on JDK7
InvalidObjectException e = new InvalidObjectException(cause.toString());
e.initCause(cause);
throw e;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java b/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
index f87b9c5..10bd023 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
@@ -70,7 +70,7 @@
*
* @see javax.xml.bind.annotation.XmlID
*/
- IdentifierSpace<String> ID = new NonMarshalledAuthority<>("gml:id", NonMarshalledAuthority.ID);
+ IdentifierSpace<String> ID = new NonMarshalledAuthority<String>("gml:id", NonMarshalledAuthority.ID);
/**
* An optional attribute available on every object-with-identity provided in the GMD schemas
@@ -87,7 +87,7 @@
*
* @see UUID
*/
- IdentifierSpace<UUID> UUID = new NonMarshalledAuthority<>("gco:uuid", NonMarshalledAuthority.UUID);
+ IdentifierSpace<UUID> UUID = new NonMarshalledAuthority<UUID>("gco:uuid", NonMarshalledAuthority.UUID);
/**
* An optional attribute for URN to an external resources, or to an other part of a XML
@@ -99,7 +99,7 @@
*
* @see XLink#getHRef()
*/
- IdentifierSpace<URI> HREF = new NonMarshalledAuthority<>("xlink:href", NonMarshalledAuthority.HREF);
+ IdentifierSpace<URI> HREF = new NonMarshalledAuthority<URI>("xlink:href", NonMarshalledAuthority.HREF);
/**
* Any XML attributes defined by OGC in the
@@ -109,7 +109,7 @@
*
* @see XLink
*/
- IdentifierSpace<XLink> XLINK = new NonMarshalledAuthority<>("xlink", NonMarshalledAuthority.XLINK);
+ IdentifierSpace<XLink> XLINK = new NonMarshalledAuthority<XLink>("xlink", NonMarshalledAuthority.XLINK);
/**
* Returns the name of this identifier space.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/LegacyCodes.java b/core/sis-utility/src/main/java/org/apache/sis/xml/LegacyCodes.java
index 2304f5b..5cfccbc 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/LegacyCodes.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/LegacyCodes.java
@@ -51,14 +51,16 @@
static final Map<String,String> IANA_TO_LEGACY, LEGACY_TO_IANA;
static {
final Properties codes = new Properties();
- try (InputStream in = Metadata.class.getResourceAsStream("2003/charset-codes.properties")) {
+ final InputStream in = Metadata.class.getResourceAsStream("2003/charset-codes.properties");
+ try {
codes.load(in);
+ in.close();
} catch (IOException e) {
Logging.unexpectedException(Logging.getLogger(Loggers.XML), ValueConverter.class, "toCharset[Code]", e);
}
final int capacity = Containers.hashMapCapacity(codes.size());
- IANA_TO_LEGACY = new HashMap<>(capacity);
- LEGACY_TO_IANA = new HashMap<>(capacity);
+ IANA_TO_LEGACY = new HashMap<String,String>(capacity);
+ LEGACY_TO_IANA = new HashMap<String,String>(capacity);
for (final Map.Entry<Object,Object> entry : codes.entrySet()) {
final String legacy = ((String) entry.getKey()).intern();
final String name = ((String) entry.getValue()).intern();
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java b/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
index 0dcb6f3..6033e6d 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
@@ -19,7 +19,7 @@
import java.util.Map;
import java.util.Deque;
import java.util.ServiceLoader;
-import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -221,11 +221,11 @@
mapper = null;
} else try {
mapper = Class.forName(classname).getConstructor(String.class).newInstance(rootNamespace);
- } catch (ReflectiveOperationException | NoClassDefFoundError exception) {
+ } catch (Throwable exception) { // (ReflectiveOperationException | NoClassDefFoundError) on JDK7 branch.
throw new JAXBException(exception);
}
- marshallers = new ConcurrentLinkedDeque<>();
- unmarshallers = new ConcurrentLinkedDeque<>();
+ marshallers = new LinkedBlockingDeque<Marshaller>();
+ unmarshallers = new LinkedBlockingDeque<Unmarshaller>();
isRemovalScheduled = new AtomicBoolean();
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java b/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
index 222c388..359117b 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
@@ -188,7 +188,7 @@
*/
private static final Map<String,String> SPECIFIC_URLS;
static {
- final Map<String,String> p = new HashMap<>(40);
+ final Map<String,String> p = new HashMap<String,String>(40);
p.put(XMLConstants.W3C_XML_SCHEMA_NS_URI, "xsd");
p.put(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi");
p.put("http://www.w3.org/2004/02/skos/core#", "skos");
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java b/core/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
index ba8d63e..88ca9c2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
@@ -34,7 +34,7 @@
import org.apache.sis.internal.jaxb.ModifiableIdentifierMap;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -67,7 +67,7 @@
* or modify identifiers.
*/
NilObjectHandler(final Identifier[] identifiers) {
- final List<Identifier> asList = new ArrayList<>(identifiers.length);
+ final List<Identifier> asList = new ArrayList<Identifier>(identifiers.length);
for (final Identifier identifier : identifiers) {
if (identifier != null) {
asList.add(identifier);
@@ -127,21 +127,21 @@
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final String name = method.getName();
if (args == null) {
- switch (name) {
- case "getNilReason": {
+ /*switch (name)*/ {
+ if ("getNilReason".equals(name)) {
return (attribute instanceof NilReason) ? (NilReason) attribute : null;
}
- case "getIdentifierMap": {
+ if ("getIdentifierMap".equals(name)) {
return (attribute instanceof IdentifierMap) ? (IdentifierMap) attribute : null;
}
- case "getIdentifiers": {
+ if ("getIdentifiers".equals(name)) {
return (attribute instanceof IdentifierMapAdapter) ?
((IdentifierMapAdapter) attribute).identifiers : null;
}
- case "toString": {
+ if ("toString".equals(name)) {
return getInterface(proxy).getSimpleName() + '[' + attribute + ']';
}
- case "hashCode": {
+ if ("hashCode".equals(name)) {
return ~attribute.hashCode();
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java b/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
index b8d8044..ef0dd19 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
@@ -139,7 +139,7 @@
/**
* The pool of other nil reasons created up to date.
*/
- private static final WeakHashSet<NilReason> POOL = new WeakHashSet<>(NilReason.class);
+ private static final WeakHashSet<NilReason> POOL = new WeakHashSet<NilReason>(NilReason.class);
/**
* Either the XML value as a {@code String} (including the explanation if the prefix
@@ -389,7 +389,7 @@
* ReferenceQueueConsumer thread is shared by all the SIS library.
*/
if (nilObjects == null) {
- nilObjects = new WeakValueHashMap<>((Class) Class.class);
+ nilObjects = new WeakValueHashMap<Class<?>, Object>((Class) Class.class);
}
Object object = nilObjects.get(type);
if (object == null) {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java b/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
index 423d35e..8b86be2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
@@ -20,7 +20,6 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.ConcurrentModificationException;
-import java.util.IllformedLocaleException;
import java.util.Locale;
import java.util.TimeZone;
import javax.xml.validation.Schema;
@@ -176,7 +175,7 @@
*/
Pooled(final boolean internal) {
this.internal = internal;
- initialProperties = new LinkedHashMap<>();
+ initialProperties = new LinkedHashMap<Object,Object>();
}
/**
@@ -186,7 +185,7 @@
* @param template The {@link PooledTemplate} from which to get the initial values.
*/
Pooled(final Pooled template) {
- initialProperties = new LinkedHashMap<>();
+ initialProperties = new LinkedHashMap<Object,Object>();
internal = template.internal;
}
@@ -325,20 +324,20 @@
*/
public final void setProperty(String name, final Object value) throws PropertyException {
try {
- switch (name) {
- case XML.LOCALE: {
+ /* switch (name) */ {
+ if (name.equals(XML.LOCALE)) {
locale = (value instanceof CharSequence) ? Locales.parse(value.toString()) : (Locale) value;
return;
}
- case XML.TIMEZONE: {
+ if (name.equals(XML.TIMEZONE)) {
timezone = (value instanceof CharSequence) ? TimeZone.getTimeZone(value.toString()) : (TimeZone) value;
return;
}
- case XML.SCHEMAS: {
+ if (name.equals(XML.SCHEMAS)) {
final Map<?,?> map = (Map<?,?>) value;
Map<String,String> copy = null;
if (map != null) {
- copy = new HashMap<>(4);
+ copy = new HashMap<String,String>(4);
for (final String key : SCHEMA_KEYS) {
final Object schema = map.get(key);
if (schema != null) {
@@ -354,19 +353,19 @@
schemas = copy;
return;
}
- case XML.GML_VERSION: {
+ if (name.equals(XML.GML_VERSION)) {
versionGML = (value instanceof CharSequence) ? new Version(value.toString()) : (Version) value;
return;
}
- case XML.RESOLVER: {
+ if (name.equals(XML.RESOLVER)) {
resolver = (ReferenceResolver) value;
return;
}
- case XML.CONVERTER: {
+ if (name.equals(XML.CONVERTER)) {
converter = (ValueConverter) value;
return;
}
- case XML.STRING_SUBSTITUTES: {
+ if (name.equals(XML.STRING_SUBSTITUTES)) {
bitMasks &= ~(Context.SUBSTITUTE_LANGUAGE |
Context.SUBSTITUTE_COUNTRY |
Context.SUBSTITUTE_FILENAME |
@@ -386,11 +385,11 @@
}
return;
}
- case XML.WARNING_LISTENER: {
+ if (name.equals(XML.WARNING_LISTENER)) {
warningListener = (WarningListener<?>) value;
return;
}
- case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
+ if (name.equals(LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS)) {
xmlnsReplaceCode = 0;
if (value != null) {
xmlnsReplaceCode = ((Boolean) value) ? (byte) 1 : (byte) 2;
@@ -398,7 +397,7 @@
return;
}
}
- } catch (ClassCastException | IllformedLocaleException e) {
+ } catch (RuntimeException e) { // (ClassCastException | IllformedLocaleException) on the JDK7 branch.
throw new PropertyException(Errors.format(
Errors.Keys.IllegalPropertyValueClass_2, name, value.getClass()), e);
}
@@ -420,15 +419,15 @@
* A method which is common to both {@code Marshaller} and {@code Unmarshaller}.
*/
public final Object getProperty(final String name) throws PropertyException {
- switch (name) {
- case XML.LOCALE: return locale;
- case XML.TIMEZONE: return timezone;
- case XML.SCHEMAS: return schemas;
- case XML.GML_VERSION: return versionGML;
- case XML.RESOLVER: return resolver;
- case XML.CONVERTER: return converter;
- case XML.WARNING_LISTENER: return warningListener;
- case XML.STRING_SUBSTITUTES: {
+ /*switch (name)*/ {
+ if (name.equals(XML.LOCALE)) return locale;
+ if (name.equals(XML.TIMEZONE)) return timezone;
+ if (name.equals(XML.SCHEMAS)) return schemas;
+ if (name.equals(XML.GML_VERSION)) return versionGML;
+ if (name.equals(XML.RESOLVER)) return resolver;
+ if (name.equals(XML.CONVERTER)) return converter;
+ if (name.equals(XML.WARNING_LISTENER)) return warningListener;
+ if (name.equals(XML.STRING_SUBSTITUTES)) {
int n = 0;
final String[] substitutes = new String[4];
if ((bitMasks & Context.SUBSTITUTE_LANGUAGE) != 0) substitutes[n++] = "language";
@@ -437,16 +436,14 @@
if ((bitMasks & Context.SUBSTITUTE_MIMETYPE) != 0) substitutes[n++] = "mimetype";
return (n != 0) ? ArraysExt.resize(substitutes, n) : null;
}
- case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
+ if (name.equals(LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS)) {
switch (xmlnsReplaceCode) {
case 1: return Boolean.TRUE;
case 2: return Boolean.FALSE;
default: return null;
}
}
- default: {
- return getStandardProperty(convertPropertyKey(name));
- }
+ return getStandardProperty(convertPropertyKey(name));
}
}
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java b/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
index 02a9853..c2b5ef6 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
@@ -186,10 +186,13 @@
public void marshal(final Object object, final File output) throws JAXBException {
final FilterVersion version = getFilterVersion();
if (version != null) try {
- try (OutputStream s = new BufferedOutputStream(new FileOutputStream(output))) {
+ final OutputStream s = new BufferedOutputStream(new FileOutputStream(output));
+ try {
marshal(object, XMLOutputFactory.createXMLStreamWriter(s, getEncoding()), version);
+ } finally {
+ s.close();
}
- } catch (IOException | XMLStreamException e) {
+ } catch (Exception e) { // (IOException | XMLStreamException) on the JDK7 branch.
throw new JAXBException(e);
} else {
// Marshalling to the default GML version.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java b/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
index f8647ed..89eabe4 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
@@ -179,10 +179,13 @@
public Object unmarshal(final URL input) throws JAXBException {
final FilterVersion version = getFilterVersion();
if (version != null) try {
- try (final InputStream s = input.openStream()) {
+ final InputStream s = input.openStream();
+ try {
return unmarshal(XMLInputFactory.createXMLStreamReader(s), version);
+ } finally {
+ s.close();
}
- } catch (IOException | XMLStreamException e) {
+ } catch (Exception e) { // (IOException | XMLStreamException) on the JDK7 branch.
throw new JAXBException(e);
} else {
final Context context = begin();
@@ -201,10 +204,13 @@
public Object unmarshal(final File input) throws JAXBException {
final FilterVersion version = getFilterVersion();
if (version != null) try {
- try (final InputStream s = new BufferedInputStream(new FileInputStream(input))) {
+ final InputStream s = new BufferedInputStream(new FileInputStream(input));
+ try {
return unmarshal(XMLInputFactory.createXMLStreamReader(s), version);
+ } finally {
+ s.close();
}
- } catch (IOException | XMLStreamException e) {
+ } catch (Exception e) { // (IOException | XMLStreamException) on the JDK7 branch.
throw new JAXBException(e);
} else {
final Context context = begin();
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java b/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
index f3b667c..9175216 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
@@ -21,7 +21,6 @@
import java.net.URISyntaxException;
import java.net.MalformedURLException;
import java.util.MissingResourceException;
-import java.util.IllformedLocaleException;
import java.util.Locale;
import java.util.UUID;
import java.nio.charset.Charset;
@@ -254,15 +253,16 @@
* @param value The string to convert to a locale, or {@code null}.
* @return The converted locale, or {@code null} if the given value was null or empty, or
* if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
- * @throws IllformedLocaleException If the given string can not be converted to a locale.
+ * @throws RuntimeException If the given string can not be converted to a locale
+ * ({@code IllformedLocaleException} on the JDK7 branch).
*
* @see Locales#parse(String)
*/
- public Locale toLocale(final MarshalContext context, String value) throws IllformedLocaleException {
+ public Locale toLocale(final MarshalContext context, String value) {
value = trimWhitespaces(value);
if (value != null && !value.isEmpty()) try {
return Locales.parse(value);
- } catch (IllformedLocaleException e) {
+ } catch (RuntimeException e) { // IllformedLocaleException on the JDK7 branch.
if (!exceptionOccured(context, value, String.class, Locale.class, e)) {
throw e;
}
@@ -435,9 +435,12 @@
public URL toURL(final MarshalContext context, final URI value) throws MalformedURLException {
if (value != null) try {
return value.toURL();
- } catch (MalformedURLException | IllegalArgumentException e) {
+ } catch (Exception e) { // MalformedURLException | IllegalArgumentException
if (!exceptionOccured(context, value, URI.class, URL.class, e)) {
- throw e;
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
+ throw (MalformedURLException) e;
}
}
return null;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/XLink.java b/core/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
index 0311313..0f3e96f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
@@ -31,7 +31,7 @@
import org.apache.sis.internal.system.Loggers;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java b/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
index 1f40ae3..823c3a9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
@@ -22,7 +22,6 @@
import java.util.logging.LogRecord; // For javadoc
import java.net.URL;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
@@ -34,7 +33,6 @@
import javax.xml.transform.Result;
import org.apache.sis.util.Static;
import org.apache.sis.util.Version;
-import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.WarningListener;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.SystemListener;
@@ -42,11 +40,6 @@
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-// Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
-
/**
* Provides convenience methods for marshalling and unmarshalling SIS objects.
@@ -405,26 +398,6 @@
}
/**
- * Marshall the given object into a path.
- *
- * @param object The root of content tree to be marshalled.
- * @param output The file to be written.
- * @throws JAXBException if an error occurred during the marshalling.
- */
- public static void marshal(final Object object, final Path output) throws JAXBException {
- ensureNonNull("object", object);
- ensureNonNull("output", output);
- try (OutputStream out = Files.newOutputStream(output, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
- final MarshallerPool pool = getPool();
- final Marshaller marshaller = pool.acquireMarshaller();
- marshaller.marshal(object, out);
- pool.recycle(marshaller);
- } catch (IOException e) {
- throw new JAXBException(Errors.format(Errors.Keys.CanNotOpen_1, output), e);
- }
- }
-
- /**
* Marshall the given object to a stream, DOM or other destinations.
* This is the most flexible marshalling method provided in this {@code XML} class.
* The destination is specified by the {@code output} argument implementation, for example
@@ -522,27 +495,6 @@
}
/**
- * Unmarshall an object from the given path.
- *
- * @param input The path from which to read a XML representation.
- * @return The object unmarshalled from the given input.
- * @throws JAXBException if an error occurred during the unmarshalling.
- */
- public static Object unmarshal(final Path input) throws JAXBException {
- ensureNonNull("input", input);
- final Object object;
- try (InputStream in = Files.newInputStream(input, StandardOpenOption.READ)) {
- final MarshallerPool pool = getPool();
- final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
- object = unmarshaller.unmarshal(in);
- pool.recycle(unmarshaller);
- } catch (IOException e) {
- throw new JAXBException(Errors.format(Errors.Keys.CanNotRead_1, input), e);
- }
- return object;
- }
-
- /**
* Unmarshall an object from the given stream, DOM or other sources.
* This is the most flexible unmarshalling method provided in this {@code XML} class.
* The source is specified by the {@code input} argument implementation, for example
diff --git a/core/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter b/core/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
index 6adeeaa..259e486 100644
--- a/core/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
+++ b/core/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
@@ -14,19 +14,12 @@
org.apache.sis.internal.converter.StringConverter$Charset
org.apache.sis.internal.converter.StringConverter$InternationalString
org.apache.sis.internal.converter.StringConverter$File
-org.apache.sis.internal.converter.StringConverter$Path
org.apache.sis.internal.converter.StringConverter$URI
org.apache.sis.internal.converter.StringConverter$URL
org.apache.sis.internal.converter.StringConverter$Unit
org.apache.sis.internal.converter.StringConverter$Angle
org.apache.sis.internal.converter.AngleConverter
org.apache.sis.internal.converter.AngleConverter$Inverse
-org.apache.sis.internal.converter.PathConverter$FilePath
-org.apache.sis.internal.converter.PathConverter$URLPath
-org.apache.sis.internal.converter.PathConverter$URIPath
-org.apache.sis.internal.converter.PathConverter$PathURI
-org.apache.sis.internal.converter.PathConverter$PathURL
-org.apache.sis.internal.converter.PathConverter$PathFile
org.apache.sis.internal.converter.PathConverter$FileURI
org.apache.sis.internal.converter.PathConverter$FileURL
org.apache.sis.internal.converter.PathConverter$URLFile
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ArrayConverterTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ArrayConverterTest.java
index fcce4d7..953971d 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ArrayConverterTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ArrayConverterTest.java
@@ -37,7 +37,7 @@
* The types need to be specified because we want to test wrapper and primitive types.
*/
private static <S,T> ArrayConverter<S,T> create(final Class<S> sourceClass, final Class<T> targetClass) {
- return new ArrayConverter<>(sourceClass, targetClass, new NumberConverter<>(Integer.class, Double.class));
+ return new ArrayConverter<S,T>(sourceClass, targetClass, new NumberConverter<Integer,Double>(Integer.class, Double.class));
}
/**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ConverterRegistryTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ConverterRegistryTest.java
index d2105d6..3d2422b 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ConverterRegistryTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/ConverterRegistryTest.java
@@ -58,7 +58,7 @@
* All converters registered in a test case. Only the converter type and properties
* will be verified; no conversion or serialization shall be attempted.
*/
- private final Deque<ObjectConverter<?,?>> converters = new ArrayDeque<>();
+ private final Deque<ObjectConverter<?,?>> converters = new ArrayDeque<ObjectConverter<?,?>>();
/**
* Registers a converter to test.
@@ -319,7 +319,7 @@
* Expected side-effect: none
*/
assertAllConvertersAreRegistered();
- register(new NumberConverter<>(Number.class, Float.class));
+ register(new NumberConverter<Number,Float>(Number.class, Float.class));
assertSameConverterForTarget(Float.class);
assertMultilinesEquals("After NumberConverter.Float",
"ConverterRegistry\n" +
@@ -341,7 +341,7 @@
*/
@Test
public void testArrayOfWrapperTypes() {
- register(new NumberConverter<>(Float.class, Double.class));
+ register(new NumberConverter<Float,Double>(Float.class, Double.class));
final ObjectConverter<?,?> converter = registry.find(Float[].class, Double[].class);
assertInstanceOf("Array conversions", ArrayConverter.class, converter);
assertEquals(Float [].class, converter.getSourceClass());
@@ -355,7 +355,7 @@
@Test
@DependsOnMethod("testArrayOfWrapperTypes")
public void testArrayOfPrimitiveTypes() {
- register(new NumberConverter<>(Float.class, Double.class));
+ register(new NumberConverter<Float,Double>(Float.class, Double.class));
final ObjectConverter<?,?> converter = registry.find(float[].class, double[].class);
assertInstanceOf("Array conversions", ArrayConverter.class, converter);
assertEquals(float [].class, converter.getSourceClass());
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
index bc1cbc7..971bb67 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
@@ -42,9 +42,7 @@
import static org.apache.sis.test.Assert.*;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
@@ -260,17 +258,6 @@
}
/**
- * Tests conversions to {@link Path}.
- */
- @Test
- public void testPath() {
- final ObjectConverter<String,Path> c = new StringConverter.Path();
- final String path = "home/user/index.txt".replace('/', File.separatorChar);
- runInvertibleConversion(c, path, Paths.get(path));
- assertSerializedEquals(c);
- }
-
- /**
* Tests conversions to {@link URI}.
*
* @throws URISyntaxException Should never happen.
@@ -309,7 +296,7 @@
*/
@Test
public void testCodeList() {
- final ObjectConverter<String, OnLineFunction> c = new StringConverter.CodeList<>(OnLineFunction.class);
+ final ObjectConverter<String, OnLineFunction> c = new StringConverter.CodeList<OnLineFunction>(OnLineFunction.class);
runInvertibleConversion(c, "OFFLINE_ACCESS", OnLineFunction.OFFLINE_ACCESS);
tryUnconvertibleValue(c);
assertSerializedEquals(c);
@@ -322,7 +309,7 @@
*/
@Test
public void testEnum() {
- final ObjectConverter<String, ElementType> c = new StringConverter.Enum<>(ElementType.class);
+ final ObjectConverter<String, ElementType> c = new StringConverter.Enum<ElementType>(ElementType.class);
runInvertibleConversion(c, "PACKAGE", ElementType.PACKAGE);
tryUnconvertibleValue(c);
assertSerializedEquals(c);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java
index d084871..1e7d371 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java
@@ -46,7 +46,7 @@
assertSame(UUID, assertSerializedEquals(UUID));
assertSame(HREF, assertSerializedEquals(HREF));
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final Map<Citation,String> map = new IdentifierMapAdapter(identifiers);
assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID")));
assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMapTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMapTest.java
index 8931afa..7e37f24 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/ModifiableIdentifierMapTest.java
@@ -81,7 +81,7 @@
*/
@Test
public void testGetAndPut() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final Map<Citation,String> map = new ModifiableIdentifierMap(identifiers);
assertTrue ("Newly created map shall be empty.", map.isEmpty());
assertEquals("Newly created map shall be empty.", 0, map.size());
@@ -155,7 +155,7 @@
*/
@Test
public void testPutSpecialized() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
final String myID = "myID";
final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7");
@@ -181,7 +181,7 @@
*/
@Test
public void testGetSpecialized() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
assertNull(map.put(ID, "myID"));
@@ -204,7 +204,7 @@
*/
@Test
public void testDuplicatedAuthorities() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID1")));
assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID2")));
@@ -232,7 +232,7 @@
*/
@Test
public void testHRefSubstitution() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
assertNull(map.put(HREF, "myHREF"));
assertEquals("Shall contain the entry we added.", "myHREF", map.get(HREF));
@@ -252,7 +252,7 @@
*/
@Test
public void testUUIDs() {
- final List<Identifier> identifiers = new ArrayList<>();
+ final List<Identifier> identifiers = new ArrayList<Identifier>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
final java.util.UUID id1 = fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c");
final java.util.UUID id2 = fromString("42924124-032a-4dfe-b06e-113e3cb81cf0");
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java
index ec3ba32..ce70508 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeMock.java
@@ -83,7 +83,7 @@
/** Creates a new instance with initially no identifier. */
Value() {
- identifiers = new ArrayList<>();
+ identifiers = new ArrayList<Identifier>();
map = new ModifiableIdentifierMap(identifiers);
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
index 467893a..6b9037a 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
@@ -80,7 +80,7 @@
*/
@BeforeClass
public static void createMarshallerPool() throws JAXBException {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(XML.LOCALE, Locale.UK));
assertNull(properties.put(XML.TIMEZONE, "UTC"));
pool = new MarshallerPool(JAXBContext.newInstance(MetadataMock.class), properties);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
index 95888b2..ef4c31e 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
@@ -71,7 +71,7 @@
*/
@BeforeClass
public static void createMarshallerPool() throws JAXBException {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(XML.LOCALE, Locale.FRANCE));
assertNull(properties.put(XML.TIMEZONE, "CET"));
pool = new MarshallerPool(JAXBContext.newInstance(TimeInstant.class, TimePeriod.class), properties);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/system/ReferenceQueueConsumerTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/system/ReferenceQueueConsumerTest.java
index fa1156b..cac7b1d 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/system/ReferenceQueueConsumerTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/system/ReferenceQueueConsumerTest.java
@@ -45,7 +45,7 @@
*/
@Test(expected=InterruptedException.class)
public void verifyInterruptAssumption() throws InterruptedException {
- final ReferenceQueue<Object> queue = new ReferenceQueue<>();
+ final ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
Thread.currentThread().interrupt();
assertNull(queue.remove(1000));
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java
index ed702aa..f8c4301 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java
@@ -47,7 +47,7 @@
* or consistency.
*/
private static final class Count extends AbstractMap<Integer,String> {
- private final List<String> values = new ArrayList<>(Arrays.asList("one", "two", "three"));
+ private final List<String> values = new ArrayList<String>(Arrays.asList("one", "two", "three"));
@Override public void clear () { values.clear();}
@Override public String get (Object k) {return values.get(((Integer) k) - 1);}
@@ -88,12 +88,12 @@
assertArrayEquals("values", new String[] {"one", "two", "three"}, values.toArray());
final Collection<Map.Entry<Integer,String>> entries = map.entrySet();
- assertTrue ("contains", entries.contains(new SimpleEntry<>(2, "two")));
- assertFalse("contains", entries.contains(new SimpleEntry<>(2, "deux")));
+ assertTrue ("contains", entries.contains(new SimpleEntry<Integer,String>(2, "two")));
+ assertFalse("contains", entries.contains(new SimpleEntry<Integer,String>(2, "deux")));
assertArrayEquals("entrySet", new SimpleEntry<?,?>[] {
- new SimpleEntry<>(1, "one"),
- new SimpleEntry<>(2, "two"),
- new SimpleEntry<>(3, "three")
+ new SimpleEntry<Integer,String>(1, "one"),
+ new SimpleEntry<Integer,String>(2, "two"),
+ new SimpleEntry<Integer,String>(3, "three")
}, entries.toArray());
map.clear();
@@ -120,10 +120,10 @@
assertTrue(map.keySet().add(4));
assertEquals("size", 4, map.size());
assertArrayEquals("entrySet", new SimpleEntry<?,?>[] {
- new SimpleEntry<>(1, "one"),
- new SimpleEntry<>(2, "two"),
- new SimpleEntry<>(3, "three"),
- new SimpleEntry<>(4, "four")
+ new SimpleEntry<Integer,String>(1, "one"),
+ new SimpleEntry<Integer,String>(2, "two"),
+ new SimpleEntry<Integer,String>(3, "three"),
+ new SimpleEntry<Integer,String>(4, "four")
}, map.entrySet().toArray());
}
@@ -139,10 +139,10 @@
assertTrue(map.values().add("quatre"));
assertEquals("size", 4, map.size());
assertArrayEquals("entrySet", new SimpleEntry<?,?>[] {
- new SimpleEntry<>(1, "one"),
- new SimpleEntry<>(2, "two"),
- new SimpleEntry<>(3, "three"),
- new SimpleEntry<>(4, "quatre")
+ new SimpleEntry<Integer,String>(1, "one"),
+ new SimpleEntry<Integer,String>(2, "two"),
+ new SimpleEntry<Integer,String>(3, "three"),
+ new SimpleEntry<Integer,String>(4, "quatre")
}, map.entrySet().toArray());
}
@@ -153,7 +153,7 @@
@Test
public void testEquals() {
final Count map = new Count();
- final Map<Integer,String> copy = new HashMap<>(map);
+ final Map<Integer,String> copy = new HashMap<Integer,String>(map);
assertTrue ("equals", copy.equals(map));
assertTrue ("equals", map.equals(copy));
assertEquals("hashCode", copy.hashCode(), map.hashCode());
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CheckedArrayListTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CheckedArrayListTest.java
index 349db34..6ca9072 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CheckedArrayListTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CheckedArrayListTest.java
@@ -41,7 +41,7 @@
*/
@Test
public void testAdd() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
assertTrue(list.add("One"));
assertTrue(list.add("Two"));
assertTrue(list.add("Three"));
@@ -53,7 +53,7 @@
*/
@Test
public void testAddAll() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
assertTrue(list.add("One"));
assertTrue(list.addAll(Arrays.asList("Two", "Three")));
assertEquals(Arrays.asList("One", "Two", "Three"), list);
@@ -64,7 +64,7 @@
*/
@Test
public void testAddNull() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
try {
list.add(null);
} catch (NullArgumentException e) {
@@ -78,7 +78,7 @@
*/
@Test
public void testAddAllNull() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
final Collection<String> toAdd = Arrays.asList("One", null, "Three");
try {
list.addAll(toAdd);
@@ -93,7 +93,7 @@
*/
@Test
public void testAddWrongType() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
final String message = testAddWrongType(list);
assertTrue("element", message.contains("element"));
assertTrue("Integer", message.contains("Integer"));
@@ -121,7 +121,7 @@
@Test
@DependsOnMethod("testAddWrongType")
public void testAddWrongTypeToSublist() {
- final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
+ final CheckedArrayList<String> list = new CheckedArrayList<String>(String.class);
assertTrue(list.add("One"));
assertTrue(list.add("Two"));
assertTrue(list.add("Three"));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
index 810512f..17bb4d7 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
@@ -29,6 +29,7 @@
import org.junit.Test;
import static org.junit.Assert.*;
+import static org.junit.Assume.assumeTrue;
/**
@@ -69,8 +70,8 @@
*/
@Test
public void testHasCommonIdentifier() {
- final List<Identifier> id1 = new ArrayList<>(3);
- final List<Identifier> id2 = new ArrayList<>(2);
+ final List<Identifier> id1 = new ArrayList<Identifier>(3);
+ final List<Identifier> id2 = new ArrayList<Identifier>(2);
assertNull(Citations.hasCommonIdentifier(id1, id2));
/*
* Add codes for two Operation Methods which are implemented in Apache SIS by the same class:
@@ -127,6 +128,8 @@
@Test
@DependsOnMethod("testGetIdentifier")
public void testGetCodeSpace() {
+ assumeTrue(Character.isIdentifierIgnorable('\u2060')
+ && Character.isIdentifierIgnorable('\u200B'));
final SimpleCitation citation = new SimpleCitation(" Valid\u2060Id\u200Bentifier ");
assertEquals("ValidIdentifier", Citations.getCodeSpace(citation));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java
index 844fd0b..fd0a31d 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/CollectionsExtTest.java
@@ -102,7 +102,7 @@
*/
@Test
public void testAddToMultiValuesMap() {
- final Map<String, List<Integer>> map = new LinkedHashMap<>();
+ final Map<String, List<Integer>> map = new LinkedHashMap<String, List<Integer>>();
final Integer A1 = 2;
final Integer A2 = 4;
final Integer B1 = 3;
@@ -127,7 +127,7 @@
@Test
public void testToCaseInsensitiveNameMap() {
final Function<String,String> nameFunction = ObjectConverters.identity(String.class);
- final Map<String,String> expected = new HashMap<>();
+ final Map<String,String> expected = new HashMap<String,String>();
assertNull(expected.put("AA", "AA"));
assertNull(expected.put("Aa", "Aa")); // No mapping for "aa", because of ambiguity between "AA" and "Aa".
assertNull(expected.put("BB", "BB"));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
index 4a5a86b..baa9f46 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
@@ -352,10 +352,10 @@
* <li>The arrays do not contains an entry for a value that could be omitted.</li>
* </ul>
*
- * @throws ReflectiveOperationException Should never happen.
+ * @throws Exception If a reflective operation failed (should never happen).
*/
@Test
- public void testArraysConsistency() throws ReflectiveOperationException {
+ public void testArraysConsistency() throws Exception {
Field field = DoubleDouble.class.getDeclaredField("VALUES");
field.setAccessible(true);
final double[] values = (double[]) field.get(null);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java b/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java
index c84fa25..9d02a40 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/internal/util/LazySetTest.java
@@ -43,7 +43,7 @@
* Creates the set to use for testing purpose.
*/
private static LazySet<String> create() {
- return new LazySet<>(Arrays.asList(LABELS).iterator());
+ return new LazySet<String>(Arrays.asList(LABELS).iterator());
}
/**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/io/TableAppenderTest.java b/core/sis-utility/src/test/java/org/apache/sis/io/TableAppenderTest.java
index af56cb3..a9b964c 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/io/TableAppenderTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/io/TableAppenderTest.java
@@ -22,6 +22,9 @@
import static org.junit.Assert.*;
+// Related to JK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Tests {@link TableAppender} implementation.
@@ -84,7 +87,7 @@
* implementation), but simply in order to allow the test to pass.
*/
if (out instanceof SingleCharAppendable) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
assertOutputEquals(
"╔═════════╤═════════╤════════╗" + lineSeparator
diff --git a/core/sis-utility/src/test/java/org/apache/sis/io/WordWrapTest.java b/core/sis-utility/src/test/java/org/apache/sis/io/WordWrapTest.java
index 01f0830..873bb11 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/io/WordWrapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/io/WordWrapTest.java
@@ -24,6 +24,9 @@
import static org.junit.Assert.*;
import static org.apache.sis.util.Characters.SOFT_HYPHEN;
+// Related to JK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Tests {@link LineAppender} implementation when used for wrapping lines to 80 characters.
@@ -81,7 +84,7 @@
*/
String insertedLineSeparator = lineSeparator;
if (f instanceof SingleCharAppendable) {
- insertedLineSeparator = System.lineSeparator();
+ insertedLineSeparator = JDK7.lineSeparator();
}
insertedLineSeparator = expectedLineSeparator(insertedLineSeparator);
final String expectedLineSeparator = expectedLineSeparator(lineSeparator);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
index 5256ac6..cc21a9e 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
@@ -46,8 +46,8 @@
final Date in1 = date("1998-05-12 11:00:00");
final Date in2 = date("1998-06-08 14:00:00");
final Date max = date("1998-07-01 19:00:00");
- final Range<Date> r1 = new Range<>(Date.class, min, true, in2, true);
- final Range<Date> r2 = new Range<>(Date.class, in1, true, max, true);
+ final Range<Date> r1 = new Range<Date>(Date.class, min, true, in2, true);
+ final Range<Date> r2 = new Range<Date>(Date.class, in1, true, max, true);
final Range<Date> rt = r1.union(r2);
assertEquals(min, rt.getMinValue());
assertEquals(max, rt.getMaxValue());
@@ -55,8 +55,8 @@
/*
* Test a range fully included in the other range.
*/
- final Range<Date> outer = new Range<>(Date.class, min, true, max, true);
- final Range<Date> inner = new Range<>(Date.class, in1, true, in2, true);
+ final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+ final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
assertSame(outer, outer.union(inner));
assertSame(outer, inner.union(outer));
}
@@ -70,8 +70,8 @@
final Date in1 = date("1998-05-12 11:00:00");
final Date in2 = date("1998-06-08 14:00:00");
final Date max = date("1998-07-01 19:00:00");
- final Range<Date> r1 = new Range<>(Date.class, min, true, in2, true);
- final Range<Date> r2 = new Range<>(Date.class, in1, true, max, true);
+ final Range<Date> r1 = new Range<Date>(Date.class, min, true, in2, true);
+ final Range<Date> r2 = new Range<Date>(Date.class, in1, true, max, true);
final Range<Date> rt = r1.intersect(r2);
assertEquals(in1, rt.getMinValue());
assertEquals(in2, rt.getMaxValue());
@@ -79,8 +79,8 @@
/*
* Test a range fully included in the other range.
*/
- final Range<Date> outer = new Range<>(Date.class, min, true, max, true);
- final Range<Date> inner = new Range<>(Date.class, in1, true, in2, true);
+ final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+ final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
assertSame(inner, outer.intersect(inner));
assertSame(inner, inner.intersect(outer));
}
@@ -94,8 +94,8 @@
final Date in1 = date("1998-05-12 11:00:00");
final Date in2 = date("1998-06-08 14:00:00");
final Date max = date("1998-07-01 19:00:00");
- final Range<Date> outer = new Range<>(Date.class, min, true, max, true);
- final Range<Date> inner = new Range<>(Date.class, in1, true, in2, true);
+ final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+ final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
final Range<Date>[] rt = outer.subtract(inner);
assertEquals(2, rt.length);
assertEquals(min, rt[0].getMinValue());
diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java
index c02fed1..2df4d83 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java
@@ -112,7 +112,7 @@
* @param withNumberFields {@code true} for including the keys for {@code NumberFormat} fields.
*/
private static Set<Attribute> getAllAttributeKeys(final boolean withNumberFields) {
- final Set<Attribute> keys = new HashSet<>(8);
+ final Set<Attribute> keys = new HashSet<Attribute>(8);
assertTrue(keys.add(DEGREES));
assertTrue(keys.add(MINUTES));
assertTrue(keys.add(SECONDS));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
index 1168e3e..ca20cef 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
@@ -132,7 +132,7 @@
final ValueRange values = NumberRangeTest.class
.getMethod("testValueRangeAnnotation").getAnnotation(ValueRange.class);
assertNotNull("Annotation not found.", values);
- final NumberRange<Short> range = new NumberRange<>(Short.class, values);
+ final NumberRange<Short> range = new NumberRange<Short>(Short.class, values);
assertEquals(NumberRange.create((short) 4, true, (short) 8, false), range);
}
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
index 3fc9885..489c489 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
@@ -315,7 +315,7 @@
final long DAY = 24L * HOUR;
final long YEAR = round(365.25 * DAY);
- Range<Date> range = new Range<>(Date.class,
+ Range<Date> range = new Range<Date>(Date.class,
new Date(15*DAY + 18*HOUR), true,
new Date(20*YEAR + 15*DAY + 9*HOUR), true);
AttributedCharacterIterator it = format.formatToCharacterIterator(range);
@@ -331,7 +331,7 @@
/*
* Try again with the infinity symbol in one endpoint.
*/
- range = new Range<>(Date.class, (Date) null, true, new Date(20*YEAR), true);
+ range = new Range<Date>(Date.class, (Date) null, true, new Date(20*YEAR), true);
it = format.formatToCharacterIterator(range);
text = it.toString();
findYears(it, RangeFormat.Field.MAX_VALUE, maxPos);
@@ -340,7 +340,7 @@
assertEquals(14, maxPos.getEndIndex());
assertEquals(range, parse(text));
- range = new Range<>(Date.class, new Date(20*YEAR), true, (Date) null, true);
+ range = new Range<Date>(Date.class, new Date(20*YEAR), true, (Date) null, true);
it = format.formatToCharacterIterator(range);
text = it.toString();
findYears(it, RangeFormat.Field.MIN_VALUE, minPos);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
index 6e6e9dc..1599700 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
@@ -38,35 +38,35 @@
*/
@Test
public void testConstructor() {
- Range<Integer> range = new Range<>(Integer.class, 3, true, 5, true);
+ Range<Integer> range = new Range<Integer>(Integer.class, 3, true, 5, true);
assertEquals(Integer.valueOf(3), range.getMinValue());
assertEquals(Integer.valueOf(5), range.getMaxValue());
assertTrue (range.isMaxIncluded());
assertTrue (range.isMinIncluded());
assertFalse (range.isEmpty());
- range = new Range<>(Integer.class, 3, false, 5, true);
+ range = new Range<Integer>(Integer.class, 3, false, 5, true);
assertEquals(Integer.valueOf(3), range.getMinValue());
assertEquals(Integer.valueOf(5), range.getMaxValue());
assertTrue (range.isMaxIncluded());
assertFalse (range.isMinIncluded());
assertFalse (range.isEmpty());
- range = new Range<>(Integer.class, 2, true, 7, false);
+ range = new Range<Integer>(Integer.class, 2, true, 7, false);
assertEquals(Integer.valueOf(2), range.getMinValue());
assertEquals(Integer.valueOf(7), range.getMaxValue());
assertFalse (range.isMaxIncluded());
assertTrue (range.isMinIncluded());
assertFalse (range.isEmpty());
- range = new Range<>(Integer.class, 3, false, 10, false);
+ range = new Range<Integer>(Integer.class, 3, false, 10, false);
assertEquals(Integer.valueOf( 3), range.getMinValue());
assertEquals(Integer.valueOf(10), range.getMaxValue());
assertFalse (range.isMaxIncluded());
assertFalse (range.isMinIncluded());
assertFalse (range.isEmpty());
- range = new Range<>(Integer.class, 10, true, 2, true);
+ range = new Range<Integer>(Integer.class, 10, true, 2, true);
assertEquals(Integer.valueOf(10), range.getMinValue());
assertEquals(Integer.valueOf( 2), range.getMaxValue());
assertTrue (range.isEmpty());
@@ -107,7 +107,7 @@
*/
@Test
public void testContains() {
- final Range<Integer> range = new Range<>(Integer.class, 3, true, 5, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, 3, true, 5, true);
assertTrue (range.contains(4));
assertFalse(range.contains(6));
assertFalse(range.contains(2));
@@ -120,7 +120,7 @@
*/
@Test
public void testContainsNotInclusiveMinimum() {
- final Range<Integer> range = new Range<>(Integer.class, 2, false, 5, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, 2, false, 5, true);
assertTrue (range.contains(4));
assertFalse(range.contains(6));
assertFalse(range.contains(2));
@@ -134,7 +134,7 @@
*/
@Test
public void testContainsNotInclusiveMaximum() {
- final Range<Integer> range = new Range<>(Integer.class, 3, true, 6, false);
+ final Range<Integer> range = new Range<Integer>(Integer.class, 3, true, 6, false);
assertTrue (range.contains(4));
assertFalse(range.contains(6));
assertFalse(range.contains(2));
@@ -147,7 +147,7 @@
*/
@Test
public void testContainsNoLowerEndpoint() {
- final Range<Integer> range = new Range<>(Integer.class, null, true, 5, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, null, true, 5, true);
assertTrue (range.contains(-555));
assertTrue (range.contains(5));
assertFalse(range.contains(6));
@@ -158,7 +158,7 @@
*/
@Test
public void testContainsNoUpperEndpoint() {
- final Range<Integer> range = new Range<>(Integer.class, 3, true, null, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, 3, true, null, true);
assertFalse(range.contains(1));
assertTrue (range.contains(3));
assertTrue (range.contains(10000));
@@ -169,7 +169,7 @@
*/
@Test
public void testContainsNoEndpoints() {
- final Range<Integer> range = new Range<>(Integer.class, null, true, null, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, null, true, null, true);
assertTrue(range.contains(-55555));
assertTrue(range.contains(100000));
}
@@ -179,8 +179,8 @@
*/
@Test
public void testContainsRange() {
- final Range<Integer> range = new Range<>(Integer.class, -10, true, 10, true);
- final Range<Integer> inside = new Range<>(Integer.class, -5, true, 5, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, -10, true, 10, true);
+ final Range<Integer> inside = new Range<Integer>(Integer.class, -5, true, 5, true);
assertTrue(range.contains(inside));
assertFalse(inside.contains(range));
@@ -191,8 +191,8 @@
*/
@Test
public void testContainsRangeNoLowerEndpoint() {
- final Range<Integer> range = new Range<>(Integer.class, null, true, 500, true);
- final Range<Integer> inside = new Range<>(Integer.class, -2500, true, 305, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, null, true, 500, true);
+ final Range<Integer> inside = new Range<Integer>(Integer.class, -2500, true, 305, true);
assertTrue (range.contains(inside));
assertFalse(inside.contains(range));
@@ -203,8 +203,8 @@
*/
@Test
public void testContainsRangeNoUpperEndpoint() {
- final Range<Integer> range = new Range<>(Integer.class, -2500, true, null, true);
- final Range<Integer> inside = new Range<>(Integer.class, 17, true, 305, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, -2500, true, null, true);
+ final Range<Integer> inside = new Range<Integer>(Integer.class, 17, true, 305, true);
assertTrue(range.contains(inside));
assertFalse(inside.contains(range));
@@ -215,9 +215,9 @@
*/
@Test
public void testIntersects() {
- final Range<Character> range1 = new Range<>(Character.class, 'a', true, 'g', true);
- final Range<Character> range2 = new Range<>(Character.class, 'c', true, 'm', true);
- final Range<Character> range3 = new Range<>(Character.class, 'o', true, 'z', true);
+ final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'g', true);
+ final Range<Character> range2 = new Range<Character>(Character.class, 'c', true, 'm', true);
+ final Range<Character> range3 = new Range<Character>(Character.class, 'o', true, 'z', true);
assertTrue (range1.intersects(range2));
assertTrue (range2.intersects(range1));
@@ -230,8 +230,8 @@
*/
@Test
public void testIntersection() {
- final Range<Integer> range1 = new Range<>(Integer.class, 1, true, 5, true);
- final Range<Integer> range2 = new Range<>(Integer.class, 4, true, 6, true);
+ final Range<Integer> range1 = new Range<Integer>(Integer.class, 1, true, 5, true);
+ final Range<Integer> range2 = new Range<Integer>(Integer.class, 4, true, 6, true);
final Range<?> intersection = range1.intersect(range2);
assertEquals(Integer.class, intersection.getElementType());
@@ -244,8 +244,8 @@
*/
@Test
public void testIntersectionOfNonIntersectingRanges() {
- final Range<Integer> range1 = new Range<>(Integer.class, 1, true, 5, true);
- final Range<Integer> range2 = new Range<>(Integer.class, 8, true, 10, true);
+ final Range<Integer> range1 = new Range<Integer>(Integer.class, 1, true, 5, true);
+ final Range<Integer> range2 = new Range<Integer>(Integer.class, 8, true, 10, true);
final Range<?> intersection = range1.intersect(range2);
assertEquals(Integer.class, intersection.getElementType());
@@ -257,8 +257,8 @@
*/
@Test
public void testUnion() {
- final Range<Character> range1 = new Range<>(Character.class, 'a', true, 'f', true);
- final Range<Character> range2 = new Range<>(Character.class, 'd', true, 'h', true);
+ final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+ final Range<Character> range2 = new Range<Character>(Character.class, 'd', true, 'h', true);
final Range<?> union = range1.union(range2);
assertFalse(union.isEmpty());
@@ -271,8 +271,8 @@
*/
@Test
public void testDisjointUnion() {
- final Range<Character> range1 = new Range<>(Character.class, 'a', true, 'f', true);
- final Range<Character> range2 = new Range<>(Character.class, 'm', true, 'v', true);
+ final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+ final Range<Character> range2 = new Range<Character>(Character.class, 'm', true, 'v', true);
final Range<?> unionRange = range1.union(range2);
assertFalse(unionRange.isEmpty());
@@ -285,12 +285,12 @@
*/
@Test
public void testSubtract() {
- final Range<Integer> range1 = new Range<>(Integer.class, 10, true, 40, true);
- final Range<Integer> range2 = new Range<>(Integer.class, 20, true, 25, true);
+ final Range<Integer> range1 = new Range<Integer>(Integer.class, 10, true, 40, true);
+ final Range<Integer> range2 = new Range<Integer>(Integer.class, 20, true, 25, true);
final Range<Integer>[] subtract = range1.subtract(range2);
assertEquals(2, subtract.length);
- assertEquals(new Range<>(Integer.class, 10, true, 20, false), subtract[0]);
- assertEquals(new Range<>(Integer.class, 25, false, 40, true), subtract[1]);
+ assertEquals(new Range<Integer>(Integer.class, 10, true, 20, false), subtract[0]);
+ assertEquals(new Range<Integer>(Integer.class, 25, false, 40, true), subtract[1]);
}
/**
@@ -298,12 +298,12 @@
*/
@Test
public void testToString() {
- assertEquals("{}", new Range<>(Integer.class, 10, false, 10, false).toString());
- assertEquals("{10}", new Range<>(Integer.class, 10, true, 10, true ).toString());
- assertEquals("[10 … 20]", new Range<>(Integer.class, 10, true, 20, true ).toString());
- assertEquals("(10 … 20)", new Range<>(Integer.class, 10, false, 20, false).toString());
- assertEquals("[10 … 20)", new Range<>(Integer.class, 10, true, 20, false).toString());
- assertEquals("(10 … 20]", new Range<>(Integer.class, 10, false, 20, true ).toString());
+ assertEquals("{}", new Range<Integer>(Integer.class, 10, false, 10, false).toString());
+ assertEquals("{10}", new Range<Integer>(Integer.class, 10, true, 10, true ).toString());
+ assertEquals("[10 … 20]", new Range<Integer>(Integer.class, 10, true, 20, true ).toString());
+ assertEquals("(10 … 20)", new Range<Integer>(Integer.class, 10, false, 20, false).toString());
+ assertEquals("[10 … 20)", new Range<Integer>(Integer.class, 10, true, 20, false).toString());
+ assertEquals("(10 … 20]", new Range<Integer>(Integer.class, 10, false, 20, true ).toString());
}
/**
@@ -311,7 +311,7 @@
*/
@Test
public void testFormatTo() {
- final Range<Integer> range = new Range<>(Integer.class, 10, true, 20, false);
+ final Range<Integer> range = new Range<Integer>(Integer.class, 10, true, 20, false);
assertEquals("[10 … 20)", String.format(Locale.CANADA, "%s", range));
assertEquals("[10 … 20)", String.format(Locale.CANADA, "%4s", range));
assertEquals("[10 … 20) ", String.format(Locale.CANADA, "%-12s", range));
@@ -325,20 +325,20 @@
@Test
public void testEquality() {
// Positive test - success case
- final Range<Character> range1 = new Range<>(Character.class, 'a', true, 'f', true);
- final Range<Character> range2 = new Range<>(Character.class, 'a', true, 'f', true);
+ final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+ final Range<Character> range2 = new Range<Character>(Character.class, 'a', true, 'f', true);
assertTrue(range1.equals(range2));
// Positive test - failure case
- final Range<Character> range3 = new Range<>(Character.class, 'a', true, 'g', true);
+ final Range<Character> range3 = new Range<Character>(Character.class, 'a', true, 'g', true);
assertFalse(range1.equals(range3));
// Failure due to type incompatibility
- final Range<String> range4 = new Range<>(String.class, "a", true, "g", true);
+ final Range<String> range4 = new Range<String>(String.class, "a", true, "g", true);
assertFalse(range3.equals(range4));
- final Range<Character> range5 = new Range<>(Character.class, 'g', true, 'a', true);
- final Range<Character> range6 = new Range<>(Character.class, 'g', true, 'a', true);
+ final Range<Character> range5 = new Range<Character>(Character.class, 'g', true, 'a', true);
+ final Range<Character> range6 = new Range<Character>(Character.class, 'g', true, 'a', true);
assertTrue(range5.isEmpty());
assertTrue(range6.isEmpty());
assertTrue(range5.equals(range6));
@@ -349,7 +349,7 @@
*/
@Test
public void testSerialization() {
- final Range<Integer> range = new Range<>(Integer.class, -10, true, 10, true);
+ final Range<Integer> range = new Range<Integer>(Integer.class, -10, true, 10, true);
assertNotSame(range, assertSerializedEquals(range));
}
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/setup/OptionKeyTest.java b/core/sis-utility/src/test/java/org/apache/sis/setup/OptionKeyTest.java
index 7adc729..a731901 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/setup/OptionKeyTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/setup/OptionKeyTest.java
@@ -90,7 +90,7 @@
*/
@Test
public void testSubclassSerialization() {
- final CustomKey<Integer> key = new CustomKey<>("key", Integer.class);
+ final CustomKey<Integer> key = new CustomKey<Integer>("key", Integer.class);
assertNotSame(key, assertSerializedEquals(key));
}
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java b/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
index f9085be..3832882 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
@@ -186,7 +186,7 @@
wrapper.isInherited = true;
return wrapper;
} catch (ClassNotFoundException e2) {
- e.addSuppressed(e2);
+ // JDK7 branch does: e.addSuppressed(e2);
}
}
throw e;
@@ -442,7 +442,7 @@
*/
@Test
public void testPackageAnnotations() {
- final Set<Package> packages = new HashSet<>();
+ final Set<Package> packages = new HashSet<Package>();
for (final Class<?> type : types) {
if (!ControlledVocabulary.class.isAssignableFrom(type)) {
testingClass = type.getCanonicalName();
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java b/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
index 99badf2..4ba279e 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
@@ -37,7 +37,7 @@
import org.apache.sis.util.Classes;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -120,8 +120,10 @@
for (int i=0; i<length; i++) try {
assertEqualsIgnoreMetadata(expected[i], actual[i]);
} catch (AssertionError e) {
- throw new AssertionError(Exceptions.formatChainedMessages(null, "Comparison failure at index "
- + i + " (a " + Classes.getShortClassName(actual[i]) + ").", e), e);
+ final AssertionError ne = new AssertionError(Exceptions.formatChainedMessages(null,
+ "Comparison failure at index " + i + " (a " + Classes.getShortClassName(actual[i]) + ").", e));
+ ne.initCause(e);
+ throw ne;
}
assertEquals("Unexpected array length.", expected.length, actual.length);
}
@@ -182,7 +184,7 @@
*/
public static void assertSetEquals(final Collection<?> expected, final Collection<?> actual) {
if (expected != null && actual != null && !expected.isEmpty()) {
- final Set<Object> r = new LinkedHashSet<>(expected);
+ final Set<Object> r = new LinkedHashSet<Object>(expected);
assertTrue("The two sets are disjoint.", r.removeAll(actual));
assertTrue("The set is missing elements: " + r, r.isEmpty());
assertTrue("The set unexpectedly became empty.", r.addAll(actual));
@@ -203,7 +205,7 @@
*/
public static void assertMapEquals(final Map<?,?> expected, final Map<?,?> actual) {
if (expected != null && actual != null && !expected.isEmpty()) {
- final Map<Object,Object> r = new LinkedHashMap<>(expected);
+ final Map<Object,Object> r = new LinkedHashMap<Object,Object>(expected);
for (final Map.Entry<?,?> entry : actual.entrySet()) {
final Object key = entry.getKey();
if (!r.containsKey(key)) {
@@ -352,12 +354,16 @@
final XMLComparator comparator;
try {
comparator = new XMLComparator(expected, actual);
- } catch (IOException | ParserConfigurationException | SAXException e) {
+ } catch (IOException e) {
// We don't throw directly those exceptions since failing to parse the XML file can
// be considered as part of test failures and the JUnit exception for such failures
// is AssertionError. Having no checked exception in "assert" methods allow us to
// declare the checked exceptions only for the library code being tested.
throw new AssertionError(e);
+ } catch (ParserConfigurationException e) {
+ throw new AssertionError(e);
+ } catch (SAXException e) {
+ throw new AssertionError(e);
}
comparator.tolerance = tolerance;
comparator.ignoreComments = true;
@@ -389,20 +395,26 @@
final Object deserialized;
try {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
+ final ObjectOutputStream out = new ObjectOutputStream(buffer);
+ try {
out.writeObject(object);
+ } finally {
+ out.close();
}
// Now reads the object we just serialized.
final byte[] data = buffer.toByteArray();
- try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
+ try {
try {
deserialized = in.readObject();
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
+ } finally {
+ in.close();
}
} catch (IOException e) {
- throw new AssertionError(e.toString(), e);
+ throw new AssertionError(e);
}
// Compares with the original object and returns it.
@SuppressWarnings("unchecked")
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java b/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java
index 379cd1c..eee9694 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java
@@ -19,8 +19,8 @@
import org.apache.sis.internal.system.DataDirectory;
// Branch-specific imports
-import java.nio.file.Path;
-import java.nio.file.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Files;
/**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java b/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
index eb3b83d..700f3d7 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
@@ -27,6 +27,9 @@
import org.apache.sis.io.TableAppender;
import org.junit.runner.Description;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Collects who emitted logging messages during the execution of a test suite.
@@ -53,7 +56,7 @@
* <li>Logging level</li>
* </ul>
*/
- private final List<String> records = new ArrayList<>();
+ private final List<String> records = new ArrayList<String>();
/**
* The description of the test currently running.
@@ -116,7 +119,7 @@
*/
final void report(final Appendable out) throws IOException {
synchronized (records) {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
if (!records.isEmpty()) {
out.append(lineSeparator)
.append("The following tests have logged messages at level INFO or higher:").append(lineSeparator)
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java b/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
index 927dc36..baec9d3 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
@@ -65,7 +65,7 @@
/**
* The logged messages.
*/
- private final Queue<String> messages = new LinkedList<>();
+ private final Queue<String> messages = new LinkedList<String>();
/**
* The logger to watch.
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java b/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
index b6a4d3b..6c71a76 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
@@ -198,7 +198,7 @@
final TestClass testClass = getTestClass();
final List<FrameworkMethod> depends = testClass.getAnnotatedMethods(DependsOnMethod.class);
if (!isNullOrEmpty(depends)) {
- final Set<String> dependencies = new HashSet<>(hashMapCapacity(depends.size()));
+ final Set<String> dependencies = new HashSet<String>(hashMapCapacity(depends.size()));
for (final FrameworkMethod method : depends) {
for (final String value : method.getAnnotation(DependsOnMethod.class).value()) {
dependencies.add(value);
@@ -268,7 +268,7 @@
* @param methods The methods to sort.
*/
private static void sortDependantTestsLast(final FrameworkMethod[] methods) {
- final Set<String> dependencies = new HashSet<>();
+ final Set<String> dependencies = new HashSet<String>();
int retryCount = methods.length;
for (int i=methods.length-1; --i>=0;) {
final FrameworkMethod method = methods[i];
@@ -385,12 +385,12 @@
*/
final void addDependencyFailure(final String methodName) {
if (methodDependencyFailures == null) {
- methodDependencyFailures = new HashSet<>();
+ methodDependencyFailures = new HashSet<String>();
}
methodDependencyFailures.add(methodName);
synchronized (TestRunner.class) {
if (classDependencyFailures == null) {
- classDependencyFailures = new HashSet<>();
+ classDependencyFailures = new HashSet<Class<?>>();
}
classDependencyFailures.add(getTestClass().getJavaClass());
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java b/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
index b829dbb..54058ac 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
@@ -95,7 +95,7 @@
File root;
try {
root = new File(url.toURI());
- } catch (URISyntaxException | IllegalArgumentException e) {
+ } catch (Exception e) { // (URISyntaxException | IllegalArgumentException) on JDK7 branch.
// If not a file, then it is probably an entry in a JAR file.
fail(e.toString());
return;
@@ -125,9 +125,9 @@
* and fail on the first missing test file if any.
*/
List<Class<?>> declared = Arrays.asList(suite.getAnnotation(Suite.SuiteClasses.class).value());
- final Set<Class<?>> tests = new HashSet<>(declared);
+ final Set<Class<?>> tests = new HashSet<Class<?>>(declared);
if (tests.size() != declared.size()) {
- declared = new ArrayList<>(declared);
+ declared = new ArrayList<Class<?>>(declared);
assertTrue(declared.removeAll(tests));
fail("Classes defined twice in " + suite.getSimpleName() + ": " + declared);
}
@@ -217,7 +217,7 @@
*/
protected static void verifyTestList(final Class<? extends TestSuite> suite, final Class<?>[] baseTestClasses) {
final Class<?>[] testCases = suite.getAnnotation(Suite.SuiteClasses.class).value();
- final Set<Class<?>> done = new HashSet<>(testCases.length);
+ final Set<Class<?>> done = new HashSet<Class<?>>(testCases.length);
for (final Class<?> testCase : testCases) {
if (!Classes.isAssignableToAny(testCase, baseTestClasses)) {
fail("Class " + testCase.getCanonicalName() + " does not extends TestCase.");
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java b/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
index 8a6fdd4..373eced 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
@@ -49,6 +49,9 @@
import static org.apache.sis.util.Characters.NO_BREAK_SPACE;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Compares the XML document produced by a test method with the expected XML document.
@@ -84,7 +87,7 @@
*
* @see #substitutePrefix(String)
*/
- private static final Map<String, String> PREFIX_URL = new HashMap<>(16);
+ private static final Map<String, String> PREFIX_URL = new HashMap<String, String>(16);
static {
final Map<String,String> map = PREFIX_URL;
map.put("xmlns", "http://www.w3.org/2000/xmlns"); // No trailing slash.
@@ -206,8 +209,11 @@
expectedDoc = (Node) expected;
} else {
builder = newDocumentBuilder();
- try (InputStream stream = toInputStream(expected)) {
+ final InputStream stream = toInputStream(expected);
+ try {
expectedDoc = builder.parse(stream);
+ } finally {
+ stream.close();
}
}
if (actual instanceof Node) {
@@ -216,12 +222,15 @@
if (builder == null) {
builder = newDocumentBuilder();
}
- try (InputStream stream = toInputStream(actual)) {
+ final InputStream stream = toInputStream(actual);
+ try {
actualDoc = builder.parse(stream);
+ } finally {
+ stream.close();
}
}
- ignoredAttributes = new HashSet<>();
- ignoredNodes = new HashSet<>();
+ ignoredAttributes = new HashSet<String>();
+ ignoredNodes = new HashSet<String>();
}
/**
@@ -631,7 +640,7 @@
if (abs(doubleValue(expected) - doubleValue(actual)) <= tolerance) {
return;
}
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(1024).append("Expected ")
.append(propertyName).append(" \"")
.append(expected).append("\" but got \"")
@@ -655,6 +664,7 @@
* returns {@code NaN}. This is used only if a {@linkplain #tolerance} threshold greater
* than zero has been provided.
*/
+ @SuppressWarnings("unchecked")
private static double doubleValue(final Comparable<?> property) {
if (property instanceof Number) {
return ((Number) property).doubleValue();
@@ -676,7 +686,7 @@
* @return An error message containing the expected and actual node.
*/
protected String formatErrorMessage(final Node expected, final Node result) {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(256).append("Nodes are not equal:").append(lineSeparator);
formatErrorMessage(buffer, expected, result, lineSeparator);
return buffer.toString();
@@ -713,7 +723,7 @@
private static List<String> formatHierarchy(final StringBuilder buffer, Node node,
final List<String> expected, final String lineSeparator)
{
- final List<String> hierarchy = new ArrayList<>();
+ final List<String> hierarchy = new ArrayList<String>();
while (node != null) {
hierarchy.add(node.getNodeName());
if (node instanceof Attr) {
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java b/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
index 2005b13..8bbf108 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
@@ -123,7 +123,7 @@
*/
protected static synchronized MarshallerPool getMarshallerPool() throws JAXBException {
if (defaultPool == null) {
- final Map<String,Object> properties = new HashMap<>(4);
+ final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(XML.LOCALE, Locale.UK));
assertNull(properties.put(XML.TIMEZONE, TIMEZONE));
defaultPool = new MarshallerPool(properties);
@@ -180,6 +180,19 @@
}
/**
+ * Appends explicitely {@code "xmlns:xsi"} to the list of attributes to ignore.
+ * This is not needed on JDK7 if the {@code "xmlns:*"} property has been defined,
+ * but required on JDK6. Not sure why...
+ */
+ @org.apache.sis.util.Workaround(library = "JDK", version = "1.6")
+ private static String[] addIgnoreXSI(String[] ignoredAttributes) {
+ final int length = ignoredAttributes.length;
+ ignoredAttributes = java.util.Arrays.copyOf(ignoredAttributes, length + 1);
+ ignoredAttributes[length] = "xmlns:xsi";
+ return ignoredAttributes;
+ }
+
+ /**
* Marshals the given object and ensure that the result is equals to the content of the given file.
*
* @param filename The name of the XML file in the package of the final subclass of {@code this}.
@@ -193,7 +206,7 @@
protected final void assertMarshalEqualsFile(final String filename, final Object object,
final String... ignoredAttributes) throws JAXBException
{
- assertXmlEquals(getResource(filename), marshal(object), ignoredAttributes);
+ assertXmlEquals(getResource(filename), marshal(object), addIgnoreXSI(ignoredAttributes));
}
/**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java b/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
index c13d390..a41071c 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
@@ -36,12 +36,12 @@
/**
* A constant for column of latitudes as floating point value.
*/
- public static final TableColumn<Float> LATITUDE = new SerializableTableColumn<>("LATITUDE", Float.class, "Latitude");
+ public static final TableColumn<Float> LATITUDE = new SerializableTableColumn<Float>("LATITUDE", Float.class, "Latitude");
/**
* A constant for column of longitudes as floating point value.
*/
- public static final TableColumn<Float> LONGITUDE = new SerializableTableColumn<>("LONGITUDE", Float.class, "Longitude");
+ public static final TableColumn<Float> LONGITUDE = new SerializableTableColumn<Float>("LONGITUDE", Float.class, "Longitude");
/**
* The programmatic name of the static final field holding this constant.
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
index f7649da..5eb0df8 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
@@ -129,7 +129,7 @@
*/
@Test
public void testFindCommonParent() {
- final Set<Object> types = new HashSet<>();
+ final Set<Object> types = new HashSet<Object>();
assertTrue(types.add(new NotSerializableException()));
assertEquals(NotSerializableException.class, findCommonClass (types));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
index bd1d1e9..44a495e 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
@@ -24,6 +24,9 @@
import static org.junit.Assert.*;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Tests the {@link Exceptions} utility methods.
@@ -39,7 +42,7 @@
*/
@Test
public void testFormatChainedMessages() {
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final FileNotFoundException cause = new FileNotFoundException("MisingFile.txt");
cause.initCause(new IOException("Disk is not mounted."));
final Exception e = new Exception("Can not find “MisingFile.txt”.", cause);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
index bf4992b..6d971df 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
@@ -17,7 +17,6 @@
package org.apache.sis.util;
import java.util.Locale;
-import java.util.IllformedLocaleException;
import org.apache.sis.test.TestCase;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.DependsOnMethod;
@@ -94,6 +93,7 @@
* This functionality is supported only on the JDK7 branch.
*/
@Test
+ @org.junit.Ignore("Not supported on the JDK6 branch")
public void testParseIETF() {
assertEquals(Locale.JAPAN, Locales.parse("ja-JP"));
assertEquals(new Locale("en", "US", "POSIX"), Locales.parse("en-US-x-lvariant-POSIX"));
@@ -107,7 +107,7 @@
try {
Locales.parse("orange_APPLE");
fail("Shall not parse invalid locale.");
- } catch (IllformedLocaleException e) {
+ } catch (RuntimeException e) { // IllformedLocaleException on the JDK7 branch.
final String message = e.getMessage();
assertTrue(message, message.contains("APPLE"));
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/UtilitiesTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/UtilitiesTest.java
index 7621872..f941de7 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/UtilitiesTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/UtilitiesTest.java
@@ -65,11 +65,11 @@
final Collection<DummyLenient> c1, c2;
if (orderIsSignificant) {
- c1 = new ArrayList<>();
- c2 = new ArrayList<>();
+ c1 = new ArrayList<DummyLenient>();
+ c2 = new ArrayList<DummyLenient>();
} else {
- c1 = new LinkedHashSet<>();
- c2 = new LinkedHashSet<>();
+ c1 = new LinkedHashSet<DummyLenient>();
+ c2 = new LinkedHashSet<DummyLenient>();
}
assertTrue(c1.add(e1)); assertTrue(c1.add(e2));
assertTrue(c2.add(e3)); assertTrue(c2.add(e4));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
index 6ac4f4e..e8c2905 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
@@ -85,7 +85,7 @@
public void testPutAndUnlock() {
final String key = "The key";
final String value = "The value";
- final Cache<String,String> cache = new Cache<>();
+ final Cache<String,String> cache = new Cache<String,String>();
assertTrue("No initial value expected.", cache.isEmpty());
assertNull("No initial value expected.", cache.peek(key));
@@ -96,7 +96,7 @@
assertEquals(1, cache.size());
assertEquals(value, cache.peek(key));
assertEquals(singleton(key), cache.keySet());
- assertEquals(singleton(new SimpleEntry<>(key, value)), cache.entrySet());
+ assertEquals(singleton(new SimpleEntry<String,String>(key, value)), cache.entrySet());
}
/**
@@ -112,7 +112,7 @@
final String valueByMainThread = "valueByMainThread";
final String keyByOtherThread = "keyByOtherThread";
final String valueByOtherThread = "valueByOtherThread";
- final Cache<String,String> cache = new Cache<>();
+ final Cache<String,String> cache = new Cache<String,String>();
final class OtherThread extends Thread {
/**
* If an error occurred, the cause. It may be an {@link AssertionError}.
@@ -150,7 +150,7 @@
if (failure == null) {
failure = e;
} else {
- failure.addSuppressed(e);
+ // The JDK7 branch invokes Throwable.addSuppressed(…) here.
}
}
}
@@ -174,7 +174,7 @@
/*
* Checks the map content.
*/
- final Map<String,String> expected = new HashMap<>(4);
+ final Map<String,String> expected = new HashMap<String,String>(4);
assertNull(expected.put( keyByMainThread, valueByMainThread));
assertNull(expected.put(keyByOtherThread, valueByOtherThread));
assertMapEquals(expected, cache);
@@ -210,8 +210,8 @@
@DependsOnMethod("testThreadBlocking")
public void stress() throws InterruptedException {
final int count = 5000;
- final Cache<Integer,Integer> cache = new Cache<>();
- final AtomicReference<Throwable> failures = new AtomicReference<>();
+ final Cache<Integer,Integer> cache = new Cache<Integer,Integer>();
+ final AtomicReference<Throwable> failures = new AtomicReference<Throwable>();
final class WriterThread extends Thread {
/**
* Incremented every time a value has been added. This is not the number of time the
@@ -244,7 +244,7 @@
assertEquals(expected, value);
} catch (Throwable e) {
if (!failures.compareAndSet(null, e)) {
- failures.get().addSuppressed(e);
+ // The JDK7 branch invokes Throwable.addSuppressed(…) here.
}
continue;
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java
index 468019f..0f4bba2 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java
@@ -50,7 +50,7 @@
*/
@SuppressWarnings("fallthrough")
private CodeListSet<AxisDirection> create(final int n) {
- final CodeListSet<AxisDirection> c = new CodeListSet<>(AxisDirection.class);
+ final CodeListSet<AxisDirection> c = new CodeListSet<AxisDirection>(AxisDirection.class);
assertTrue(c.isEmpty());
switch (n) {
default: throw new AssertionError(n);
@@ -72,7 +72,7 @@
private CodeListSet<OnLineFunction> createOtherKind() {
// For the validity of the tests, ordinal value must be the same.
assertEquals(NORTH.ordinal(), OnLineFunction.INFORMATION.ordinal());
- final CodeListSet<OnLineFunction> c = new CodeListSet<>(OnLineFunction.class);
+ final CodeListSet<OnLineFunction> c = new CodeListSet<OnLineFunction>(OnLineFunction.class);
assertTrue(c.add(OnLineFunction.INFORMATION));
return c;
}
@@ -217,7 +217,7 @@
@Test
@DependsOnMethod("testContains")
public void testFill() {
- final CodeListSet<AxisDirection> c = new CodeListSet<>(AxisDirection.class, true);
+ final CodeListSet<AxisDirection> c = new CodeListSet<AxisDirection>(AxisDirection.class, true);
assertTrue("Expect at least 32 elements as of GeoAPI 3.0.0.", c.size() >= 32);
assertTrue(c.toString().startsWith("[AxisDirection[OTHER], AxisDirection[NORTH], "));
/*
@@ -233,9 +233,9 @@
*/
@Test
public void testLargeCodeList() {
- final Set<LargeCodeList> master = new HashSet<>(Arrays.asList(LargeCodeList.values()));
+ final Set<LargeCodeList> master = new HashSet<LargeCodeList>(Arrays.asList(LargeCodeList.values()));
assertTrue("This test requires more than 64 elements.", master.size() > Long.SIZE);
- final CodeListSet<LargeCodeList> c = new CodeListSet<>(LargeCodeList.class);
+ final CodeListSet<LargeCodeList> c = new CodeListSet<LargeCodeList>(LargeCodeList.class);
/*
* Copy all content from the master to the CodeListSet. This will indirectly
* test CodeListSet.add(E), through the AbstractSet.addAll(Collection) method.
@@ -250,7 +250,7 @@
final CodeListSet<LargeCodeList> clone = c.clone();
assertNotSame("Clone shall be a new instance.", c, clone);
assertEquals("Clone shall be equal to the original.", master, clone);
- assertEquals(clone, new CodeListSet<>(LargeCodeList.class, true));
+ assertEquals(clone, new CodeListSet<LargeCodeList>(LargeCodeList.class, true));
/*
* Tests contains(Object) and remove(Object). We also remove elements
* from the master set, then we verify that the result is the same.
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java
index d50d7bd..492ed36 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java
@@ -68,8 +68,8 @@
*/
@Test
public void testNoExclusion() {
- final Map<Integer,Integer> source = new HashMap<>();
- final Map<Integer,Integer> target = new HashMap<>();
+ final Map<Integer,Integer> source = new HashMap<Integer,Integer>();
+ final Map<Integer,Integer> target = new HashMap<Integer,Integer>();
final Map<Integer,Integer> tested = DerivedMap.create(source, this, new DerivedSetTest());
fill(source, target);
assertEquals(target.size(), tested.size());
@@ -95,8 +95,8 @@
*/
@Test
public void testWithExclusion() {
- final Map<Integer,Integer> source = new HashMap<>();
- final Map<Integer,Integer> target = new HashMap<>();
+ final Map<Integer,Integer> source = new HashMap<Integer,Integer>();
+ final Map<Integer,Integer> target = new HashMap<Integer,Integer>();
final Map<Integer,Integer> tested = DerivedMap.create(source, this, new DerivedSetTest());
fill(source, target);
assertNull(source.put(EXCLUDED, 4));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java
index b0a487e..19452d4 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java
@@ -50,8 +50,8 @@
*/
@Test
public void testNoExclusion() {
- final Set<Integer> source = new HashSet<>(Arrays.asList(2, 7, 12, 17, 20 ));
- final Set<Integer> target = new HashSet<>(Arrays.asList(20, 70, 120, 170, 200));
+ final Set<Integer> source = new HashSet<Integer>(Arrays.asList(2, 7, 12, 17, 20 ));
+ final Set<Integer> target = new HashSet<Integer>(Arrays.asList(20, 70, 120, 170, 200));
final Set<Integer> tested = DerivedSet.create(source, this);
assertEquals(target.size(), tested.size());
assertEquals(target, tested);
@@ -76,8 +76,8 @@
*/
@Test
public void testWithExclusion() {
- final Set<Integer> source = new HashSet<>(Arrays.asList(2, 7, 12, EXCLUDED, 20));
- final Set<Integer> target = new HashSet<>(Arrays.asList(20, 70, 120, 200));
+ final Set<Integer> source = new HashSet<Integer>(Arrays.asList(2, 7, 12, EXCLUDED, 20));
+ final Set<Integer> target = new HashSet<Integer>(Arrays.asList(20, 70, 120, 200));
final Set<Integer> tested = DerivedSet.create(source, this);
assertEquals(target.size(), tested.size());
assertEquals(target, tested);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
index e550111..be27c2f 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
@@ -55,7 +55,7 @@
// Use half the lenght as initial capacity in order to test dynamic resizing.
list = new IntegerList(length / 2, maximalValue);
assertTrue(list.maximalValue() >= maximalValue);
- final List<Integer> copy = new ArrayList<>(length);
+ final List<Integer> copy = new ArrayList<Integer>(length);
for (int i=0; i<length; i++) {
assertEquals(i, list.size());
final Integer value = nextInt(random, maximalValue);
@@ -108,7 +108,7 @@
*/
private void testFill(final int value) {
assertEquals(400, list.size());
- final Set<Integer> set = new HashSet<>();
+ final Set<Integer> set = new HashSet<Integer>();
list.fill(value);
set.addAll(list);
assertEquals(Collections.singleton(value), set);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
index b63ecb9..09baeba 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
@@ -156,13 +156,13 @@
final Date yesterday = new Date(now.getTime() - day);
assertTrue(ranges.add(yesterday, now));
assertEquals(1, ranges.size());
- checkContains(ranges, new Range<>(Date.class, yesterday, true, now, false), true, true);
+ checkContains(ranges, new Range<Date>(Date.class, yesterday, true, now, false), true, true);
/*
* Add a disjoint range.
*/
final Date lastWeek = new Date(now.getTime() - 7*day);
final Date other = new Date(lastWeek.getTime() + 2*day);
- assertTrue(ranges.add(new Range<>(Date.class, lastWeek, true, other, false)));
+ assertTrue(ranges.add(new Range<Date>(Date.class, lastWeek, true, other, false)));
assertEquals(2, ranges.size());
/*
* Verify the RangeSet content.
@@ -182,13 +182,13 @@
assertTrue(ranges.isEmpty());
assertTrue(ranges.add("FAA", "FBB"));
assertEquals(1, ranges.size());
- checkContains(ranges, new Range<>(String.class, "FAA", true, "FBB", false), true, true);
+ checkContains(ranges, new Range<String>(String.class, "FAA", true, "FBB", false), true, true);
/*
* Merge the singleton range with the given range.
*/
assertTrue(ranges.add("FAZ", "FCC"));
assertEquals(1, ranges.size());
- checkContains(ranges, new Range<>(String.class, "FAA", true, "FCC", false), true, true);
+ checkContains(ranges, new Range<String>(String.class, "FAA", true, "FCC", false), true, true);
/*
* Add a disjoint range.
*/
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java
index c5f10dd..3ecc81a 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java
@@ -90,8 +90,8 @@
@Test
@DependsOnMethod("testTreeFormat")
public void testTreeTableFormat() {
- final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
- final TableColumn<String> valueB = new TableColumn<>(String .class, "value #2");
+ final TableColumn<Integer> valueA = new TableColumn<Integer>(Integer.class, "value #1");
+ final TableColumn<String> valueB = new TableColumn<String> (String .class, "value #2");
final DefaultTreeTable table = new DefaultTreeTable(NAME, valueA, valueB);
final TreeTable.Node root = new DefaultTreeTable.Node(table);
root.setValue(NAME, "Node #1");
@@ -144,8 +144,8 @@
@Test
@DependsOnMethod("testTreeTableFormat")
public void testTreeTableParse() throws ParseException {
- final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
- final TableColumn<String> valueB = new TableColumn<>(String .class, "value #2");
+ final TableColumn<Integer> valueA = new TableColumn<Integer>(Integer.class, "value #1");
+ final TableColumn<String> valueB = new TableColumn<String> (String .class, "value #2");
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setColumns(NAME, valueA, valueB);
tf.setVerticalLinePosition(1);
@@ -166,8 +166,8 @@
@Test
@DependsOnMethod("testTreeTableParse")
public void testAlternativeColumnSeparatorPattern() throws ParseException {
- final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
- final TableColumn<String> valueB = new TableColumn<>(String .class, "value #2");
+ final TableColumn<Integer> valueA = new TableColumn<Integer>(Integer.class, "value #1");
+ final TableColumn<String> valueB = new TableColumn<String> (String .class, "value #2");
final TreeTableFormat tf = new TreeTableFormat(null, null);
assertEquals("?……[…] ", tf.getColumnSeparatorPattern());
tf.setColumns(NAME, valueA, valueB);
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTablesTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTablesTest.java
index 0948b08..aa4556e 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTablesTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTablesTest.java
@@ -18,8 +18,6 @@
import java.util.List;
import java.io.File;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
import java.text.ParseException;
import org.junit.Test;
import org.apache.sis.test.TestCase;
@@ -92,33 +90,6 @@
}
/**
- * Tests the {@link TreeTables#nodeForPath(TreeTable.Node, TableColumn, Path)} method.
- */
- @Test
- public void testNodeForPath() {
- final FileSystem fs = FileSystems.getDefault();
- final TreeTable table = new DefaultTreeTable(NAME, VALUE_AS_NUMBER);
- final TreeTable.Node files = table.getRoot();
- files.setValue(NAME, "Root");
- nodeForPath(files, NAME, fs.getPath("users","Alice","data")) .setValue(VALUE_AS_NUMBER, 10);
- nodeForPath(files, NAME, fs.getPath("users","Bob","data")) .setValue(VALUE_AS_NUMBER, 20);
- nodeForPath(files, NAME, fs.getPath("users","Bob")) .setValue(VALUE_AS_NUMBER, 30);
- nodeForPath(files, NAME, fs.getPath("lib")) .setValue(VALUE_AS_NUMBER, 40);
- nodeForPath(files, NAME, fs.getPath("users","Alice","document")) .setValue(VALUE_AS_NUMBER, 50);
- nodeForPath(files, NAME, fs.getPath("users","Alice","data","mercator")).setValue(VALUE_AS_NUMBER, 60);
- assertMultilinesEquals(
- "Root\n" +
- " ├─users\n" +
- " │ ├─Alice\n" +
- " │ │ ├─data………………………… 10\n" +
- " │ │ │ └─mercator…… 60\n" +
- " │ │ └─document……………… 50\n" +
- " │ └─Bob……………………………………… 30\n" +
- " │ └─data………………………… 20\n" +
- " └─lib………………………………………………… 40\n", table.toString());
- }
-
- /**
* Tests the {@link TreeTables#nodeForPath(TreeTable.Node, TableColumn, File)} method.
*/
@Test
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
index a7a1cb8..64925e3 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
@@ -59,8 +59,8 @@
public void testStrongReferences() {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = new WeakHashSet<>(Integer.class);
- final HashSet<Integer> strongSet = new HashSet<>();
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
+ final HashSet<Integer> strongSet = new HashSet<Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = random.nextInt(SAMPLE_SIZE);
if (random.nextBoolean()) {
@@ -102,8 +102,8 @@
public void testWeakReferences() throws InterruptedException {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = new WeakHashSet<>(Integer.class);
- final HashSet<Integer> strongSet = new HashSet<>();
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
+ final HashSet<Integer> strongSet = new HashSet<Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = new Integer(random.nextInt(SAMPLE_SIZE)); // Really need new instances
if (random.nextBoolean()) {
@@ -180,7 +180,7 @@
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayElements() {
- final WeakHashSet<int[]> weakSet = new WeakHashSet<>(int[].class);
+ final WeakHashSet<int[]> weakSet = new WeakHashSet<int[]>(int[].class);
final int[] array = new int[] {2, 5, 3};
assertTrue (weakSet.add(array));
assertFalse(weakSet.add(array));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
index f3a31d3..d7d2888 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
@@ -71,7 +71,7 @@
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
weakMap.clear();
- final HashMap<Integer,Integer> strongMap = new HashMap<>();
+ final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer key = random.nextInt(SAMPLE_SIZE);
final Integer value = random.nextInt(SAMPLE_SIZE);
@@ -113,7 +113,7 @@
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
weakMap.clear();
- final HashMap<Integer,Integer> strongMap = new HashMap<>();
+ final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
// We really want new instances here.
final Integer key = new Integer(random.nextInt(SAMPLE_SIZE));
@@ -184,7 +184,7 @@
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayKeys() {
- final WeakValueHashMap<int[],Integer> weakMap = new WeakValueHashMap<>(int[].class);
+ final WeakValueHashMap<int[],Integer> weakMap = new WeakValueHashMap<int[],Integer>(int[].class);
final int[] k1 = new int[] {2, 5, 3};
final int[] k2 = new int[] {2, 5, 4};
final Integer v1 = 1;
@@ -207,7 +207,7 @@
@Test
@DependsOnMethod("testStrongReferences")
public void testIdentityComparisons() {
- final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<>(Integer.class, true);
+ final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<Integer,Integer>(Integer.class, true);
final Integer k1 = 10;
final Integer k2 = 20;
final Integer k3 = new Integer(10); // Really want a new instance.
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
index 24dba2f..4161460 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
@@ -50,7 +50,7 @@
@Test
public void testCreateRecordType() {
final DefaultRecordSchema schema = new DefaultRecordSchema(null, null, "MySchema");
- final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(8);
+ final Map<CharSequence,Class<?>> members = new LinkedHashMap<CharSequence,Class<?>>(8);
assertNull(members.put("city", String.class));
assertNull(members.put("latitude", Double.class));
assertNull(members.put("longitude", Double.class));
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTest.java
index 97df460..faa30b3 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTest.java
@@ -53,7 +53,7 @@
@BeforeClass
public static void createRecordType() {
final DefaultRecordSchema schema = new SerializableRecordSchema("MySchema");
- final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(8);
+ final Map<CharSequence,Class<?>> members = new LinkedHashMap<CharSequence,Class<?>>(8);
assertNull(members.put("city", String.class));
assertNull(members.put("latitude", Double.class));
assertNull(members.put("longitude", Double.class));
@@ -178,7 +178,7 @@
@Test
@DependsOnMethod({"testSetAll", "testToString", "testSerialization"})
public void testPrimitiveType() {
- final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(8);
+ final Map<CharSequence,Class<?>> members = new LinkedHashMap<CharSequence,Class<?>>(8);
assertNull(members.put("latitude", Double.class));
assertNull(members.put("longitude", Double.class));
final DefaultRecord record = new DefaultRecord(
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
index 5773bcc..82d33af 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
@@ -68,7 +68,7 @@
* Creates a new record type from the current values of private fields.
*/
private DefaultRecordType create() throws IllegalArgumentException {
- final Type memberType = new SimpleAttributeType<>(memberTypeName, Integer.class);
+ final Type memberType = new SimpleAttributeType<Integer>(memberTypeName, Integer.class);
return new DefaultRecordType(recordTypeName, container, Collections.singletonMap(memberName, memberType));
}
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java b/core/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java
index 40719ac..a77e206 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java
@@ -37,7 +37,7 @@
/**
* List of all enumerations of this type.
*/
- private static final List<LargeCodeList> VALUES = new ArrayList<>(100);
+ private static final List<LargeCodeList> VALUES = new ArrayList<LargeCodeList>(100);
/**
* Creates 100 code list elements.
diff --git a/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java b/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java
index 5d97ef9..8aab076 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java
@@ -49,7 +49,7 @@
* Creates a new test case.
*/
public WarningListenersTest() {
- listeners = new WarningListeners<>("source");
+ listeners = new WarningListeners<String>("source");
}
/**
diff --git a/core/sis-utility/src/test/java/org/apache/sis/xml/OGCNamespacePrefixMapperTest.java b/core/sis-utility/src/test/java/org/apache/sis/xml/OGCNamespacePrefixMapperTest.java
index fd25a45..6d85e77 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/xml/OGCNamespacePrefixMapperTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/xml/OGCNamespacePrefixMapperTest.java
@@ -48,11 +48,11 @@
* defined in the JDK class. This test is ignored if the Java framework running this test
* is not the Oracle one (i.e. if it does not bundle the Sun internal JAXB implementation).
*
- * @throws ReflectiveOperationException If an error occurred while invoking a method by
+ * @throws Exception If an error occurred while invoking a method by
* the reflection API.
*/
@Test
- public void testInternalJAXB() throws ReflectiveOperationException {
+ public void testInternalJAXB() throws Exception {
try {
ensureOverrideMethods(new OGCNamespacePrefixMapper(null));
} catch (NoClassDefFoundError e) {
@@ -65,11 +65,11 @@
* methods defined in the JAXB class. This test is ignored if the Java framework running
* this test does not contains JAXB in its endorsed directory.
*
- * @throws ReflectiveOperationException If an error occurred while invoking a method by
+ * @throws Exception If an error occurred while invoking a method by
* the reflection API.
*/
@Test
- public void testEndorsedJAXB() throws ReflectiveOperationException {
+ public void testEndorsedJAXB() throws Exception {
try {
ensureOverrideMethods(new OGCNamespacePrefixMapper_Endorsed(null));
} catch (NoClassDefFoundError e) {
@@ -86,10 +86,10 @@
*
* @param The {@code OGCNamespacePrefixMapper} or {@code OGCNamespacePrefixMapper_Endorsed}
* instance to check.
- * @throws ReflectiveOperationException If an error occurred while invoking a method by
+ * @throws Exception If an error occurred while invoking a method by
* the reflection API.
*/
- private void ensureOverrideMethods(final Object mapper) throws ReflectiveOperationException {
+ private void ensureOverrideMethods(final Object mapper) throws Exception {
String preferredPrefix = "getPreferredPrefix_method_has_not_been_found";
final Method[] methods = mapper.getClass().getSuperclass().getDeclaredMethods();
/*
diff --git a/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java b/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java
index ac3e551..85bbe44 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/xml/ValueConverterTest.java
@@ -24,7 +24,7 @@
import static org.junit.Assert.*;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
diff --git a/ide-project/NetBeans/README.txt b/ide-project/NetBeans/README.txt
index 0733117..b7cafed 100644
--- a/ide-project/NetBeans/README.txt
+++ b/ide-project/NetBeans/README.txt
@@ -11,7 +11,7 @@
directory of all SIS-related projects):
mkdir SIS
- svn checkout http://svn.apache.org/repos/asf/sis/branches/JDK7 SIS/JDK7
+ svn checkout http://svn.apache.org/repos/asf/sis/branches/JDK6 SIS/JDK6
mkdir GeoAPI
git clone http://github.com/opengeospatial/geoapi GeoAPI/master
@@ -22,7 +22,7 @@
| +-- README.txt
| +-- etc...
+-- SIS
- +-- JDK7
+ +-- JDK6
+-- README
+-- etc...
diff --git a/ide-project/NetBeans/nbproject/build-impl.xml b/ide-project/NetBeans/nbproject/build-impl.xml
index df30449..7dd2c22 100644
--- a/ide-project/NetBeans/nbproject/build-impl.xml
+++ b/ide-project/NetBeans/nbproject/build-impl.xml
@@ -19,7 +19,7 @@
- cleanup
-->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Apache_SIS_for_JDK7-impl">
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Apache_SIS_for_JDK6-impl">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
@@ -533,7 +533,7 @@
</fileset>
</union>
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
- <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Apache_SIS_for_JDK7" testname="TestNG tests" workingDir="${work.dir}">
+ <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Apache_SIS_for_JDK6" testname="TestNG tests" workingDir="${work.dir}">
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
<propertyset>
<propertyref prefix="test-sys-prop."/>
@@ -708,7 +708,7 @@
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
<isset property="test.method"/>
</condition>
- <condition else="-suitename Apache_SIS_for_JDK7 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+ <condition else="-suitename Apache_SIS_for_JDK6 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
<matches pattern=".*\.xml" string="@{testClass}"/>
</condition>
<delete dir="${build.test.results.dir}" quiet="true"/>
@@ -1000,7 +1000,7 @@
<delete file="${built-jar.properties}" quiet="true"/>
</target>
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: Apache SIS for JDK7 was already built"/>
+ <echo level="warn" message="Cycle detected: Apache SIS for JDK6 was already built"/>
</target>
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
<mkdir dir="${build.dir}"/>
@@ -1579,7 +1579,7 @@
<delete file="${built-clean.properties}" quiet="true"/>
</target>
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: Apache SIS for JDK7 was already built"/>
+ <echo level="warn" message="Cycle detected: Apache SIS for JDK6 was already built"/>
</target>
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
<mkdir dir="${build.dir}"/>
diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties
index 36fb251..2124e3d 100644
--- a/ide-project/NetBeans/nbproject/project.properties
+++ b/ide-project/NetBeans/nbproject/project.properties
@@ -34,8 +34,8 @@
project.license = apache20
no.dependencies = true
source.encoding = UTF-8
-javac.source = 1.7
-javac.target = 1.7
+javac.source = 1.6
+javac.target = 1.6
platform.active = default_platform
run.jvmargs = -ea -Dorg.apache.sis.test.verbose=true -Dorg.apache.sis.test.extensive=true
junit.forkmode = once
@@ -87,10 +87,10 @@
jdom2.version = 2.0.4
jee.version = 6.0
osgi.version = 6.0.0
-netcdf.version = 4.6.4
+netcdf.version = 4.4.2
joda-time.version = 2.2
-httpclient.version = 4.3.6
-slf4j.version = 1.7.7
+httpclient.version = 4.2.6
+slf4j.version = 1.7.5
junit.version = 4.12
hamcrest.version = 1.3
jaxb-ns-mapper = 2.2.4
diff --git a/ide-project/NetBeans/nbproject/project.xml b/ide-project/NetBeans/nbproject/project.xml
index f401c92..d66aba9 100644
--- a/ide-project/NetBeans/nbproject/project.xml
+++ b/ide-project/NetBeans/nbproject/project.xml
@@ -21,7 +21,7 @@
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>Apache SIS for JDK7</name>
+ <name>Apache SIS for JDK6</name>
<source-roots>
<root id="src.local-src.dir" name="Local sources (unversioned)"/>
<root id="src.webapp.dir" name="Web application"/>
diff --git a/pom.xml b/pom.xml
index 6877508..e35bb10 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
============================================================== -->
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Apache SIS</name>
@@ -81,7 +81,7 @@
<ciManagement>
<system>jenkins</system>
- <url>https://builds.apache.org/job/sis-jdk7</url>
+ <url>https://builds.apache.org/job/sis-trunk</url>
</ciManagement>
<issueManagement>
@@ -365,7 +365,7 @@
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
- <version>7.0</version>
+ <version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -390,7 +390,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
- <version>1.7.7</version> <!-- Must matches the version used by NetCDF. -->
+ <version>1.7.5</version> <!-- Must matches the version used by NetCDF. -->
<scope>runtime</scope> <!-- Should never be needed at compile time. -->
</dependency>
</dependencies>
@@ -416,14 +416,14 @@
The last properties in this list depend on the Apache SIS branch.
=================================================================== -->
<properties>
- <netcdf.version>4.6.5</netcdf.version>
+ <netcdf.version>4.4.2</netcdf.version> <!-- Last version compatible with JDK6. -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<website.encoding>UTF-8</website.encoding>
<website.locale>en</website.locale>
<!-- Following properties are branch-specific -->
- <maven.compile.source>1.7</maven.compile.source>
- <maven.compile.target>1.7</maven.compile.target>
+ <maven.compile.source>1.6</maven.compile.source>
+ <maven.compile.target>1.6</maven.compile.target>
<sis.plugin.version>${project.version}</sis.plugin.version>
<geoapi.version>4.0-SNAPSHOT</geoapi.version>
</properties>
@@ -501,7 +501,7 @@
<encoding>${project.build.sourceEncoding}</encoding>
<useIncrementalCompilation>false</useIncrementalCompilation> <!-- https://jira.codehaus.org/browse/MCOMPILER-209 -->
<compilerArgs>
- <arg>-Xlint:all</arg>
+ <arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
@@ -579,7 +579,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>3.0.1</version>
+ <version>2.5.4</version> <!-- Last version compatible with JDK6. -->
<extensions>true</extensions>
<configuration>
<excludeDependencies>true</excludeDependencies>
@@ -590,37 +590,7 @@
</plugin>
<!-- Checkstype configuration
- Legal note: Checkstyle is under LGPL license, but it is okay to use it only for
- the build if it is downloaded by Maven (not included in Apache SIS distribution).
- See http://www.apache.org/legal/resolved.html#prohibited
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</version>
- <executions>
- <execution>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <skip>${skipTests}</skip> <!-- When skipping tests, skip also checkstyle verification. -->
- <encoding>${project.build.sourceEncoding}</encoding>
- <consoleOutput>true</consoleOutput>
- <checkstyleRules>
- <module name="Checker">
- <module name="FileTabCharacter"/> <!-- Checks that there are no tab characters in the file. -->
- <module name="NewlineAtEndOfFile"/> <!-- Checks that there is a newline at the end of each file. -->
- <module name="TreeWalker">
- <module name="RedundantImport"/> <!-- Checks for redundant import statements. -->
- <module name="GenericWhitespace"/> <!-- Checks that the whitespace around the Generic tokens follow the typical convention. -->
- </module>
- </module>
- </checkstyleRules>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ Omitted from the JDK6 branch because Checkstyle requires a higher JDK version. -->
<!-- JavaDoc configuration. -->
<plugin>
@@ -744,12 +714,12 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.10</version>
+ <version>1.9.1</version> <!-- Last version compatible with JDK6. -->
</plugin>
<plugin>
- <groupId>org.eclipse.jetty</groupId>
+ <groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
- <version>9.2.13.v20150730</version> <!-- Versions 9.3.* require JDK 8 -->
+ <version>8.1.16.v20140903</version> <!-- Versions 9.0.* require JDK 7 -->
</plugin>
</plugins>
</pluginManagement>
diff --git a/profiles/pom.xml b/profiles/pom.xml
index 17b64bc..964154e 100644
--- a/profiles/pom.xml
+++ b/profiles/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/profiles/sis-french-profile/pom.xml b/profiles/sis-french-profile/pom.xml
index d58ecac..5bb2e47 100644
--- a/profiles/sis-french-profile/pom.xml
+++ b/profiles/sis-french-profile/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>profiles</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/src/main/javadoc/stylesheet.css b/src/main/javadoc/stylesheet.css
index b8692c1..3d31bf4 100644
--- a/src/main/javadoc/stylesheet.css
+++ b/src/main/javadoc/stylesheet.css
@@ -248,6 +248,11 @@
font-size: 1em;
}
+h5 {
+ font-size: 110%;
+ margin-bottom: 3pt;
+}
+
/* Appareance of links in the "Description" column of class and package summaries.
* JDK style uses bold characters for the left column, which contains the class and
* package names. But we do not want those bold characters to apply to the descriptions.
diff --git a/storage/pom.xml b/storage/pom.xml
index 9959d12..2bc32d4 100644
--- a/storage/pom.xml
+++ b/storage/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>parent</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/storage/sis-netcdf/pom.xml b/storage/sis-netcdf/pom.xml
index c5d51cd..5eb7904 100644
--- a/storage/sis-netcdf/pom.xml
+++ b/storage/sis-netcdf/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>storage</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
index 7aaa830..ba69c15 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
@@ -24,7 +24,7 @@
import org.apache.sis.util.logging.WarningListeners;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
index 547e9e1..e58f3d1 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
@@ -667,7 +667,9 @@
dates[i] = new Date(epoch + Math.round(converter.convert(value.doubleValue())));
}
}
- } catch (ConversionException | IllegalArgumentException e) {
+ } catch (ConversionException e) {
+ listeners.warning(null, e);
+ } catch (IllegalArgumentException e) {
listeners.warning(null, e);
}
return dates;
@@ -702,7 +704,7 @@
* grid dimensions which are the domain of the variable (i.e. the sources of the conversion
* from grid coordinates to CRS coordinates).
*/
- final Map<Dimension, List<VariableInfo>> dimToAxes = new IdentityHashMap<>();
+ final Map<Dimension, List<VariableInfo>> dimToAxes = new IdentityHashMap<Dimension, List<VariableInfo>>();
for (final VariableInfo variable : variables) {
if (variable.isCoordinateSystemAxis()) {
for (final Dimension dimension : variable.dimensions) {
@@ -716,8 +718,8 @@
* and consequently the same axes, so we will remember the previously created instances in order
* to share them.
*/
- final Set<VariableInfo> axes = new LinkedHashSet<>(4);
- final Map<List<Dimension>, GridGeometryInfo> dimsToGG = new LinkedHashMap<>();
+ final Set<VariableInfo> axes = new LinkedHashSet<VariableInfo>(4);
+ final Map<List<Dimension>, GridGeometryInfo> dimsToGG = new LinkedHashMap<List<Dimension>, GridGeometryInfo>();
nextVar: for (final VariableInfo variable : variables) {
if (variable.isCoordinateSystemAxis()) {
continue;
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
index 3cdf41d..3297deb 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
@@ -276,7 +276,7 @@
private static <T> Set<T> addIfNonNull(Set<T> collection, final T element) {
if (element != null) {
if (collection == null) {
- collection = new LinkedHashSet<>(4);
+ collection = new LinkedHashSet<T>(4);
}
collection.add(element);
}
@@ -617,7 +617,7 @@
final String list = stringValue(standard ? STANDARD_NAME : KEYWORDS);
DefaultKeywords keywords = null;
if (list != null) {
- final Set<InternationalString> words = new LinkedHashSet<>();
+ final Set<InternationalString> words = new LinkedHashSet<InternationalString>();
for (String keyword : list.split(KEYWORD_SEPARATOR)) {
keyword = keyword.trim();
if (!keyword.isEmpty()) {
@@ -789,7 +789,8 @@
* @throws IOException If an I/O operation was necessary but failed.
*/
private Collection<DefaultCoverageDescription> createContentInfo() throws IOException {
- final Map<List<String>, DefaultCoverageDescription> contents = new HashMap<>(4);
+ final Map<List<String>, DefaultCoverageDescription> contents =
+ new HashMap<List<String>, DefaultCoverageDescription>(4);
final String processingLevel = stringValue(PROCESSING_LEVEL);
for (final Variable variable : decoder.getVariables()) {
if (!variable.isCoverage(2)) {
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
index 81957ea..abdc966 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
@@ -38,9 +38,6 @@
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.Version;
-// Branch-specific import
-import java.nio.file.NoSuchFileException;
-
/**
* The provider of {@link NetcdfStore} instances. Given a {@link StorageConnector} input,
@@ -165,7 +162,7 @@
if (cause instanceof DataStoreException) throw (DataStoreException) cause;
if (cause instanceof RuntimeException) throw (RuntimeException) cause;
if (cause instanceof Error) throw (Error) cause;
- if (cause instanceof FileNotFoundException || cause instanceof NoSuchFileException) {
+ if (cause instanceof FileNotFoundException) {
/*
* Happen if the String argument uses any protocol not recognized by the UCAR library,
* in which case UCAR tries to open it as a file even if it is not a file. For example
@@ -233,11 +230,9 @@
keepOpen = input;
} catch (DataStoreException e) {
final String path = storage.getStorageAs(String.class);
- if (path != null) try {
+ if (path != null) {
decoder = createByReflection(listeners, path, false);
keepOpen = path;
- } catch (IOException | DataStoreException s) {
- e.addSuppressed(s);
}
throw e;
} else {
@@ -290,7 +285,7 @@
if (cause instanceof RuntimeException) throw (RuntimeException) cause;
if (cause instanceof Error) throw (Error) cause;
throw new UndeclaredThrowableException(cause); // Should never happen actually.
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new AssertionError(e); // Should never happen (shall be verified by the JUnit tests).
}
}
@@ -326,7 +321,7 @@
createFromUCAR = wrapper.getConstructor(parameterTypes);
parameterTypes[1] = String.class;
createFromPath = wrapper.getConstructor(parameterTypes);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
throw new AssertionError(e); // Should never happen (shall be verified by the JUnit tests).
}
}
diff --git a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
index d713298..a060b87 100644
--- a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
+++ b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
@@ -47,7 +47,7 @@
/**
* A dummy list of listeners which can be given to the {@link Decoder} constructor.
*/
- public static EmptyWarningListeners<Decoder> LISTENERS = new EmptyWarningListeners<>(null, Modules.NETCDF);
+ public static EmptyWarningListeners<Decoder> LISTENERS = new EmptyWarningListeners<Decoder>(null, Modules.NETCDF);
/**
* The {@code searchPath} argument value to be given to the {@link Decoder#setSearchPath(String[])}
@@ -58,7 +58,7 @@
/**
* The decoders cached by {@link #selectDataset(String)}.
*/
- private static final Map<String,Decoder> DECODERS = new HashMap<>();
+ private static final Map<String,Decoder> DECODERS = new HashMap<String,Decoder>();
/**
* The decoder to test, which is set by {@link #selectDataset(String)}.
@@ -155,7 +155,7 @@
if (failure == null) {
failure = e;
} else {
- failure.addSuppressed(e);
+ // On JDK7 branch: failure.addSuppressed(e);
}
}
it.remove();
diff --git a/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java b/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
index 6dd0513..88e0213 100644
--- a/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
+++ b/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
@@ -57,8 +57,11 @@
@Test
public void testEmbedded() throws IOException, DataStoreException {
final Metadata metadata;
- try (Decoder input = ChannelDecoderTest.createChannelDecoder(NCEP)) {
+ final Decoder input = ChannelDecoderTest.createChannelDecoder(NCEP);
+ try {
metadata = new MetadataReader(input).read();
+ } finally {
+ input.close();
}
compareToExpected(metadata);
}
@@ -72,8 +75,11 @@
@Test
public void testUCAR() throws IOException {
final Metadata metadata;
- try (Decoder input = new DecoderWrapper(TestCase.LISTENERS, new NetcdfDataset(open(NCEP)))) {
+ final Decoder input = new DecoderWrapper(TestCase.LISTENERS, new NetcdfDataset(open(NCEP)));
+ try {
metadata = new MetadataReader(input).read();
+ } finally {
+ input.close();
}
compareToExpected(metadata);
}
diff --git a/storage/sis-shapefile/pom.xml b/storage/sis-shapefile/pom.xml
index f26b2a8..a67316b 100644
--- a/storage/sis-shapefile/pom.xml
+++ b/storage/sis-shapefile/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>storage</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java
index 9f69d96..ab1452a 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java
@@ -19,13 +19,15 @@
import java.lang.reflect.Constructor;
import java.text.MessageFormat;
import java.util.MissingResourceException;
-import java.util.Objects;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.sis.util.logging.Logging;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* Base class for objets having auto-checking abilities
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
index 0e46f07..5b1e663 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
@@ -35,6 +35,10 @@
import com.esri.core.geometry.*;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* Reader of a Shapefile Binary content by the way of a {@link java.nio.MappedByteBuffer}
*
@@ -55,16 +59,16 @@
/** Type of the features contained in this shapefile. */
private DefaultFeatureType featuresType;
-
+
/** Shapefile index. */
private File shapeFileIndex;
-
+
/** Shapefile indexes (loaded from .SHX file, if any found). */
private ArrayList<Integer> indexes;
-
+
/** Shapefile records lengths (loaded from .SHX file, if any found). */
private ArrayList<Integer> recordsLengths;
-
+
/**
* Construct a shapefile byte reader.
* @param shapefile Shapefile.
@@ -78,10 +82,10 @@
public ShapefileByteReader(File shapefile, File dbaseFile, File shapefileIndex) throws InvalidShapefileFormatException, SQLInvalidDbaseFileFormatException, SQLShapefileNotFoundException, SQLDbaseFileNotFoundException {
super(shapefile, InvalidShapefileFormatException.class, SQLShapefileNotFoundException.class);
this.shapeFileIndex = shapefileIndex;
-
+
loadDatabaseFieldDescriptors(dbaseFile);
loadDescriptor();
-
+
if (this.shapeFileIndex != null) {
loadShapefileIndexes();
}
@@ -123,17 +127,17 @@
final int n = this.databaseFieldsDescriptors.size();
final DefaultAttributeType<?>[] attributes = new DefaultAttributeType<?>[n + 1];
- final Map<String, Object> properties = new HashMap<>(4);
+ final Map<String, Object> properties = new HashMap<String, Object>(4);
// Load data field.
for (int i = 0; i < n; i++) {
properties.put(DefaultAttributeType.NAME_KEY, this.databaseFieldsDescriptors.get(i).getName());
- attributes[i] = new DefaultAttributeType<>(properties, String.class, 1, 1, null);
+ attributes[i] = new DefaultAttributeType<String>(properties, String.class, 1, 1, null);
}
// Add geometry field.
properties.put(DefaultAttributeType.NAME_KEY, GEOMETRY_NAME);
- attributes[n] = new DefaultAttributeType<>(properties, Geometry.class, 1, 1, null);
+ attributes[n] = new DefaultAttributeType<Geometry>(properties, Geometry.class, 1, 1, null);
// Add name.
properties.put(DefaultAttributeType.NAME_KEY, name);
@@ -156,23 +160,24 @@
if (this.shapeFileIndex == null) {
return false;
}
-
- try(FileInputStream fis = new FileInputStream(this.shapeFileIndex); FileChannel fc = fis.getChannel()) {
+
+ try {
+ FileInputStream fis = new FileInputStream(this.shapeFileIndex); FileChannel fc = fis.getChannel();
try {
int fsize = (int)fc.size();
MappedByteBuffer indexesByteBuffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fsize);
-
+
// Indexes entries follow.
- this.indexes = new ArrayList<>();
- this.recordsLengths = new ArrayList<>();
+ this.indexes = new ArrayList<Integer>();
+ this.recordsLengths = new ArrayList<Integer>();
indexesByteBuffer.position(100);
indexesByteBuffer.order(ByteOrder.BIG_ENDIAN);
-
+
while(indexesByteBuffer.hasRemaining()) {
this.indexes.add(indexesByteBuffer.getInt()); // Data offset : the position of the record in the main shapefile, expressed in words (16 bits).
this.recordsLengths.add(indexesByteBuffer.getInt()); // Length of this shapefile record.
}
-
+
log(Level.INFO, "log.index_has_been_read", this.shapeFileIndex.getAbsolutePath(), this.indexes.size(), this.getFile().getAbsolutePath());
return true;
}
@@ -180,6 +185,8 @@
log(Level.WARNING, "log.invalid_file_content_for_shapefile_index", this.shapeFileIndex.getAbsolutePath(), e.getMessage());
this.shapeFileIndex = null;
return false;
+ } finally {
+ fis.close();
}
}
catch(FileNotFoundException e) {
@@ -236,15 +243,15 @@
String message = format(Level.SEVERE, "excp.no_direct_access", getFile().getAbsolutePath());
throw new SQLNoDirectAccessAvailableException(message);
}
-
+
int position = this.indexes.get(recordNumber - 1) * 2; // Indexes unit are words (16 bits).
-
+
// Check that the asked record number is not after the last.
if (position >= this.getByteBuffer().capacity()) {
String message = format(Level.SEVERE, "excp.wrong_direct_access_after_last", recordNumber, getFile().getAbsolutePath());
throw new SQLInvalidRecordNumberForDirectAccessException(recordNumber, message);
}
-
+
try {
getByteBuffer().position(position);
}
@@ -253,7 +260,7 @@
throw new RuntimeException(message, e);
}
}
-
+
/**
* Complete a feature with shapefile content.
* @param feature Feature to complete.
@@ -321,23 +328,23 @@
// Handle multiple polygon parts.
if (numParts > 1) {
Logger log = Logging.getLogger(ShapefileByteReader.class.getName());
-
+
if (log.isLoggable(Level.FINER)) {
String format = "Polygon with multiple linear rings encountered at position {0,number} with {1,number} parts.";
String message = MessageFormat.format(format, getByteBuffer().position(), numParts);
log.finer(message);
}
-
+
poly = readMultiplePolygonParts(numParts, numPoints);
}
else {
// Polygon with an unique part.
poly = readUniquePolygonPart(numPoints);
}
-
+
feature.setPropertyValue(GEOMETRY_NAME, poly);
}
-
+
/**
* Read a polygon that has a unique part.
* @param numPoints Number of the points of the polygon.
@@ -346,7 +353,7 @@
@Deprecated // As soon as the readMultiplePolygonParts method proofs working well, this readUniquePolygonPart method can be removed and all calls be deferred to readMultiplePolygonParts.
private Polygon readUniquePolygonPart(int numPoints) {
/*int part = */ getByteBuffer().getInt();
-
+
Polygon poly = new Polygon();
// create a line from the points
@@ -360,10 +367,10 @@
ypnt = getByteBuffer().getDouble();
poly.lineTo(xpnt, ypnt);
}
-
+
return poly;
}
-
+
/**
* Read a polygon that has multiple parts.
* @param numParts Number of parts of this polygon.
@@ -371,8 +378,8 @@
* @return a multiple part polygon.
*/
private Polygon readMultiplePolygonParts(int numParts, int numPoints) {
- /**
- * From ESRI Specification :
+ /**
+ * From ESRI Specification :
* Parts : 0 5 (meaning : 0 designs the first v1, 5 designs the first v5 on the points list below).
* Points : v1 v2 v3 v4 v1 v5 v8 v7 v6 v5
*
@@ -382,10 +389,10 @@
* Byte 36 NumParts NumParts Integer 1 Little
* Byte 40 NumPoints NumPoints Integer 1 Little
* Byte 44 Parts Parts Integer NumParts Little
- * Byte X Points Points Point NumPoints Little
+ * Byte X Points Points Point NumPoints Little
*/
int[] partsIndexes = new int[numParts];
-
+
// Read all the parts indexes (starting at byte 44).
for(int index=0; index < numParts; index ++) {
partsIndexes[index] = getByteBuffer().getInt();
@@ -399,7 +406,7 @@
xPoints[index] = getByteBuffer().getDouble();
yPoints[index] = getByteBuffer().getDouble();
}
-
+
// Create the polygon from the points.
Polygon poly = new Polygon();
@@ -414,18 +421,18 @@
break;
}
}
-
+
if (newPolygon) {
- poly.startPath(xPoints[index], yPoints[index]);
+ poly.startPath(xPoints[index], yPoints[index]);
}
else {
- poly.lineTo(xPoints[index], yPoints[index]);
+ poly.lineTo(xPoints[index], yPoints[index]);
}
}
-
+
return poly;
}
-
+
/**
* Load polyline feature.
* @param feature Feature to fill.
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
index 7678216..5255ea4 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
@@ -22,9 +22,12 @@
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
-import java.util.Objects;
import java.util.logging.Level;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* The Abstract Byte Reader.
* @author Marc Le Bihan
@@ -185,7 +188,7 @@
*/
private String toCodePage(byte pageCodeBinaryValue) {
// From http://trac.osgeo.org/gdal/ticket/2864
- HashMap<Integer, String> knownConversions = new HashMap<>();
+ HashMap<Integer, String> knownConversions = new HashMap<Integer,String>();
knownConversions.put(0x01, "cp437"); // U.S. MS–DOS
knownConversions.put(0x02, "cp850"); // International MS–DOS
knownConversions.put(0x03, "cp1252"); // Windows ANSI
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java
index e1fadd7..e8d6861 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java
@@ -19,11 +19,14 @@
import java.io.*;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.AutoChecker;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* Common byte reader.
* @author Marc Le Bihan
@@ -33,7 +36,7 @@
* @since 0.5
* @module
*/
-public abstract class CommonByteReader<InvalidFormatException extends Exception, FNFException extends Exception> extends AutoChecker implements AutoCloseable {
+public abstract class CommonByteReader<InvalidFormatException extends Exception, FNFException extends Exception> extends AutoChecker {
/** The File. */
private File file;
@@ -95,7 +98,6 @@
* Close the MappedByteReader.
* @throws IOException if the close operation fails.
*/
- @Override
public void close() throws IOException {
if (this.fc != null)
this.fc.close();
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
index 198ffa7..b94d13b 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
@@ -20,13 +20,15 @@
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
-import java.util.Objects;
import java.util.Properties;
import java.util.logging.Logger;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.internal.system.Modules;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* Database driver for DBF 3.
@@ -138,7 +140,6 @@
/**
* The logger used by this driver.
*/
- @Override
public Logger getParentLogger() {
return super.getLogger();
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
index e4be43f..64c03f1 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
@@ -40,9 +40,9 @@
* @since 0.5
* @module
*/
-public class MappedByteReader extends AbstractDbase3ByteReader implements AutoCloseable {
+public class MappedByteReader extends AbstractDbase3ByteReader {
/** List of field descriptors. */
- private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<>();
+ private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<DBase3FieldDescriptor>();
/** Connection properties. */
private Properties info;
@@ -62,7 +62,6 @@
if (this.info != null) {
// Sometimes, DBF files have a wrong charset, or more often : none, and you have to specify it.
String recordCharset = (String)this.info.get("record_charset");
-
if (recordCharset != null) {
Charset cs = Charset.forName(recordCharset);
setCharset(cs);
@@ -111,7 +110,6 @@
boolean isEOF = (eofCheck == 0x1A);
this.log(Level.FINER, "log.delete_status", getRowNum(), eofCheck, isEOF ? "EOF" : "Active");
-
if (eofCheck == 0x1A) {
return false;
}
@@ -143,7 +141,7 @@
/* byte isDeleted = */ getByteBuffer().get(); // denotes whether deleted or current
// read first part of record
- HashMap<String, byte[]> fieldsValues = new HashMap<>();
+ HashMap<String, byte[]> fieldsValues = new HashMap<String, byte[]>();
for (DBase3FieldDescriptor fd : this.fieldsDescriptors) {
byte[] data = new byte[fd.getLength()];
@@ -151,7 +149,6 @@
// Trim the bytes right.
int length = data.length;
-
while (length != 0 && JDK8.toUnsignedInt(data[length - 1]) <= ' ') {
length--;
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
index 89d1845..caceb3b 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
@@ -68,7 +68,6 @@
/**
* Unsupported by default.
*/
- @Override
public String getSchema() throws SQLException {
throw unsupportedOperation("getSchema");
}
@@ -76,7 +75,6 @@
/**
* Unsupported by default.
*/
- @Override
public void setSchema(String schema) throws SQLException {
throw unsupportedOperation("setSchema");
}
@@ -395,7 +393,6 @@
/**
* Defaults to 0, which means there is no limit.
*/
- @Override
public int getNetworkTimeout() {
return 0; // Means there is no limt.
}
@@ -403,7 +400,6 @@
/**
* Unsupported by default.
*/
- @Override
public void setNetworkTimeout(Executor executor, int milliseconds) {
logUnsupportedOperation("setNetworkTimeout");
}
@@ -411,7 +407,6 @@
/**
* Unsupported by default.
*/
- @Override
public void abort(Executor executor) throws SQLException {
throw unsupportedOperation("abort");
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
index 6e7528c..b081f53 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
@@ -28,6 +28,9 @@
import org.apache.sis.internal.shapefile.jdbc.resultset.*;
import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* Connection to a DBF database.
@@ -41,7 +44,7 @@
final File databaseFile;
/** Opened statement. */
- private HashSet<DBFStatement> openedStatements = new HashSet<>();
+ private HashSet<DBFStatement> openedStatements = new HashSet<DBFStatement>();
/** ByteReader. */
private Dbase3ByteReader byteReader;
@@ -239,7 +242,7 @@
}
}
}
- catch(SQLNoResultException e) {
+ catch(java.sql.SQLException e) {
// if we run out of bound of the ResultSet, the boolean returned by next() has not been checked well, and it's an internal error.
rs.close();
throw new RuntimeException(e.getMessage(), e);
@@ -272,7 +275,7 @@
try {
rs.next();
}
- catch(SQLNoResultException e) {
+ catch(java.sql.SQLException e) {
// We encounter an internal API error in this case.
rs.close();
throw new RuntimeException(e.getMessage(), e);
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java
index 91d0f0d..fdf799d 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java
@@ -119,7 +119,7 @@
/**
* @see java.sql.DatabaseMetaData#getPseudoColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
- @Override public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
throw unsupportedOperation("getPseudoColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern);
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
index 931ed87..18f9d92 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
@@ -19,13 +19,16 @@
import java.io.File;
import java.sql.*;
import java.util.Arrays;
-import java.util.Objects;
import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.internal.shapefile.jdbc.resultset.*;
import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* Database Metadata.
* @author Marc LE BIHAN
@@ -73,8 +76,11 @@
*/
@Override
public ResultSet getColumns(@SuppressWarnings("unused") String catalog, @SuppressWarnings("unused") String schemaPattern, @SuppressWarnings("unused") String tableNamePattern, @SuppressWarnings("unused") String columnNamePattern) throws SQLConnectionClosedException {
- try(DBFStatement stmt = (DBFStatement)this.connection.createStatement()) {
+ DBFStatement stmt = (DBFStatement)this.connection.createStatement();
+ try {
return new DBFBuiltInMemoryResultSetForColumnsListing(stmt, this.connection.getFieldsDescriptors());
+ } finally {
+ stmt.close();
}
}
@@ -1286,7 +1292,7 @@
/**
* @see java.sql.DatabaseMetaData#generatedKeyAlwaysReturned()
*/
- @Override public boolean generatedKeyAlwaysReturned() {
+ public boolean generatedKeyAlwaysReturned() {
logStep("generatedKeyAlwaysReturned");
return false;
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
index f3ae694..fb51b54 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
@@ -20,7 +20,6 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
@@ -29,6 +28,10 @@
import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
import org.apache.sis.internal.shapefile.jdbc.resultset.*;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* ResultSet Metadata.
* @author Marc LE BIHAN
@@ -92,13 +95,16 @@
@Override public boolean isAutoIncrement(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("isAutoIncrement", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getString("TYPE_NAME").equals("AUTO_INCREMENT");
}
catch(SQLNoSuchFieldException e) {
// We encounter an internal API error in this case.
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -126,12 +132,15 @@
@Override public boolean isCurrency(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("isCurrency", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getString("TYPE_NAME").equals("CURRENCY");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -159,43 +168,47 @@
@Override public int getColumnDisplaySize(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnDisplaySize", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
- switch(rsDatabase.getString("TYPE_NAME")) {
- case "AUTO_INCREMENT":
- case "CHAR":
- case "INTEGER":
- return rsDatabase.getInt("COLUMN_SIZE");
-
- case "DATE":
- return 8;
-
- // Add decimal separator for decimal numbers.
- case "DOUBLE":
- case "FLOAT":
- case "DECIMAL":
- return rsDatabase.getInt("COLUMN_SIZE") + 1;
-
- case "BOOLEAN":
- return 5; // Translation for true, false, null.
-
- // Unhandled types default to field length.
- case "CURRENCY":
- case "DATETIME":
- case "TIMESTAMP":
- case "MEMO":
- case "PICTURE":
- case "VARIFIELD":
- case "VARIANT":
- case "UNKNOWN":
- return rsDatabase.getInt("COLUMN_SIZE");
-
- default:
- return rsDatabase.getInt("COLUMN_SIZE");
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
+ final String v = rsDatabase.getString("TYPE_NAME");
+ if (v.equals("AUTO_INCREMENT") ||
+ v.equals("CHAR") ||
+ v.equals("INTEGER"))
+ {
+ return rsDatabase.getInt("COLUMN_SIZE");
}
+ if (v.equals("DATE")) {
+ return 8;
+ }
+ if (v.equals("DOUBLE") ||
+ v.equals("FLOAT") ||
+ v.equals("DECIMAL"))
+ {
+ // Add decimal separator for decimal numbers.
+ return rsDatabase.getInt("COLUMN_SIZE") + 1;
+ }
+ if (v.equals("BOOLEAN")) {
+ return 5; // Translation for true, false, null.
+ }
+ if (v.equals("CURRENCY") ||
+ v.equals("DATETIME") ||
+ v.equals("TIMESTAMP") ||
+ v.equals("MEMO") ||
+ v.equals("PICTURE") ||
+ v.equals("VARIFIELD") ||
+ v.equals("VARIANT") ||
+ v.equals("UNKNOWN"))
+ {
+ // Unhandled types default to field length.
+ return rsDatabase.getInt("COLUMN_SIZE");
+ }
+ return rsDatabase.getInt("COLUMN_SIZE");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -207,12 +220,15 @@
@Override public String getColumnLabel(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnLabel", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getString("COLUMN_NAME");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -224,12 +240,15 @@
@Override public String getColumnName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnName", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getString("COLUMN_NAME");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -249,12 +268,15 @@
@Override public int getPrecision(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getPrecision", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getInt("COLUMN_SIZE");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_SIZE", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -266,12 +288,15 @@
@Override public int getScale(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getScale", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getInt("DECIMAL_DIGITS");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DECIMAL_DIGITS", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -304,12 +329,15 @@
@Override public int getColumnType(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnType", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getInt("DATA_TYPE");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DATA_TYPE", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -321,12 +349,15 @@
@Override public String getColumnTypeName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnTypeName", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
return rsDatabase.getString("TYPE_NAME");
}
catch(SQLNoSuchFieldException e) {
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -363,64 +394,65 @@
@Override public String getColumnClassName(int column) throws SQLFeatureNotSupportedException, SQLIllegalColumnIndexException, SQLConnectionClosedException {
logStep("getColumnClassName", column);
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
- switch(rsDatabase.getString("TYPE_NAME")) {
- case "AUTO_INCREMENT":
- return Integer.class.getName();
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+ try {
+ final String v = rsDatabase.getString("TYPE_NAME");
+ if (v.equals("AUTO_INCREMENT"))
+ return Integer.class.getName();
- case "CHAR":
- return String.class.getName();
+ if (v.equals("CHAR"))
+ return String.class.getName();
- case "INTEGER":
- return Integer.class.getName();
+ if (v.equals("INTEGER"))
+ return Integer.class.getName();
- case "DATE":
- return java.sql.Date.class.getName();
+ if (v.equals("DATE"))
+ return java.sql.Date.class.getName();
- case "DOUBLE":
- return Double.class.getName();
+ if (v.equals("DOUBLE"))
+ return Double.class.getName();
- case "FLOAT":
- return Float.class.getName();
+ if (v.equals("FLOAT"))
+ return Float.class.getName();
- case "DECIMAL":
- return Double.class.getName();
+ if (v.equals("DECIMAL"))
+ return Double.class.getName();
- case "BOOLEAN":
- return Boolean.class.getName();
+ if (v.equals("BOOLEAN"))
+ return Boolean.class.getName();
- case "CURRENCY":
- return Double.class.getName();
+ if (v.equals("CURRENCY"))
+ return Double.class.getName();
- case "DATETIME":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
+ if (v.equals("DATETIME"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
- case "TIMESTAMP":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
+ if (v.equals("TIMESTAMP"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
- case "MEMO":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
+ if (v.equals("MEMO"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
- case "PICTURE":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
+ if (v.equals("PICTURE"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
- case "VARIFIELD":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
+ if (v.equals("VARIFIELD"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
- case "VARIANT":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
+ if (v.equals("VARIANT"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
- case "UNKNOWN":
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
+ if (v.equals("UNKNOWN"))
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
- default:
- throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
- }
+ throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
}
catch(SQLNoSuchFieldException e) {
// We encounter an internal API error in this case.
String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
throw new RuntimeException(message, e);
+ } finally {
+ rsDatabase.close();
}
}
@@ -460,7 +492,7 @@
try {
rsDatabase.next();
}
- catch(SQLNoResultException e) {
+ catch(java.sql.SQLException e) {
// We encounter an internal API error in this case.
rsDatabase.close();
String message = format(Level.SEVERE, "assert.less_column_in_metadata_than_expected", column, getColumnCount());
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
index 2c332ed..8b0a6d7 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
@@ -289,7 +289,6 @@
/**
* Unsupported by default.
*/
- @Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw unsupportedOperation("getObject", columnIndex, type);
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
index de9a111..b9270a3 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
@@ -60,23 +60,23 @@
@Override public String getString(String columnLabel) throws SQLNoSuchFieldException {
logStep("getString", columnLabel);
- switch(columnLabel) {
+ { // On the JDK7 branch, this is a switch on strings.
// String => table name
- case "TABLE_NAME": {
+ if (columnLabel.equals("TABLE_NAME")) {
String tableName = getTableName();
this.wasNull = (tableName == null);
return tableName;
}
// String => column name
- case "COLUMN_NAME": {
+ else if (columnLabel.equals("COLUMN_NAME")) {
String columnName = this.current.getName();
this.wasNull = (columnName == null);
return columnName;
}
// String => Data source dependent type name, for a UDT the type name is fully qualified
- case "TYPE_NAME": {
+ else if (columnLabel.equals("TYPE_NAME")) {
String typeName = this.current.getType() != null ? toColumnTypeName() : null;
this.wasNull = (typeName == null);
return typeName;
@@ -88,42 +88,43 @@
*/
// String => table catalog (may be null)
- case "TABLE_CAT": {
+ else if (columnLabel.equals("TABLE_CAT")) {
this.wasNull = true;
return null;
}
// String => table schema (may be null)
- case "TABLE_SCHEM": {
+ else if (columnLabel.equals("TABLE_SCHEM")) {
this.wasNull = true;
return null;
}
// String => comment describing column (may be null)
- case "REMARKS":
+ else if (columnLabel.equals("REMARKS")) {
this.wasNull = true;
return null;
+ }
// String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null)
- case "COLUMN_DEF": {
+ else if (columnLabel.equals("COLUMN_DEF")) {
this.wasNull = true;
return null;
}
// String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
- case "SCOPE_CATALOG": {
+ else if (columnLabel.equals("SCOPE_CATALOG")) {
this.wasNull = true;
return null;
}
// String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
- case "SCOPE_SCHEMA": {
+ else if (columnLabel.equals("SCOPE_SCHEMA")) {
this.wasNull = true;
return null;
}
// String => table name that this the scope of a reference attribute (null if the DATA_TYPE isn't REF)
- case "SCOPE_TABLE": {
+ else if (columnLabel.equals("SCOPE_TABLE")) {
this.wasNull = true;
return null;
}
@@ -134,7 +135,7 @@
* NO --- if the column is not auto incremented
* empty string --- if it cannot be determined whether the column is auto incremented
*/
- case "IS_AUTOINCREMENT": {
+ else if (columnLabel.equals("IS_AUTOINCREMENT")) {
this.wasNull = false;
return "NO";
}
@@ -145,12 +146,12 @@
* NO --- if this not a generated column
* empty string --- if it cannot be determined whether this is a generated column
*/
- case "IS_GENERATEDCOLUMN": {
+ else if (columnLabel.equals("IS_GENERATEDCOLUMN")) {
this.wasNull = false;
return "NO";
}
- default: {
+ else {
// Attempt to load it from an Integer column and convert it.
int value = getInt(columnLabel);
return MessageFormat.format("{0,number,#0}", value); // Remove decimal separators.
@@ -165,28 +166,28 @@
@Override public int getInt(String columnLabel) throws SQLNoSuchFieldException {
logStep("getInt", columnLabel);
- switch(columnLabel) {
+ { // On the JDK7 branch, this is a switch on strings.
// int => SQL type from java.sql.Types
- case "DATA_TYPE": {
+ if (columnLabel.equals("DATA_TYPE")) {
this.wasNull = false;
return toSQLDataType();
}
// int => column size.
- case "COLUMN_SIZE": {
+ else if (columnLabel.equals("COLUMN_SIZE")) {
this.wasNull = false;
return toPrecision();
}
// int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.
- case "DECIMAL_DIGITS": {
+ else if (columnLabel.equals("DECIMAL_DIGITS")) {
int scale = toScale();
this.wasNull = toScale() == -1;
return scale == -1 ? 0 : scale;
}
// int => Radix (typically either 10 or 2)
- case "NUM_PREC_RADIX": {
+ else if (columnLabel.equals("NUM_PREC_RADIX")) {
return 10;
}
@@ -196,19 +197,19 @@
* columnNullable - definitely allows NULL values
* columnNullableUnknown - nullability unknown
*/
- case "NULLABLE": {
+ else if (columnLabel.equals("NULLABLE")) {
this.wasNull = false;
return DatabaseMetaData.columnNullableUnknown;
}
// int => unused
- case "SQL_DATA_TYPE": {
+ else if (columnLabel.equals("SQL_DATA_TYPE")) {
this.wasNull = false;
return toSQLDataType();
}
// int => for char types the maximum number of bytes in the column
- case "CHAR_OCTET_LENGTH": {
+ else if (columnLabel.equals("CHAR_OCTET_LENGTH")) {
if (toSQLDataType() == Types.CHAR) {
return toPrecision();
}
@@ -217,7 +218,7 @@
}
// int => index of column in table (starting at 1)
- case "ORDINAL_POSITION": {
+ else if (columnLabel.equals("ORDINAL_POSITION")) {
return this.columnIndex;
}
@@ -227,29 +228,30 @@
*/
// short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
- case "SOURCE_DATA_TYPE": {
+ else if (columnLabel.equals("SOURCE_DATA_TYPE")) {
this.wasNull = true;
return 0;
}
// is not used.
- case "BUFFER_LENGTH": {
+ else if (columnLabel.equals("BUFFER_LENGTH")) {
this.wasNull = false;
return 0;
}
// int => unused
- case "SQL_DATETIME_SUB": {
+ else if (columnLabel.equals("SQL_DATETIME_SUB")) {
this.wasNull = false;
return 0;
}
- default:
+ else {
// FIXME : this function is not perfect. It a column label is given that refers to a field described in getString(..) this function
// will tell that the field doesn't exist. It's not true : the field is not numeric. But as getString(..) defaults to getInt(...),
// getInt(..) cannot default to getString(..), else the function will run in a cycle.
String message = format(Level.WARNING, "excp.no_desc_field", columnLabel, getTableName());
throw new SQLNoSuchFieldException(message, "asking columns desc", getFile(), columnLabel);
+ }
}
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
index 6b0cb60..cee1273 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
@@ -42,32 +42,35 @@
@Override public String getString(String columnLabel) {
logStep("getString", columnLabel);
- switch(columnLabel) {
- case "TABLE_NAME": // String => table name.
+ { // On the JDK7 branch, this is a switch on strings.
+ if (columnLabel.equals("TABLE_NAME")) // String => table name.
{
String tableName = getTableName();
this.wasNull = (tableName == null);
return tableName;
}
- case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+ else if (columnLabel.equals("TABLE_TYPE")) { // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
this.wasNull = false;
return "TABLE";
+ }
- case "TYPE_NAME": // String => type name (may be null)
- case "TABLE_CAT": // String => table catalog (may be null)
- case "TABLE_SCHEM": // String => table schema (may be null)
- case "REMARKS": // String => explanatory comment on the table
- case "TYPE_CAT": // String => the types catalog (may be null)
- case "TYPE_SCHEM": // String => the types schema (may be null)
- case "SELF_REFERENCING_COL_NAME": // String => name of the designated "identifier" column of a typed table (may be null)
- case "REF_GENERATION": // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
+ else if (columnLabel.equals("TYPE_NAME") // String => type name (may be null)
+ || columnLabel.equals("TABLE_CAT") // String => table catalog (may be null)
+ || columnLabel.equals("TABLE_SCHEM") // String => table schema (may be null)
+ || columnLabel.equals("REMARKS") // String => explanatory comment on the table
+ || columnLabel.equals("TYPE_CAT") // String => the types catalog (may be null)
+ || columnLabel.equals("TYPE_SCHEM") // String => the types schema (may be null)
+ || columnLabel.equals("SELF_REFERENCING_COL_NAME") // String => name of the designated "identifier" column of a typed table (may be null)
+ || columnLabel.equals("REF_GENERATION")) { // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
this.wasNull = true;
return null;
+ }
- default:
+ else {
this.wasNull = true;
return null;
+ }
}
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
index 60676c9..4c73ac3 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
@@ -42,18 +42,21 @@
@Override public String getString(String columnLabel) {
logStep("getString", columnLabel);
- switch(columnLabel) {
- case "OBJECTID": // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
+ { // On the JDK7 branch, this is a switch on strings.
+ if (columnLabel.equals("OBJECTID")) { // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
this.wasNull = false;
return "1";
+ }
- case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+ else if (columnLabel.equals("TABLE_TYPE")) { // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
this.wasNull = false;
return "TABLE"; // and DBase 3 only knows tables.
+ }
- default:
+ else {
this.wasNull = true;
return null;
+ }
}
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
index 513218f..93034e8 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
@@ -51,10 +51,10 @@
/** Indicates that the last result set record matching conditions has already been returned, and a further call of next() shall throw a "no more record" exception. */
private boolean lastResultSetRecordAlreadyReturned;
-
+
/** The record number of this record. */
private int recordNumber;
-
+
/**
* Constructs a result set.
* @param stmt Parent statement.
@@ -79,7 +79,8 @@
assertNotClosed();
// Act as if we were a double, but store the result in a pre-created BigDecimal at the end.
- try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) {
+ final DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql);
+ try {
MathContext mc = new MathContext(field.getInt("DECIMAL_DIGITS"), RoundingMode.HALF_EVEN);
Double doubleValue = getDouble(columnLabel);
@@ -92,6 +93,8 @@
this.wasNull = true;
return null;
}
+ } finally {
+ field.close();
}
}
@@ -338,7 +341,8 @@
*/
@Override
public Object getObject(int column) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
- try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql)) {
+ DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql);
+ try {
String fieldType;
try {
@@ -349,18 +353,18 @@
throw new RuntimeException(e.getMessage(), e);
}
- switch(fieldType) {
- case "AUTO_INCREMENT":
- case "INTEGER":
+ { // On the JDK7 branch, this is a switch on strings.
+ if (fieldType.equals("AUTO_INCREMENT") ||
+ fieldType.equals("INTEGER"))
return getInt(column);
- case "CHAR":
+ else if (fieldType.equals("CHAR"))
return getString(column);
- case "DATE":
+ else if (fieldType.equals("DATE"))
return getDate(column);
- case "DECIMAL": {
+ else if (fieldType.equals("DECIMAL")) {
// Choose Integer or Long type, if no decimal and that the field is not to big.
if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
if (field.getInt("COLUMN_SIZE") <= 9)
@@ -372,40 +376,42 @@
return getDouble(column);
}
- case "DOUBLE":
- case "CURRENCY":
+ else if (fieldType.equals("DOUBLE")
+ || fieldType.equals("CURRENCY"))
return getDouble(column);
- case "FLOAT":
+ else if (fieldType.equals("FLOAT"))
return getFloat(column);
- case "BOOLEAN":
+ else if (fieldType.equals("BOOLEAN"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Boolean");
- case "DATETIME":
+ else if (fieldType.equals("DATETIME"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
- case "TIMESTAMP":
+ else if (fieldType.equals("TIMESTAMP"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
- case "MEMO":
+ else if (fieldType.equals("MEMO"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
- case "PICTURE":
+ else if (fieldType.equals("PICTURE"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
- case "VARIFIELD":
+ else if (fieldType.equals("VARIFIELD"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
- case "VARIANT":
+ else if (fieldType.equals("VARIANT"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
- case "UNKNOWN":
+ else if (fieldType.equals("UNKNOWN"))
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
- default:
+ else
throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
}
+ } finally {
+ field.close();
}
}
@@ -415,7 +421,7 @@
@Override
public Object getObject(String columnLabel) throws SQLConnectionClosedException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
int index = -1;
-
+
try {
index = findColumn(columnLabel);
return getObject(index);
@@ -433,7 +439,7 @@
public int getRowNum() {
return this.recordNumber;
}
-
+
/**
* @see java.sql.ResultSet#getShort(java.lang.String)
* @throws SQLConnectionClosedException if the connection is closed.
@@ -492,7 +498,7 @@
// If a non null value has been readed, convert it to the wished Charset (provided one has been given).
DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection();
Charset charset = cnt.getCharset();
-
+
if (charset == null) {
return new String(bytes);
}
@@ -603,9 +609,10 @@
private <T extends Number> T getNumeric(String columnLabel, Function<String, T> parse) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
assertNotClosed();
- try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql);
+ try {
String textValue = getString(columnLabel);
-
+
if (textValue == null) {
return null;
}
@@ -619,6 +626,8 @@
String message = format(Level.WARNING, "excp.field_is_not_numeric", columnLabel, rs.getString("TYPE_NAME"), this.sql, textValue);
throw new SQLNotNumericException(message, this.sql, getFile(), columnLabel, textValue);
}
+ } finally {
+ rs.close();
}
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
index 1e664a5..9dffaaa 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
@@ -24,13 +24,16 @@
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* Common implemented features of all ResultSets : those based on a record, but also those returning results forged in memory.
* @author Marc LE BIHAN
@@ -372,7 +375,6 @@
* Defaults to the index-based version of this method.
* The given column name is mapped to a column index by {@link #findColumn(String)}.
*/
- @Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
return getObject(findColumn(columnLabel), type);
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
index b06891f..adbd71b 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.shapefile.jdbc.sql;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.AutoChecker;
@@ -25,6 +24,7 @@
// Branch-dependent imports
import org.apache.sis.internal.jdk8.Function;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.util.Numbers;
@@ -116,26 +116,24 @@
* @throws SQLConnectionClosedException if the connection is closed.
*/
public boolean isVerified(DBFRecordBasedResultSet rs) throws SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException {
- switch(getOperator()) {
- case "=" :
- return compare(rs) == 0;
+ final String v = getOperator();
+ if (v.equals("="))
+ return compare(rs) == 0;
- case ">" :
- return compare(rs) > 0;
+ if (v.equals(">"))
+ return compare(rs) > 0;
- case ">=" :
- return compare(rs) >= 0;
+ if (v.equals(">="))
+ return compare(rs) >= 0;
- case "<" :
- return compare(rs) < 0;
+ if (v.equals("<"))
+ return compare(rs) < 0;
- case "<=" :
- return compare(rs) <= 0;
+ if (v.equals("<="))
+ return compare(rs) <= 0;
- default :
- String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
- throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
- }
+ String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
+ throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
}
/**
@@ -311,8 +309,11 @@
}
else {
// The string designs a field name, return its value.
- try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL())) {
+ DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL());
+ try {
return valueOf(rs, field);
+ } finally {
+ field.close();
}
}
}
@@ -331,52 +332,51 @@
private Object valueOf(DBFRecordBasedResultSet rs, DBFBuiltInMemoryResultSetForColumnsListing field) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLUnsupportedParsingFeatureException, SQLNotDateException {
String columnName = field.getString("COLUMN_NAME");
- switch(field.getString("TYPE_NAME")) {
- case "AUTO_INCREMENT":
- return rs.getInt(columnName);
+ final String v = field.getString("TYPE_NAME");
+ if (v.equals("AUTO_INCREMENT"))
+ return rs.getInt(columnName);
- case "CHAR":
- return rs.getString(columnName);
+ if (v.equals("CHAR"))
+ return rs.getString(columnName);
- case "INTEGER":
- return rs.getInt(columnName);
+ if (v.equals("INTEGER"))
+ return rs.getInt(columnName);
- case "DATE":
- return rs.getDate(columnName);
+ if (v.equals("DATE"))
+ return rs.getDate(columnName);
- case "DOUBLE":
- return rs.getDouble(columnName);
+ if (v.equals("DOUBLE"))
+ return rs.getDouble(columnName);
- case "FLOAT":
- return rs.getFloat(columnName);
+ if (v.equals("FLOAT"))
+ return rs.getFloat(columnName);
- case "DECIMAL": {
- // Choose Integer or Long type, if no decimal and that the field is not to big.
- if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
- if (field.getInt("COLUMN_SIZE") <= 9)
- return rs.getInt(columnName);
- else
- return rs.getLong(columnName);
- }
-
- return rs.getDouble(columnName);
+ if (v.equals("DECIMAL")) {
+ // Choose Integer or Long type, if no decimal and that the field is not to big.
+ if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
+ if (field.getInt("COLUMN_SIZE") <= 9)
+ return rs.getInt(columnName);
+ else
+ return rs.getLong(columnName);
}
- case "BOOLEAN":
- case "CURRENCY":
- case "DATETIME":
- case "TIMESTAMP":
- case "MEMO":
- case "PICTURE":
- case "VARIFIELD":
- case "VARIANT":
- case "UNKNOWN":
- String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
- throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
-
- default:
- throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
+ return rs.getDouble(columnName);
}
+
+ if (v.equals("BOOLEAN") ||
+ v.equals("CURRENCY") ||
+ v.equals("DATETIME") ||
+ v.equals("TIMESTAMP") ||
+ v.equals("MEMO") ||
+ v.equals("PICTURE") ||
+ v.equals("VARIFIELD") ||
+ v.equals("VARIANT") ||
+ v.equals("UNKNOWN"))
+ {
+ String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
+ throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
+ }
+ throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
}
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
index 6e9785e..12334b6 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
@@ -17,12 +17,15 @@
package org.apache.sis.internal.shapefile.jdbc.sql;
import java.io.File;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
/**
* Simple and temporary SQL parser.
* @author Marc LE BIHAN
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
index 1374a02..f20d27c 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
@@ -293,7 +293,6 @@
/**
* Unsupported by default.
*/
- @Override
public void closeOnCompletion() throws SQLException {
throw unsupportedOperation("closeOnCompletion");
}
@@ -301,7 +300,6 @@
/**
* Unsupported by default.
*/
- @Override
public boolean isCloseOnCompletion() throws SQLException {
throw unsupportedOperation("isCloseOnCompletion");
}
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
index 7355aef..f11c4e1 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
@@ -20,7 +20,6 @@
import java.sql.*;
import java.text.MessageFormat;
import java.util.HashSet;
-import java.util.Objects;
import java.util.logging.Level;
import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
@@ -29,6 +28,9 @@
import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* DBF Statement.
@@ -42,7 +44,7 @@
private DBFConnection connection;
/** ResultSets that are currently opened. */
- private HashSet<DBFResultSet> openedResultSets = new HashSet<>();
+ private HashSet<DBFResultSet> openedResultSets = new HashSet<DBFResultSet>();
/** The current result set, or {@code null} if none. */
private DBFResultSet currentResultSet;
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
index c93eb84..35eebc0 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
@@ -51,10 +51,10 @@
public class InputFeatureStream extends InputStream {
/** Logger. */
private static Logger LOGGER = Logging.getLogger(InputFeatureStream.class.getSimpleName());
-
+
/** Resource bundle. */
private ResourceBundle rsc = ResourceBundle.getBundle(InputFeatureStream.class.getName());
-
+
/** Dedicated connection to DBF. */
private DBFConnection connection;
@@ -75,12 +75,12 @@
/** Database file. */
private File databaseFile;
-
+
/** Shapefile index. */
private File shapefileIndex;
-
+
/** Indicates that the shape file has a valid index provided with it. */
- private boolean hasShapefileIndex;
+ private boolean hasShapefileIndex;
/** Type of the features contained in this shapefile. */
private DefaultFeatureType featuresType;
@@ -102,17 +102,17 @@
public InputFeatureStream(File shpfile, File dbaseFile, File shpfileIndex, String sqlStatement) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
try {
this.connection = (DBFConnection)new DBFDriver().connect(dbaseFile.getAbsolutePath(), null);
-
+
if (sqlStatement == null) {
this.sql = MessageFormat.format("SELECT * FROM {0}", dbaseFile.getName());
}
else {
this.sql = sqlStatement;
}
-
+
this.shapefile = shpfile;
this.databaseFile = dbaseFile;
-
+
if (shpfileIndex != null && (shpfileIndex.exists() && shpfileIndex.isFile())) {
this.shapefileIndex = shpfileIndex;
this.hasShapefileIndex = true;
@@ -120,10 +120,10 @@
else {
this.hasShapefileIndex = false;
}
-
+
this.shapefileReader = new ShapefileByteReader(this.shapefile, this.databaseFile, this.shapefileIndex);
this.featuresType = this.shapefileReader.getFeaturesType();
-
+
try {
executeQuery();
}
@@ -149,7 +149,7 @@
throw new ShapefileNotFoundException(ex.getMessage(), ex);
}
}
-
+
/**
* Create an input stream of features over a connection, responding to a SELECT * FROM DBF statement.
* @param shpfile Shapefile.
@@ -176,7 +176,7 @@
public InputFeatureStream(File shpfile, File dbaseFile) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
this(shpfile, dbaseFile, null);
}
-
+
/**
* @see java.io.InputStream#read()
*/
@@ -218,17 +218,17 @@
catch(SQLConnectionClosedException e) {
throw new DataStoreClosedException(e.getMessage(), e);
}
- catch(SQLInvalidStatementException | SQLIllegalParameterException | SQLNoSuchFieldException | SQLUnsupportedParsingFeatureException | SQLFeatureNotSupportedException e) {
- throw new DataStoreQueryException(e.getMessage(), e);
- }
- catch(SQLNotNumericException | SQLNotDateException e) {
+ catch(SQLNotNumericException e) {
throw new DataStoreQueryResultException(e.getMessage(), e);
}
- catch(SQLNoDirectAccessAvailableException e) {
+ catch(SQLNotDateException e) {
+ throw new DataStoreQueryResultException(e.getMessage(), e);
+ }
+ catch(java.sql.SQLException e) {
throw new DataStoreQueryException(e.getMessage(), e);
}
}
-
+
/**
* Return the features type.
* @return Features type.
@@ -236,7 +236,7 @@
public DefaultFeatureType getFeaturesType() {
return this.featuresType;
}
-
+
/**
* Returns the shapefile descriptor.
* @return Shapefile descriptor.
@@ -244,15 +244,15 @@
public ShapefileDescriptor getShapefileDescriptor() {
return this.shapefileReader.getShapefileDescriptor();
}
-
- /**
+
+ /**
* Returns the database fields descriptors.
- * @return List of fields descriptors.
+ * @return List of fields descriptors.
*/
public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
return this.shapefileReader.getFieldsDescriptors();
}
-
+
/**
* Checks if the shapefile has an index provided with it.
* @return true if an index file (.shx) has been given with the shapefile.
@@ -260,7 +260,7 @@
public boolean hasShapefileIndex() {
return this.hasShapefileIndex;
}
-
+
/**
* Read next feature responding to the SQL query.
* @return Feature, null if no more feature is available.
@@ -282,24 +282,24 @@
}
int previousRecordNumber = this.rs.getRowNum();
-
+
if (this.rs.next() == false) {
this.endOfFile = true;
return null;
}
-
+
int currentRecordNumber = this.rs.getRowNum();
-
+
// On the shapefile, only jump in another place if a direct access is needed.
boolean directAccesRequired = currentRecordNumber != (previousRecordNumber + 1);
-
+
if (directAccesRequired) {
try {
if (LOGGER.isLoggable(Level.FINER)) {
MessageFormat format = new MessageFormat(this.rsc.getString("log.shapefile_reading_with_direct_access"));
LOGGER.finer(format.format(new Object[] {previousRecordNumber, currentRecordNumber}));
}
-
+
this.shapefileReader.setRowNum(currentRecordNumber);
}
catch(SQLInvalidRecordNumberForDirectAccessException e) {
@@ -313,12 +313,13 @@
LOGGER.finer(format.format(new Object[] {previousRecordNumber, currentRecordNumber}));
}
}
-
+
Feature feature = this.featuresType.newInstance();
this.shapefileReader.completeFeature(feature);
DBFDatabaseMetaData metadata = (DBFDatabaseMetaData)this.connection.getMetaData();
- try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null)) {
+ DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null);
+ try {
while(rsDatabase.next()) {
String fieldName = rsDatabase.getString("COLUMN_NAME");
Object fieldValue = this.rs.getObject(fieldName);
@@ -350,9 +351,11 @@
return feature;
}
- catch(SQLNoResultException e) {
+ catch(java.sql.SQLException e) {
// This an internal trouble, if it occurs.
throw new RuntimeException(e.getMessage(), e);
+ } finally {
+ rsDatabase.close();
}
}
catch(SQLNoResultException e) {
diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
index d11c178..7b6b5ba 100644
--- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
+++ b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
@@ -18,7 +18,7 @@
import java.io.File;
import java.util.List;
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.feature.DefaultFeatureType;
import org.apache.sis.internal.shapefile.ShapefileDescriptor;
@@ -50,10 +50,10 @@
/** Shapefile descriptor. */
private ShapefileDescriptor shapefileDescriptor;
-
+
/** Database field descriptors. */
private List<DBase3FieldDescriptor> databaseFieldsDescriptors;
-
+
/**
* Construct a Shapefile from a file.
* @param shpfile file to read.
@@ -119,7 +119,7 @@
public DefaultFeatureType getFeaturesType() {
return this.featuresType;
}
-
+
/**
* Returns the shapefile descriptor.
* @return Shapefile descriptor.
@@ -127,10 +127,10 @@
public ShapefileDescriptor getShapefileDescriptor() {
return this.shapefileDescriptor;
}
-
- /**
+
+ /**
* Returns the database fields descriptors.
- * @return List of fields descriptors.
+ * @return List of fields descriptors.
*/
public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
return this.databaseFieldsDescriptors;
@@ -200,7 +200,7 @@
public void loadDescriptors() throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
// Doing an simple query will init the internal descriptors.
// It prepares a SELECT * FROM <DBase> but don't read a record by itself.
- try(InputFeatureStream is = findAll()) {
- }
+ InputFeatureStream is = findAll();
+ is.close();
}
}
diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
index e51038e..c8358f2 100644
--- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
+++ b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
@@ -44,13 +44,20 @@
*/
@Test
public void readFirstRecord() throws SQLException {
- try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+ Connection connection = connect();
+ Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+ try {
rs.next();
assertEquals("getString(\"ST_NAME\")", "36TH ST", rs.getString("ST_NAME")); // ST_NAME Character(29)
assertEquals("getInt(\"FNODE_\")", 1199, rs.getInt("FNODE_")); // FNODE_ Number(10, 0)
assertEquals("getDouble(\"SHAPE_LEN\")", 43.0881492571, rs.getDouble("SHAPE_LEN"), 0.1); // SHAPE_LEN Number(19, 11)
assertEquals("getBigDecimal(\"SHAPE_LEN\")", 43.0881492571, rs.getBigDecimal("SHAPE_LEN").doubleValue(), 0.1); // SHAPE_LEN Number(19, 11)
assertEquals("getDate(\"TR_DATE\")", null, rs.getDate("TR_DATE")); // TR_DATE Date(8)
+ } finally {
+ rs.close();
+ stmt.close();
+ connection.close();
}
}
@@ -61,11 +68,14 @@
@Test
@DependsOnMethod("readFirstRecord")
public void readAllRecords() throws SQLException {
- try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+ Connection connection = connect();
+ Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+ try {
int count = 0;
while(rs.next()) {
- ArrayList<Object> record = new ArrayList<>();
+ ArrayList<Object> record = new ArrayList<Object>();
record.add(rs.getLong("OBJECTID")); // Type : Number, Field length : 10, Decimal positions : 0
record.add(rs.getLong("FNODE_")); // Type : Number, Field length : 10, Decimal positions : 0
@@ -130,6 +140,10 @@
}
assertTrue("Less than one record was readed.", count > 1);
+ } finally {
+ rs.close();
+ stmt.close();
+ connection.close();
}
}
@@ -141,8 +155,9 @@
public void resultSetClosed() throws SQLException {
// 1) Open a connection, open a statement, open and close a ResultSet.
String sql = "SELECT * FROM SignedBikeRoute";
-
- try(Connection connection = connect(); Statement stmt = connection.createStatement()) {
+ Connection connection = connect();
+ Statement stmt = connection.createStatement();
+ try {
// Then, attempt to use it.
try {
ResultSet rs = stmt.executeQuery(sql);
@@ -155,11 +170,14 @@
catch(SQLException e) {
fail("Not the expected exception for using a closed ResultSet.");
}
+ } finally {
+ stmt.close();
+ connection.close();
}
// 2) Same, but we close the connection instead.
- Connection connection = connect();
- Statement stmt = connection.createStatement();
+ connection = connect();
+ stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement and one ResultSet still opened.
@@ -180,7 +198,8 @@
}
// 3) Same, but we close the statement instead .
- try(Connection cnt = connect()) {
+ Connection cnt = connect();
+ try {
stmt = cnt.createStatement();
rs = stmt.executeQuery(sql);
@@ -200,6 +219,8 @@
rs.close();
stmt.close();
}
+ } finally {
+ cnt.close();
}
}
}
diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
index 0eb9d46..b4ae70f 100644
--- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
+++ b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
@@ -41,12 +41,15 @@
public void openCloseStatement() throws SQLException {
final Driver driver = new DBFDriver();
- try(Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null)) {
+ Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null);
+ try {
final Statement stmt = connection.createStatement();
assertFalse("Statement should be opened", stmt.isClosed());
stmt.close();
assertTrue ("Statement should be closed", stmt.isClosed());
+ } finally {
+ connection.close();
}
}
@@ -58,7 +61,8 @@
@DependsOnMethod("openCloseStatement")
public void statementClosed() throws SQLException {
// Open a connection, open and close a statement.
- try(Connection connection = connect()) {
+ Connection connection = connect();
+ try {
final Statement stmt = connection.createStatement();
stmt.close();
@@ -72,10 +76,12 @@
catch(SQLException e) {
fail("Not the expected exception for using a closed statement.");
}
+ } finally {
+ connection.close();
}
// Same, but we close the connection instead.
- Connection connection = connect();
+ connection = connect();
final Statement stmt = connection.createStatement();
connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement still opened.
diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
index e2a0dd5..3fce1c2 100644
--- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
+++ b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
@@ -36,7 +36,10 @@
*/
@Test
public void operators() throws SQLException {
- try(Connection connection = connect(); Statement stmt = connection.createStatement(); DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+ Connection connection = connect();
+ Statement stmt = connection.createStatement();
+ DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+ try {
rs.next();
assertTrue("FNODE_ = 1199", new ConditionalClauseResolver("FNODE_", 1199L, "=").isVerified(rs));
@@ -60,6 +63,10 @@
assertTrue("SHAPE_LEN = 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "=").isVerified(rs));
assertTrue("SHAPE_LEN > 43.088", new ConditionalClauseResolver("SHAPE_LEN", 43.088, ">").isVerified(rs));
assertFalse("SHAPE_LEN < 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "<").isVerified(rs));
+ } finally {
+ rs.close();
+ stmt.close();
+ connection.close();
}
}
@@ -140,7 +147,10 @@
private void checkAndCount(String whereCondition, ResultSetPredicate<ResultSet> condition, int countExpected) throws SQLException {
String sql = "SELECT * FROM SignedBikeRoute WHERE " + whereCondition;
- try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
+ Connection connection = connect();
+ Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(sql);
+ try {
int count = 0;
while(rs.next()) {
@@ -150,6 +160,10 @@
if (countExpected != -1)
assertEquals("Wrong number of records red by : " + sql, countExpected, count);
+ } finally {
+ rs.close();
+ stmt.close();
+ connection.close();
}
}
}
diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
index c75d7ac..aa02097 100644
--- a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
+++ b/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
@@ -84,30 +84,30 @@
}
/**
- * Test loading of shapefile descriptors.
+ * Test loading of shapefile descriptors.
* @throws URISyntaxException if the resource name is incorrect.
* @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
public void testDescriptors() throws URISyntaxException, DataStoreException {
Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
-
+
ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
shp.loadDescriptors();
-
+
assertNotNull("The features type of the shapefile should have been set.", shp.getFeaturesType());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp features type : {0}", shp.getFeaturesType()));
-
+
assertNotNull("The shapefile descriptor of the shapefile should have been set.", shp.getShapefileDescriptor());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp shapefile descriptor : {0}", shp.getShapefileDescriptor()));
assertNotNull("The DBase III fields descriptors of the shapefile should have been set.", shp.getDatabaseFieldsDescriptors());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp DBase fields descriptors : {0}", shp.getDatabaseFieldsDescriptors()));
-
+
// Loading of the descriptor shall not prevent the shapefile from being red again.
readAll(shp);
}
-
+
/**
* Checks that the reader is able to detect EoF signs in the DBase file.
* @throws URISyntaxException if the resource name is incorrect.
@@ -120,7 +120,8 @@
Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
- try(InputFeatureStream is = shp.findAll()) {
+ InputFeatureStream is = shp.findAll();
+ try {
Feature feature = is.readFeature();
// Read and retain the first and the last feature.
@@ -128,7 +129,7 @@
if (first == null) {
first = feature;
}
-
+
// Advice : To debug just before the last record, put a conditional breakpoint on department name "MEURTHE-ET-MOSELLE".
String deptName = (String)feature.getProperty("NOM_DEPT").getValue();
log.info(deptName);
@@ -136,69 +137,80 @@
last = feature;
feature = is.readFeature();
}
+ } finally {
+ is.close();
}
-
+
assertNotNull("No record has been found in the DBase file or Shapefile.", first);
assertNotNull("This test is not working well : last feature should always be set if any feature has been found.", last);
assertEquals("The first record red must be JURA department.", "JURA", first.getProperty("NOM_DEPT").getValue());
assertEquals("The last record red must be DEUX-SEVRES department.", "DEUX-SEVRES", last.getProperty("NOM_DEPT").getValue());
}
-
+
/**
* Testing direct access in the shapefile.
* @throws URISyntaxException if the resource name is incorrect.
* @throws DataStoreException if a general file reading trouble occurs.
*/
- @Test
+ @Test
public void testDirectAcces() throws DataStoreException, URISyntaxException {
ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
-
+
// 1) Find the third record, sequentially.
Feature thirdFeature;
-
- try(InputFeatureStream isSequential = shp.findAll()) {
+
+ InputFeatureStream isSequential = shp.findAll();
+ try {
isSequential.readFeature();
isSequential.readFeature();
thirdFeature = isSequential.readFeature();
+ } finally {
+ isSequential.close();
}
-
+
// Take one of its key fields and another field for reference, and its geometry.
Double sequentialAddressId = Double.valueOf((String)(thirdFeature.getProperty("ADDRID")).getValue());
String sequentialAddress = (String)(thirdFeature.getProperty("ADDRESS")).getValue();
Object sequentialGeometry = thirdFeature.getPropertyValue("geometry");
-
- // 2) Now attempt a direct access to this feature.
+
+ // 2) Now attempt a direct access to this feature.
Feature directFeature;
String sql = MessageFormat.format("SELECT * FROM ABRALicenseePt_4326_clipped WHERE ADDRID = {0,number,#0}", sequentialAddressId);
-
- try(InputFeatureStream isDirect = shp.find(sql)) {
+
+ InputFeatureStream isDirect = shp.find(sql);
+ try {
directFeature = isDirect.readFeature();
assertNotNull("The direct access feature returned should not be null", directFeature);
+ } finally {
+ isDirect.close();
}
assertNotNull("The field ADDRID in the direct access feature has not been found again.", directFeature.getProperty("ADDRID"));
-
+
Double directAddressId = Double.valueOf((String)(directFeature.getProperty("ADDRID")).getValue());
String directAddress = (String)(directFeature.getProperty("ADDRESS")).getValue();
Object directGeometry = directFeature.getPropertyValue("geometry");
-
+
assertEquals("DBase part : direct access didn't returned the same address id than sequential access.", sequentialAddressId, directAddressId);
assertEquals("DBase part : direct access didn't returned the same address than sequential access.", sequentialAddress, directAddress);
assertEquals("Shapefile part : direct access didn't returned the same geometry than sequential access.", sequentialGeometry, directGeometry);
}
-
+
/**
* Read all the shapefile content.
* @param shp Shapefile to read.
* @throws DataStoreException if a general file reading trouble occurs.
*/
private void readAll(ShapeFile shp) throws DataStoreException {
- try(InputFeatureStream is = shp.findAll()) {
+ InputFeatureStream is = shp.findAll();
+ try {
Feature feature = is.readFeature();
while(feature != null) {
feature = is.readFeature();
}
+ } finally {
+ is.close();
}
}
}
diff --git a/storage/sis-storage/pom.xml b/storage/sis-storage/pom.xml
index edf6494..c0d55ba 100644
--- a/storage/sis-storage/pom.xml
+++ b/storage/sis-storage/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.sis</groupId>
<artifactId>storage</artifactId>
- <version>0.8-jdk7-SNAPSHOT</version>
+ <version>0.8-jdk6-SNAPSHOT</version>
</parent>
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
index 5feabc9..65226a8 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
@@ -26,7 +26,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureBetween;
// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
/**
@@ -121,7 +121,7 @@
ChannelData(final String filename, final Channel channel, final ByteBuffer buffer) throws IOException {
this.filename = filename;
this.buffer = buffer;
- this.channelOffset = (channel instanceof SeekableByteChannel) ? ((SeekableByteChannel) channel).position() : 0;
+ this.channelOffset = (channel instanceof FileChannel) ? ((FileChannel) channel).position() : 0;
}
/**
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
index ef0c100..0b61e04 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
@@ -33,7 +33,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureBetween;
// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
/**
@@ -847,14 +847,14 @@
* Requested position is inside the current limits of the buffer.
*/
buffer.position((int) p);
- } else if (channel instanceof SeekableByteChannel) {
+ } else if (channel instanceof FileChannel) {
/*
* Requested position is outside the current limits of the buffer,
* but we can set the new position directly in the channel. Note
* that StorageConnector.rewind() needs the buffer content to be
* valid as a result of this seek, so we reload it immediately.
*/
- ((SeekableByteChannel) channel).position(channelOffset + position);
+ ((FileChannel) channel).position(channelOffset + position);
bufferOffset = position;
buffer.clear().limit(0);
} else if (p >= 0) {
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
index 5c70b3e..0e94e1e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
@@ -33,7 +33,7 @@
import static org.apache.sis.util.ArgumentChecks.ensureBetween;
// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
/**
@@ -616,13 +616,13 @@
*/
buffer.position((int) p);
clearBitOffset();
- } else if (channel instanceof SeekableByteChannel) {
+ } else if (channel instanceof FileChannel) {
/*
* Requested position is outside the current limits of the buffer,
* but we can set the new position directly in the channel.
*/
flush();
- ((SeekableByteChannel) channel).position(channelOffset + position);
+ ((FileChannel) channel).position(channelOffset + position);
bufferOffset = position;
} else if (p >= 0) {
/*
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
index 08042d1..e87019e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
@@ -25,7 +25,7 @@
import javax.imageio.stream.ImageInputStream;
// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
/**
@@ -112,8 +112,8 @@
*/
@Override
public final long length() throws IOException {
- if (channel instanceof SeekableByteChannel) {
- return ((SeekableByteChannel) channel).size();
+ if (channel instanceof FileChannel) {
+ return ((FileChannel) channel).size();
}
return -1;
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
index 00b12ce..34a00f5 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
@@ -93,7 +93,7 @@
*/
private static final Map<String,CodeType> FOR_PROTOCOL;
static {
- FOR_PROTOCOL = new HashMap<>();
+ FOR_PROTOCOL = new HashMap<String,CodeType>();
FOR_PROTOCOL.put("urn", CodeType.URN);
FOR_PROTOCOL.put("http", CodeType.HTTP_OGC); // Will actually need verification.
FOR_PROTOCOL.put("https", CodeType.HTTP_OGC); // Will actually need verification.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
index 6bb34f1..eb8a2ba 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
@@ -17,7 +17,7 @@
package org.apache.sis.internal.storage;
import java.util.Set;
-import java.util.EnumSet;
+import java.util.List;
import java.util.HashSet;
import java.util.Collections;
import java.util.Arrays;
@@ -41,14 +41,9 @@
import org.apache.sis.internal.system.Modules;
// Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.Files;
-import java.nio.file.InvalidPathException;
-import java.nio.file.FileSystemNotFoundException;
-import java.nio.file.OpenOption;
-import java.nio.file.StandardOpenOption;
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardOpenOption;
/**
@@ -70,7 +65,7 @@
/**
* Options to be rejected by {@link #open(Object, String, OpenOption[])} for safety reasons.
*/
- private static final Set<StandardOpenOption> ILLEGAL_OPTIONS = EnumSet.of(
+ private static final List<String> ILLEGAL_OPTIONS = Arrays.asList( // EnumSet of StandardOpenOption on JDK7 branch
StandardOpenOption.APPEND, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.DELETE_ON_CLOSE);
/**
@@ -113,8 +108,6 @@
final String name;
if (path instanceof File) {
name = ((File) path).getName();
- } else if (path instanceof Path) {
- name = ((Path) path).getFileName().toString();
} else {
char separator = '/';
if (path instanceof URL) {
@@ -153,7 +146,7 @@
public static String toString(final Object path) {
// For the following types, the string that we want can be obtained only by toString(),
// or the class is final so we know that the toString(à behavior can not be changed.
- if (path instanceof CharSequence || path instanceof Path || path instanceof URL || path instanceof URI) {
+ if (path instanceof CharSequence || path instanceof URL || path instanceof URI) {
return path.toString();
}
// While toString() would work too on the default implementation, the following
@@ -309,51 +302,6 @@
}
/**
- * Converts a {@link URL} to a {@link Path}. This is equivalent to a call to the standard
- * {@link URL#toURI()} method followed by a call to the {@link Paths#get(URI)} static method,
- * except for the following functionalities:
- *
- * <ul>
- * <li>Optionally decodes the {@code "%XX"} sequences, where {@code "XX"} is a number.</li>
- * <li>Converts various exceptions into subclasses of {@link IOException}.</li>
- * </ul>
- *
- * @param url The URL to convert, or {@code null}.
- * @param encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
- * MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
- * not encoded, then {@code null}.
- * @return The path for the given URL, or {@code null} if the given URL was null.
- * @throws IOException if the URL can not be converted to a path.
- *
- * @see Paths#get(URI)
- */
- public static Path toPath(final URL url, final String encoding) throws IOException {
- if (url == null) {
- return null;
- }
- final URI uri = toURI(url, encoding);
- try {
- return Paths.get(uri);
- } catch (IllegalArgumentException | FileSystemNotFoundException cause) {
- final String message = Exceptions.formatChainedMessages(null,
- Errors.format(Errors.Keys.IllegalArgumentValue_2, "URL", url), cause);
- /*
- * If the exception is IllegalArgumentException, then the URI scheme has been recognized
- * but the URI syntax is illegal for that file system. So we can consider that the URL is
- * malformed in regard to the rules of that particular file system.
- */
- final IOException e;
- if (cause instanceof IllegalArgumentException) {
- e = new MalformedURLException(message);
- e.initCause(cause);
- } else {
- e = new IOException(message, cause);
- }
- throw e;
- }
- }
-
- /**
* Parses the following path as a {@link File} if possible, or a {@link URL} otherwise.
* In the special case where the given {@code path} is a URL using the {@code "file"} protocol,
* the URL is converted to a {@link File} object using the given {@code encoding} for decoding
@@ -436,15 +384,15 @@
* @return The channel for the given input, or {@code null} if the given input is of unknown type.
* @throws IOException If an error occurred while opening the given file.
*/
- public static ReadableByteChannel open(Object input, final String encoding, OpenOption... options) throws IOException {
+ public static ReadableByteChannel open(Object input, final String encoding, Object... options) throws IOException {
/*
* Unconditionally verify the options, even if we may not use them.
*/
- final Set<OpenOption> optionSet;
+ final Set<Object> optionSet;
if (options == null || options.length == 0) {
- optionSet = Collections.<OpenOption>singleton(StandardOpenOption.READ);
+ optionSet = Collections.<Object>singleton(StandardOpenOption.READ);
} else {
- optionSet = new HashSet<>(Arrays.asList(options));
+ optionSet = new HashSet<Object>(Arrays.asList(options));
optionSet.add(StandardOpenOption.READ);
if (optionSet.removeAll(ILLEGAL_OPTIONS)) {
throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2,
@@ -466,13 +414,15 @@
}
return Channels.newChannel((InputStream) input);
}
+ // NOTE: Many comments below this point actually apply to the JDK7 branch.
+ // We keep them here for making easier the synchonization between the branches.
/*
* In the following cases, we will try hard to convert to Path objects before to fallback
* on File, URL or URI, because only Path instances allow us to use the given OpenOptions.
*/
if (input instanceof URL) {
try {
- input = toPath((URL) input, encoding);
+ input = toFile((URL) input, encoding);
} catch (IOException e) {
// This is normal if the URL uses HTTP or FTP protocol for instance.
// Log the exception at FINE level without stack trace. We will open
@@ -491,14 +441,9 @@
// so we are better to check now and provide a more appropriate exception for this method.
throw new IOException(Errors.format(Errors.Keys.MissingSchemeInURI));
} else try {
- input = Paths.get(uri);
- } catch (IllegalArgumentException | FileSystemNotFoundException e) {
- try {
- input = uri.toURL();
- } catch (MalformedURLException ioe) {
- ioe.addSuppressed(e);
- throw ioe;
- }
+ input = new File(uri);
+ } catch (IllegalArgumentException e) {
+ input = uri.toURL();
// We have been able to convert to URL, but the given OpenOptions may not be used.
// Log the exception at FINE level without stack trace, because the exception is
// probably a normal behavior in this context.
@@ -508,31 +453,6 @@
if (input instanceof CharSequence) { // Needs to be before the check for File or URL.
input = toFileOrURL(input.toString(), encoding);
}
- /*
- * If the input is a File or a CharSequence that we have been able to convert to a File,
- * try to convert to a Path in order to be able to use the OpenOptions. Only if we fail
- * to convert to a Path (which is unlikely), we will use directly the File.
- */
- if (input instanceof File) {
- try {
- input = ((File) input).toPath();
- } catch (InvalidPathException e) {
- // Unlikely to happen. But if it happens anyway, try to open the channel in a
- // way less surprising for the user (closer to the object he has specified).
- final ReadableByteChannel channel;
- try {
- channel = new FileInputStream((File) input).getChannel();
- } catch (IOException ioe) {
- ioe.addSuppressed(e);
- throw ioe;
- }
- // We have been able to create a channel, maybe not with the given OpenOptions.
- // But the exception was nevertheless unexpected, so log its stack trace in order
- // to allow the developer to check if there is something wrong.
- Logging.unexpectedException(Logging.getLogger(Modules.STORAGE), IOUtilities.class, "open", e);
- return channel;
- }
- }
}
/*
* One last check for URL. The URL may be either the given input if we have not been able
@@ -542,8 +462,8 @@
if (input instanceof URL) {
return Channels.newChannel(((URL) input).openStream());
}
- if (input instanceof Path) {
- return Files.newByteChannel((Path) input, optionSet);
+ if (input instanceof File) {
+ return Files.newByteChannel((File) input, optionSet);
}
return null;
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreTypeDetector.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreTypeDetector.java
deleted file mode 100644
index 2ece0e8..0000000
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreTypeDetector.java
+++ /dev/null
@@ -1,64 +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.internal.storage;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.spi.FileTypeDetector;
-import org.apache.sis.storage.DataStores;
-import org.apache.sis.storage.DataStoreException;
-
-
-/**
- * A {@code java.nio.file} service to be registered for probing content type.
- * The {@link #probeContentType(Path)} will be automatically invoked by
- * {@link java.nio.file.Files#probeContentType(Path)}.
- *
- * @author Martin Desruisseaux (Geomatys)
- * @since 0.4
- * @version 0.4
- * @module
- */
-public class StoreTypeDetector extends FileTypeDetector {
- /**
- * Constructor for {@link java.util.ServiceLoader}.
- */
- public StoreTypeDetector() {
- }
-
- /**
- * Probes the given file by delegating to {@link DataStores#probeContentType(Object)}.
- *
- * @param path the path to the file to probe.
- * @return The content type or {@code null} if the file type is not recognized.
- * @throws IOException if an I/O error occurs while reading the file.
- *
- * @see java.nio.file.Files#probeContentType(Path)
- */
- @Override
- public String probeContentType(final Path path) throws IOException {
- try {
- return DataStores.probeContentType(path);
- } catch (DataStoreException e) {
- final Throwable cause = e.getCause();
- if (cause instanceof IOException) {
- throw (IOException) cause;
- }
- throw new IOException(e);
- }
- }
-}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
index 2de6e36..6906ba0 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
@@ -58,7 +58,6 @@
// Branch-dependent imports
import org.apache.sis.internal.jdk8.Instant;
-import org.apache.sis.internal.jdk8.DateTimeException;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
import org.opengis.feature.PropertyType;
@@ -183,7 +182,7 @@
FeatureType featureType = null;
Foliation foliation = null;
try {
- final List<String> elements = new ArrayList<>();
+ final List<String> elements = new ArrayList<String>();
source.mark(1024);
String line;
while ((line = source.readLine()) != null) {
@@ -194,15 +193,15 @@
if (c != METADATA) break;
split(line, elements);
final String keyword = elements.get(0);
- switch (keyword.toLowerCase(Locale.US)) {
- case "@stboundedby": {
+ /*switch (k)*/ {
+ final String k = keyword.toLowerCase(Locale.US);
+ if (k.equals("@stboundedby")) {
if (envelope != null) {
throw new DataStoreException(duplicated("@stboundedby"));
}
envelope = parseEnvelope(elements);
- break;
}
- case "@columns": {
+ else if (k.equals("@columns")) {
if (featureType != null) {
throw new DataStoreException(duplicated("@columns"));
}
@@ -210,35 +209,32 @@
if (foliation == null) {
foliation = Foliation.TIME;
}
- break;
}
- case "@foliation": {
+ else if (k.equals("@foliation")) {
if (foliation != null) {
throw new DataStoreException(duplicated("@foliation"));
}
foliation = parseFoliation(elements);
- break;
}
- default: {
+ else {
final LogRecord record = errors().getLogRecord(Level.WARNING, Errors.Keys.UnknownKeyword_1, keyword);
record.setSourceClassName(Store.class.getName());
record.setSourceMethodName("parseHeader");
listeners.warning(record);
- break;
}
}
elements.clear();
source.mark(1024);
}
source.reset();
- } catch (IOException | FactoryException | IllegalArgumentException | DateTimeException e) {
+ } catch (Exception e) { // This is a multi-catch on the JDK7 branch.
throw new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", name), e);
}
this.envelope = envelope;
this.featureType = featureType;
this.foliation = foliation;
this.metadata = MetadataHelper.createForTextFile(connector);
- this.features = new ArrayList<>();
+ this.features = new ArrayList<Feature>();
}
/**
@@ -266,15 +262,21 @@
GeneralEnvelope envelope = null;
switch (elements.size()) {
default:final String unit = elements.get(7);
- switch (unit.toLowerCase(Locale.US)) {
- case "":
- case "sec":
- case "second": /* Already SI.SECOND. */ break;
- case "minute": timeUnit = NonSI.MINUTE; break;
- case "hour": timeUnit = NonSI.HOUR; break;
- case "day": timeUnit = NonSI.DAY; break;
- case "absolute": isTimeAbsolute = true; break;
- default: throw new DataStoreException(errors().getString(Errors.Keys.UnknownUnit_1, unit));
+ /*switch (k)*/ {
+ final String k = unit.toLowerCase(Locale.US);
+ if (k.isEmpty() || k.equals("sec") || k.equals("second")) {
+ /* Already SI.SECOND. */
+ } else if (k.equals("minute")) {
+ timeUnit = NonSI.MINUTE;
+ } else if (k.equals("hour")) {
+ timeUnit = NonSI.HOUR;
+ } else if (k.equals("day")) {
+ timeUnit = NonSI.DAY;
+ } else if (k.equals("absolute")) {
+ isTimeAbsolute = true;
+ } else {
+ throw new DataStoreException(errors().getString(Errors.Keys.UnknownUnit_1, unit));
+ }
}
// Fall through
case 7: endTime = Instant .parse( elements.get(6));
@@ -282,12 +284,16 @@
case 5: upperCorner = CharSequences.parseDoubles(elements.get(4), ORDINATE_SEPARATOR);
case 4: lowerCorner = CharSequences.parseDoubles(elements.get(3), ORDINATE_SEPARATOR);
case 3: final String dimension = elements.get(2);
- switch (dimension.toUpperCase(Locale.US)) {
- case "": // Default to 2D.
- case "2D": break;
- case "3D": is3D = true; break;
- default: throw new DataStoreException(errors().getString(
+ /* switch (k)*/ {
+ final String k = dimension.toUpperCase(Locale.US);
+ if (k.isEmpty() || k.equals("2D")) {
+ // Default to 2D.
+ } else if (k.equals("3D")) {
+ is3D = true;
+ } else {
+ throw new DataStoreException(errors().getString(
Errors.Keys.IllegalCoordinateSystem_1, dimension));
+ }
}
// Fall through
case 2: crs = CRS.forCode(elements.get(1));
@@ -366,7 +372,7 @@
*/
private FeatureType parseFeatureType(final List<String> elements) throws DataStoreException {
final int size = elements.size();
- final List<PropertyType> properties = new ArrayList<>();
+ final List<PropertyType> properties = new ArrayList<PropertyType>();
for (int i=1; i<size; i++) {
final String name = elements.get(i);
Class<?> type = null;
@@ -374,14 +380,22 @@
String tn = elements.get(i);
if (!tn.isEmpty() && tn.regionMatches(true, 0, TYPE_PREFIX, 0, TYPE_PREFIX.length())) {
String st = tn.substring(TYPE_PREFIX.length()).toLowerCase(Locale.US);
- switch (st) {
- case "boolean": type = Boolean.class; break;
- case "decimal": type = Double .class; break;
- case "integer": type = Integer.class; break;
- case "string": type = String .class; break;
- case "datetime": type = Instant.class; break;
- case "anyuri": type = URI .class; break;
- default: throw new DataStoreException(errors().getString(Errors.Keys.UnknownType_1, tn));
+ /*switch (st)*/ {
+ if (st.equals("boolean")) {
+ type = Boolean.class;
+ } else if (st.equals("decimal")) {
+ type = Double.class;
+ } else if (st.equals("integer")) {
+ type = Integer.class;
+ } else if (st.equals("string")) {
+ type = String.class;
+ } else if (st.equals("datetime")) {
+ type = Instant.class;
+ } else if (st.equals("anyuri")) {
+ type = URI.class;
+ } else {
+ throw new DataStoreException(errors().getString(Errors.Keys.UnknownType_1, tn));
+ }
}
}
}
@@ -425,7 +439,7 @@
* Creates a property type for the given name and type.
*/
private static PropertyType createProperty(final String name, final Class<?> type, final int minOccurrence) {
- return new DefaultAttributeType<>(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name), type, minOccurrence, 1, null);
+ return new DefaultAttributeType(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name), type, minOccurrence, 1, null);
}
/**
@@ -483,7 +497,7 @@
final String[] propertyNames = new String[converters.length];
final boolean hasTrajectories = this.hasTrajectories;
final TimeEncoding timeEncoding = this.timeEncoding;
- final List<String> values = new ArrayList<>();
+ final List<String> values = new ArrayList<String>();
int i = -1;
for (final PropertyType p : properties) {
propertyNames[++i] = p.getName().tip().toString();
@@ -558,7 +572,7 @@
}
values.clear();
}
- } catch (IOException | IllegalArgumentException | DateTimeException e) {
+ } catch (Exception e) { // Multi-catch on the JDK7 branch.
throw new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", name), e);
}
return features.iterator();
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
index fa803db..a381082 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
@@ -76,7 +76,7 @@
* @throws DataStoreException If an error occurred while opening the stream.
*/
public Store(final StorageConnector connector) throws DataStoreException {
- objects = new ArrayList<>();
+ objects = new ArrayList<Object>();
name = connector.getStorageName();
source = connector.getStorageAs(Reader.class);
connector.closeAllExcept(source);
@@ -125,7 +125,9 @@
listeners.warning(record);
}
} while (pos.getIndex() < wkt.length());
- } catch (IOException | ParseException e) {
+ } catch (IOException e) { // Multi-catch on the JDK7 branch.
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT", name), e);
+ } catch (ParseException e) {
throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT", name), e);
}
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
index 464d870..39ada9b 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
@@ -64,7 +64,7 @@
*/
private static final Set<String> KEYWORDS = keywords();
static Set<String> keywords() {
- final Set<String> s = new HashSet<>(22);
+ final Set<String> s = new HashSet<String>(22);
s.add(WKTKeywords.GeodeticCRS);
s.add(WKTKeywords.GeodCRS);
s.add(WKTKeywords.GeogCS);
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
index ffa7393..0f4eacd 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
@@ -46,7 +46,7 @@
* The mapping from XML namespace to MIME type.
* This map shall be read-only, since we do not synchronize it.
*/
- private static final Map<String,String> TYPES = new HashMap<>();
+ private static final Map<String,String> TYPES = new HashMap<String,String>();
static {
TYPES.put(Namespaces.GML, "application/gml+xml");
TYPES.put(Namespaces.GMD, "application/vnd.iso.19139+xml");
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
index ac1a250..f472d25 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
@@ -151,7 +151,9 @@
} finally {
in.close();
}
- } catch (JAXBException | IOException e) {
+ } catch (JAXBException e) {
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
+ } catch (IOException e) {
throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
}
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
index 1e7a598..dc2b017 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
@@ -24,6 +24,9 @@
import org.apache.sis.util.logging.WarningListener;
import org.apache.sis.util.logging.WarningListeners;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.AutoCloseable;
+
/**
* Manages a series of features, coverages or sensor data.
@@ -41,7 +44,8 @@
*
* @see DataStores#open(Object)
*/
-public abstract class DataStore implements Localized, AutoCloseable {
+@AutoCloseable
+public abstract class DataStore implements Localized {
/**
* The locale to use for formatting warnings.
*
@@ -59,8 +63,8 @@
* Creates a new instance with initially no listener.
*/
protected DataStore() {
- locale = Locale.getDefault(Locale.Category.DISPLAY);
- listeners = new WarningListeners<>(this);
+ locale = Locale.getDefault();
+ listeners = new WarningListeners<DataStore>(this);
}
/**
@@ -143,6 +147,5 @@
*
* @throws DataStoreException if an error occurred while closing this data store.
*/
- @Override
public abstract void close() throws DataStoreException;
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
index 70164ca..641fbb8 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
@@ -88,7 +88,7 @@
* The {@code storage} argument can be any of the following types:
*
* <ul>
- * <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
+ * <li>A {@link java.io.File} for a file or a directory.</li>
* <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
* <li>A {@link java.lang.CharSequence} interpreted as a filename or a URL.</li>
* <li>A {@link java.nio.channels.Channel}, {@link java.io.DataInput}, {@link java.io.InputStream} or {@link java.io.Reader}.</li>
@@ -154,7 +154,7 @@
* found an other provider.
*/
if (deferred == null) {
- deferred = new LinkedList<>();
+ deferred = new LinkedList<ProbeProviderPair>();
}
deferred.add(new ProbeProviderPair(provider, probe));
} else if (ProbeResult.UNDETERMINED.equals(probe)) {
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
index 5da9458..829c30e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
@@ -93,7 +93,7 @@
* The {@code storage} argument can be any of the following types:
*
* <ul>
- * <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
+ * <li>A {@link java.io.File} for a file or a directory.</li>
* <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
* <li>A {@link java.lang.CharSequence} interpreted as a filename or a URL.</li>
* <li>A {@link java.nio.channels.Channel}, {@link java.io.DataInput}, {@link java.io.InputStream} or {@link java.io.Reader}.</li>
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
index a616eab..c64fcc6 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
@@ -22,7 +22,7 @@
import org.apache.sis.internal.util.Utilities;
// Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -290,7 +290,7 @@
Object readResolve() {
try {
return ProbeResult.class.getField(name).get(null);
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) { // ReflectiveOperationException on the JDK7 branch.
return this; // See javadoc
}
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
index 0529380..0cac625 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
@@ -46,13 +46,16 @@
import org.apache.sis.internal.storage.ChannelImageInputStream;
import org.apache.sis.setup.OptionKey;
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
/**
* Information for creating a connection to a {@link DataStore} in read and/or write mode.
* {@code StorageConnector} wraps an input {@link Object}, which can be any of the following types:
*
* <ul>
- * <li>A {@link java.nio.file.Path} or a {@link java.io.File} for a file or a directory.</li>
+ * <li>A {@link java.io.File} for a file or a directory.</li>
* <li>A {@link java.net.URI} or a {@link java.net.URL} to a distant resource.</li>
* <li>A {@link CharSequence} interpreted as a filename or a URL.</li>
* <li>A {@link java.nio.channels.Channel}, {@link DataInput}, {@link InputStream} or {@link Reader}.</li>
@@ -225,8 +228,8 @@
* the following choices based on the type of the {@linkplain #getStorage() storage} object:
*
* <ul>
- * <li>For {@link java.nio.file.Path}, {@link java.io.File}, {@link java.net.URI} or {@link java.net.URL}
- * instances, this method uses dedicated API like {@link java.nio.file.Path#getFileName()}.</li>
+ * <li>For {@link java.io.File}, {@link java.net.URI} or {@link java.net.URL}
+ * instances, this method uses dedicated API.</li>
* <li>For {@link CharSequence} instances, this method gets a string representation of the storage object
* and returns the part after the last {@code '/'} character or platform-dependent name separator.</li>
* <li>For instances of unknown type, this method builds a string representation using the class name.
@@ -250,7 +253,7 @@
* the following choices based on the type of the {@linkplain #getStorage() storage} object:
*
* <ul>
- * <li>For {@link java.nio.file.Path}, {@link java.io.File}, {@link java.net.URI}, {@link java.net.URL} or
+ * <li>For {@link java.io.File}, {@link java.net.URI}, {@link java.net.URL} or
* {@link CharSequence} instances, this method returns the string after the last {@code '.'} character
* in the filename, provided that the {@code '.'} is not the first filename character. This may be an
* empty string if the filename has no extension, but never {@code null}.</li>
@@ -274,7 +277,7 @@
* <ul>
* <li>{@link String}:
* <ul>
- * <li>If the {@linkplain #getStorage() storage} object is an instance of the {@link java.nio.file.Path},
+ * <li>If the {@linkplain #getStorage() storage} object is an instance of the
* {@link java.io.File}, {@link java.net.URL}, {@link java.net.URI} or {@link CharSequence} types,
* returns the string representation of their path.</li>
*
@@ -295,7 +298,7 @@
* (including the {@link ImageInputStream} and {@link javax.imageio.stream.ImageOutputStream} types),
* then it is returned unchanged.</li>
*
- * <li>Otherwise if the input is an instance of {@link java.nio.file.Path}, {@link java.io.File},
+ * <li>Otherwise if the input is an instance of {@link java.io.File},
* {@link java.net.URI}, {@link java.net.URL}, {@link CharSequence}, {@link InputStream} or
* {@link java.nio.channels.ReadableByteChannel}, then an {@link ImageInputStream} backed by a
* {@link ByteBuffer} is created when first needed and returned.</li>
@@ -378,7 +381,7 @@
return (view != Void.TYPE) ? type.cast(view) : null;
}
} else {
- views = new IdentityHashMap<>();
+ views = new IdentityHashMap<Class<?>, Object>();
}
/*
* Special case for DataInput and ByteBuffer, because those values are created together.
@@ -712,7 +715,7 @@
*/
private void addViewToClose(final Object input, final Object delegate) {
if (viewsToClose == null) {
- viewsToClose = new IdentityHashMap<>(4);
+ viewsToClose = new IdentityHashMap<Object,Object>(4);
}
if (viewsToClose.put(input, delegate) != null) {
throw new AssertionError(input);
@@ -742,8 +745,8 @@
viewsToClose = Collections.emptyMap();
views = Collections.emptyMap();
if (toClose == null) {
- if (storage != view && storage instanceof AutoCloseable) try {
- ((AutoCloseable) storage).close();
+ if (storage != view && JDK7.isAutoCloseable(storage)) try {
+ JDK7.close(storage);
} catch (Exception e) {
throw new DataStoreException(e);
}
@@ -771,7 +774,7 @@
* Those wrappers shall not be closed. For example if the caller does not want to close the
* InputStream view, then we shall not close the InputStreamReader wrapper neither.
*/
- final Queue<Object> deferred = new LinkedList<>();
+ final Queue<Object> deferred = new LinkedList<Object>();
Object doNotClose = view;
do {
final Iterator<Map.Entry<Object,Object>> it = toClose.entrySet().iterator();
@@ -806,13 +809,13 @@
*/
DataStoreException failure = null;
for (final Object c : toClose.keySet()) {
- if (c instanceof AutoCloseable) try {
- ((AutoCloseable) c).close();
+ if (JDK7.isAutoCloseable(c)) try {
+ JDK7.close(c);
} catch (Exception e) {
if (failure == null) {
failure = new DataStoreException(e);
} else {
- failure.addSuppressed(e);
+ // failure.addSuppressed(e) on the JDK7 branch.
}
}
}
diff --git a/storage/sis-storage/src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector b/storage/sis-storage/src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector
deleted file mode 100644
index f8debc5..0000000
--- a/storage/sis-storage/src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.sis.internal.storage.StoreTypeDetector
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
index 9b3d636..5b02ce4 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
@@ -22,7 +22,7 @@
import org.apache.sis.util.ArgumentChecks;
// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.ByteChannel;
/**
@@ -38,7 +38,7 @@
* @see ChannelDataOutputTest
* @see ChannelImageOutputStream
*/
-final strictfp class ByteArrayChannel implements SeekableByteChannel {
+final strictfp class ByteArrayChannel implements ByteChannel {
/**
* Bytes array where to write the data.
* The length of this array is the capacity.
@@ -105,7 +105,6 @@
/**
* Returns this channel position.
*/
- @Override
public long position() throws IOException {
ensureOpen();
return position;
@@ -114,8 +113,7 @@
/**
* Sets this channel position.
*/
- @Override
- public SeekableByteChannel position(final long newPosition) throws IOException {
+ public ByteArrayChannel position(final long newPosition) throws IOException {
ensureOpen();
ArgumentChecks.ensureBetween("position", 0, data.length, newPosition);
position = (int) newPosition;
@@ -125,7 +123,6 @@
/**
* Returns the current size.
*/
- @Override
public long size() throws IOException {
ensureOpen();
return limit;
@@ -134,8 +131,7 @@
/**
* Truncates the data to the given size.
*/
- @Override
- public SeekableByteChannel truncate(final long size) throws IOException {
+ public ByteArrayChannel truncate(final long size) throws IOException {
ensureOpen();
ArgumentChecks.ensureBetween("position", 0, limit, size);
limit = (int) size;
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
index 692e85c..d60da85 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
@@ -140,6 +140,14 @@
final ByteBuffer arrayView = ByteBuffer.wrap(expectedArray);
for (int i=0; i<100; i++) {
final int position = random.nextInt(seekRange);
+
+ // JDK6 specific: can not seek to arbitrary position because
+ // Java 6 does not provide the SeekableByteChannel interface.
+ if (position < testedStream.getFlushedPosition()) {
+ continue;
+ }
+ // End of JDK6 specific.
+
testedStream.seek(position);
assertEquals("getStreamPosition()", position, testedStream.getStreamPosition());
final long v = random.nextLong();
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
index b766c65..e2688d2 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
@@ -108,7 +108,7 @@
operation = random.nextInt(numOperations);
transferRandomData(operation);
}
- } catch (AssertionError | RuntimeException e) {
+ } catch (AssertionError e) {
out.println("Iter. count: " + count);
out.println("Position: " + position);
out.println("Bit offset: " + bitOffset);
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
index dba291b..2b89f38 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
@@ -87,7 +87,7 @@
*/
@Test
public void testMarkAndReset() throws IOException {
- initialize("testMarkAndReset", STREAM_LENGTH, 1000); // We need a larger buffer for this test.
+ initialize("testMarkAndReset", STREAM_LENGTH, STREAM_LENGTH); // We need a larger buffer for this test.
final ImageOutputStream referenceStream = (ImageOutputStream) this.referenceStream;
/*
* Fill both streams with random data.
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
index b4cab82..b0f0c05 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
@@ -32,7 +32,9 @@
* @module
*/
@Workaround(library = "JDK", version = "1.8")
-final strictfp class MemoryCacheImageOutputStream extends javax.imageio.stream.MemoryCacheImageOutputStream {
+final strictfp class MemoryCacheImageOutputStream extends javax.imageio.stream.MemoryCacheImageOutputStream
+ implements java.io.Closeable // Needed on JDK 6 only.
+{
/**
* Creates a new instance which will write the data in the given stream.
*/
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
index 0ecacf7..2383d23 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
@@ -63,8 +63,11 @@
@org.junit.Ignore("Pending completion of sis-referencing")
public void testGetMetadata() throws DataStoreException {
final Metadata metadata;
- try (Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)))) {
+ Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)));
+ try {
metadata = store.getMetadata();
+ } finally {
+ store.close();
}
final SpatialTemporalExtent extent = (SpatialTemporalExtent) getSingleton(getSingleton(getSingleton(
metadata.getIdentificationInfo()).getExtents()).getTemporalElements());
@@ -84,13 +87,16 @@
*/
@Test
public void testGetFeatures() throws DataStoreException {
- try (Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)))) {
+ Store store = new Store(new StorageConnector(new StringReader(TEST_DATA)));
+ try {
final Iterator<Feature> it = store.getFeatures();
assertFeatureEquals(it.next(), "a", new double[] {11, 2, 12, 3}, "walking", 1);
assertFeatureEquals(it.next(), "b", new double[] {10, 2, 11, 3}, "walking", 2);
assertFeatureEquals(it.next(), "a", new double[] {12, 3, 10, 3}, "walking", 2);
assertFeatureEquals(it.next(), "c", new double[] {12, 1, 10, 2, 11, 3}, "vehicle", 1);
assertFalse(it.hasNext());
+ } finally {
+ store.close();
}
}
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java
index 3f16363..71366a3 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java
@@ -31,7 +31,7 @@
import static org.opengis.test.Assert.*;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
@@ -73,9 +73,12 @@
@Test
public void testFromReader() throws DataStoreException {
final Metadata metadata;
- try (Store store = new Store(new StorageConnector(new StringReader(WKT)))) {
+ final Store store = new Store(new StorageConnector(new StringReader(WKT)));
+ try {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
+ } finally {
+ store.close();
}
validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
}
@@ -93,9 +96,12 @@
final StoreProvider p = new StoreProvider();
final StorageConnector c = new StorageConnector(new ByteArrayInputStream(StoreTest.WKT.getBytes(StandardCharsets.US_ASCII)));
assertTrue("isSupported", p.probeContent(c).isSupported());
- try (Store store = new Store(c)) {
+ final Store store = new Store(c);
+ try {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
+ } finally {
+ store.close();
}
validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
}
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
index b6b1eb1..9effc7f 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
@@ -31,7 +31,7 @@
import static org.apache.sis.test.TestUtilities.getSingleton;
// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.jdk7.StandardCharsets;
/**
@@ -93,9 +93,12 @@
@Test
public void testMetadata() throws DataStoreException {
final Metadata metadata;
- try (Store store = new Store(new StorageConnector(new StringReader(XML)))) {
+ final Store store = new Store(new StorageConnector(new StringReader(XML)));
+ try {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
+ } finally {
+ store.close();
}
final Responsibility resp = getSingleton(metadata.getContacts());
final Party party = getSingleton(resp.getParties());