sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1748701 - in /sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice: AnglePattern.java CacheKey.java ReferencingFunctions.java Registration.java Transformer.java
Date Thu, 16 Jun 2016 12:27:42 GMT
Author: desruisseaux
Date: Thu Jun 16 12:27:41 2016
New Revision: 1748701

URL: http://svn.apache.org/viewvc?rev=1748701&view=rev
Log:
Adapt for JDK6.

Modified:
    sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
    sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
    sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
    sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
    sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java

Modified: sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java?rev=1748701&r1=1748700&r2=1748701&view=diff
==============================================================================
--- sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
[UTF-8] (original)
+++ sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java
[UTF-8] Thu Jun 16 12:27:41 2016
@@ -94,7 +94,7 @@ final class AnglePattern {
      * @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();

Modified: sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java?rev=1748701&r1=1748700&r2=1748701&view=diff
==============================================================================
--- sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
[UTF-8] (original)
+++ sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CacheKey.java
[UTF-8] Thu Jun 16 12:27:41 2016
@@ -20,7 +20,7 @@ import java.util.Arrays;
 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 @@ final class CacheKey<T> {
     /**
      * 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.

Modified: sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java?rev=1748701&r1=1748700&r2=1748701&view=diff
==============================================================================
--- sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
[UTF-8] (original)
+++ sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
[UTF-8] Thu Jun 16 12:27:41 2016
@@ -111,7 +111,7 @@ public class ReferencingFunctions extend
     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 @@ public class ReferencingFunctions extend
                          * 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 @@ public class ReferencingFunctions extend
             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 @@ public class ReferencingFunctions extend
      */
     @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 @@ public class ReferencingFunctions extend
      */
     @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();

Modified: sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java?rev=1748701&r1=1748700&r2=1748701&view=diff
==============================================================================
--- sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
[UTF-8] (original)
+++ sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Registration.java
[UTF-8] Thu Jun 16 12:27:41 2016
@@ -35,6 +35,9 @@ import com.sun.star.lang.XSingleComponen
 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 @@ public final class Registration implemen
             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 @@ public final class Registration implemen
         } 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 @@ public final class Registration implemen
      * 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();

Modified: sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java?rev=1748701&r1=1748700&r2=1748701&view=diff
==============================================================================
--- sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
[UTF-8] (original)
+++ sis/branches/JDK6/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java
[UTF-8] Thu Jun 16 12:27:41 2016
@@ -108,7 +108,7 @@ final class Transformer {
          * 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();



Mime
View raw message