You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/11/09 20:57:42 UTC
svn commit: r1713527 [4/4] - in /sis/branches/JDK7: ./
core/sis-build-helper/src/main/java/org/apache/sis/internal/book/
core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/
core/sis-feature/src/main/java/org/apache/sis/feature/ core/...
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -72,12 +72,12 @@ public final strictfp class ObliqueStere
* <li>Parameters used in linear operations (additions or multiplications) performed <strong>before</strong> the
* non-linear part (the "kernel") of the map projection. Those parameters are <var>λ₀</var> and <var>n</var>
* and their values are stored in the normalization matrix given by
- * <code>{@linkplain ContextualParameters#getMatrix(boolean) ContextualParameters.getMatrix}(true)</code>.</li>
+ * <code>{@linkplain ContextualParameters#getMatrix ContextualParameters.getMatrix}(NORMALIZATION)</code>.</li>
*
* <li>Parameters used in linear operations (additions or multiplications) performed <strong>after</strong> the
* non-linear part (the "kernel") of the map projection. Those parameters are <var>k₀</var>, <var>R</var>,
* <var>FE</var> and <var>FN</var> and their values are stored in the denormalization matrix given by
- * <code>{@linkplain ContextualParameters#getMatrix(boolean) ContextualParameters.getMatrix}(false)</code>.</li>
+ * <code>{@linkplain ContextualParameters#getMatrix ContextualParameters.getMatrix}(DENORMALIZATION)</code>.</li>
*
* <li>Other parameters are either used in the non-linear "kernel" of the map projection or used for computing the
* above-cited parameters.</li>
@@ -93,8 +93,8 @@ public final strictfp class ObliqueStere
/* After kernel */ R = 6382644.571, // Radius of conformal sphere (m)
a = 6377397.155, // Semi-major axis length (m)
ivf = 299.15281, // Inverse flattening factor
- e = 0.08169683, // Excentricity
- /* Before kernel */ n = 1.000475857, // Coefficient computed from excentricity and φ₀.
+ e = 0.08169683, // Eccentricity
+ /* Before kernel */ n = 1.000475857, // Coefficient computed from eccentricity and φ₀.
/* After kernel */ k0 = 0.9999079, // Scale factor
/* After kernel */ FE = 155000.00, // False Easting (m)
/* After kernel */ FN = 463000.00; // False Northing (m)
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ProjectionResultComparator.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -105,7 +105,7 @@ final strictfp class ProjectionResultCom
final Class<?> sphericalClass = spherical.getClass();
final Class<?> ellipticalClass = sphericalClass.getSuperclass();
assertEquals("Class name for the spherical formulas.", "Spherical", sphericalClass.getSimpleName());
- assertEquals("Excentricity of spherical case.", 0, spherical.excentricity, 0);
+ assertEquals("Eccentricity of spherical case.", 0, spherical.eccentricity, 0);
assertSame("In SIS implementation, the spherical cases are defined as inner classes named “Spherical”"
+ " which extend their enclosing class. This is only a convention, which we verify here. But"
+ " there is nothing wrong if a future version choose to not follow this convention anymore.",
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -62,8 +62,10 @@ public final strictfp class ContextualPa
public void testParameters() {
final ContextualParameters p = create(1, 1);
assertTrue("values().isEmpty()", p.values().isEmpty());
- assertTrue("normalize.isIdentity()", p.getMatrix(true).isIdentity());
- assertTrue("denormalize.isIdentity()", p.getMatrix(false).isIdentity());
+ assertTrue("normalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION).isIdentity());
+ assertTrue("denormalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION).isIdentity());
+ assertTrue("normalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.INVERSE_NORMALIZATION).isIdentity());
+ assertTrue("denormalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.INVERSE_DENORMALIZATION).isIdentity());
final ParameterValue<?> p1 = p.parameter("Mandatory 1");
final ParameterValue<?> p2 = p.parameter("Mandatory 2");
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -384,6 +384,18 @@ public abstract strictfp class MathTrans
}
/**
+ * Asserts that the current {@linkplain #transform transform} produces the given internal WKT.
+ *
+ * @param expected The expected internal WKT.
+ *
+ * @since 0.7
+ */
+ protected final void assertInternalWktEquals(final String expected) {
+ assertNotNull("The 'transform' field shall be assigned a value.", transform);
+ ReferencingAssert.assertWktEquals(Convention.INTERNAL, expected, transform);
+ }
+
+ /**
* Prints the current {@linkplain #transform transform} as normal and internal WKT.
* This method is for debugging purpose only.
*
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -33,7 +33,7 @@ import org.apache.sis.internal.metadata.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.7
* @module
*/
@SuppressWarnings("serial")
@@ -59,6 +59,11 @@ public final strictfp class GeodeticDatu
public static final GeodeticDatum NAD27 = new GeodeticDatumMock("NAD27", 6378206.4, 6356583.8, 294.97869821390583, false);
/**
+ * The "European Datum 1950" datum with "International 1924" ellipsoid.
+ */
+ public static final GeodeticDatum ED50 = new GeodeticDatumMock("ED50", 6378388, 6356912, 297, true);
+
+ /**
* The "Nouvelle Triangulation Française" (EPSG:6807) datum with "Clarke 1880 (IGN)" ellipsoid.
* This is the same datum than "Nouvelle Triangulation Française (Paris)" (EPSG:6275) except
* for the prime meridian, which is Greenwich instead of Paris.
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -74,6 +74,33 @@ import org.junit.BeforeClass;
org.apache.sis.internal.jaxb.referencing.CC_GeneralOperationParameterTest.class,
org.apache.sis.internal.jaxb.referencing.CC_OperationParameterGroupTest.class,
+ // Coordinate Reference System components (except derived CRS).
+ org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
+ org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
+ org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+ org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
+ org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
+ org.apache.sis.referencing.datum.DefaultTemporalDatumTest.class,
+ org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
+ org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
+ org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
+ org.apache.sis.referencing.cs.NormalizerTest.class,
+ org.apache.sis.referencing.cs.AbstractCSTest.class,
+ org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
+ org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
+ org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
+ org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
+ org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
+ org.apache.sis.referencing.cs.HardCodedCSTest.class,
+ org.apache.sis.referencing.crs.AbstractCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
+
// Test transforms other than map projections.
org.apache.sis.referencing.operation.transform.CoordinateDomainTest.class,
org.apache.sis.referencing.operation.transform.IterationStrategyTest.class,
@@ -88,15 +115,19 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.transform.TransferFunctionTest.class,
org.apache.sis.referencing.operation.transform.MathTransformsTest.class,
org.apache.sis.referencing.operation.transform.ContextualParametersTest.class,
-
- // Registration of map projections and other math transforms.
+ org.apache.sis.referencing.operation.transform.EllipsoidalToCartesianTransformTest.class,
+ org.apache.sis.referencing.operation.transform.MolodenskyTransformTest.class,
org.apache.sis.referencing.operation.DefaultFormulaTest.class,
org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
org.apache.sis.referencing.operation.AbstractSingleOperationTest.class,
- // Other test classes from the 'operation' package after the CRS tests below.
org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class,
+
+ // Registration of map projections and other math transforms.
org.apache.sis.internal.referencing.provider.AffineTest.class,
org.apache.sis.internal.referencing.provider.LongitudeRotationTest.class,
+ org.apache.sis.internal.referencing.provider.GeocentricTranslationTest.class,
+ org.apache.sis.internal.referencing.provider.PositionVector7ParamTest.class,
+ org.apache.sis.internal.referencing.provider.CoordinateFrameRotationTest.class,
org.apache.sis.internal.referencing.provider.MapProjectionTest.class,
org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class,
@@ -112,32 +143,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.projection.PolarStereographicTest.class,
org.apache.sis.referencing.operation.projection.ObliqueStereographicTest.class,
- // Coordinate Reference System components.
- org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
- org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
- org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
- org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
- org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
- org.apache.sis.referencing.datum.DefaultTemporalDatumTest.class,
- org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
- org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
- org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
- org.apache.sis.referencing.cs.NormalizerTest.class,
- org.apache.sis.referencing.cs.AbstractCSTest.class,
- org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
- org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
- org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
- org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
- org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
- org.apache.sis.referencing.cs.HardCodedCSTest.class,
- org.apache.sis.referencing.crs.AbstractCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
- org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
- org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
- org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
- org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
+ // Coordinate operation and derived Coordinate Reference Systems (cyclic dependency).
org.apache.sis.referencing.operation.DefaultTransformationTest.class,
org.apache.sis.referencing.operation.DefaultConversionTest.class,
org.apache.sis.referencing.operation.SingleOperationMarshallingTest.class,
@@ -148,6 +154,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.SubTypesTest.class,
org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
org.apache.sis.referencing.crs.HardCodedCRSTest.class,
+
org.apache.sis.referencing.factory.GIGS3002.class,
org.apache.sis.referencing.factory.GIGS3003.class,
org.apache.sis.referencing.factory.GIGS3004.class,
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -44,7 +44,7 @@ import org.apache.sis.internal.jaxb.Cont
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.7
* @module
*/
public abstract class CodeListAdapter<ValueType extends CodeListAdapter<ValueType,BoundType>,
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -172,6 +172,7 @@ public final class CodeListUID {
*
* @return The identifier to be given to the {@code CodeList.valueOf(…)} method.
*/
+ @Override
public String toString() {
String id = codeListValue;
if (id == null) {
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -96,6 +96,11 @@ public final class Errors extends Indexe
public static final short CanNotComputeDerivative = 1;
/**
+ * Can not compute “{0}”.
+ */
+ public static final short CanNotCompute_1 = 201;
+
+ /**
* Can not concatenate transforms “{0}” and “{1}”.
*/
public static final short CanNotConcatenateTransforms_2 = 160;
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -33,6 +33,7 @@ CanNotConcatenateTransforms_2 = Can
CanNotConnectTo_1 = Can not connect to \u201c{0}\u201d.
CanNotConvertFromType_2 = Can not convert from type \u2018{0}\u2019 to type \u2018{1}\u2019.
CanNotConvertValue_2 = Can not convert value \u201c{0}\u201d to type \u2018{1}\u2019.
+CanNotCompute_1 = Can not compute \u201c{0}\u201d.
CanNotComputeDerivative = Can not compute the derivative.
CanNotInstantiate_1 = Can not instantiate an object of type \u2018{0}\u2019.
CanNotMapAxisToDirection_2 = Can not map an axis from \u201c{0}\u201d to direction \u201c{1}\u201d.
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -30,6 +30,7 @@ CanNotConcatenateTransforms_2 = Les
CanNotConnectTo_1 = Ne peut pas se connecter \u00e0 \u00ab\u202f{0}\u202f\u00bb.
CanNotConvertFromType_2 = Ne peut pas convertir du type \u2018{0}\u2019 vers le type \u2018{1}\u2019.
CanNotConvertValue_2 = La valeur \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre convertie vers le type \u2018{1}\u2019.
+CanNotCompute_1 = Ne peut pas calculer \u00ab\u202f{0}\u202f\u00bb.
CanNotComputeDerivative = La d\u00e9riv\u00e9 ne peut pas \u00eatre calcul\u00e9e.
CanNotInstantiate_1 = Ne peut pas cr\u00e9er un objet de type \u2018{0}\u2019.
CanNotMapAxisToDirection_2 = Aucun axe de \u00ab\u202f{0}\u202f\u00bb n\u2019a pu \u00eatre associ\u00e9 \u00e0 la direction \u00ab\u202f{1}\u202f\u00bb.
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/build-impl.xml Mon Nov 9 19:57:39 2015
@@ -209,7 +209,12 @@ is divided into following sections:
</not>
</and>
</condition>
- <property name="javac.fork" value="${jdkBug6558476}"/>
+ <condition else="false" property="javac.fork">
+ <or>
+ <istrue value="${jdkBug6558476}"/>
+ <istrue value="${javac.external.vm}"/>
+ </or>
+ </condition>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
@@ -235,6 +240,7 @@ is divided into following sections:
<condition else="" property="testng.debug.mode" value="-mixed">
<istrue value="${junit+testng.available}"/>
</condition>
+ <property name="java.failonerror" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
@@ -801,7 +807,7 @@ is divided into following sections:
<sequential>
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
- <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+ <java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
@@ -876,7 +882,7 @@ is divided into following sections:
<attribute default="${debug.classpath}" name="classpath"/>
<element name="customize" optional="true"/>
<sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
@@ -903,7 +909,7 @@ is divided into following sections:
<attribute default="jvm" name="jvm"/>
<element name="customize" optional="true"/>
<sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -4,5 +4,5 @@ build.xml.data.CRC32=58e6b21c
build.xml.script.CRC32=462eaba0
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
nbproject/build-impl.xml.data.CRC32=8bd6b764
-nbproject/build-impl.xml.script.CRC32=fc0a5456
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
+nbproject/build-impl.xml.script.CRC32=e337b80c
+nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.xml Mon Nov 9 19:57:39 2015
@@ -66,7 +66,6 @@
<word>deserialization</word>
<word>deserialized</word>
<word>endianness</word>
- <word>excentricity</word>
<word>geoidal</word>
<word>hectopascals</word>
<word>initially</word>
Modified: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -34,6 +34,11 @@ import static org.apache.sis.test.TestUt
* @module
*/
public final strictfp class DataIdentificationTest extends TestCase {
+ /**
+ * Tests marshalling and unmarshalling of a XML fragment.
+ *
+ * @throws JAXBException if an error occurred during (un)marshalling.
+ */
@Test
public void testMarshalling() throws JAXBException {
final String xml =
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -21,12 +21,15 @@ import java.io.IOException;
import java.nio.ByteOrder;
import java.text.MessageFormat;
import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.sis.feature.DefaultAttributeType;
import org.apache.sis.feature.DefaultFeatureType;
import org.apache.sis.internal.shapefile.jdbc.*;
import org.apache.sis.storage.shapefile.InvalidShapefileFormatException;
import org.apache.sis.storage.shapefile.ShapeTypeEnum;
+import org.apache.sis.util.logging.Logging;
import org.opengis.feature.Feature;
import com.esri.core.geometry.*;
@@ -137,7 +140,7 @@ public class ShapefileByteReader extends
MappedByteReader databaseReader = null;
try {
- databaseReader = new MappedByteReader(dbaseFile);
+ databaseReader = new MappedByteReader(dbaseFile, null);
databaseFieldsDescriptors = databaseReader.getFieldsDescriptors();
}
finally {
@@ -204,40 +207,125 @@ public class ShapefileByteReader extends
/**
* Load polygon feature.
* @param feature Feature to fill.
- * @throws InvalidShapefileFormatException if the polygon cannot be handled.
*/
- private void loadPolygonFeature(Feature feature) throws InvalidShapefileFormatException {
+ private void loadPolygonFeature(Feature feature) {
/* double xmin = */getByteBuffer().getDouble();
/* double ymin = */getByteBuffer().getDouble();
/* double xmax = */getByteBuffer().getDouble();
/* double ymax = */getByteBuffer().getDouble();
- int NumParts = getByteBuffer().getInt();
- int NumPoints = getByteBuffer().getInt();
+ int numParts = getByteBuffer().getInt();
+ int numPoints = getByteBuffer().getInt();
- if (NumParts > 1) {
- throw new InvalidShapefileFormatException("Polygons with multiple linear rings have not implemented yet.");
- }
+ Polygon poly;
- // read the one part
- @SuppressWarnings("unused")
- int Part = getByteBuffer().getInt();
+ // 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.
+ * @return Polygon.
+ */
+ @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
double xpnt = getByteBuffer().getDouble();
double ypnt = getByteBuffer().getDouble();
- // Point oldpnt = new Point(xpnt, ypnt);
+
poly.startPath(xpnt, ypnt);
- for (int j = 0; j < NumPoints - 1; j++) {
+ for (int j = 0; j < numPoints - 1; j++) {
xpnt = getByteBuffer().getDouble();
ypnt = getByteBuffer().getDouble();
poly.lineTo(xpnt, ypnt);
}
-
- feature.setPropertyValue(GEOMETRY_NAME, poly);
+
+ return poly;
}
+
+ /**
+ * Read a polygon that has multiple parts.
+ * @param numParts Number of parts of this polygon.
+ * @param numPoints Total number of points of this polygon, all parts considered.
+ * @return a multiple part polygon.
+ */
+ private Polygon readMultiplePolygonParts(int numParts, int numPoints) {
+ /**
+ * 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
+ *
+ * POSITION FIELD VALUE TYPE NUMBER ORDER
+ * Byte 0 Shape Type 5 Integer 1 Little
+ * Byte 4 Box Box Double 4 Little
+ * 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
+ */
+ 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();
+ }
+
+ // Read all the points.
+ double[] xPoints = new double[numPoints];
+ double[] yPoints = new double[numPoints];
+
+ for(int index=0; index < numPoints; index ++) {
+ xPoints[index] = getByteBuffer().getDouble();
+ yPoints[index] = getByteBuffer().getDouble();
+ }
+
+ // Create the polygon from the points.
+ Polygon poly = new Polygon();
+ // create a line from the points
+ for(int index=0; index < numPoints; index ++) {
+ // Check if this index is one that begins a new part.
+ boolean newPolygon = false;
+
+ for(int j=0; j < partsIndexes.length; j ++) {
+ if (partsIndexes[j] == index) {
+ newPolygon = true;
+ break;
+ }
+ }
+
+ if (newPolygon) {
+ poly.startPath(xPoints[index], yPoints[index]);
+ }
+ else {
+ poly.lineTo(xPoints[index], yPoints[index]);
+ }
+ }
+
+ return poly;
+ }
+
/**
* Load polyline feature.
* @param feature Feature to fill.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -135,11 +135,9 @@ abstract class AbstractDbase3ByteReader
* Convert the binary code page value of the Dbase 3 file to a recent Charset.
* @param codePageBinaryValue page code binary value.
* @return Charset.
- * @throws SQLInvalidDbaseFileFormatException if the binary value is not one of the standard values that the DBF file should carry : the Dbase 3
- * file might be corrupted.
* @throws UnsupportedCharsetException if the code page as no representation in recents Charset (legacy DOS or macintosh charsets).
*/
- protected Charset toCharset(byte codePageBinaryValue) throws SQLInvalidDbaseFileFormatException, UnsupportedCharsetException {
+ protected Charset toCharset(byte codePageBinaryValue) throws UnsupportedCharsetException {
// Attempt to find a known conversion.
String dbfCodePage = toCodePage(codePageBinaryValue);
@@ -153,21 +151,15 @@ abstract class AbstractDbase3ByteReader
case 0x97: dbfCodePage = "unsupported"; break; // eastern european macintosh
case 0x98: dbfCodePage = "unsupported"; break; // greek macintosh
case 0xC8: dbfCodePage = "unsupported"; break; // windows ee
- default: dbfCodePage = "invalid"; break;
+ default: dbfCodePage = "unsupported"; break;
}
}
assert dbfCodePage != null;
- // If the code page is invalid, the database itself has chances to be invalid too.
- if (dbfCodePage.equals("invalid")) {
- String message = format(Level.WARNING, "excp.illegal_codepage", codePageBinaryValue, getFile().getAbsolutePath());
- throw new SQLInvalidDbaseFileFormatException(message);
- }
-
// If the code page cannot find a match for a more recent Charset, we wont be able to handle this DBF.
if (dbfCodePage.equals("unsupported")) {
- String message = format(Level.WARNING, "excp.unsupported_codepage", dbfCodePage, getFile().getAbsolutePath());
+ String message = format(Level.WARNING, "excp.unsupported_codepage", codePageBinaryValue, getFile().getAbsolutePath());
throw new UnsupportedCharsetException(message);
}
@@ -251,6 +243,14 @@ abstract class AbstractDbase3ByteReader
return(knownConversions.get(pageCodeBinaryValue & 0xFF));
}
+
+ /**
+ * Set a charset.
+ * @param cs Charset.
+ */
+ public void setCharset(Charset cs) {
+ this.charset = cs;
+ }
/**
* Return a date from a byte array.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -16,13 +16,16 @@
*/
package org.apache.sis.internal.shapefile.jdbc;
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
+import java.io.File;
+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.*;
+import org.apache.sis.internal.system.Modules;
/**
@@ -61,7 +64,7 @@ public class DBFDriver extends AbstractJ
* Attempts to make a database connection to the given filename.
*
* @param url The path to a {@code .dbf} file.
- * @param info Ignored in current implementation.
+ * @param info Properties to ask for special features, behavior, or compatibility.
* @return A connection to the given DBF file.
* @throws SQLInvalidDbaseFileFormatException if the database file format is invalid.
* @throws SQLDbaseFileNotFoundException if the database file doesn't exist.
@@ -69,11 +72,10 @@ public class DBFDriver extends AbstractJ
*/
@Override
@SuppressWarnings("resource") // the function opens a connection.
- public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
+ public Connection connect(final String url, Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
Objects.requireNonNull(url, "the DBase3 url cannot be null");
File file = new File(url);
-
- return new DBFConnection(file, new MappedByteReader(file));
+ return new DBFConnection(file, new MappedByteReader(file, info));
}
/**
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -114,5 +114,5 @@ public interface Dbase3ByteReader {
* Read the next row as a set of objects.
* @return Map of field name / object value.
*/
- public Map<String, Object> readNextRowAsObjects();
+ public Map<String, byte[]> readNextRowAsObjects();
}
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -19,6 +19,8 @@ package org.apache.sis.internal.shapefil
import java.io.File;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
import java.util.*;
import java.util.logging.Level;
@@ -39,14 +41,31 @@ public class MappedByteReader extends Ab
/** List of field descriptors. */
private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<>();
+ /** Connection properties. */
+ private Properties info;
+
/**
* Construct a mapped byte reader on a file.
* @param dbase3File File.
+ * @param connectionInfos Connection properties, maybe null.
* @throws SQLInvalidDbaseFileFormatException if the database seems to be invalid.
* @throws SQLDbaseFileNotFoundException if the Dbase file has not been found.
*/
- public MappedByteReader(File dbase3File) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
+ public MappedByteReader(File dbase3File, Properties connectionInfos) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
super(dbase3File);
+ this.info = connectionInfos;
+
+ // React to special features asked.
+ if (info != null) {
+ // Sometimes, DBF files have a wrong charset, or more often : none, and you have to specify it.
+ String recordCharset = (String)info.get("record_charset");
+
+ if (recordCharset != null) {
+ Charset cs = Charset.forName(recordCharset);
+ setCharset(cs);
+ }
+ }
+
loadDescriptor();
}
@@ -81,7 +100,26 @@ public class MappedByteReader extends Ab
*/
@Override
public boolean nextRowAvailable() {
- return getByteBuffer().hasRemaining();
+ // 1) Check for remaining bytes.
+ if (getByteBuffer().hasRemaining() == false) {
+ return false;
+ }
+
+ // 2) Check that the immediate next byte read isn't the EOF signal.
+ byte eofCheck = getByteBuffer().get();
+
+ boolean isEOF = (eofCheck == 0x1A);
+ this.log(Level.FINER, "log.delete_status", rowNum, eofCheck, isEOF ? "EOF" : "Active");
+
+ if (eofCheck == 0x1A) {
+ return false;
+ }
+ else {
+ // Return one byte back.
+ int position = getByteBuffer().position();
+ getByteBuffer().position(position-1);
+ return true;
+ }
}
/**
@@ -89,24 +127,36 @@ public class MappedByteReader extends Ab
* @return Map of field name / object value.
*/
@Override
- public Map<String, Object> readNextRowAsObjects() {
+ public Map<String, byte[]> readNextRowAsObjects() {
// TODO: ignore deleted records
/* byte isDeleted = */ getByteBuffer().get(); // denotes whether deleted or current
+
// read first part of record
-
- HashMap<String, Object> fieldsValues = new HashMap<>();
+ HashMap<String, byte[]> fieldsValues = new HashMap<>();
for (DBase3FieldDescriptor fd : fieldsDescriptors) {
byte[] data = new byte[fd.getLength()];
getByteBuffer().get(data);
+ // Trim the bytes right.
int length = data.length;
+
while (length != 0 && data[length - 1] <= ' ') {
length--;
}
-
- String value = new String(data, 0, length);
- fieldsValues.put(fd.getName(), value);
+
+ if (length != data.length) {
+ byte[] dataTrimmed = new byte[length];
+
+ for(int index=0; index < length; index ++) {
+ dataTrimmed[index] = data[index];
+ }
+
+ fieldsValues.put(fd.getName(), dataTrimmed);
+ }
+ else {
+ fieldsValues.put(fd.getName(), data);
+ }
}
rowNum ++;
@@ -137,7 +187,19 @@ public class MappedByteReader extends Ab
// Translate code page value to a known charset.
this.codePage = getByteBuffer().get();
- this.charset = toCharset(this.codePage);
+
+ if (this.charset == null) {
+ try {
+ this.charset = toCharset(this.codePage);
+ }
+ catch(UnsupportedCharsetException e) {
+ // Warn the caller that he will have to perform is own conversions.
+ format(Level.WARNING, "log.no_valid_charset", getFile().getAbsolutePath(), e.getMessage());
+ }
+ }
+ else {
+ format(Level.INFO, "log.record_charset", this.charset.name());
+ }
getByteBuffer().get(reservedFiller2);
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -311,9 +311,9 @@ public class DBFConnection extends Abstr
/**
* Read the next row as a set of objects.
- * @return Map of field name / object value.
+ * @return Map of field name / object value, or null if EoF has been encountered.
*/
- public Map<String, Object> readNextRowAsObjects() {
+ public Map<String, byte[]> readNextRowAsObjects() {
return byteReader.readNextRowAsObjects();
}
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -44,14 +44,11 @@ import org.apache.sis.internal.jdk8.Func
*/
public class DBFRecordBasedResultSet extends DBFResultSet {
/** The current record. */
- private Map<String, Object> record;
+ private Map<String, byte[]> record;
/** Condition of where clause (currently, only one is handled). */
private ConditionalClauseResolver singleConditionOfWhereClause;
- /** UTF-8 charset. */
- private static Charset UTF8 = Charset.forName("UTF-8");
-
/**
* Constructs a result set.
* @param stmt Parent statement.
@@ -468,35 +465,27 @@ public class DBFRecordBasedResultSet ext
assertNotClosed();
getFieldDesc(columnLabel, sql); // Ensure that the field queried exists, else a null value here can be interpreted as "not existing" or "has a null value".
- String withoutCharset = (String)record.get(columnLabel);
+ byte[] bytes = record.get(columnLabel);
- if (withoutCharset == null) {
+ if (bytes == null) {
wasNull = true;
- return withoutCharset;
+ return null;
}
else {
wasNull = false;
}
- // If a non null value has been readed, convert it to the wished Charset.
+ // 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();
- String withDatabaseCharset = new String(withoutCharset.getBytes(), cnt.getCharset());
- log(Level.FINER, "log.string_field_charset", columnLabel, withoutCharset, withDatabaseCharset, cnt.getCharset());
-
- // Because the Database is old (end of 1980's), it has not been made to support UTF-8 encoding.
- // But must users of DBase 3 don't know this, and sometimes a String field may carry such characters.
- // Attempt to determine if the string could be an UTF-8 String instead.
- String withUtf8Encoding = new String(withoutCharset.getBytes(), UTF8);
-
- // If conversion contains a not convertible character, it's not an UTF-8 string.
- // If the UTF-8 string is shorter than the one that would have given the database charset, it's a good sign : it has chances to be better.
- boolean unsureResult = withUtf8Encoding.indexOf('\ufffd') != -1 || withUtf8Encoding.length() >= withDatabaseCharset.length();
-
- if (unsureResult)
- return withDatabaseCharset;
+ Charset charset = cnt.getCharset();
+
+ if (charset == null) {
+ return new String(bytes);
+ }
else {
- log(Level.FINER, "log.string_field_charset", columnLabel, withoutCharset, withUtf8Encoding, UTF8);
- return withUtf8Encoding;
+ String withDatabaseCharset = new String(bytes, charset);
+ log(Level.FINER, "log.string_field_charset", columnLabel, withDatabaseCharset, charset);
+ return withDatabaseCharset;
}
}
@@ -594,8 +583,8 @@ public class DBFRecordBasedResultSet ext
assertNotClosed();
try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) {
- String textValue = (String)record.get(columnLabel);
-
+ String textValue = getString(columnLabel);
+
if (textValue == null) {
return null;
}
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -13,3 +13,18 @@ excp.illegal_column_index=Illegal column
#1 : SQL Query that was attempted but failed.
#2 : Database name.
excp.no_such_column_in_resultset=There is no ''{0}'' column in this SQL query ''{1}'' on database {2}.
+
+# Log : status of deletion of a record.
+#0 : Record number.
+#1 : Byte status.
+#2 : Meaning of this status.
+log.delete_status=rownum {0,number} : record byte status is {1}, meaning : {2}.
+
+# Log : no valid charset found on DBase file. None will be used.
+#0 : Database name.
+#1 : Error message received that explains the problem.
+log.no_valid_charset=No valid charset has been found on this {0} file : (error message : ''{1}'') and ResultSet.getString(...) methods will provide characters as they are. Reader might have to perform his own conversions.
+
+# Log : A given charset overrides the Dbase file one.
+#0 : Overriding charset.
+log.record_charset=A given record charset ''{0}'' has been set from the connection and will override the Dbase file one.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -13,3 +13,18 @@ excp.illegal_column_index=Index de colon
#1: SQL Query that was attempted but failed.
#2: Database name.
excp.no_such_column_in_resultset=Il n''y a pas de colonne ''{0}'' dans cette requête SQL ''{1}'' sur la base de données {2}.
+
+# Log : status of deletion of a record.
+#0 : Record number.
+#1 : Byte status.
+#2 : Meaning of this status.
+log.delete_status=rownum {0,number} : l''octet de statut d''enregistrement vaut {1}, signifiant : {2}.
+
+# Log : no valid charset found on DBase file. None will be used.
+#0 : Database name.
+#1 : Error message received that explains the problem.
+log.no_valid_charset=Aucun jeu de caractères valide n''a été trouvé dans le fichier {0} : (message d''erreur : ''{1}'') et les méthodes ResultSet.getString(...) vont fournir les caractères comme ils sont. Le lecteur pourra devoir réaliser ses propres conversions.
+
+# Log : A given charset overrides the Dbase file one.
+#0 : Overriding charset.
+log.record_charset=Un charset ''{0}'' a été défini dans la connection et va remplacer celui du fichier DBase.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -23,6 +23,6 @@ excp.no_more_results=The result set has
# Log : a string value has been converted with a charset.
#0 : Field name.
-#1 : Field original database value.
-#2 : Field value after being converted with the charset.
-log.string_field_charset=String field name ''{0}'', value ''{1}'' changed to ''{2}'' using charset {3}.
+#1 : Field value after being converted with the charset.
+#2 : Charset used.
+log.string_field_charset=String field name ''{0}'' bytes values converted to ''{1}'' using charset {2}.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] Mon Nov 9 19:57:39 2015
@@ -23,7 +23,6 @@ excp.no_more_results=Le ResultSet n''a p
# Log : a string value has been converted with a charset.
#0 : Field name.
-#1 : Field original database value.
-#2 : Field value after being converted with the charset.
-log.string_field_charset=String field name ''{0}'', value ''{1}'' changed to ''{2}'' using charset {3}.
-
+#1 : Field value after being converted with the charset.
+#2 : Charset used.
+log.string_field_charset=Les octets du champ de nom ''{0}'' ont été converties en ''{1}'' en utilisant le jeu de caractères {2}.
Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java?rev=1713527&r1=1713526&r2=1713527&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] Mon Nov 9 19:57:39 2015
@@ -17,6 +17,7 @@
package org.apache.sis.internal.shapefile.jdbc;
import java.sql.*;
+import java.util.Properties;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.test.DependsOnMethod;
@@ -44,6 +45,25 @@ public class DBFConnectionTest extends A
assertFalse("Connection should be opened", connection.isClosed());
assertTrue ("Connection should be valid", connection.isValid(0));
+ connection.close();
+ assertTrue ("Connection should be closed", connection.isClosed());
+ assertFalse("Connection should no more be valid", connection.isValid(0));
+ }
+
+ /**
+ * Open and close a connection.
+ * @throws SQLException if an error occurred while opening the database.
+ */
+ @Test
+ public void openCloseConnectionWithAnotherCharset() throws SQLException {
+ Properties info = new Properties();
+ info.put("record_charset", "UTF-8");
+
+ final Driver driver = new DBFDriver();
+ final Connection connection = driver.connect(dbfFile.getAbsolutePath(), info);
+ assertFalse("Connection should be opened", connection.isClosed());
+ assertTrue ("Connection should be valid", connection.isValid(0));
+
connection.close();
assertTrue ("Connection should be closed", connection.isClosed());
assertFalse("Connection should no more be valid", connection.isValid(0));