sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1773528 [3/3] - in /sis/branches/JDK7: ./ application/sis-console/ application/sis-openoffice/src/main/unopkg/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-referen...
Date Sat, 10 Dec 2016 17:35:39 GMT
Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -22,6 +22,7 @@ import java.util.Locale;
 import java.lang.reflect.Field;
 import javax.measure.Unit;
 import javax.measure.format.ParserException;
+import org.apache.sis.util.Characters;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
@@ -137,6 +138,16 @@ public final strictfp class UnitFormatTe
         assertEquals(field, symbol,    UnitFormat.INSTANCE.format(unit));
         if (name != null) {
             assertEquals(field, name, UnitFormat.getBundle(Locale.UK).getString(symbol));
+            for (int i=0; i<name.length();) {
+                final int c = name.codePointAt(i);
+                assertTrue(name, AbstractUnit.isSymbolChar(c) || Character.isWhitespace(c));
+                i += Character.charCount(c);
+            }
+        }
+        for (int i=0; i<symbol.length();) {
+            final int c = symbol.codePointAt(i);
+            assertTrue(symbol, AbstractUnit.isSymbolChar(c) || Characters.isSuperScript(c)
|| c == '∕');
+            i += Character.charCount(c);
         }
         declared.remove(field);
     }
@@ -264,6 +275,7 @@ public final strictfp class UnitFormatTe
         assertSame(Units.CELSIUS,       f.parse("degC"));
         assertSame(Units.CELSIUS,       f.parse("deg C"));
         assertSame(Units.WATT,          f.parse("watt"));
+        assertSame(Units.UNITY,         f.parse("unity"));
         try {
             f.parse("degree foo");
             fail("Should not accept unknown unit.");
@@ -362,10 +374,41 @@ public final strictfp class UnitFormatTe
     public void testParseMultiplier() {
         final UnitFormat f = new UnitFormat(Locale.UK);
         assertSame(Units.MILLIMETRE, f.parse("m/1000"));
+        assertSame(Units.KILOMETRE,  f.parse( "1000*m"));
+        assertSame(Units.KILOMETRE,  f.parse( "1000.0*m"));
         ConventionalUnitTest.verify(Units.METRE, f.parse("10*-6⋅m"),   "µm", 1E-6);
         ConventionalUnitTest.verify(Units.METRE, f.parse("10*-6.m"),   "µm", 1E-6);
-        ConventionalUnitTest.verify(Units.METRE, f.parse( "1000*m"),   "km", 1E+3);
-        ConventionalUnitTest.verify(Units.METRE, f.parse( "1000.0*m"), "km", 1E+3);
         ConventionalUnitTest.verify(Units.METRE, f.parse( "100 feet"), null, 30.48);
     }
+
+    /**
+     * Tests parsing expressions containing parenthesis.
+     */
+    @Test
+    @DependsOnMethod("testParseMultiplier")
+    public void testParseWithParenthesis() {
+        final UnitFormat f = new UnitFormat(Locale.UK);
+        assertSame(Units.PASCAL, f.parse("kg∕(m⋅s²)"));
+        assertSame(Units.PASCAL, f.parse("(kg)∕m∕s²"));
+        assertSame(Units.VOLT,   f.parse("kg⋅m²∕(s³⋅A)"));
+        assertSame(Units.VOLT,   f.parse("(kg)m²∕(s³⋅A)"));
+    }
+
+    /**
+     * Tests {@link UnitFormat#clone()}.
+     */
+    @Test
+    public void testClone() {
+        final UnitFormat f1 = new UnitFormat(Locale.FRANCE);
+        f1.label(Units.METRE,  "myMeterLabel");
+        f1.label(Units.SECOND, "mySecondLabel");
+        final UnitFormat f2 = f1.clone();
+        f2.label(Units.METRE, "otherMeterLabel");
+        assertSame  (Locale.FRANCE,     f1.getLocale());
+        assertSame  (Locale.FRANCE,     f2.getLocale());
+        assertEquals("myMeterLabel",    f1.format(Units.METRE));
+        assertEquals("mySecondLabel",   f1.format(Units.SECOND));
+        assertEquals("otherMeterLabel", f2.format(Units.METRE));
+        assertEquals("mySecondLabel",   f2.format(Units.SECOND));
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/foreigner/SerializableTableColumn.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -17,6 +17,7 @@
 package org.apache.sis.test.foreigner;
 
 import java.io.Serializable;
+import java.io.ObjectStreamException;
 import java.io.InvalidObjectException;
 import org.apache.sis.util.collection.TableColumn;
 
@@ -67,7 +68,7 @@ public final strictfp class Serializable
      * @return One of the predefined constants.
      * @throws InvalidObjectException If this instance can not be resolved.
      */
-    private Object readResolve() throws InvalidObjectException {
+    private Object readResolve() throws ObjectStreamException {
         try {
             return SerializableTableColumn.class.getField(field).get(null);
         } catch (Exception cause) { // Many exceptions, including unchecked ones.

Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Sat Dec
10 17:35:38 2016
@@ -196,3 +196,9 @@ dist.dir
 dist.jar                                 = ${dist.dir}/SIS.jar
 dist.javadoc.dir                         = ${dist.dir}/javadoc
 mkdist.disabled                          = true
+
+#
+# Editor
+#
+auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsEnabled=true
+auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml

Modified: sis/branches/JDK7/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/pom.xml?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/pom.xml (original)
+++ sis/branches/JDK7/pom.xml Sat Dec 10 17:35:38 2016
@@ -81,7 +81,7 @@ Apache SIS is a free software, Java lang
 
   <ciManagement>
     <system>jenkins</system>
-    <url>https://builds.apache.org/job/sis-jdk7</url>
+    <url>https://builds.apache.org/job/sis-dev</url>
   </ciManagement>
 
   <issueManagement>

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -61,6 +61,11 @@ public final class Resources extends Ind
         }
 
         /**
+         * TIFF file “{0}” has circular references in its chain of images.
+         */
+        public static final short CircularImageReference_1 = 18;
+
+        /**
          * No value specified for the “{0}” TIFF tag. Computed the {1} value from other
tags.
          */
         public static final short ComputedValueForAttribute_2 = 0;
@@ -124,8 +129,8 @@ public final class Resources extends Ind
         public static final short MissingValue_2 = 7;
 
         /**
-         * The file defines “{2}” with a value of {3}{4}, but that value should be {1}{4}
for
-         * consistency with {0}.
+         * The file defines “{2}” with a value of {3}{4}, but that value should be {1}{4}
according
+         * parent definition ({0}).
          */
         public static final short NotTheEpsgValue_5 = 17;
 

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources.properties
[ISO-8859-1] Sat Dec 10 17:35:38 2016
@@ -19,6 +19,7 @@
 # Resources in this file are for "sis-geotiff" usage only and should not be used by any other
module.
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources"
package.
 #
+CircularImageReference_1          = TIFF file \u201c{0}\u201d has circular references in
its chain of images.
 ConstantValueRequired_3           = Apache SIS implementation requires that all \u201c{0}\u201d
elements have the same value, but the element found in \u201c{1}\u201d are {2}.
 ComputedValueForAttribute_2       = No value specified for the \u201c{0}\u201d TIFF tag.
Computed the {1} value from other tags.
 DefaultValueForAttribute_2        = No value specified for the \u201c{0}\u201d TIFF tag.
The {1} default value will be used.
@@ -31,7 +32,7 @@ ListTooShort_3                    = TIFF
 MismatchedLength_4                = TIFF tags \u201c{0}\u201d and \u201c{1}\u201d have values
of different lengths. Found \u201c{2}\u201d and \u201c{3}\u201d elements respectively.
 MissingGeoValue_1                 = No value has been found for the \u201c{0}\u201d GeoTIFF
key.
 MissingValue_2                    = Can not read TIFF image from \u201c{0}\u201d because
the \u201c{1}\u201d tag is missing.
-NotTheEpsgValue_5                 = The file defines \u201c{2}\u201d with a value of {3}{4},
but that value should be {1}{4} for consistency with {0}.
+NotTheEpsgValue_5                 = The file defines \u201c{2}\u201d with a value of {3}{4},
but that value should be {1}{4} according parent definition ({0}).
 RandomizedProcessApplied          = A randomized process such as error diffusion has been
applied to the image data.
 UnexpectedListOfValues_2          = A single value was expected for the \u201c{0}\u201d key
but {1} values have been found.
 UnexpectedTileCount_3             = Found {2} tiles or strips in the \u201c{0}\u201d file
while {1} were expected.

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Resources_fr.properties
[ISO-8859-1] Sat Dec 10 17:35:38 2016
@@ -24,6 +24,7 @@
 #   U+202F NARROW NO-BREAK SPACE  before  ; ! and ?
 #   U+00A0 NO-BREAK SPACE         before  :
 #
+CircularImageReference_1          = Le fichier TIFF \u00ab\u202f{0}\u202f\u00bb a des r\u00e9f\u00e9rences
circulaires dans sa cha\u00eene d\u2019images.
 ConstantValueRequired_3           = L\u2019impl\u00e9mentation de Apache SIS requiert que
tous les \u00e9l\u00e9ments de \u00ab\u202f{0}\u202f\u00bb aient la m\u00eame valeur, mais
les \u00e9l\u00e9ments trouv\u00e9s dans \u00ab\u202f{1}\u202f\u00bb sont {2}.
 ComputedValueForAttribute_2       = Aucune valeur n\u2019a \u00e9t\u00e9 sp\u00e9cifi\u00e9e
pour le tag TIFF \u00ab\u202f{0}\u202f\u00bb. La valeur {1} a \u00e9t\u00e9 calcul\u00e9e
\u00e0 partir des autres tags.
 DefaultValueForAttribute_2        = Aucune valeur n\u2019a \u00e9t\u00e9 sp\u00e9cifi\u00e9e
pour le tag TIFF \u00ab\u202f{0}\u202f\u00bb. La valeur par d\u00e9faut sera {1}.
@@ -36,7 +37,7 @@ ListTooShort_3                    = Le t
 MismatchedLength_4                = Les tags TIFF \u00ab\u202f{0}\u202f\u00bb et \u00ab\u202f{1}\u202f\u00bb
contiennent des valeurs de longueurs diff\u00e9rentes. On a trouv\u00e9 {2} et {3} \u00e9l\u00e9ments
respectivement.
 MissingGeoValue_1                 = Aucune valeur n\u2019a \u00e9t\u00e9 trouv\u00e9e pour
la cl\u00e9 GeoTIFF \u00ab\u202f{0}\u202f\u00bb.
 MissingValue_2                    = Ne peut pas lire l\u2019image TIFF provenant de \u00ab\u202f{0}\u202f\u00bb
car le tag \u00ab\u202f{1}\u202f\u00bb est manquant.
-NotTheEpsgValue_5                 = Le fichier d\u00e9finit \u00ab\u202f{2}\u202f\u00bb avec
la valeur {3}{4}, mais cette valeur devrait \u00eatre {1}{4} pour \u00eatre coh\u00e9rent
avec {0}.
+NotTheEpsgValue_5                 = Le fichier d\u00e9finit \u00ab\u202f{2}\u202f\u00bb avec
la valeur {3}{4}, mais cette valeur devrait \u00eatre {1}{4} pour \u00eatre en accord avec
la d\u00e9finition du parent {0}.
 RandomizedProcessApplied          = Un processus randomis\u00e9 comme la diffusion d\u2019erreur
a \u00e9t\u00e9 appliqu\u00e9.
 UnexpectedListOfValues_2          = Une seule valeur \u00e9tait attendue pour la cl\u00e9
\u00ab\u202f{0}\u202f\u00bb, mais on en a trouv\u00e9es {1}.
 UnexpectedTileCount_3             = {2} tuiles ont \u00e9t\u00e9 trouv\u00e9es dans le fichier
\u00ab\u202f{0}\u202f\u00bb alors qu\u2019on en attendait {1}.

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/CRSBuilder.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -54,6 +54,7 @@ import org.opengis.util.FactoryException
 
 import org.apache.sis.internal.geotiff.Resources;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.referencing.CoordinateOperations;
 import org.apache.sis.internal.referencing.NilReferencingObject;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.storage.MetadataBuilder;
@@ -78,6 +79,7 @@ import org.apache.sis.util.Characters;
 import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.Utilities.equalsIgnoreMetadata;
+import org.apache.sis.util.iso.DefaultNameSpace;
 
 
 /**
@@ -289,7 +291,7 @@ final class CRSBuilder {
      */
     private CoordinateOperationFactory operationFactory() {
         if (operationFactory == null) {
-            operationFactory = DefaultFactories.forBuildin(CoordinateOperationFactory.class);
+            operationFactory = CoordinateOperations.factory();
         }
         return operationFactory;
     }
@@ -483,8 +485,12 @@ final class CRSBuilder {
                     symbol = ' ' + symbol;    // Add a space before "m" but not before "°".
                 }
             }
+            /*
+             * Use Double.toString(…) instead of NumberFormat because the later does not
show
+             * enough significant digits for parameters like inverse flattening.
+             */
             warning(Resources.Keys.NotTheEpsgValue_5, IdentifiedObjects.getIdentifierOrName(epsg),
-                    expected, GeoKeys.name(key), actual, symbol);
+                    String.valueOf(expected), GeoKeys.name(key), String.valueOf(actual),
symbol);
         }
     }
 
@@ -494,10 +500,11 @@ final class CRSBuilder {
      * there is no need to specify the EPSG codes of the components, but the file still supply
      * those EPSG codes. If the values do not match, a warning is reported.
      *
-     * @param  epsg  the EPSG object.
-     * @param  key   the GeoTIFF key for the EPSG code of the given {@code epsg} object.
+     * @param  parent  the parent which contains the {@code epsg} object
+     * @param  epsg    the object created from the EPSG geodetic dataset.
+     * @param  key     the GeoTIFF key for the EPSG code of the given {@code epsg} object.
      */
-    private void verifyIdentifier(final IdentifiedObject epsg, final short key) {
+    private void verifyIdentifier(final IdentifiedObject parent, final IdentifiedObject epsg,
final short key) {
         final int code = getAsInteger(key);
         if (code > GeoCodes.undefined && code < GeoCodes.userDefined) {
             final Identifier id = IdentifiedObjects.getIdentifier(epsg, Citations.EPSG);
@@ -510,8 +517,9 @@ final class CRSBuilder {
                     return;
                 }
                 if (code != expected) {
-                    warning(Resources.Keys.NotTheEpsgValue_5, IdentifiedObjects.getIdentifierOrName(epsg),
-                            expected, GeoKeys.name(key), code, "");
+                    warning(Resources.Keys.NotTheEpsgValue_5, IdentifiedObjects.getIdentifierOrName(parent),
+                            Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + expected,
GeoKeys.name(key),
+                            Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code, "");
                 }
             }
         }
@@ -1050,10 +1058,10 @@ final class CRSBuilder {
      */
     private void verify(final GeodeticDatum datum, final Unit<Angle> angularUnit, final
Unit<Length> linearUnit) {
         final PrimeMeridian pm = datum.getPrimeMeridian();
-        verifyIdentifier(pm, GeoKeys.PrimeMeridian);
+        verifyIdentifier(datum, pm, GeoKeys.PrimeMeridian);
         verify(pm, angularUnit);
         final Ellipsoid ellipsoid = datum.getEllipsoid();
-        verifyIdentifier(ellipsoid, GeoKeys.Ellipsoid);
+        verifyIdentifier(datum, ellipsoid, GeoKeys.Ellipsoid);
         verify(ellipsoid, linearUnit);
     }
 
@@ -1206,7 +1214,7 @@ final class CRSBuilder {
          */
         final Unit<Length> linearUnit = createUnit(GeoKeys.GeogLinearUnits, GeoKeys.GeogLinearUnitSize,
Length.class, Units.METRE);
         final GeodeticDatum datum = crs.getDatum();
-        verifyIdentifier(datum, GeoKeys.GeodeticDatum);
+        verifyIdentifier(crs, datum, GeoKeys.GeodeticDatum);
         verify(datum, angularUnit, linearUnit);
     }
 
@@ -1290,10 +1298,10 @@ final class CRSBuilder {
         final Unit<Length> linearUnit  = createUnit(GeoKeys.LinearUnits,  GeoKeys.LinearUnitSize,
Length.class, Units.METRE);
         final Unit<Angle>  angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize,
Angle.class, Units.DEGREE);
         final GeographicCRS baseCRS = crs.getBaseCRS();
-        verifyIdentifier(baseCRS, GeoKeys.GeographicType);
+        verifyIdentifier(crs, baseCRS, GeoKeys.GeographicType);
         verify(baseCRS, angularUnit);
         final Conversion projection = crs.getConversionFromBase();
-        verifyIdentifier(projection, GeoKeys.Projection);
+        verifyIdentifier(crs, projection, GeoKeys.Projection);
         verify(projection, angularUnit, linearUnit);
     }
 

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTIFF.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -52,6 +52,16 @@ abstract class GeoTIFF implements Closea
     static final Locale LOCALE = Locale.US;
 
     /**
+     * The magic number for big-endian TIFF files or little-endian TIFF files.
+     */
+    static final short BIG_ENDIAN = 0x4D4D, LITTLE_ENDIAN = 0x4949;
+
+    /**
+     * The magic number for classic (32 bits) or big TIFF files.
+     */
+    static final short CLASSIC = 42, BIG_TIFF= 43;
+
+    /**
      * The store which created this reader or writer.
      */
     final GeoTiffStore owner;

Copied: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
(from r1773526, sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java?p2=sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java&p1=sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java&r1=1773526&r2=1773528&rev=1773528&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -66,7 +66,7 @@ public class GeoTiffStoreProvider extend
     public ProbeResult probeContent(StorageConnector connector) throws DataStoreException
{
         final ByteBuffer buffer = connector.getStorageAs(ByteBuffer.class);
         if (buffer != null) {
-            if (buffer.remaining() < 2 * Short.BYTES) {
+            if (buffer.remaining() < 2 * (Short.SIZE / Byte.SIZE)) {
                 return ProbeResult.INSUFFICIENT_BYTES;
             }
             final int p = buffer.position();
@@ -76,7 +76,7 @@ public class GeoTiffStoreProvider extend
                 final ByteOrder old = buffer.order();
                 try {
                     buffer.order(isBigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
-                    switch (buffer.getShort(p + Short.BYTES)) {
+                    switch (buffer.getShort(p + (Short.SIZE / Byte.SIZE))) {
                         case GeoTIFF.CLASSIC:
                         case GeoTIFF.BIG_TIFF: return new ProbeResult(true, MIME_TYPE, null);
                     }

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -19,6 +19,8 @@ package org.apache.sis.storage.geotiff;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.LinkedList;
+import java.util.Set;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.io.IOException;
 import java.nio.ByteOrder;
@@ -27,6 +29,7 @@ import org.apache.sis.storage.DataStoreE
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.internal.storage.ChannelDataInput;
 import org.apache.sis.internal.storage.MetadataBuilder;
+import org.apache.sis.internal.geotiff.Resources;
 import org.apache.sis.util.resources.Errors;
 
 // Branch-dependent imports
@@ -83,10 +86,21 @@ final class Reader extends GeoTIFF {
     /**
      * Offset (relative to the beginning of the TIFF file) of the next Image File Directory
(IFD)
      * to read, or 0 if we have finished to read all of them.
+     *
+     * @see #readNextImageOffset()
      */
     private long nextIFD;
 
     /**
+     * Offsets of all <cite>Image File Directory</cite> (IFD) that have been
read so far.
+     * This field is used only as a protection against infinite recursivity, by preventing
+     * the same offset to appear twice.
+     *
+     * @see #readNextImageOffset()
+     */
+    private final Set<Long> doneIFD;
+
+    /**
      * Positions of each <cite>Image File Directory</cite> (IFD) in this file.
      * Those positions are fetched when first needed.
      */
@@ -125,14 +139,15 @@ final class Reader extends GeoTIFF {
         this.input    = input;
         this.origin   = input.getStreamPosition();
         this.metadata = new MetadataBuilder();
+        this.doneIFD  = new HashSet<>();
         /*
          * A TIFF file begins with either "II" (0x4949) or "MM" (0x4D4D) characters.
          * Those characters identify the byte order. Note that we do not need to care
          * about the byte order for this flag since the two bytes shall have the same value.
          */
         final short order = input.readShort();
-        final boolean isBigEndian = (order == 0x4D4D);
-        if (isBigEndian || order == 0x4949) {
+        final boolean isBigEndian = (order == BIG_ENDIAN);
+        if (isBigEndian || order == LITTLE_ENDIAN) {
             input.buffer.order(isBigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
             /*
              * Magic number of TIFF file is 42, followed by nothing else.
@@ -143,12 +158,12 @@ final class Reader extends GeoTIFF {
              * but a future BigTIFF version may allow 16 bytes wide pointers.
              */
             switch (input.readShort()) {
-                case 42: {                                          // Magic number of classical
format.
+                case CLASSIC: {                                     // Magic number of classical
format.
                     intSizeExpansion = 0;
-                    nextIFD = input.readUnsignedInt();
+                    readNextImageOffset();
                     return;
                 }
-                case 43: {                                          // Magic number of BigTIFF
format.
+                case BIG_TIFF: {                                    // Magic number of BigTIFF
format.
                     final int numBits  = input.readUnsignedShort();
                     final int powerOf2 = Integer.numberOfTrailingZeros(numBits);    // In
the [0 … 32] range.
                     if (numBits == (1L << powerOf2) && input.readShort() ==
0) {
@@ -159,7 +174,7 @@ final class Reader extends GeoTIFF {
                              * one result in the end, but we did that generic computation
anyway for keeping the
                              * code almost ready if the BigTIFF specification adds support
for 16 bytes pointer.
                              */
-                            nextIFD = readUnsignedInt();
+                            readNextImageOffset();
                             return;
                         }
                     }
@@ -171,6 +186,18 @@ final class Reader extends GeoTIFF {
     }
 
     /**
+     * Sets {@link #nextIFD} to the next offset read from the TIFF file
+     * and makes sure that it will not cause an infinite loop.
+     */
+    private void readNextImageOffset() throws IOException, DataStoreException {
+        nextIFD = readUnsignedInt();
+        if (!doneIFD.add(nextIFD)) {
+            throw new DataStoreContentException(resources().getString(
+                    Resources.Keys.CircularImageReference_1, input.filename));
+        }
+    }
+
+    /**
      * Returns a default message for parsing error.
      */
     final String canNotDecode() {
@@ -280,7 +307,7 @@ final class Reader extends GeoTIFF {
                 }
             }
             imageFileDirectories.add(dir);
-            nextIFD = readUnsignedInt();                    // Zero if the IFD that we just
read was the last one.
+            readNextImageOffset();                          // Zero if the IFD that we just
read was the last one.
         }
         /*
          * At this point we got the requested IFD. But maybe some deferred entries need to
be read.

Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -19,6 +19,7 @@ package org.apache.sis.storage.netcdf;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.file.NoSuchFileException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -38,9 +39,6 @@ import org.apache.sis.util.logging.Warni
 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,
@@ -121,7 +119,7 @@ public class NetcdfStoreProvider extends
      * {@linkplain StorageConnector#getStorage() storage object} or contents.
      *
      * @param  connector  information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile}
instance, <i>etc</i>).
-     * @return {@code SUPPORTED} if the given storage seems to be usable by the {@code NetcdfStore}
instances.
+     * @return {@code SUPPORTED} if the given storage seems to be usable by {@code NetcdfStore}
instances.
      * @throws DataStoreException if an I/O error occurred.
      */
     @Override

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -71,6 +71,9 @@ import org.apache.sis.metadata.iso.acqui
 import org.apache.sis.metadata.iso.acquisition.DefaultOperation;
 import org.apache.sis.metadata.iso.acquisition.DefaultPlatform;
 import org.apache.sis.metadata.iso.acquisition.DefaultRequirement;
+import org.apache.sis.metadata.iso.lineage.DefaultLineage;
+import org.apache.sis.metadata.iso.lineage.DefaultProcessStep;
+import org.apache.sis.metadata.iso.lineage.DefaultProcessing;
 import org.apache.sis.metadata.sql.MetadataStoreException;
 import org.apache.sis.metadata.sql.MetadataSource;
 import org.apache.sis.util.CharSequences;
@@ -82,9 +85,6 @@ import static org.apache.sis.internal.ut
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.LocalDate;
 import org.apache.sis.internal.jdk8.JDK8;
-import org.apache.sis.metadata.iso.lineage.DefaultLineage;
-import org.apache.sis.metadata.iso.lineage.DefaultProcessStep;
-import org.apache.sis.metadata.iso.lineage.DefaultProcessing;
 import org.opengis.feature.FeatureType;
 
 

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java?rev=1773528&r1=1773527&r2=1773528&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
[UTF-8] Sat Dec 10 17:35:38 2016
@@ -16,14 +16,13 @@
  */
 package org.apache.sis.storage;
 
+import java.util.Objects;
 import java.io.Serializable;
+import java.io.ObjectStreamException;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.Version;
 import org.apache.sis.internal.util.Utilities;
 
-// Branch-dependent imports
-import java.util.Objects;
-
 
 /**
  * Tells whether a storage (file, database) appears to be supported by a {@code DataStore}.
@@ -156,10 +155,10 @@ public class ProbeResult implements Seri
     /**
      * Creates a new {@code ProbeResult} with the given support status, MIME type and version
number.
      *
-     * @param isSupported {@code true} if the storage is supported by the {@link DataStoreProvider}.
-     * @param mimeType    The storage MIME type, or {@code null} if unknown or not applicable.
-     * @param version     The version of file format or database schema used by the storage,
-     *                    or {@code null} if unknown or not applicable.
+     * @param isSupported  {@code true} if the storage is supported by the {@link DataStoreProvider}.
+     * @param mimeType     the storage MIME type, or {@code null} if unknown or not applicable.
+     * @param version      the version of file format or database schema used by the storage,
+     *                     or {@code null} if unknown or not applicable.
      */
     public ProbeResult(final boolean isSupported, final String mimeType, final Version version)
{
         this.isSupported = isSupported;
@@ -203,7 +202,7 @@ public class ProbeResult implements Seri
      *   <tr><td>{@code "application/soap+xml"}</td>                  
            <td></td><td></td></tr>
      * </table>
      *
-     * @return The storage MIME type, or {@code null} if unknown or not applicable.
+     * @return the storage MIME type, or {@code null} if unknown or not applicable.
      */
     public String getMimeType() {
         return mimeType;
@@ -213,7 +212,7 @@ public class ProbeResult implements Seri
      * Returns the version of file format or database schema used by the storage,
      * or {@code null} if unknown or not applicable.
      *
-     * @return The version of file format or database schema used by the storage,
+     * @return the version of file format or database schema used by the storage,
      *         or {@code null} if unknown or not applicable.
      */
     public Version getVersion() {
@@ -233,7 +232,7 @@ public class ProbeResult implements Seri
      * Two {@code ProbeResult}s are equal if they are instances of the same class
      * and all their properties are equal.
      *
-     * @param  object The object to compare with this {@code ProbeResult}.
+     * @param  object  the object to compare with this {@code ProbeResult}.
      * @return {@code true} if the two objects are equal.
      */
     @Override
@@ -287,7 +286,7 @@ public class ProbeResult implements Seri
          * okay if all comparisons are performed by the {@code equals} method instead
          * than the {@code ==} operator.
          */
-        Object readResolve() {
+        Object readResolve() throws ObjectStreamException {
             try {
                 return ProbeResult.class.getField(name).get(null);
             } catch (ReflectiveOperationException e) {



Mime
View raw message