Author: desruisseaux
Date: Fri Apr 20 16:18:08 2018
New Revision: 1829670
URL: http://svn.apache.org/viewvc?rev=1829670&view=rev
Log:
Merge from JDK8 branch. Most of the sis-sql module is excluded for now since
this is a work in progress.
Added:
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/internal/feature/ESRITest.java
- copied unchanged from r1829667,
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/ESRITest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/internal/feature/GeometriesTestCase.java
- copied unchanged from r1829667,
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/GeometriesTestCase.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/internal/feature/JTSTest.java
- copied unchanged from r1829667,
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/JTSTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/internal/feature/Java2DTest.java
- copied unchanged from r1829667,
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/Java2DTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/xml/
- copied from r1829667,
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/xml/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/
- copied from r1829667,
sis/branches/JDK8/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/
sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml~
- copied, changed from r1829667,
sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml
sis/trunk/storage/sis-sql/
- copied from r1829667, sis/branches/JDK8/storage/sis-sql/
Removed:
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/internal/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/extent/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/quality/
sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/internal/
sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/pom.xml
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MimeTypeCommandTest.java
sis/trunk/application/sis-openoffice/pom.xml
sis/trunk/core/sis-build-helper/pom.xml
sis/trunk/core/sis-feature/pom.xml
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
sis/trunk/core/sis-metadata/pom.xml
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/Context.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LanguageCode.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformedEvent.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/Transformer.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingReader.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingWriter.java
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/cat/EnumAdapterTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/FreeTextMarshallingTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/LanguageCodeTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/PT_LocaleTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/DefaultExtentTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/ServiceIdentification.xml
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/ServiceIdentification.xml
sis/trunk/core/sis-portrayal/pom.xml
sis/trunk/core/sis-raster/pom.xml
sis/trunk/core/sis-referencing-by-identifiers/pom.xml
sis/trunk/core/sis-referencing/pom.xml
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
sis/trunk/core/sis-utility/pom.xml
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/GeometryLibrary.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml
sis/trunk/ide-project/NetBeans/nbproject/genfiles.properties
sis/trunk/ide-project/NetBeans/nbproject/project.properties
sis/trunk/ide-project/NetBeans/nbproject/project.xml
sis/trunk/pom.xml
sis/trunk/profiles/sis-french-profile/pom.xml
sis/trunk/storage/pom.xml
sis/trunk/storage/sis-earth-observation/pom.xml
sis/trunk/storage/sis-gdal/pom.xml
sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java
sis/trunk/storage/sis-gdal/src/main/resources/native/darwin/libproj-binding.so
sis/trunk/storage/sis-geotiff/pom.xml
sis/trunk/storage/sis-netcdf/pom.xml
sis/trunk/storage/sis-shapefile/pom.xml
sis/trunk/storage/sis-storage/pom.xml
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
sis/trunk/storage/sis-xmlstore/pom.xml
sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java
sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 20 16:18:08 2018
@@ -2,5 +2,5 @@
/sis/branches/ISO-19115-3:1804459-1825252
/sis/branches/JDK6:1394364-1758914
/sis/branches/JDK7:1394913-1822221
-/sis/branches/JDK8:1584960-1828701
+/sis/branches/JDK8:1584960-1829667
/sis/branches/JDK9:1773327-1803064
Modified: sis/trunk/application/sis-console/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/pom.xml?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
--- sis/trunk/application/sis-console/pom.xml (original)
+++ sis/trunk/application/sis-console/pom.xml Fri Apr 20 16:18:08 2018
@@ -37,12 +37,9 @@
=========================================================== -->
<groupId>org.apache.sis.application</groupId>
<artifactId>sis-console</artifactId>
- <packaging>bundle</packaging>
<name>Apache SIS console</name>
<description>
- <!-- Left alignment because this description will be copied in
META-INF/MANIFEST.MF
- The leading space after the first line is necessary for proper
formatting. -->
-Console application.
+ Console application.
</description>
@@ -78,25 +75,15 @@ Console application.
<manifest>
<mainClass>org.apache.sis.console.Command</mainClass>
</manifest>
+ <manifestEntries>
+ <Automatic-Module-Name>
+ org.apache.sis.console
+ </Automatic-Module-Name>
+ </manifestEntries>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</plugin>
-
- <!-- Package as OSGi bundle -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.sis.console
- </Export-Package>
- <Main-Class>org.apache.sis.console.Command</Main-Class>
- <Bundle-SymbolicName>org.apache.sis.console</Bundle-SymbolicName>
- </instructions>
- </configuration>
- </plugin>
</plugins>
</build>
Modified:
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MimeTypeCommandTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MimeTypeCommandTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MimeTypeCommandTest.java
[UTF-8] (original)
+++
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MimeTypeCommandTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -18,24 +18,24 @@ package org.apache.sis.console;
import java.net.URL;
import org.apache.sis.internal.storage.gpx.MetadataTest;
-import org.apache.sis.metadata.iso.extent.DefaultExtentTest;
+import org.apache.sis.metadata.xml.TestUsingFile;
import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;
+import static org.apache.sis.metadata.iso.extent.DefaultExtentTest.FILENAME;
/**
* Tests the {@link MimeTypeCommand} sub-command.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.4
* @module
*/
@DependsOn(CommandRunnerTest.class)
-public final strictfp class MimeTypeCommandTest extends TestCase {
+public final strictfp class MimeTypeCommandTest extends TestUsingFile {
/**
* Tests the sub-command on a metadata file.
*
@@ -43,7 +43,7 @@ public final strictfp class MimeTypeComm
*/
@Test
public void testWithMetadataXML() throws Exception {
- final URL url = DefaultExtentTest.getTestFile(true);
+ final URL url = TestUsingFile.class.getResource(XML2007+FILENAME);
final MimeTypeCommand test = new MimeTypeCommand(0,
CommandRunner.TEST, url.toString());
test.run();
final String output = test.outputBuffer.toString().trim();
Modified: sis/trunk/application/sis-openoffice/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/application/sis-openoffice/pom.xml?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
--- sis/trunk/application/sis-openoffice/pom.xml (original)
+++ sis/trunk/application/sis-openoffice/pom.xml Fri Apr 20 16:18:08 2018
@@ -37,7 +37,6 @@
=========================================================== -->
<groupId>org.apache.sis.application</groupId>
<artifactId>sis-openoffice</artifactId>
- <packaging>jar</packaging>
<name>Bridges to Apache OpenOffice or LibreOffice</name>
<description>
Modified: sis/trunk/core/sis-build-helper/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/pom.xml?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/pom.xml (original)
+++ sis/trunk/core/sis-build-helper/pom.xml Fri Apr 20 16:18:08 2018
@@ -45,12 +45,10 @@
<packaging>maven-plugin</packaging>
<name>Apache SIS build helper</name>
<description>
- <!-- Left alignment because this description will be copied in
META-INF/MANIFEST.MF
- The leading space after the first line is necessary for proper
formatting. -->
-Define Maven Mojos and Javadoc taglets for generating resource files
- formatting the Javadoc or creating ".oxt" files for OpenOffice.org.
- While any project could use it, this module is primarily for internal
- use by Apache SIS and may change in any future version.
+ Define Maven Mojos and Javadoc taglets for generating resource files
+ formatting the Javadoc or creating ".oxt" files for OpenOffice.org.
+ While any project could use it, this module is primarily for internal
+ use by Apache SIS and may change in any future version.
</description>
Modified: sis/trunk/core/sis-feature/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/pom.xml?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/pom.xml (original)
+++ sis/trunk/core/sis-feature/pom.xml Fri Apr 20 16:18:08 2018
@@ -37,12 +37,9 @@
=========================================================== -->
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-feature</artifactId>
- <packaging>bundle</packaging>
<name>Apache SIS features</name>
<description>
- <!-- Left alignment because this description will be copied in
META-INF/MANIFEST.MF
- The leading space after the first line is necessary for proper
formatting. -->
-Representations of geographic features.
+ Representations of geographic features.
</description>
@@ -85,15 +82,18 @@ Representations of geographic features.
=========================================================== -->
<build>
<plugins>
-
- <!-- Package as OSGi bundle -->
+ <!-- Anticipation for Java 9 -->
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
<configuration>
- <instructions>
- <Bundle-SymbolicName>org.apache.sis.feature</Bundle-SymbolicName>
- </instructions>
+ <archive>
+ <manifestEntries>
+ <Automatic-Module-Name>
+ org.apache.sis.feature
+ </Automatic-Module-Name>
+ </manifestEntries>
+ </archive>
</configuration>
</plugin>
</plugins>
@@ -124,6 +124,11 @@ Representations of geographic features.
<artifactId>esri-geometry-api</artifactId>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.locationtech.jts</groupId>
+ <artifactId>jts-core</artifactId>
+ <optional>true</optional>
+ </dependency>
<!-- Test dependencies -->
<dependency>
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -23,6 +23,8 @@ import com.esri.core.geometry.MultiPath;
import com.esri.core.geometry.Polyline;
import com.esri.core.geometry.Polygon;
import com.esri.core.geometry.Point;
+import com.esri.core.geometry.Point2D;
+import com.esri.core.geometry.Point3D;
import com.esri.core.geometry.WktImportFlags;
import com.esri.core.geometry.OperatorImportFromWkt;
import org.apache.sis.geometry.GeneralEnvelope;
@@ -33,12 +35,11 @@ import org.apache.sis.util.Classes;
/**
* Centralizes some usages of ESRI geometry API by Apache SIS.
- * We use this class for isolating dependencies from the {@code
org.apache.feature} package
- * to ESRI's API or to Java Topology Suite (JTS) API.
+ * We use this class for isolating dependencies from the {@code
org.apache.feature} package to ESRI's API.
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -51,7 +52,7 @@ final class ESRI extends Geometries<Geom
}
/**
- * If the given object is a JTS geometry, returns a short string
representation the class name.
+ * If the given object is an ESRI geometry, returns a short string
representation of the class name.
*/
@Override
final String tryGetLabel(Object geometry) {
@@ -100,6 +101,12 @@ final class ESRI extends Geometries<Geom
coord[1] = pt.getY();
coord[0] = pt.getX();
return coord;
+ } else if (point instanceof Point2D) {
+ final Point2D pt = (Point2D) point;
+ return new double[] {pt.x, pt.y};
+ } else if (point instanceof Point3D) {
+ final Point3D pt = (Point3D) point;
+ return new double[] {pt.x, pt.y, pt.z};
}
return null;
}
@@ -108,7 +115,8 @@ final class ESRI extends Geometries<Geom
* Creates a two-dimensional point from the given coordinate.
*/
@Override
- public Object createPoint(double x, double y) {
+ public Object createPoint(final double x, final double y) {
+ // Need to explicitely set z to NaN because default value is 0.
return new Point(x, y, Double.NaN);
}
@@ -147,7 +155,7 @@ final class ESRI extends Geometries<Geom
/**
* Merges a sequence of points or paths if the first instance is an
implementation of this library.
*
- * @throws ClassCastException if an element in the iterator is not a JTS
geometry.
+ * @throws ClassCastException if an element in the iterator is not an ESRI
geometry.
*/
@Override
final Geometry tryMergePolylines(Object next, final Iterator<?> polylines)
{
@@ -159,15 +167,18 @@ final class ESRI extends Geometries<Geom
for (;; next = polylines.next()) {
if (next != null) {
if (next instanceof Point) {
- final double x = ((Point) next).getX();
- final double y = ((Point) next).getY();
- if (Double.isNaN(x) || Double.isNaN(y)) {
+ final Point pt = (Point) next;
+ if (pt.isEmpty()) {
lineTo = false;
- } else if (lineTo) {
- path.lineTo(x, y);
} else {
- path.startPath(x, y);
- lineTo = true;
+ final double x = ((Point) next).getX();
+ final double y = ((Point) next).getY();
+ if (lineTo) {
+ path.lineTo(x, y);
+ } else {
+ path.startPath(x, y);
+ lineTo = true;
+ }
}
} else {
path.add((MultiPath) next, false);
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -37,7 +37,7 @@ import org.apache.sis.math.Vector;
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -195,7 +195,7 @@ public abstract class Geometries<G> {
/**
* If the given geometry is the type supported by this {@code Geometries}
instance,
- * returns a short string representation the class name. Otherwise returns
{@code null}.
+ * returns a short string representation of the class name. Otherwise
returns {@code null}.
*/
abstract String tryGetLabel(Object geometry);
@@ -288,8 +288,9 @@ public abstract class Geometries<G> {
*
* @param wkt the WKT to parse.
* @return the geometry object for the given WKT.
+ * @throws Exception if the WKT can not be parsed. The exception sub-class
depends on the implementation.
*/
- public abstract Object parseWKT(String wkt);
+ public abstract Object parseWKT(String wkt) throws Exception;
/**
* Returns an error message for an unsupported geometry object.
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -16,10 +16,22 @@
*/
package org.apache.sis.internal.feature;
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Iterator;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.Polygon;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.MultiLineString;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.io.WKTReader;
+import org.locationtech.jts.io.ParseException;
import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.math.Vector;
import org.apache.sis.util.Classes;
@@ -31,43 +43,31 @@ import org.apache.sis.util.Classes;
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.7
* @module
- *
- * @todo avoid use of reflection and use JTS API directly after JTS released
- * a new version of the library under BSD-like license.
*/
-final class JTS extends Geometries<Object> {
+final class JTS extends Geometries<Geometry> {
/**
- * Getter methods on JTS envelopes.
- * Each methods take no argument and return a {@code double} value.
+ * The factory to use for creating JTS geometries. Currently set to a
factory using
+ * double-precision floating point numbers and a spatial-reference ID of 0.
*/
- private final Method getEnvelopeInternal, getMinX, getMinY, getMaxX,
getMaxY;
+ private final GeometryFactory factory;
/**
* Creates the singleton instance.
*/
- JTS() throws ClassNotFoundException, NoSuchMethodException {
- super(/*GeometryLibrary.JTS, */ null, //
TODO
- (Class) Class.forName("com.vividsolutions.jts.geom.Geometry"),
// TODO
- Class.forName("com.vividsolutions.jts.geom.Point"),
- Class.forName("com.vividsolutions.jts.geom.LineString"),
- Class.forName("com.vividsolutions.jts.geom.Polygon"));
- getEnvelopeInternal = rootClass.getMethod("getEnvelopeInternal",
(Class[]) null);
- final Class<?> envt = getEnvelopeInternal.getReturnType();
- getMinX = envt.getMethod("getMinX", (Class[]) null);
- getMinY = envt.getMethod("getMinY", (Class[]) null);
- getMaxX = envt.getMethod("getMaxX", (Class[]) null);
- getMaxY = envt.getMethod("getMaxY", (Class[]) null);
+ JTS() {
+ super(GeometryLibrary.JTS, Geometry.class, Point.class,
LineString.class, Polygon.class);
+ factory = new GeometryFactory(); // Default to double
precision and SRID of 0.
}
/**
- * If the given object is a JTS geometry, returns a short string
representation the class name.
+ * If the given object is a JTS geometry, returns a short string
representation of the class name.
*/
@Override
final String tryGetLabel(Object geometry) {
- return (rootClass.isInstance(geometry)) ?
Classes.getShortClassName(geometry) : null;
+ return (geometry instanceof Geometry) ?
Classes.getShortClassName(geometry) : null;
}
/**
@@ -80,31 +80,14 @@ final class JTS extends Geometries<Objec
*/
@Override
final GeneralEnvelope tryGetEnvelope(final Object geometry) {
- final double xmin, ymin, xmax, ymax;
- if (rootClass.isInstance(geometry)) {
- try {
- final Object env = getEnvelopeInternal.invoke(geometry,
(Object[]) null);
- xmin = (Double) getMinX.invoke(env, (Object[]) null);
- ymin = (Double) getMinY.invoke(env, (Object[]) null);
- xmax = (Double) getMaxX.invoke(env, (Object[]) null);
- ymax = (Double) getMaxY.invoke(env, (Object[]) null);
- } catch (ReflectiveOperationException e) {
- if (e instanceof InvocationTargetException) {
- final Throwable cause = e.getCause();
- if (cause instanceof RuntimeException) {
- throw (RuntimeException) cause;
- }
- if (cause instanceof Error) {
- throw (Error) cause;
- }
- }
- // Should never happen unless JTS's API changed.
- throw (Error) new
IncompatibleClassChangeError(e.toString()).initCause(e);
- }
+ if (geometry instanceof Geometry) {
+ final Envelope bounds = ((Geometry)
geometry).getEnvelopeInternal();
final GeneralEnvelope env = new GeneralEnvelope(2);
- env.setRange(0, xmin, xmax);
- env.setRange(1, ymin, ymax);
- return env;
+ env.setRange(0, bounds.getMinX(), bounds.getMaxX());
+ env.setRange(1, bounds.getMinY(), bounds.getMaxY());
+ if (!env.isEmpty()) {
+ return env;
+ }
}
return null;
}
@@ -115,15 +98,33 @@ final class JTS extends Geometries<Objec
*/
@Override
final double[] tryGetCoordinate(final Object point) {
- return null; // TODO - see class javadoc
+ final Coordinate pt;
+ if (point instanceof Point) {
+ pt = ((Point) point).getCoordinate();
+ } else if (point instanceof Coordinate) {
+ pt = (Coordinate) point;
+ } else {
+ return null;
+ }
+ final double z = pt.z;
+ final double[] coord;
+ if (Double.isNaN(z)) {
+ coord = new double[2];
+ } else {
+ coord = new double[3];
+ coord[2] = z;
+ }
+ coord[1] = pt.y;
+ coord[0] = pt.x;
+ return coord;
}
/**
* Creates a two-dimensional point from the given coordinate.
*/
@Override
- public Object createPoint(double x, double y) {
- throw unsupported(2); // TODO - see class javadoc
+ public Object createPoint(final double x, final double y) {
+ return factory.createPoint(new Coordinate(x, y));
}
/**
@@ -132,9 +133,68 @@ final class JTS extends Geometries<Objec
* The implementation returned by this method must be an instance of
{@link #rootClass}.
*/
@Override
- public Object createPolyline(final int dimension, final Vector...
ordinates) {
- // TODO - see class javadoc
- throw unsupported(dimension);
+ public Geometry createPolyline(final int dimension, final Vector...
ordinates) {
+ final boolean is3D = (dimension == 3);
+ if (!is3D && dimension != 2) {
+ throw unsupported(dimension);
+ }
+ final List<Coordinate> coordinates = new ArrayList<>(32);
+ final List<LineString> lines = new ArrayList<>();
+ for (final Vector v : ordinates) {
+ if (v != null) {
+ final int size = v.size();
+ for (int i=0; i<size;) {
+ final double x = v.doubleValue(i++);
+ final double y = v.doubleValue(i++);
+ if (!Double.isNaN(x) && !Double.isNaN(y)) {
+ final Coordinate c;
+ if (is3D) {
+ c = new Coordinate(x, y, v.doubleValue(i++));
+ } else {
+ c = new Coordinate(x, y);
+ }
+ coordinates.add(c);
+ } else {
+ if (is3D) i++;
+ toLineString(coordinates, lines);
+ coordinates.clear();
+ }
+ }
+ }
+ }
+ toLineString(coordinates, lines);
+ return toGeometry(lines);
+ }
+
+ /**
+ * Makes a line string or linear ring from the given coordinates, and add
the line string to the given list.
+ * If the given coordinates array is empty, then this method does nothing.
+ * This method does not modify the given coordinates list.
+ */
+ private void toLineString(final List<Coordinate> coordinates, final
List<LineString> addTo) {
+ final int s = coordinates.size();
+ if (s >= 2) {
+ final LineString line;
+ final Coordinate[] ca = coordinates.toArray(new Coordinate[s]);
+ if (ca[0].equals2D(ca[s-1])) {
+ line = factory.createLinearRing(ca); // Throws an
exception if s < 4.
+ } else {
+ line = factory.createLineString(ca); // Throws an
exception if contains duplicated point.
+ }
+ addTo.add(line);
+ }
+ }
+
+ /**
+ * Returns the given list of line string as a single geometry.
+ */
+ private Geometry toGeometry(final List<LineString> lines) {
+ final int s = lines.size();
+ switch (s) {
+ case 0: return factory.createLinearRing((Coordinate[]) null);
// Creates an empty linear ring.
+ case 1: return lines.get(0);
+ default: return factory.createMultiLineString(lines.toArray(new
LineString[s]));
+ }
}
/**
@@ -143,15 +203,50 @@ final class JTS extends Geometries<Objec
* @throws ClassCastException if an element in the iterator is not a JTS
geometry.
*/
@Override
- final Object tryMergePolylines(final Object first, final Iterator<?>
polylines) {
- throw unsupported(2); // TODO - see class javadoc
+ final Geometry tryMergePolylines(Object next, final Iterator<?> polylines)
{
+ if (!(next instanceof MultiLineString || next instanceof LineString ||
next instanceof Point)) {
+ return null;
+ }
+ final List<Coordinate> coordinates = new ArrayList<>();
+ final List<LineString> lines = new ArrayList<>();
+ for (;; next = polylines.next()) {
+ if (next != null) {
+ if (next instanceof Point) {
+ final Coordinate pt = ((Point) next).getCoordinate();
+ if (!Double.isNaN(pt.x) && !Double.isNaN(pt.y)) {
+ coordinates.add(pt);
+ } else {
+ toLineString(coordinates, lines);
+ coordinates.clear();
+ }
+ } else {
+ final Geometry g = (Geometry) next;
+ final int n = g.getNumGeometries();
+ for (int i=0; i<n; i++) {
+ final LineString ls = (LineString) g.getGeometryN(i);
+ if (coordinates.isEmpty()) {
+ lines.add(ls);
+ } else {
+
coordinates.addAll(Arrays.asList(ls.getCoordinates()));
+ toLineString(coordinates, lines);
+ coordinates.clear();
+ }
+ }
+ }
+ }
+ if (!polylines.hasNext()) { // Should be part of the 'for'
instruction, but we need
+ break; // to skip this condition
during the first iteration.
+ }
+ }
+ toLineString(coordinates, lines);
+ return toGeometry(lines);
}
/**
* Parses the given WKT.
*/
@Override
- public Object parseWKT(final String wkt) {
- throw unsupported(2);
+ public Object parseWKT(final String wkt) throws ParseException {
+ return new WKTReader(factory).read(wkt);
}
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -31,8 +31,7 @@ import org.apache.sis.util.Classes;
/**
* Centralizes usages of some (not all) Java2D geometry API by Apache SIS.
- * We use this class for isolating dependencies from the {@code
org.apache.feature} package
- * to ESRI's API or to Java Topology Suite (JTS) API.
+ * We use this class for isolating dependencies from the {@code
org.apache.feature} package to Java2D API.
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
@@ -49,7 +48,7 @@ final class Java2D extends Geometries<Sh
}
/**
- * If the given geometry is a Java2D geometry, returns a short string
representation the class name,
+ * If the given geometry is a Java2D geometry, returns a short string
representation of the class name,
* ignoring the primitive type specialization. For example if the class is
{@code Rectangle2D.Float},
* then this method returns {@code "Rectangle2D"}.
*/
Modified:
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
*
* @author Martin Desruisseaux (Geomatys)
* @author Johann Sorel (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.5
* @module
*/
@@ -50,6 +50,9 @@ import org.junit.BeforeClass;
org.apache.sis.feature.FeatureFormatTest.class,
org.apache.sis.feature.FeaturesTest.class,
org.apache.sis.internal.feature.AttributeConventionTest.class,
+ org.apache.sis.internal.feature.Java2DTest.class,
+ org.apache.sis.internal.feature.ESRITest.class,
+ org.apache.sis.internal.feature.JTSTest.class,
org.apache.sis.feature.builder.CharacteristicTypeBuilderTest.class,
org.apache.sis.feature.builder.AttributeTypeBuilderTest.class,
org.apache.sis.feature.builder.AssociationRoleBuilderTest.class,
Modified: sis/trunk/core/sis-metadata/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/pom.xml?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/pom.xml (original)
+++ sis/trunk/core/sis-metadata/pom.xml Fri Apr 20 16:18:08 2018
@@ -37,14 +37,11 @@
=========================================================== -->
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-metadata</artifactId>
- <packaging>bundle</packaging>
<name>Apache SIS metadata</name>
<description>
- <!-- Left alignment because this description will be copied in
META-INF/MANIFEST.MF
- The leading space after the first line is necessary for proper
formatting. -->
-Implementations of metadata derived from ISO 19115. This module provides both
an implementation
- of the metadata interfaces defined in GeoAPI, and a framework for handling
those metadata through
- Java reflection.
+ Implementations of metadata derived from ISO 19115. This module provides
both an implementation
+ of the metadata interfaces defined in GeoAPI, and a framework for handling
those metadata through
+ Java reflection.
</description>
@@ -117,20 +114,18 @@ Implementations of metadata derived from
=========================================================== -->
<build>
<plugins>
-
- <!-- Package as OSGi bundle -->
+ <!-- Anticipation for Java 9 -->
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
<configuration>
- <instructions>
- <Bundle-SymbolicName>org.apache.sis.metadata</Bundle-SymbolicName>
- <Export-Package>org.apache.sis.internal.jaxb.metadata,
*</Export-Package>
- <Require-Capability>osgi.extender;
-
filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
- <Provide-Capability>osgi.serviceloader;
-
osgi.serviceloader=org.apache.sis.internal.jaxb.TypeRegistration</Provide-Capability>
- </instructions>
+ <archive>
+ <manifestEntries>
+ <Automatic-Module-Name>
+ org.apache.sis.metadata
+ </Automatic-Module-Name>
+ </manifestEntries>
+ </archive>
</configuration>
</plugin>
</plugins>
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -33,6 +33,7 @@ import org.apache.sis.util.logging.Warni
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Messages;
import org.apache.sis.util.resources.IndexedResourceBundle;
+import org.apache.sis.util.CorruptedObjectException;
import org.apache.sis.internal.jaxb.gco.PropertyType;
import org.apache.sis.internal.system.Semaphores;
import org.apache.sis.internal.system.Loggers;
@@ -508,8 +509,8 @@ public final class Context extends Marsh
/**
* Returns {@code true} if the given identifier is available, or {@code
false} if it is used by another object.
* If this method returns {@code true}, then the given identifier is
associated to the given object for future
- * invocation of {@code Context} method. If this method returns {@code
false}, then the caller is responsible
- * for computing an other identifier candidate.
+ * invocation of {@code Context} methods. If this method returns {@code
false}, then the caller is responsible
+ * for computing another identifier candidate.
*
* @param context the current context, or {@code null} if none.
* @param object the object for which to assign the {@code gml:id}.
@@ -521,12 +522,11 @@ public final class Context extends Marsh
public static boolean setObjectForID(final Context context, final Object
object, final String id) {
if (context != null) {
final Object existing = context.identifiers.putIfAbsent(id,
object);
- if (existing == null) {
- if (context.identifiedObjects.put(object, id) != null) {
- throw new AssertionError(id); // Caller forgot to invoke
getExistingID(context, object).
- }
- } else if (existing != object) {
- return false;
+ if (existing != null) {
+ return existing == object;
+ }
+ if (context.identifiedObjects.put(object, id) != null) {
+ throw new CorruptedObjectException(id); // Should never
happen since all put calls are in this method.
}
}
return true;
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlSche
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.datatype.DatatypeConstants;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.XmlUtilities;
@@ -33,9 +34,21 @@ import org.apache.sis.internal.jaxb.XmlU
* At marshalling time, the choice is performed depending on whatever the
given date contains
* hour, minute or seconds information different than zero.
*
+ * <div class="section">Difference between ISO 19139:2007 and ISO
19115-3:2016</div>
+ * The ISO {@code baseTypes.xsd} files define two kinds of date property:
+ * <ul>
+ * <li>{@code gco:Date_PropertyType} accepts either {@code gco:Date} or
{@code gco:DateTime}.</li>
+ * <li>{@code gco:DateTime_PropertyType} accepts only {@code
gco:DateTime}.</li>
+ * </ul>
+ *
+ * In the legacy standard (ISO 19139:2007), date properties (in particular in
citations) were of type
+ * {@code Date_PropertyType}. But in the new standard (ISO 19115-3:2016), most
date properties are of
+ * type {@code DateTime_PropertyType}, i.e. {@code gco:Date} is not legal
anymore. The only exception
+ * is {@code versionDate} in {@code cat:AbstractCT_Catalogue}.
+ *
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.0
*
* @see org.apache.sis.internal.jaxb.gml.DateAdapter
* @see org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter
@@ -76,9 +89,16 @@ public final class GO_DateTime extends X
final Context context = Context.current();
try {
final XMLGregorianCalendar gc = XmlUtilities.toXML(context, date);
- if (XmlUtilities.trimTime(gc, false)) {
- this.date = gc;
+ if (Context.isFlagSet(context, Context.LEGACY_METADATA)) {
+ if (XmlUtilities.trimTime(gc, false)) {
+ this.date = gc;
+ } else {
+ dateTime = gc;
+ }
} else {
+ if (gc.getMillisecond() == 0) {
+ gc.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
+ }
dateTime = gc;
}
} catch (DatatypeConfigurationException e) {
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LanguageCode.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LanguageCode.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LanguageCode.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LanguageCode.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -30,7 +30,7 @@ import org.apache.sis.internal.jaxb.gco.
* in order to wrap the value in an XML element as specified by ISO 19115-3
standard.
* See package documentation for more information about the handling of {@code
CodeList} in ISO 19115-3.
*
- * <p>This adapter formats the locale like below:</p>
+ * <p>This adapter formats the locale like below (by {@link
LocaleAdapter}):</p>
*
* {@preformat xml
* <gmd:language>
@@ -38,6 +38,16 @@ import org.apache.sis.internal.jaxb.gco.
* </gmd:language>
* }
*
+ * or (when using {@link PT_Locale} adapter):
+ *
+ * {@preformat xml
+ * <lan:PT_Locale>
+ * <lan:language>
+ * <lan:LanguageCode codeList="http://(...snip...)"
codeListValue="eng">English</lan:LanguageCode>
+ * </lan:language>
+ * </lan:PT_Locale>
+ * }
+ *
* Note that {@code <gco:CharacterString>} can be substituted to the language
code.
*
* @author Cédric Briançon (Geomatys)
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -26,11 +26,14 @@ import org.apache.sis.internal.jaxb.Cont
* mapped to {@link Locale}. This adapter formats the locale like below:
*
* {@preformat xml
- * <lan:language>
- * <lan:LanguageCode codeList="(snip)#LanguageCode"
codeListValue="jpn">Japanese</lan:LanguageCode>
- * </lan:language>
+ * <gmd:language>
+ * <gmd:LanguageCode codeList="(snip)#LanguageCode"
codeListValue="jpn">Japanese</gmd:LanguageCode>
+ * </gmd:language>
* }
*
+ * This adapter is used for legacy locales in {@code gmd} namespace.
+ * For locales in the newer {@code lan} namespace, see {@link PT_Locale}.
+ *
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @version 0.4
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -53,7 +53,7 @@ import org.apache.sis.internal.jaxb.Cont
* </lan:locale>
* }
*
- * For an alternative (simpler) format, see {@link LocaleAdapter}.
+ * For an alternative (simpler) format used in the legacy {@code gmd}
namespace, see {@link LocaleAdapter}.
*
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -34,6 +34,9 @@ import org.apache.sis.internal.util.Util
* @version 0.8
* @since 0.3
* @module
+ *
+ * @todo Most methods in this class are related to (un)marshalling. We should
rename as {@code MarshallingUtilities}
+ * and move to a JAXB package after we removed the {@code
toMilliseconds(…)} and {@code toDate(…)} methods.
*/
public final class MetadataUtilities extends Static {
/**
@@ -135,7 +138,7 @@ public final class MetadataUtilities ext
*
* @param classe the caller class, used only in case of warning
message to log.
* @param property the property name. Method name will be inferred by
the usual Java bean convention.
- * @param key a {@code Errors.Keys} value.
+ * @param key an {@code Errors.Keys} value.
* @param arguments the argument to use for formatting the error message.
* @return {@code null} if the message has been logged, or the message to
put in an exception otherwise.
*/
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -29,6 +29,8 @@ import org.apache.sis.metadata.TitleProp
import org.apache.sis.measure.ValueRange;
import org.apache.sis.util.iso.Types;
import org.apache.sis.xml.Namespaces;
+import org.apache.sis.xml.NilReason;
+import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.internal.jaxb.FilterByVersion;
import org.apache.sis.internal.metadata.Dependencies;
@@ -90,7 +92,7 @@ import static org.opengis.annotation.Spe
"obligation",
"condition",
"dataType",
- "maximumOccurrence",
+ "maxOccurs",
"domainValue",
"parentEntity",
"rule",
@@ -444,7 +446,7 @@ public class DefaultExtendedElementInfor
/**
* Maximum occurrence of the extended element.
- * Returns {@code null} if it doesn't apply, for example if the
+ * Returns {@code null} if it does not apply, for example if the
* {@linkplain #getDataType() data type} is {@linkplain
Datatype#ENUMERATION enumeration},
* {@linkplain Datatype#CODE_LIST code list} or {@linkplain
Datatype#CODE_LIST_ELEMENT
* code list element}.
@@ -453,7 +455,6 @@ public class DefaultExtendedElementInfor
*/
@Override
@ValueRange(minimum = 0)
- @XmlElement(name = "maximumOccurrence")
public Integer getMaximumOccurrence() {
return maximumOccurrence;
}
@@ -614,4 +615,56 @@ public class DefaultExtendedElementInfor
public void setSources(final Collection<? extends ResponsibleParty>
newValues) {
sources = writeCollection(newValues, sources, ResponsibleParty.class);
}
+
+
+
+
+
//////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////
////////
+ //////// XML support with JAXB
////////
+ ////////
////////
+ //////// The following methods are invoked by JAXB using reflection
(even if ////////
+ //////// they are private) or are helpers for other methods invoked
by JAXB. ////////
+ //////// Those methods can be safely removed if Geographic Markup
Language ////////
+ //////// (GML) support is not needed.
////////
+ ////////
////////
+
//////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Returns the maximum occurrence as a string, since it is the way that
ISO 19115 represents
+ * this information. This method is invoked by JAXB at marshalling time.
+ */
+ @XmlElement(name = "maximumOccurrence")
+ private String getMaxOccurs() {
+ final Integer value = getMaximumOccurrence();
+ if (value == null) {
+ return null;
+ }
+ final NilReason nil = NilReason.forObject(value);
+ if (nil != null) {
+ return nil.createNilObject(String.class);
+ }
+ return value.toString();
+ }
+
+ /**
+ * Sets the maximum occurrence from a string.
+ * This method is invoked by JAXB at unmarshalling time.
+ */
+ @SuppressWarnings("unused")
+ private void setMaxOccurs(final String value) {
+ if (value != null) {
+ final Integer n;
+ final NilReason nil = NilReason.forObject(value);
+ if (nil != null) {
+ n = nil.createNilObject(Integer.class);
+ } else try {
+ n = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ Context.warningOccured(Context.current(),
DefaultExtendedElementInformation.class, "setMaximumOccurrence", e, true);
+ return;
+ }
+ setMaximumOccurrence(n);
+ }
+ }
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -546,7 +546,7 @@ public class DefaultMetadata extends ISO
*
* @return language used for documenting metadata, or {@code null}.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link #getLanguages()}.
+ * @deprecated As of SIS 0.5, replaced by {@link #getLanguages()}.
*/
@Override
@Deprecated
@@ -572,7 +572,7 @@ public class DefaultMetadata extends ISO
*
* @param newValue the new language.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link
#setLanguages(Collection)}.
+ * @deprecated As of SIS 0.5, replaced by {@link
#setLanguages(Collection)}.
*/
@Deprecated
public void setLanguage(final Locale newValue) {
@@ -585,7 +585,7 @@ public class DefaultMetadata extends ISO
*
* @return alternatively used localized character string for a linguistic
extension.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link #getLanguages()}.
+ * @deprecated As of SIS 0.5, replaced by {@link #getLanguages()}.
*/
@Override
@Deprecated
@@ -600,7 +600,7 @@ public class DefaultMetadata extends ISO
*
* @param newValues the new locales.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link
#setLanguages(Collection)}.
+ * @deprecated As of SIS 0.5, replaced by {@link
#setLanguages(Collection)}.
*/
@Deprecated
public void setLocales(final Collection<? extends Locale> newValues) {
@@ -646,7 +646,7 @@ public class DefaultMetadata extends ISO
*
* @since 0.5
*/
- public void setCharacterSets(final Collection<Charset> newValues) {
+ public void setCharacterSets(final Collection<? extends Charset>
newValues) {
characterSets = writeCollection(newValues, characterSets,
Charset.class);
}
@@ -655,7 +655,7 @@ public class DefaultMetadata extends ISO
*
* @return character coding standard used for the metadata, or {@code
null}.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link #getCharacterSets()}.
+ * @deprecated As of SIS 0.5, replaced by {@link #getCharacterSets()}.
*/
@Override
@Deprecated
@@ -685,7 +685,7 @@ public class DefaultMetadata extends ISO
*
* @param newValue the new character set.
*
- * @deprecated As of GeoAPI 3.1, replaced by {@link
#setCharacterSets(Collection)}.
+ * @deprecated As of SIS 0.5, replaced by {@link
#setCharacterSets(Collection)}.
*/
@Deprecated
public void setCharacterSet(final CharacterSet newValue) {
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformedEvent.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformedEvent.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformedEvent.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformedEvent.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -61,8 +61,8 @@ abstract class TransformedEvent<E extend
* @param name the exported name of the attribute or element.
*/
TransformedEvent(final E event, final QName name) {
- this.event = event;
- this.name = name;
+ this.event = event;
+ this.name = name;
}
@Override public boolean isStartElement() {return false;}
@@ -128,14 +128,16 @@ abstract class TransformedEvent<E extend
/**
* Wrapper over a namespace emitted during the reading or writing of an
XML document.
- * This wrapper is used for changing the namespace URI.
+ * This wrapper is used for changing the namespace URI. The wrapped {@link
#event}
+ * should be a {@link Namespace}, but this class accepts also the {@link
Attribute}
+ * super-type for allowing the {@link Type} attribute to create synthetic
namespaces.
*/
- static final class NS extends TransformedEvent<Namespace> implements
Namespace {
+ static final class NS extends TransformedEvent<Attribute> implements
Namespace {
/** The URI of the namespace. */
private final String namespaceURI;
/** Wraps the given event with a different prefix and URI. */
- NS(final Namespace event, final String prefix, final String
namespaceURI) {
+ NS(final Attribute event, final String prefix, final String
namespaceURI) {
super(event, new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
prefix, XMLConstants.XMLNS_ATTRIBUTE));
this.namespaceURI = namespaceURI;
}
@@ -145,7 +147,7 @@ abstract class TransformedEvent<E extend
@Override public String getNamespaceURI() {return
namespaceURI;}
@Override public String getValue() {return
namespaceURI;}
@Override public String getDTDType() {return
event.getDTDType();}
- @Override public boolean isSpecified() {return
event.isSpecified();}
+ @Override public boolean isSpecified() {return
event instanceof Namespace && event.isSpecified();}
@Override public String getPrefix() {return
(name != null) ? name.getLocalPart() : null;}
@Override public boolean isDefaultNamespaceDeclaration() {return
(name != null) && name.getLocalPart().isEmpty();}
@Override void write(final Appendable out) throws IOException {
@@ -175,23 +177,29 @@ abstract class TransformedEvent<E extend
@Override public String getDTDType() {return
event.getDTDType();}
@Override public boolean isSpecified() {return
event.isSpecified();}
@Override void write(final Appendable out) throws IOException {
- name(out).append("=\"").append(event.getValue()).append('"');
+ name(out).append("=\"").append(getValue()).append('"');
}
}
/**
- * The attribute for {@code "xsi:type"}.
+ * The {@code "xsi:type"} attribute. Contrarily to other attributes, the
name is unchanged compared
+ * to the original attribute; instead the value is different. Even in
unchanged, the {@link QName}
+ * is specified at construction time because it is required by the parent
class.
*/
- static final class TypeAttr extends Attr {
+ static final class Type extends Attr {
/** The attribute value. */
private final String value;
- /** Wraps the given event with a different name. */
- TypeAttr(final Attribute event, final QName name, final String value) {
+ /** If the value requires a new prefix to be bound, the namespace
declaration for it. */
+ Namespace namespace;
+
+ /** Wraps the given event with a different value. */
+ Type(final Attribute event, final QName name, final String value) {
super(event, name);
this.value = value;
}
+ /** Returns the {@code "xsi:type"} attribute value. */
@Override public String getValue() {return value;}
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/Transformer.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/Transformer.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/Transformer.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/Transformer.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -310,7 +310,7 @@ abstract class Transformer {
}
/**
- * Imports or exports an attribute read or write from/to the XML document.
+ * Imports or exports an attribute read or written from/to the XML
document.
* If there is no name change, then this method returns the given instance
as-is.
* This method performs a special check for the {@code "xsi:type"}
attribute:
* its value is parsed as a name and converted.
@@ -320,29 +320,40 @@ abstract class Transformer {
if ("type".equals(originalName.getLocalPart()) &&
Namespaces.XSI.equals(originalName.getNamespaceURI())) {
/*
* In the special case of "xsi:type", do not convert the attribute
name.
- * Instead, parse and convert the attribute value.
+ * Instead, parse and convert the attribute value. For example in
the following:
+ *
+ * <cit:title xsi:type="lan:PT_FreeText_PropertyType">
+ *
+ * The "lan" prefix needs to be changed to "gmd" if exporting to
legacy ISO 19139:2007.
*/
final String value = attribute.getValue();
if (value != null) {
final int s = value.indexOf(':');
if (s >= 0) {
- String prefix = value.substring(0, s);
- String ns = namespaces.get(prefix);
- if (ns != null) {
- String localPart = value.substring(s+1);
- final Map<String,String> renaming =
renamingMap().get(localPart);
- if (renaming != null) {
- QName name = new QName(ns, localPart, prefix);
- final Map<String,String> currentMap =
outerElementProperties;
- outerElementProperties = renaming;
- name = convert(name);
- outerElementProperties = currentMap;
+ String prefix = value.substring(0, s).trim();
+ String namespace = namespaces.get(prefix);
+ if (namespace != null) {
+ String localPart = value.substring(s+1).trim();
+ QName name = new QName(namespace, localPart, prefix);
+ final Map<String,String> currentMap =
outerElementProperties;
+ outerElementProperties =
renamingMap().getOrDefault(localPart, Collections.emptyMap());
+ final boolean changed = (name != (name =
convert(name)));
+ outerElementProperties = currentMap;
+ if (changed) {
prefix = name.getPrefix();
localPart = name.getLocalPart();
- final String exported = prefix + ':' + localPart;
- if (!exported.equals(value)) {
- return new
TransformedEvent.TypeAttr(attribute, originalName, exported);
+ namespace = name.getNamespaceURI();
+ TransformedEvent.Type rt = new
TransformedEvent.Type(
+ attribute, originalName, prefix + ':' +
localPart);
+ /*
+ * At this point we got the new value. For example
"gmd:PT_FreeText_PropertyType" may
+ * have been replaced by
"lan:PT_FreeText_PropertyType". However we need to verify if
+ * the "lan" prefix has been bound to a namespace,
otherwise the parsing will fail.
+ */
+ if (!namespace.equals(namespaces.get(prefix))) {
+ rt.namespace = new
TransformedEvent.NS(attribute, prefix, namespace);
}
+ return rt;
}
}
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingReader.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingReader.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingReader.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingReader.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -222,21 +222,43 @@ final class TransformingReader extends T
case START_ELEMENT: {
final StartElement e = event.asStartElement();
final QName originalName = e.getName();
- open(originalName); // Must be invoked
before 'convert(QName)'.
- final QName name = convert(originalName);
- boolean changed = name != originalName;
+ open(originalName); // Must be
invoked before 'convert(QName)'.
+ final QName name = convert(originalName); // Name in the
transformed XML document.
+ boolean changed = name != originalName; // Whether the
name or an attribute changed.
+ Namespace localNS = null; // Additional
namespace required by "xsi:type".
for (final Iterator<Attribute> it = e.getAttributes();
it.hasNext();) {
final Attribute a = it.next();
final Attribute ae = convert(a);
- changed |= (a != ae);
renamedAttributes.add(ae);
+ if (a != ae) {
+ changed = true;
+ if (localNS == null && ae instanceof
TransformedEvent.Type) {
+ localNS = ((TransformedEvent.Type) ae).namespace;
+ }
+ }
}
- final List<Namespace> namespaces = importNS(e.getNamespaces(),
+ /*
+ * The list of namespaces is determined by the "xmlns:foo"
attributes, which are handled in a
+ * special way. This list is typically non-empty only in the
root element, but it is legal to
+ * have namespace declaration in non-root elements as well.
+ *
+ * Special case: if this element contains a "xsi:type"
attribute and if we changed its value
+ * (for example from "gmd:PT_FreeText_PropertyType" to
"lan:PT_FreeText_PropertyType"), then
+ * we may need to add an extra namespace declaration (e.g. for
the "lan" prefix).
+ */
+ List<Namespace> namespaces = importNS(e.getNamespaces(),
originalName.getNamespaceURI(),
name.getNamespaceURI(), changed);
if (namespaces != null) {
+ if (localNS != null) {
+ if (namespaces.isEmpty()) {
+ namespaces = Collections.singletonList(localNS);
+ } else {
+ namespaces.add(localNS);
+ }
+ }
event = new TransformedEvent.Start(e, name, namespaces,
attributes(), version);
} else {
- renamedAttributes.clear();
+ renamedAttributes.clear(); // Note: above call to
attributes() also cleared that list.
}
break;
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingWriter.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingWriter.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingWriter.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/xml/TransformingWriter.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -379,7 +379,7 @@ final class TransformingWriter extends T
if (namespaces != null) {
event = new Event(e, name, namespaces, attributes(),
version);
} else {
- renamedAttributes.clear();
+ renamedAttributes.clear(); // Note: above call to
attributes() also cleared that list.
}
/*
* At this point, we finished to export the event (i.e. to
convert namespaces to the URI
Modified:
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -3,6 +3,7 @@
# Lines with zero-space indentation are namespace URIs.
# Lines with one-space indentation are XML types.
# Lines with two-spaces indentation are properties.
+# actual/exported means that a property needs to be renamed.
#
http://www.isotc211.org/2005/gmd
MD_Georectified
Modified:
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -1,7 +1,7 @@
#
# Namespaces in which attribute are defined.
# Lines with zero-space indentation are namespace URIs.
-# Lines with one-space indentation are XML types.
+# Lines with one-space indentation are XML types.
# Lines with two-spaces indentation are properties.
# old/new means that a property needs to be renamed.
#
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/cat/EnumAdapterTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/cat/EnumAdapterTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/cat/EnumAdapterTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/cat/EnumAdapterTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -16,7 +16,7 @@
*/
package org.apache.sis.internal.jaxb.cat;
-import org.apache.sis.test.XMLTestCase;
+import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
@@ -26,11 +26,11 @@ import static org.apache.sis.test.Assert
* Tests the {@link EnumAdapter} class.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.6
+ * @version 1.0
* @since 0.6
* @module
*/
-public final strictfp class EnumAdapterTest extends XMLTestCase {
+public final strictfp class EnumAdapterTest extends TestCase {
/**
* Tests the {@link EnumAdapter#name(String)} method.
*/
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/FreeTextMarshallingTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/FreeTextMarshallingTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/FreeTextMarshallingTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/FreeTextMarshallingTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -20,8 +20,9 @@ import java.util.Locale;
import javax.xml.bind.JAXBException;
import org.opengis.metadata.citation.Citation;
import org.apache.sis.util.iso.DefaultInternationalString;
-import org.apache.sis.test.XMLTestCase;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.xml.Namespaces;
+import org.apache.sis.test.XMLTestCase;
import org.junit.Test;
import static org.apache.sis.test.MetadataAssert.*;
@@ -52,7 +53,42 @@ public final strictfp class FreeTextMars
}
/**
- * Tests parsing of a free text in an ISO 19139-compliant way.
+ * Tests parsing of a free text in an ISO 19139 compliant way.
+ * The free text is wrapped inside a citation for marshalling
+ * purpose, but only the free text is actually tested.
+ *
+ * @throws JAXBException if the XML in this test can not be parsed by JAXB.
+ */
+ @Test
+ public void testLegacy() throws JAXBException {
+ final String expected =
+ "<gmd:CI_Citation xmlns:gmd=\"" + LegacyNamespaces.GMD + '"'
+ + " xmlns:gco=\"" + LegacyNamespaces.GCO + '"'
+ + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" +
+ " <gmd:title xsi:type=\"gmd:PT_FreeText_PropertyType\">\n" +
+ " <gco:CharacterString>OpenSource
Project</gco:CharacterString>\n" +
+ " <gmd:PT_FreeText>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString
locale=\"#locale-eng\">OpenSource Project</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString
locale=\"#locale-ita\">Progetto OpenSource</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString
locale=\"#locale-fra\">Projet OpenSource</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " </gmd:PT_FreeText>\n" +
+ " </gmd:title>\n" +
+ "</gmd:CI_Citation>\n";
+
+ final Citation citation = unmarshal(Citation.class, expected);
+ assertEquals(getExpectedI18N(), citation.getTitle());
+ final String actual = marshal(citation, VERSION_2007);
+ assertXmlEquals(expected, actual, "xmlns:*");
+ }
+
+ /**
+ * Tests parsing of a free text in an ISO 19115-3 compliant way.
* The free text is wrapped inside a citation for marshalling
* purpose, but only the free text is actually tested.
*
@@ -88,7 +124,7 @@ public final strictfp class FreeTextMars
}
/**
- * Tests parsing of a free text in the legacy (pre-Geotk 3.17) format.
+ * Tests parsing of a free text in a non-standard variant.
* We continue to support this format for compatibility reason, but
* also because it is more compact and closer to what we would expect
* inside a {@code <textGroup>} node.
@@ -96,7 +132,7 @@ public final strictfp class FreeTextMars
* @throws JAXBException if the XML in this test can not be parsed by JAXB.
*/
@Test
- public void testLegacy() throws JAXBException {
+ public void testNonStandard() throws JAXBException {
final String legacy =
"<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"'
+ " xmlns:cit=\"" + Namespaces.CIT + '"'
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/LanguageCodeTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/LanguageCodeTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/LanguageCodeTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/LanguageCodeTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -41,8 +41,8 @@ import static org.apache.sis.internal.ut
/**
* Tests the XML marshaling of {@code Locale} when used for a language.
- * The locale is marshalled as a character string. This format was used by ISO
19139:2007
- * but is not used anymore in ISO 19115-3 (the newer version use {@code
PT_Locale} instead).
+ * The locale is marshalled as a character string. This format was used
directly by ISO 19139:2007
+ * but only indirectly by ISO 19115-3 (the newer version wraps the language in
{@code PT_Locale}).
*
* <p>This class also test indirectly the {@link org.apache.sis.xml}
capability to map the legacy
* {@code "http://www.isotc211.org/2005/gmd"} namespace to {@code
"http://standards.iso.org/…"}.</p>
@@ -79,8 +79,8 @@ public final strictfp class LanguageCode
* Creates the XML (un)marshaller pool to be shared by all test methods.
* The (un)marshallers locale and timezone will be set to fixed values.
*
- * <p>This test uses its own pool instead of {@link
XMLTestCase#getMarshallerPool()} because it
- * uses {@link MetadataMock} instead of {@link
org.apache.sis.metadata.iso.DefaultMetadata}.</p>
+ * <p>This test uses its own pool instead of {@link #getMarshallerPool()}
because it uses
+ * {@link MetadataMock} instead of {@link
org.apache.sis.metadata.iso.DefaultMetadata}.</p>
*
* @throws JAXBException if an error occurred while creating the pool.
*
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/PT_LocaleTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/PT_LocaleTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/PT_LocaleTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/PT_LocaleTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -21,7 +21,7 @@ import java.util.Locale;
import javax.xml.bind.JAXBException;
import org.apache.sis.util.Version;
import org.apache.sis.metadata.iso.DefaultMetadata;
-import org.apache.sis.test.XMLTestCase;
+import org.apache.sis.metadata.xml.TestUsingFile;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
@@ -36,7 +36,12 @@ import static org.apache.sis.test.Assert
* @since 0.4
* @module
*/
-public final strictfp class PT_LocaleTest extends XMLTestCase {
+public final strictfp class PT_LocaleTest extends TestUsingFile {
+ /**
+ * An XML file containing localized strings.
+ */
+ private static final String FILENAME = "Locales.xml";
+
/**
* The locales to use for the tests. For better test coverage we need at
least:
*
@@ -71,7 +76,7 @@ public final strictfp class PT_LocaleTes
*/
@Test
public void testMarshalling() throws JAXBException {
- marshalAndCompare("Locales.xml", VERSION_2014,
+ marshalAndCompare(XML2016+FILENAME, VERSION_2014,
"mdb:contact", "mdb:dateInfo",
"mdb:identificationInfo");
}
@@ -82,7 +87,7 @@ public final strictfp class PT_LocaleTes
*/
@Test
public void testMarshallingLegacy() throws JAXBException {
- marshalAndCompare("Locales (legacy).xml", VERSION_2007,
+ marshalAndCompare(XML2007+FILENAME, VERSION_2007,
"gmd:contact", "gmd:dateStamp",
"gmd:identificationInfo");
}
@@ -93,7 +98,7 @@ public final strictfp class PT_LocaleTes
*/
@Test
public void testUnmarshalling() throws JAXBException {
- final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class,
"Locales.xml");
+ final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class,
XML2016+FILENAME);
assertArrayEquals(LOCALES, metadata.getLanguages().toArray());
}
@@ -104,7 +109,7 @@ public final strictfp class PT_LocaleTes
*/
@Test
public void testUnmarshallingLegacy() throws JAXBException {
- final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class,
"Locales (legacy).xml");
+ final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class,
XML2007+FILENAME);
assertArrayEquals(LOCALES, metadata.getLanguages().toArray());
}
}
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java?rev=1829670&r1=1829669&r2=1829670&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
[UTF-8] Fri Apr 20 16:18:08 2018
@@ -37,12 +37,12 @@ import org.apache.sis.xml.IdentifierMap;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.metadata.iso.DefaultIdentifier;
+import org.apache.sis.metadata.xml.TestUsingFile;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.util.iso.DefaultInternationalString;
import org.apache.sis.util.Version;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.TestUtilities;
-import org.apache.sis.test.XMLTestCase;
import org.junit.Test;
import static org.apache.sis.test.TestUtilities.getSingleton;
@@ -58,16 +58,11 @@ import static org.apache.sis.test.Metada
* @since 0.3
* @module
*/
-public final strictfp class DefaultCitationTest extends XMLTestCase {
+public final strictfp class DefaultCitationTest extends TestUsingFile {
/**
- * An XML file in this package containing a citation.
+ * An XML file containing a citation.
*/
- private static final String XML_FILE = "Citation.xml";
-
- /**
- * An XML file in this package containing a citation in the format of
legacy ISO 19139:2007 specification.
- */
- private static final String XML_FILE_LEGACY = "Citation (legacy).xml";
+ private static final String FILENAME = "Citation.xml";
/**
* Creates a citation with an arbitrary title, presentation form and other
properties.
@@ -199,7 +194,7 @@ public final strictfp class DefaultCitat
*/
@Test
public void testMarshalling() throws JAXBException {
- testMarshalling(XML_FILE, VERSION_2014);
+ testMarshalling(XML2016+FILENAME, VERSION_2014);
}
/**
@@ -213,7 +208,7 @@ public final strictfp class DefaultCitat
@Test
@DependsOnMethod("testMarshalling")
public void testMarshallingLegacy() throws JAXBException {
- testMarshalling(XML_FILE_LEGACY, VERSION_2007);
+ testMarshalling(XML2007+FILENAME, VERSION_2007);
}
/**
@@ -255,7 +250,7 @@ public final strictfp class DefaultCitat
*/
@Test
public void testUnmarshalling() throws JAXBException {
- testUnmarshalling(XML_FILE);
+ testUnmarshalling(XML2016+FILENAME);
}
/**
@@ -269,7 +264,7 @@ public final strictfp class DefaultCitat
@Test
@DependsOnMethod("testUnmarshalling")
public void testUnmarshallingLegacy() throws JAXBException {
- testUnmarshalling(XML_FILE_LEGACY);
+ testUnmarshalling(XML2007+FILENAME);
}
/**