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 2016/01/29 13:23:11 UTC
svn commit: r1727561 [4/5] - in /sis/branches/JDK6: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/s...
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -37,7 +37,6 @@ import org.apache.sis.test.TestStep;
import org.junit.Test;
import static org.apache.sis.test.MetadataAssert.*;
-import static org.apache.sis.test.mock.GeodeticDatumMock.*;
import static org.apache.sis.referencing.GeodeticObjectVerifier.*;
@@ -105,7 +104,7 @@ public final strictfp class DefaultGeode
*/
@Test
public void testIsHeuristicMatchForName() {
- final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(WGS84);
+ final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(GeodeticDatumMock.WGS84);
assertFalse(datum.isHeuristicMatchForName("WGS72"));
assertTrue (datum.isHeuristicMatchForName("WGS84"));
assertTrue (datum.isHeuristicMatchForName("WGS 84"));
@@ -136,28 +135,29 @@ public final strictfp class DefaultGeode
* Build the datum using WGS 72 ellipsoid (so at least one of the BursaWolfParameters is real).
*/
final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(properties,
- WGS72.getEllipsoid(), WGS72.getPrimeMeridian());
+ GeodeticDatumMock.WGS72.getEllipsoid(),
+ GeodeticDatumMock.WGS72.getPrimeMeridian());
/*
* Search for BursaWolfParameters around the North Sea area.
*/
final DefaultGeographicBoundingBox areaOfInterest = new DefaultGeographicBoundingBox(-2, 8, 55, 60);
final DefaultExtent extent = new DefaultExtent("Around the North Sea", areaOfInterest, null, null);
- Matrix matrix = datum.getPositionVectorTransformation(NAD83, extent);
+ Matrix matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.NAD83, extent);
assertNull("No BursaWolfParameters for NAD83", matrix);
- matrix = datum.getPositionVectorTransformation(WGS84, extent);
+ matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.WGS84, extent);
assertNotNull("BursaWolfParameters for WGS84", matrix);
checkTransformationSignature(local, matrix, 0);
/*
* Expand the area of interest to something greater than North Sea, and test again.
*/
areaOfInterest.setWestBoundLongitude(-8);
- matrix = datum.getPositionVectorTransformation(WGS84, extent);
+ matrix = datum.getPositionVectorTransformation(GeodeticDatumMock.WGS84, extent);
assertNotNull("BursaWolfParameters for WGS84", matrix);
checkTransformationSignature(global, matrix, 0);
/*
* Search in the reverse direction.
*/
- final DefaultGeodeticDatum targetDatum = new DefaultGeodeticDatum(WGS84);
+ final DefaultGeodeticDatum targetDatum = new DefaultGeodeticDatum(GeodeticDatumMock.WGS84);
matrix = targetDatum.getPositionVectorTransformation(datum, extent);
global.invert(); // Expected result is the inverse.
checkTransformationSignature(global, matrix, 1E-6);
@@ -182,7 +182,7 @@ public final strictfp class DefaultGeode
*/
@Test
public void testToWKT() {
- final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(WGS84);
+ final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(GeodeticDatumMock.WGS84);
assertWktEquals(Convention.WKT2,
"DATUM[“WGS84”,\n" +
" ELLIPSOID[“WGS84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]]",
@@ -222,7 +222,7 @@ public final strictfp class DefaultGeode
" </gml:Ellipsoid>\n" +
" </gml:ellipsoid>\n" +
"</gml:GeodeticDatum>",
- marshal(new DefaultGeodeticDatum(WGS84)), "xmlns:*");
+ marshal(new DefaultGeodeticDatum(GeodeticDatumMock.WGS84)), "xmlns:*");
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -36,7 +36,6 @@ import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.apache.sis.test.MetadataAssert.*;
import static org.apache.sis.referencing.GeodeticObjectVerifier.*;
-import static org.apache.sis.test.mock.PrimeMeridianMock.GREENWICH;
/**
@@ -59,7 +58,7 @@ public final strictfp class DefaultPrime
*/
@Test
public void testToWKT() {
- final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
+ final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(PrimeMeridianMock.GREENWICH);
assertIsGreenwich(pm);
assertWktEquals(Convention.WKT2, "PRIMEM[“Greenwich”, 0.0, ANGLEUNIT[“degree”, 0.017453292519943295]]", pm);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "PrimeMeridian[“Greenwich”, 0.0]", pm);
@@ -123,7 +122,7 @@ public final strictfp class DefaultPrime
*/
@Test
public void testMarshall() throws JAXBException {
- final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
+ final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(PrimeMeridianMock.GREENWICH);
assertXmlEquals(getGreenwichXml(Namespaces.GML), marshal(pm), "xmlns:*");
}
@@ -135,7 +134,7 @@ public final strictfp class DefaultPrime
@Test
@DependsOnMethod("testMarshall")
public void testMarshallGML31() throws JAXBException {
- final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
+ final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(PrimeMeridianMock.GREENWICH);
final MarshallerPool pool = getMarshallerPool();
final Marshaller marshaller = pool.acquireMarshaller();
marshaller.setProperty(XML.GML_VERSION, LegacyNamespaces.VERSION_3_0);
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -23,7 +23,6 @@ import javax.measure.unit.SI;
import javax.measure.unit.NonSI;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.datum.VerticalDatumType;
-import org.apache.sis.test.mock.GeodeticDatumMock;
import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.internal.metadata.VerticalDatumTypes;
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/TimeDependentBWPTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -28,7 +28,6 @@ import org.junit.Test;
import static org.apache.sis.test.Assert.*;
import static org.apache.sis.test.TestUtilities.date;
-import static org.apache.sis.test.mock.GeodeticDatumMock.WGS84;
import static org.apache.sis.internal.referencing.Formulas.JULIAN_YEAR_LENGTH;
@@ -48,7 +47,7 @@ public final strictfp class TimeDependen
* For the purpose of this test, the target datum does not matter anyway.
*/
private static TimeDependentBWP create() {
- final TimeDependentBWP p = new TimeDependentBWP(WGS84, null, date("1994-01-01 00:00:00"));
+ final TimeDependentBWP p = new TimeDependentBWP(GeodeticDatumMock.WGS84, null, date("1994-01-01 00:00:00"));
p.tX = -0.08468; p.dtX = +1.42;
p.tY = -0.01942; p.dtY = +1.34;
p.tZ = +0.03201; p.dtZ = +0.90;
Copied: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java (from r1727537, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java?p2=sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java&r1=1727537&r2=1727561&rev=1727561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -52,8 +52,9 @@ import static org.junit.Assert.*;
* @version 0.7
* @module
*/
+@org.apache.sis.internal.jdk7.AutoCloseable
public final strictfp class AuthorityFactoryMock extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
- CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, AutoCloseable
+ CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
{
/**
* The authority.
@@ -107,7 +108,7 @@ public final strictfp class AuthorityFac
@Override
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) {
assertFalse("This factory has been closed.", isClosed());
- final Set<String> codes = new LinkedHashSet<>();
+ final Set<String> codes = new LinkedHashSet<String>();
if (type.isAssignableFrom(GeocentricCRS.class)) add(codes, 4979);
if (type.isAssignableFrom(GeographicCRS.class)) add(codes, 84, 4326);
if (type.isAssignableFrom(PrimeMeridian.class)) add(codes, 8901, 8903, 8914);
@@ -205,7 +206,6 @@ public final strictfp class AuthorityFac
/**
* Flags this factory as closed.
*/
- @Override
public synchronized void close() {
closed = true;
}
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryProxyTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryProxyTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryProxyTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryProxyTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -21,10 +21,16 @@ import org.opengis.referencing.Identifie
import org.opengis.referencing.AuthorityFactory;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.crs.*;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.Datum;
import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.crs.DefaultProjectedCRS;
import org.apache.sis.referencing.crs.DefaultDerivedCRS;
+import org.apache.sis.referencing.crs.AbstractCRS;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -61,13 +67,36 @@ public final strictfp class AuthorityFac
* Tests {@link AuthorityFactoryProxy#getInstance(Class)}.
*/
@Test
- public void testType() {
- assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getInstance(ProjectedCRS.class) .type);
- assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getInstance(DefaultProjectedCRS.class) .type);
- assertEquals(GeographicCRS.class, AuthorityFactoryProxy.getInstance(GeographicCRS.class) .type);
- assertEquals(GeographicCRS.class, AuthorityFactoryProxy.getInstance(DefaultGeographicCRS.class).type);
- assertEquals(DerivedCRS.class, AuthorityFactoryProxy.getInstance(DefaultDerivedCRS.class) .type);
- assertEquals(GeodeticDatum.class, AuthorityFactoryProxy.getInstance(DefaultGeodeticDatum.class).type);
+ public void testGetInstance() {
+ assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getInstance(ProjectedCRS.class) .type);
+ assertEquals(ProjectedCRS.class, AuthorityFactoryProxy.getInstance(DefaultProjectedCRS.class) .type);
+ assertEquals(GeographicCRS.class, AuthorityFactoryProxy.getInstance(GeographicCRS.class) .type);
+ assertEquals(GeographicCRS.class, AuthorityFactoryProxy.getInstance(DefaultGeographicCRS.class).type);
+ assertEquals(DerivedCRS.class, AuthorityFactoryProxy.getInstance(DefaultDerivedCRS.class) .type);
+ assertEquals(GeodeticDatum.class, AuthorityFactoryProxy.getInstance(DefaultGeodeticDatum.class).type);
+ assertEquals(CoordinateReferenceSystem.class, AuthorityFactoryProxy.getInstance(AbstractCRS.class) .type);
+ assertEquals(CoordinateSystem.class, AuthorityFactoryProxy.getInstance(CoordinateSystem.class) .type);
+ assertEquals(CoordinateSystemAxis.class, AuthorityFactoryProxy.getInstance(CoordinateSystemAxis.class).type);
+ assertEquals(PrimeMeridian.class, AuthorityFactoryProxy.getInstance(PrimeMeridian.class) .type);
+ assertEquals(Ellipsoid.class, AuthorityFactoryProxy.getInstance(Ellipsoid.class) .type);
+ assertEquals(Datum.class, AuthorityFactoryProxy.getInstance(Datum.class) .type);
+ }
+
+ /**
+ * Tests {@link AuthorityFactoryProxy#specialize(String)}.
+ */
+ @Test
+ public void testSpecialize() {
+ final AuthorityFactoryProxy<IdentifiedObject> base = AuthorityFactoryProxy.OBJECT;
+ assertEquals(CoordinateReferenceSystem.class, base.specialize("CRS") .type);
+ assertEquals(CoordinateSystem.class, base.specialize("CS") .type);
+ assertEquals(CoordinateSystemAxis.class, base.specialize("aXis") .type);
+ assertEquals(PrimeMeridian.class, base.specialize("Meridian") .type);
+ assertEquals(Ellipsoid.class, base.specialize("ellipsoid").type);
+ assertEquals(Datum.class, base.specialize("datum") .type);
+
+ assertEquals(GeodeticDatum.class, AuthorityFactoryProxy.GEODETIC_DATUM.specialize("datum").type);
+ assertNull(AuthorityFactoryProxy.COORDINATE_SYSTEM.specialize("datum"));
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -17,6 +17,7 @@
package org.apache.sis.referencing.factory;
import java.util.Arrays;
+import java.util.Set;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import javax.measure.unit.SI;
@@ -91,6 +92,16 @@ public final strictfp class CommonAuthor
factory.getAuthorityCodes(VerticalCRS.class));
assertSetEquals(Arrays.asList("CRS:1"),
factory.getAuthorityCodes(EngineeringCRS.class));
+
+ final Set<String> codes = factory.getAuthorityCodes(GeographicCRS.class);
+ assertFalse("CRS:1", codes.contains("CRS:1"));
+ assertTrue ("CRS:27", codes.contains("CRS:27"));
+ assertTrue ("CRS:83", codes.contains("CRS:83"));
+ assertTrue ("CRS:84", codes.contains("CRS:84"));
+ assertFalse("CRS:88", codes.contains("CRS:88"));
+ assertTrue ("0084", codes.contains("0084"));
+ assertFalse("0088", codes.contains("0088"));
+ assertTrue ("OGC:CRS084", codes.contains("OGC:CRS084"));
}
/**
@@ -112,12 +123,10 @@ public final strictfp class CommonAuthor
@Test
public void testAuthority() {
final Citation authority = factory.getAuthority();
- assertFalse(Citations.identifierMatches(authority, "CRS"));
- assertTrue (Citations.identifierMatches(authority, "OGC"));
+ assertTrue (Citations.identifierMatches(authority, "WMS"));
assertFalse(Citations.identifierMatches(authority, "OGP"));
assertFalse(Citations.identifierMatches(authority, "EPSG"));
- assertFalse(Citations.identifierMatches(authority, "AUTO"));
- assertFalse(Citations.identifierMatches(authority, "AUTO2"));
+ assertEquals(Constants.OGC, org.apache.sis.internal.util.Citations.getCodeSpace(authority));
}
/**
@@ -344,7 +353,7 @@ public final strictfp class CommonAuthor
" AXIS[“Latitude”, NORTH],\n" +
" AUTHORITY[“CRS”, “84”]]", crs);
- assertWktEquals(Convention.WKT2,
+ assertWktEqualsRegex(Convention.WKT2, "(?m)\\Q" +
"GEODCRS[“WGS 84”,\n" +
" DATUM[“World Geodetic System 1984”,\n" +
" ELLIPSOID[“WGS 84”, 6378137.0, 298.257223563, LENGTHUNIT[“metre”, 1]]],\n" +
@@ -353,8 +362,18 @@ public final strictfp class CommonAuthor
" AXIS[“Longitude (L)”, east, ORDER[1]],\n" +
" AXIS[“Latitude (B)”, north, ORDER[2]],\n" +
" ANGLEUNIT[“degree”, 0.017453292519943295],\n" +
- " AREA[“World”],\n" +
+ " SCOPE[“Horizontal component of 3D system.\\E.*\\Q”],\n" +
+ " AREA[“World\\E.*\\Q”],\n" +
" BBOX[-90.00, -180.00, 90.00, 180.00],\n" +
- " ID[“CRS”, 84, CITATION[“OGC”]]]", crs);
+ " ID[“CRS”, 84, CITATION[“OGC:WMS”], URI[“urn:ogc:def:crs:OGC:1.3:CRS84”]]]\\E", crs);
+ /*
+ * Note: the WKT specification defines the ID element as:
+ *
+ * ID[authority, code, (version), (authority citation), (URI)]
+ *
+ * where everything after the code is optional. The difference between "authority" and "authority citation"
+ * is unclear. The only example found in OGC 12-063r5 uses CITATION[…] as the source of an EPSG definition
+ * (so we could almost said "the authority of the authority").
+ */
}
}
Copied: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java (from r1727537, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java?p2=sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java&r1=1727537&r2=1727561&rev=1727561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -51,7 +51,7 @@ public final strictfp class ConcurrentAu
*/
private static final strictfp class Mock extends ConcurrentAuthorityFactory<AuthorityFactoryMock> {
/** All factories created by this mock, including any factories having been disposed. */
- private final Queue<AuthorityFactoryMock> allDAOs = new ConcurrentLinkedQueue<>();
+ private final Queue<AuthorityFactoryMock> allDAOs = new ConcurrentLinkedQueue<AuthorityFactoryMock>();
/** Creates a new concurrent authority factory. */
Mock() {
@@ -69,7 +69,7 @@ public final strictfp class ConcurrentAu
/** Returns a copy of the factories queue. */
final synchronized List<AuthorityFactoryMock> createdDAOs() {
- return new ArrayList<>(allDAOs);
+ return new ArrayList<AuthorityFactoryMock>(allDAOs);
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -53,6 +53,7 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.datum.BursaWolfParameters;
import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
import org.apache.sis.referencing.operation.AbstractCoordinateOperation;
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
import org.apache.sis.referencing.factory.IdentifiedObjectFinder;
import org.apache.sis.referencing.factory.UnavailableFactoryException;
@@ -100,8 +101,9 @@ public final strictfp class EPSGFactoryT
*/
@BeforeClass
public static void createFactory() throws FactoryException {
+ final GeodeticObjectFactory f = new GeodeticObjectFactory();
try {
- factory = new EPSGFactory();
+ factory = new EPSGFactory(null, null, f, f, f, null, null, null);
} catch (UnavailableFactoryException e) {
Logging.getLogger(Loggers.CRS_FACTORY).warning(e.toString());
// Leave INSTANCE to null. This will have the effect of skipping tests.
@@ -298,7 +300,7 @@ public final strictfp class EPSGFactoryT
/**
* Tests the "WGS 72 / UTM zone 10N" projection and ensures
* that it is not confused with "WGS 72BE / UTM zone 10N".
- * In the EPSG database, those two projected CRS uses the same conversion.
+ * In the EPSG database, those two projected CRS use the same conversion.
* However in Apache SIS the conversions must differ because the datum are not the same.
*
* @throws FactoryException if an error occurred while querying the factory.
@@ -323,6 +325,7 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, variant.getConversionFromBase().getMethod());
assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, variant.getConversionFromBase());
verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123);
+
assertSame("Operation method", crs.getConversionFromBase().getMethod(),
variant.getConversionFromBase().getMethod());
assertSame("Coordinate system", crs.getCoordinateSystem(),
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/EquirectangularTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -23,7 +23,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.referencing.provider.Equirectangular;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.referencing.operation.transform.CoordinateDomain;
-import org.apache.sis.test.mock.MathTransformFactoryMock;
+import org.apache.sis.referencing.operation.transform.MathTransformFactoryMock;
import org.apache.sis.test.ReferencingAssert;
import org.junit.Test;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -27,8 +27,8 @@ import org.apache.sis.internal.referenci
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.referencing.operation.transform.CoordinateDomain;
import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
-import org.apache.sis.test.mock.MathTransformFactoryMock;
-import org.apache.sis.test.mock.GeodeticDatumMock;
+import org.apache.sis.referencing.operation.transform.MathTransformFactoryMock;
+import org.apache.sis.referencing.datum.GeodeticDatumMock;
import static java.lang.StrictMath.*;
import static org.junit.Assert.*;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/NoOp.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -21,11 +21,11 @@ import org.opengis.parameter.ParameterDe
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.operation.Matrix;
+import org.apache.sis.referencing.datum.GeodeticDatumMock;
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.parameter.ParameterBuilder;
import org.apache.sis.parameter.Parameters;
import org.apache.sis.internal.util.Constants;
-import org.apache.sis.test.mock.GeodeticDatumMock;
import org.apache.sis.util.Workaround;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -26,10 +26,10 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.referencing.provider.PolarStereographicNorth;
import org.apache.sis.internal.referencing.provider.PolarStereographicSouth;
import org.apache.sis.referencing.operation.transform.CoordinateDomain;
+import org.apache.sis.referencing.operation.transform.MathTransformFactoryMock;
import org.apache.sis.parameter.Parameters;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.mock.MathTransformFactoryMock;
import org.junit.Test;
import static java.lang.StrictMath.*;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -24,7 +24,7 @@ import static java.lang.StrictMath.*;
import static org.apache.sis.internal.metadata.ReferencingServices.AUTHALIC_RADIUS;
// Test imports
-import org.apache.sis.test.mock.GeodeticDatumMock;
+import org.apache.sis.referencing.datum.GeodeticDatumMock;
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -73,7 +73,7 @@ public strictfp class InterpolatedGeocen
values.parameter("src_semi_minor").setValue(source.getSemiMinorAxis());
values.parameter("tgt_semi_major").setValue(target.getSemiMajorAxis());
values.parameter("tgt_semi_minor").setValue(target.getSemiMinorAxis());
- values.parameter("Geocentric translations file").setValue(file); // Automatic conversion from URL to Path.
+ values.parameter("Geocentric translation file").setValue(file); // Automatic conversion from URL to Path.
transform = provider.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
tolerance = FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE;
}
@@ -171,7 +171,7 @@ public strictfp class InterpolatedGeocen
" PARAMETER[“src_semi_minor”, 6356752.314140356],\n" +
" PARAMETER[“tgt_semi_major”, 6378249.2],\n" +
" PARAMETER[“tgt_semi_minor”, 6356515.0],\n" +
- " PARAMETER[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " PARAMETER[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”]]\\E");
transform = transform.inverse();
@@ -182,7 +182,7 @@ public strictfp class InterpolatedGeocen
" PARAMETER[“src_semi_minor”, 6356515.0],\n" +
" PARAMETER[“tgt_semi_major”, 6378137.0],\n" +
" PARAMETER[“tgt_semi_minor”, 6356752.314140356],\n" +
- " PARAMETER[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " PARAMETER[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”]]\\E");
}
@@ -208,7 +208,7 @@ public strictfp class InterpolatedGeocen
" Parameter[“src_semi_minor”, 6356515.0],\n" +
" Parameter[“tgt_semi_major”, 6378137.0],\n" +
" Parameter[“tgt_semi_minor”, 6356752.314140356],\n" +
- " ParameterFile[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " ParameterFile[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727],\n" +
" Remark[“\\E.*\\Q”]]],\n" +
" Param_MT[“Affine parametric transformation”,\n" +
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransformTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -80,7 +80,7 @@ public final strictfp class Interpolated
" PARAMETER[“src_semi_minor”, 6356752.314140356],\n" +
" PARAMETER[“tgt_semi_major”, 6378249.2],\n" +
" PARAMETER[“tgt_semi_minor”, 6356515.0],\n" +
- " PARAMETER[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " PARAMETER[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”]]\\E");
transform = transform.inverse();
@@ -91,7 +91,7 @@ public final strictfp class Interpolated
" PARAMETER[“src_semi_minor”, 6356515.0],\n" +
" PARAMETER[“tgt_semi_major”, 6378137.0],\n" +
" PARAMETER[“tgt_semi_minor”, 6356752.314140356],\n" +
- " PARAMETER[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " PARAMETER[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”]]\\E");
}
@@ -117,7 +117,7 @@ public final strictfp class Interpolated
" Parameter[“src_semi_minor”, 6356515.0],\n" +
" Parameter[“Semi-major axis length difference”, -112.2],\n" +
" Parameter[“Flattening difference”, -5.4738838833299144E-5],\n" +
- " ParameterFile[“Geocentric translations file”, “\\E.*\\W\\Q" +
+ " ParameterFile[“Geocentric translation file”, “\\E.*\\W\\Q" +
FranceGeocentricInterpolationTest.TEST_FILE + "”, Id[“EPSG”, 8727],\n" +
" Remark[“\\E.*\\Q”]],\n" +
" Parameter[“dim”, 2]],\n" +
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -40,7 +40,6 @@ import static org.apache.sis.internal.me
import org.apache.sis.internal.referencing.provider.FranceGeocentricInterpolationTest;
import org.apache.sis.internal.referencing.provider.GeocentricTranslationTest;
import org.apache.sis.referencing.datum.HardCodedDatum;
-import org.apache.sis.test.mock.MathTransformFactoryMock;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestUtilities;
Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -168,17 +168,21 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
org.apache.sis.referencing.crs.HardCodedCRSTest.class,
+ // Direct (not from authority codes) geodetic object creations.
org.apache.sis.referencing.StandardDefinitionsTest.class,
- org.apache.sis.referencing.CommonCRSTest.class,
- org.apache.sis.referencing.CRSTest.class,
+ org.apache.sis.referencing.factory.GeodeticObjectFactoryTest.class,
org.apache.sis.referencing.factory.GIGS3002.class,
org.apache.sis.referencing.factory.GIGS3003.class,
org.apache.sis.referencing.factory.GIGS3004.class,
org.apache.sis.referencing.factory.GIGS3005.class,
- org.apache.sis.referencing.factory.GeodeticObjectFactoryTest.class,
- org.apache.sis.referencing.factory.CommonAuthorityFactoryTest.class,
- org.apache.sis.referencing.factory.AuthorityFactoryProxyTest.class,
- org.apache.sis.referencing.factory.IdentifiedObjectFinderTest.class,
+
+ // Well Known Text parsing require above factory.
+ org.apache.sis.io.wkt.MathTransformParserTest.class,
+ org.apache.sis.io.wkt.GeodeticObjectParserTest.class,
+ org.apache.sis.io.wkt.WKTFormatTest.class,
+ org.apache.sis.io.wkt.WKTParserTest.class,
+
+ // Geodetic object creations from authority codes.
org.apache.sis.referencing.factory.GIGS2001.class,
org.apache.sis.referencing.factory.GIGS2002.class,
org.apache.sis.referencing.factory.GIGS2003.class,
@@ -188,12 +192,18 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.factory.GIGS2007.class,
org.apache.sis.referencing.factory.GIGS2008.class,
org.apache.sis.referencing.factory.GIGS2009.class,
- org.apache.sis.referencing.factory.sql.EPSGFactoryTest.class,
- org.apache.sis.io.wkt.MathTransformParserTest.class,
- org.apache.sis.io.wkt.GeodeticObjectParserTest.class,
- org.apache.sis.io.wkt.WKTFormatTest.class,
- org.apache.sis.io.wkt.WKTParserTest.class,
+ // Following tests use indirectly EPSG factory.
+ org.apache.sis.referencing.CommonCRSTest.class,
+ org.apache.sis.referencing.factory.CommonAuthorityFactoryTest.class,
+ org.apache.sis.referencing.factory.AuthorityFactoryProxyTest.class,
+ org.apache.sis.referencing.factory.ConcurrentAuthorityFactoryTest.class,
+ org.apache.sis.referencing.factory.IdentifiedObjectFinderTest.class,
+ org.apache.sis.referencing.factory.MultiAuthoritiesFactoryTest.class,
+ org.apache.sis.referencing.factory.sql.EPSGFactoryTest.class,
+ org.apache.sis.referencing.EPSGFactoryFallbackTest.class,
+ org.apache.sis.referencing.AuthorityFactoriesTest.class,
+ org.apache.sis.referencing.CRSTest.class,
org.apache.sis.geometry.AbstractDirectPositionTest.class,
org.apache.sis.geometry.GeneralDirectPositionTest.class,
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Collection;
import java.util.Collections;
-import java.util.AbstractSet;
import java.util.AbstractMap;
import java.util.NoSuchElementException;
import java.io.Serializable;
@@ -33,6 +32,7 @@ import org.apache.sis.util.Debug;
import org.apache.sis.xml.XLink;
import org.apache.sis.xml.IdentifierMap;
import org.apache.sis.xml.IdentifierSpace;
+import org.apache.sis.internal.util.SetOfUnknownSize;
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
@@ -358,7 +358,7 @@ public class IdentifierMapAdapter extend
* fields if the underlying list is thread-safe. Furthermore, IdentifierMapAdapter are temporary
* objects anyway in the current ISOMetadata implementation.
*/
- return new AbstractSet<Entry<Citation,String>>() {
+ return new SetOfUnknownSize<Entry<Citation,String>>() {
/** Delegates to the enclosing class. */
@Override public void clear() throws UnsupportedOperationException {
IdentifierMapAdapter.this.clear();
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -40,7 +40,7 @@ import org.apache.sis.internal.util.Meta
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*
* @see IdentifierSpace
@@ -82,7 +82,7 @@ public class CitationConstant extends Si
* </ul>
*/
@Override
- public final String getName() {
+ public String getName() {
return title;
}
@@ -92,7 +92,7 @@ public class CitationConstant extends Si
@Debug
@Override
public final String toString() {
- return "IdentifierSpace[“" + getName() + "”]";
+ return "IdentifierSpace[" + title + ']';
}
}
@@ -136,7 +136,8 @@ public class CitationConstant extends Si
if (c == null) {
c = MetadataServices.getInstance().createCitation(title);
if (c == null) {
- // 'sis-metadata' module not on the classpath (should be very rare).
+ // 'sis-metadata' module not on the classpath (should be very rare)
+ // or no citation defined for the given primary key.
c = new SimpleCitation(title);
}
delegate = c;
@@ -173,7 +174,15 @@ public class CitationConstant extends Si
* @return The instance to use, as an unique instance if possible.
*/
protected Object readResolve() {
- final Citation c = MetadataServices.getInstance().getCitationConstant(title);
- return (c != null) ? c : this;
+ CitationConstant c = MetadataServices.getInstance().getCitationConstant(title);
+ if (c == null) {
+ /*
+ * Should happen only if the sis-metadata module is not on the classpath (should be rare)
+ * or if the Citation has been serialized on a more recent version of Apache SIS than the
+ * current version.
+ */
+ c = this;
+ }
+ return c;
}
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -102,9 +102,9 @@ public class SimpleIdentifier implements
}
/**
- * Returns the name or identifier of the person or organization responsible for namespace,
- * or {@code null} if none. The default implementation returns the shortest identifier of
- * the {@linkplain #getAuthority() authority}, if any.
+ * Returns the identifier or namespace in which the code is valid, or {@code null} if none.
+ * The default implementation returns the shortest identifier of the {@linkplain #getAuthority() authority},
+ * if any.
*
* @return A code space inferred from the authority given at construction time, or {@code null} if none.
*/
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -21,7 +21,6 @@ import java.util.Set;
import java.util.Iterator;
import java.util.Collection;
import java.util.Collections;
-import java.util.AbstractSet;
import java.util.AbstractCollection;
import java.util.NoSuchElementException;
import org.apache.sis.io.TableAppender;
@@ -69,7 +68,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.6
+ * @version 0.7
* @module
*/
public abstract class AbstractMap<K,V> implements Map<K,V> {
@@ -363,7 +362,7 @@ public abstract class AbstractMap<K,V> i
*/
@Override
public Set<K> keySet() {
- return new AbstractSet<K>() {
+ return new SetOfUnknownSize<K>() {
@Override public void clear() { AbstractMap.this.clear();}
@Override public boolean isEmpty() {return AbstractMap.this.isEmpty();}
@Override public int size() {return AbstractMap.this.size();}
@@ -434,7 +433,7 @@ public abstract class AbstractMap<K,V> i
*/
@Override
public Set<Entry<K,V>> entrySet() {
- return new AbstractSet<Entry<K,V>>() {
+ return new SetOfUnknownSize<Entry<K,V>>() {
@Override public void clear() { AbstractMap.this.clear();}
@Override public boolean isEmpty() {return AbstractMap.this.isEmpty();}
@Override public int size() {return AbstractMap.this.size();}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -41,7 +41,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.6
+ * @version 0.7
* @module
*/
public final class Citations extends Static {
@@ -106,7 +106,7 @@ public final class Citations extends Sta
*
* @param s1 The first characters sequence to compare, or {@code null}.
* @param s2 The second characters sequence to compare, or {@code null}.
- * @return {@code true}if both arguments are {@code null} or if the two given texts are equal,
+ * @return {@code true} if both arguments are {@code null} or if the two given texts are equal,
* ignoring case and any characters other than digits and letters.
*
* @since 0.6
@@ -139,7 +139,7 @@ public final class Citations extends Sta
return true;
}
final String localized = candidate.toString();
- if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
+ if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
&& titleMatches(c1, localized))
{
return true;
@@ -178,7 +178,7 @@ public final class Citations extends Sta
return true;
}
final String localized = candidate.toString();
- if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
+ if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
&& equalsFiltered(localized, title))
{
return true;
@@ -209,7 +209,7 @@ public final class Citations extends Sta
public static boolean identifierMatches(Citation c1, Citation c2) {
if (c1 != null && c2 != null) {
if (c1 == c2) {
- return true; // Optimisation for a common case.
+ return true; // Optimisation for a common case.
}
/*
* If there is no identifier in both citations, fallback on title comparisons.
@@ -369,9 +369,9 @@ public final class Citations extends Sta
final String candidate = CharSequences.trimWhitespaces(id.getCode());
if (candidate != null && !candidate.isEmpty()) {
/*
- * For a non-empty identifier. Verify if both the code ans its codespace are valid
- * Unicode identifiers. If a codespace exist, the code does not need to begin with
- * a "Unicode identifier start" (it may be a "Unicode identifier part").
+ * For a non-empty identifier, verify if both the code and its codespace are valid
+ * Unicode identifiers. If a codespace exists, then the code does not need to begin
+ * with a "Unicode identifier start" (it may be a "Unicode identifier part").
*/
String cs = CharSequences.trimWhitespaces(id.getCodeSpace());
if (cs == null || cs.isEmpty()) {
@@ -381,7 +381,11 @@ public final class Citations extends Sta
isUnicode = CharSequences.isUnicodeIdentifier(cs);
if (isUnicode) for (int i = 0; i < candidate.length();) {
final int c = candidate.codePointAt(i);
- if (!Character.isUnicodeIdentifierPart(c)) {
+ if (!Character.isUnicodeIdentifierPart(c) &&
+ (strict || (c != '.' && c != '-')))
+ {
+ // Above special case for '.' and '-' characters is documented
+ // in the public Citations.getIdentifier(Citation) method.
isUnicode = false;
break;
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -19,6 +19,7 @@ package org.apache.sis.internal.util;
import java.util.Map;
import java.util.Collections;
+import org.apache.sis.util.CharSequences;
import static org.apache.sis.util.CharSequences.*;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
import static org.apache.sis.internal.util.Utilities.appendUnicodeIdentifier;
@@ -35,9 +36,16 @@ import static org.apache.sis.internal.ut
* <li>{@code "urn:ogc:def:crs:EPSG::4326"} (version number is omitted)</li>
* <li>{@code "urn:ogc:def:crs:EPSG:8.2:4326"} (explicit version number, here 8.2)</li>
* <li>{@code "urn:x-ogc:def:crs:EPSG::4326"} (prior registration of {@code "ogc"} to IANA)</li>
+ * <li>{@code "http://www.opengis.net/def/crs/EPSG/0/4326"}</li>
* <li>{@code "http://www.opengis.net/gml/srs/epsg.xml#4326"}</li>
* </ul>
*
+ * This class does not attempt to decode URL characters. For example a URL for "m/s" may be encoded as below,
+ * in which case the value in the {@code #code} field will be {@code "m%2Fs"} instead of {@code "m/s"}.
+ * <ul>
+ * <li>{@code http://www.opengis.net/def/uom/SI/0/m%2Fs}</li>
+ * </ul>
+ *
* <div class="section">Components or URN</div>
* URN begins with {@code "urn:ogc:def:"} (formerly {@code "urn:x-ogc:def:"}) followed by:
* <ul>
@@ -105,7 +113,7 @@ import static org.apache.sis.internal.ut
*/
public final class DefinitionURI {
/**
- * The {@value} prefix used in all URI supported by this class.
+ * The {@value} prefix used in all URN supported by this class.
*/
public static final String PREFIX = "urn:ogc:def";
@@ -115,22 +123,39 @@ public final class DefinitionURI {
public static final char SEPARATOR = ':';
/**
+ * The domain of URLs in the OGC namespace.
+ */
+ private static final String DOMAIN = "www.opengis.net";
+
+ /**
* Server and path portions of HTTP URL for various types (currently {@code "crs"}).
* For each URL, value starts after the protocol part and finishes before the authority filename.
*
* <p>As of Apache SIS 0.4, this map has a single entry. However more entries may be added in future SIS versions.
- * If new entries are added, then see the TODO comment in the {@link #codeForHTTP(String, String, String, int,
+ * If new entries are added, then see the TODO comment in the {@link #codeForGML(String, String, String, int,
* DefinitionURI)} method.</p>
*/
- private static final Map<String,String> PATHS = Collections.singletonMap("crs", "//www.opengis.net/gml/srs/");
+ private static final Map<String,String> PATHS = Collections.singletonMap("crs", "//" + DOMAIN + "/gml/srs/");
+
+ /**
+ * A version number to be considered as if no version were provided.
+ * This value is part of OGC specification (not a SIS-specific hack).
+ */
+ public static final String NO_VERSION = "0";
/**
- * {@code true} if the URI is a {@code "http://www.opengis.net/gml/…"} URL, or
+ * {@code true} if the URI is a {@code "http://www.opengis.net/…"} URL, or
* {@code false} if the URI is a {@code "urn:ogc:def:…"} URN.
*/
public boolean isHTTP;
/**
+ * {@code true} if the URI is a {@code "http://www.opengis.net/gml/…"} URL.
+ * A value of {@code true} should imply that {@link #isHTTP} is also {@code true}.
+ */
+ public boolean isGML;
+
+ /**
* The type part of a URI, or {@code null} if none (empty).
* Note that the set of valid types in OGC namespace is restricted.
* See class javadoc for more information.
@@ -156,6 +181,7 @@ public final class DefinitionURI {
/**
* The version part of a URI, or {@code null} if none (empty).
+ * This field is null if the version in the parsed string was {@value #NO_VERSION}.
*
* <div class="note"><b>Example:</b>
* In the {@code "urn:ogc:def:crs:EPSG:8.2:4326"} URN, this is {@code "8.2"}.</div>
@@ -185,68 +211,102 @@ public final class DefinitionURI {
}
/**
- * Parses the given URI.
+ * Attempts to parse the given URI, which may either a URN or URL.
+ * If this method does not recognize the given URI, then it returns {@code null}.
+ * If the given URI is incomplete, then the {@link #code} value will be {@code null}.
*
* @param uri The URI to parse.
* @return The parse result, or {@code null} if the given URI is not recognized.
*/
- @SuppressWarnings("null")
public static DefinitionURI parse(final String uri) {
ensureNonNull("uri", uri);
DefinitionURI result = null;
+ char separator = SEPARATOR;
int upper = -1;
+ /*
+ * Loop on all parts that we expect in the URI. Those parts are:
+ *
+ * 0: "urn" or "http://www.opengis.net"
+ * 1: "ogc" or "x-ogc"
+ * 2: "def"
+ * 3: "crs", "datum" or other types. The value is not controlled by this method.
+ * 4: "ogc", "epsg", or other authorities. The value is not controlled by this method.
+ * 5: version, or null if none.
+ * 6: code
+ * 7: parameters, or null if none.
+ */
for (int p=0; p<=6; p++) {
final int lower = upper + 1;
- upper = uri.indexOf(SEPARATOR, lower);
+ upper = uri.indexOf(separator, lower);
if (upper < 0) {
- if (p != 6) {
- return null; // No more components.
- }
upper = uri.length();
+ if (lower > upper) {
+ return result; // Happen if a component is missing.
+ }
}
- final String require;
switch (p) {
/*
- * Verifies that the 3 first components are ""urn:ogc:def:" without storing them.
- * In the particular case of second component, we also accept "x-ogc" in addition
- * to "ogc". The actual verification is performed after the 'switch' case.
+ * Verifies that the 3 first components are "urn:ogc:def:" or "http://www.opengis.net/def/"
+ * without storing them. In the particular case of second component, we also accept "x-ogc"
+ * in addition to "ogc" in URN.
*/
- case 0: if (regionMatches("http", uri, lower, upper)) {
- result = new DefinitionURI();
- return codeForHTTP(null, null, uri, upper+1, result) != null ? result : null;
+ case 0: {
+ if (regionMatches("http", uri, lower, upper)) {
+ result = new DefinitionURI();
+ result.isHTTP = true;
+ if (codeForGML(null, null, uri, ++upper, result) != null) {
+ return result;
}
- require = "urn"; break;
- case 1: if (regionMatches("ogc", uri, lower, upper)) continue;
- require = "x-ogc"; break;
- case 2: require = "def"; break;
- default: {
- /*
- * For all components after the first 3 ones, trim whitespaces and store non-empty values.
- */
- String value = trimWhitespaces(uri, lower, upper).toString();
- if (value.isEmpty()) {
- value = null;
+ if (!uri.regionMatches(upper, "//", 0, 2)) {
+ return null;
+ }
+ upper++;
+ separator = '/'; // Separator for the HTTP namespace.
+ } else if (!regionMatches("urn", uri, lower, upper)) {
+ return null;
}
- switch (p) {
- case 3: result = new DefinitionURI();
- result.type = value; break;
- case 4: result.authority = value; break;
- case 5: result.version = value; break;
- case 6: result.code = value; break;
- default: throw new AssertionError(p);
+ break;
+ }
+ case 1: {
+ final boolean isHTTP = (separator != SEPARATOR);
+ if (!regionMatches(isHTTP ? DOMAIN : "ogc", uri, lower, upper)) {
+ if (isHTTP || !regionMatches("x-ogc", uri, lower, upper)) {
+ return null;
+ }
+ }
+ break;
+ }
+ case 2: {
+ if (!regionMatches("def", uri, lower, upper)) {
+ return null;
+ }
+ break;
+ }
+ /*
+ * For all components after the first 3 ones, trim whitespaces and store non-empty values.
+ */
+ default: {
+ final String value = trimWhitespaces(uri, lower, upper).toString();
+ if (!value.isEmpty() && (p != 5 || !NO_VERSION.equals(value))) {
+ if (result == null) {
+ result = new DefinitionURI();
+ }
+ switch (p) {
+ case 3: result.type = value; break;
+ case 4: result.authority = value; break;
+ case 5: result.version = value; break;
+ case 6: result.code = value; break;
+ default: throw new AssertionError(p);
+ }
}
- continue;
}
- }
- if (!regionMatches(require, uri, lower, upper)) {
- return null;
}
}
/*
* Take every remaining components as parameters.
*/
- if (++upper < uri.length()) {
- result.parameters = (String[]) split(uri.substring(upper), SEPARATOR);
+ if (result != null && ++upper < uri.length()) {
+ result.parameters = (String[]) split(uri.substring(upper), separator);
}
return result;
}
@@ -293,7 +353,7 @@ public final class DefinitionURI {
// Ignore the version number (actually everything up to the first ':').
fromIndex = skipLeadingWhitespaces(urn, s+1, length);
if (fromIndex >= length || urn.indexOf(SEPARATOR, fromIndex) >= 0) {
- return null; // Empty code, or the code is followed by parameters.
+ return null; // Empty code, or the code is followed by parameters.
}
}
return urn.substring(fromIndex, skipTrailingWhitespaces(urn, fromIndex, length));
@@ -357,7 +417,7 @@ public final class DefinitionURI {
return null;
}
if (length == 4) {
- return codeForHTTP(type, authority, uri, upper+1, null);
+ return codeForGML(type, authority, uri, upper+1, null);
}
/*
* At this point we have determined that the protocol is URN. The next components after "urn"
@@ -387,7 +447,7 @@ public final class DefinitionURI {
}
/**
- * Implementation of URI parser for the HTTP forms.
+ * Implementation of URI parser for the HTTP forms in GML namespace.
* The current implementation recognizes the following types:
*
* <ul>
@@ -400,7 +460,8 @@ public final class DefinitionURI {
* @param url The URL to parse.
* @param result If non-null, store the type, authority and code in that object.
*/
- private static String codeForHTTP(final String type, String authority, final String url, int lower,
+ @SuppressWarnings("fallthrough")
+ private static String codeForGML(final String type, String authority, final String url, int lower,
final DefinitionURI result)
{
Map<String, String> paths = PATHS;
@@ -411,12 +472,12 @@ public final class DefinitionURI {
}
// TODO: For now do nothing since PATHS is a singleton. However if a future SIS version
// defines more PATHS entries, then we should replace here the 'paths' reference by
- // a new Collection.singletonMap containing only the entry of interest.
+ // a new Collections.singletonMap containing only the entry of interest.
}
for (final Map.Entry<String,String> entry : paths.entrySet()) {
final String path = entry.getValue();
if (url.regionMatches(true, lower, path, 0, path.length())) {
- lower += path.length();
+ lower = CharSequences.skipLeadingWhitespaces(url, lower + path.length(), url.length());
if (authority == null) {
authority = url.substring(lower, skipIdentifierPart(url, lower));
} else if (!url.regionMatches(true, lower, authority, 0, authority.length())) {
@@ -424,17 +485,24 @@ public final class DefinitionURI {
}
lower += authority.length();
int upper = url.length();
- if (lower < upper && url.charAt(lower) == '.') {
- // Ignore the extension (typically ".xml", but we accept anything).
- if ((lower = url.indexOf('#', lower+1)) >= 0) {
- final String code = trimWhitespaces(url, lower+1, upper).toString();
- if (result != null) {
- result.isHTTP = true;
- result.type = entry.getKey();
- result.authority = authority;
- result.code = code;
+ if (lower < upper) {
+ switch (url.charAt(lower)) {
+ case '.': {
+ // Ignore the extension (typically ".xml", but we accept anything).
+ lower = url.indexOf('#', lower + 1);
+ if (lower < 0) continue;
+ // Fall through
+ }
+ case '#': {
+ final String code = trimWhitespaces(url, lower+1, upper).toString();
+ if (result != null) {
+ result.isGML = true;
+ result.type = entry.getKey();
+ result.authority = authority;
+ result.code = code;
+ }
+ return code;
}
- return code;
}
}
}
@@ -464,6 +532,8 @@ public final class DefinitionURI {
* @param version The code version, or {@code null}. This is the only optional information.
* @param code The code, or {@code null}.
* @return An identifier using the URN syntax, or {@code null} if a mandatory information is missing.
+ *
+ * @see org.apache.sis.internal.metadata.NameMeaning#toURN(Class, String, String, String)
*/
public static String format(final String type, final String authority, final String version, final String code) {
final StringBuilder buffer = new StringBuilder(PREFIX);
@@ -477,8 +547,10 @@ public final class DefinitionURI {
default: throw new AssertionError(p);
}
if (!appendUnicodeIdentifier(buffer.append(SEPARATOR), '\u0000', component, ".-", false)) {
- // Only the version (p = 2) is optional. All other fields are mandatory.
- // If no character has been added for a mandatory field, we can not build a URN.
+ /*
+ * Only the version (p = 2) is optional. All other fields are mandatory.
+ * If no character has been added for a mandatory field, we can not build a URN.
+ */
if (p != 2) {
return null;
}
@@ -488,12 +560,28 @@ public final class DefinitionURI {
}
/**
- * Returns a URN representation of this URI.
+ * Returns a string representation of this URI. If the URI were originally a GML's URL, then this method formats
+ * the URI in the {@code "http://www.opengis.net/gml/srs/"} namespace. Otherwise the URI were originally an URL,
+ * then this method formats the URI in the {@code "http://www.opengis.net/"} namespace.
+ * Otherwise this method formats the URI as a URN.
*
- * @return A URN representation of this URI.
+ * @return The string representation of this URI.
*/
- public String toURN() {
+ @Override
+ public String toString() {
+ if (isGML) {
+ final String path = PATHS.get(type);
+ if (path != null) {
+ return "http:" + path + authority + ".xml#" + code;
+ }
+ }
final StringBuilder buffer = new StringBuilder(PREFIX);
+ char separator = SEPARATOR;
+ if (isHTTP) {
+ buffer.setLength(0);
+ buffer.append("http://").append(DOMAIN).append("/def");
+ separator = '/';
+ }
int n = 4;
if (parameters != null) {
n += parameters.length;
@@ -507,28 +595,13 @@ public final class DefinitionURI {
case 3: component = code; break;
default: component = parameters[p-4]; break;
}
- buffer.append(SEPARATOR);
- if (component != null) {
- buffer.append(component);
+ buffer.append(separator);
+ if (component == null) {
+ if (!isHTTP) continue;
+ component = NO_VERSION;
}
+ buffer.append(component);
}
return buffer.toString();
}
-
- /**
- * Returns a string representation of this URI. If the URI were originally a HTTP URL,
- * then this method format the URI as such. Otherwise this method returns {@link #toURN()}.
- *
- * @return The string representation of this URI.
- */
- @Override
- public String toString() {
- if (isHTTP) {
- final String path = PATHS.get(type);
- if (path != null) {
- return "http:" + path + authority + ".xml#" + code;
- }
- }
- return toURN();
- }
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -18,114 +18,154 @@ package org.apache.sis.internal.util;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.AbstractSet;
import java.util.NoSuchElementException;
import org.apache.sis.util.Workaround;
+// Branch-specific imports
+import org.apache.sis.internal.jdk7.Objects;
+
/**
* An immutable set built from an iterator, which will be filled only when needed.
* This implementation does <strong>not</strong> check if all elements in the iterator
* are really unique; we assume that this condition was already verified by the caller.
*
- * <p>One usage of {@code LazySet} is to workaround a {@link java.util.ServiceLoader} bug which block usage of two
+ * <p>One usage of {@code LazySet} is to workaround a {@link java.util.ServiceLoader} bug which blocks usage of two
* {@link Iterator} instances together: the first iteration must be fully completed or abandoned before we can start
* a new iteration. See
* {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#DefaultMathTransformFactory()}.</p>
*
+ * <p>Another usage for this class is to prepend some values before the elements given by the source {@code Iterable}.</p>
+ *
* <p>This class is not thread-safe. Synchronization, if desired, shall be done by the caller.</p>
*
* @param <E> The type of elements in the set.
*
* @author Martin Desruisseaux (IRD)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*/
@Workaround(library="JDK", version="1.8.0_31-b13")
-public final class LazySet<E> extends AbstractSet<E> {
+public class LazySet<E> extends SetOfUnknownSize<E> {
/**
* The original source of elements, or {@code null} if unknown.
*/
- public final Iterable<? extends E> source;
+ private final Iterable<? extends E> source;
/**
* The iterator to use for filling this set, or {@code null} if the iteration did not started yet
- * or is finished. Those two cases can be distinguished by looking whether the {@link #elements}
+ * or is finished. Those two cases can be distinguished by looking whether the {@link #cachedElements}
* array is null or not.
+ *
+ * @see #sourceIterator()
*/
- private Iterator<? extends E> iterator;
+ private Iterator<? extends E> sourceIterator;
/**
- * The elements in this set, or {@code null} if the iteration did not started yet.
+ * The elements that we cached so far, or {@code null} if the iteration did not started yet.
* After the iteration started, this array will grow as needed.
+ *
+ * @see #createCache()
+ * @see #cache(Object)
*/
- private E[] elements;
+ private E[] cachedElements;
/**
- * The current position in the iteration. This position will be incremented as long as
- * there is some elements remaining in the iterator.
+ * The number of valid elements in the {@link #cachedElements} array.
+ * This counter will be incremented as long as there is more elements returned by {@link #sourceIterator}.
*/
- private int position;
+ private int numCached;
/**
* Constructs a set to be filled by the elements from the specified source. Iteration will starts
* only when first needed, and at most one iteration will be performed (unless {@link #reload()}
* is invoked).
*
- * @param source The source of elements to use for filling the set.
+ * @param source The source of elements to use for filling this set.
*/
- @SuppressWarnings("unchecked")
public LazySet(final Iterable<? extends E> source) {
+ Objects.requireNonNull(source);
this.source = source;
}
/**
* Constructs a set to be filled using the specified iterator.
- * Iteration in the given iterator will occurs only when needed.
+ * Iteration with the given iterator will occur only when needed.
*
- * @param iterator The iterator to use for filling the set.
+ * @param iterator The iterator to use for filling this set.
*/
- @SuppressWarnings("unchecked")
public LazySet(final Iterator<? extends E> iterator) {
+ Objects.requireNonNull(iterator);
+ sourceIterator = iterator;
source = null;
- this.iterator = iterator;
- elements = (E[]) new Object[4];
+ createCache();
}
/**
- * Notify this {@code LazySet} that it should re-fetch the elements from the {@linkplain #source}.
+ * Notifies this {@code LazySet} that it should re-fetch the elements from the source given at construction time.
+ * This method does not verify if the source needs also to be reloaded; it is up to the caller to verify.
+ *
+ * @return The original source of elements, or {@code null} if unknown.
*/
- public void reload() {
+ public Iterable<? extends E> reload() {
if (source != null) {
- iterator = null;
- elements = null;
- position = 0;
+ sourceIterator = null;
+ cachedElements = null;
+ numCached = 0;
}
+ return source;
}
/**
- * Returns the iterator over the source elements, or {@code null} if the iteration is finished.
+ * Hook for subclasses that want to prepend some values before the source {@code Iterable}.
+ * This method is invoked only when first needed. It is safe to return a shared array since
+ * {@code LazySet} will not write in that array ({@code LazySet} will create a new array if
+ * it needs to add more values).
+ *
+ * @return Values to prepend before the source {@code Iterable}, or {@code null} if none.
+ *
+ * @since 0.7
+ */
+ protected E[] initialValues() {
+ return null;
+ }
+
+ /**
+ * Creates the {@link #cachedElements} array. This array will contains the elements
+ * given by {@link #initialContent()} if that method returned a non-null and non-empty array.
+ *
+ * @return {@code true} if {@link #initialValues()} initialized the set with at least one value.
*/
@SuppressWarnings("unchecked")
- private Iterator<? extends E> sourceElements() {
- if (iterator == null && elements == null && source != null) {
- iterator = source.iterator();
- elements = (E[]) new Object[4];
+ private boolean createCache() {
+ cachedElements = initialValues(); // No need to clone.
+ if (cachedElements != null) {
+ numCached = cachedElements.length;
+ if (numCached != 0) {
+ return true;
+ }
}
- return iterator;
+ cachedElements = (E[]) new Object[4];
+ return false;
}
/**
- * Returns {@code true} if the {@link #iterator} is non-null and have more elements to return.
+ * Returns {@code true} if the {@link #sourceIterator} is non-null and have more elements to return,
+ * or if we initialized the cache with some elements declared by {@link #initialValues()}.
*/
- private boolean hasNext() {
- final Iterator<? extends E> it = sourceElements();
- if (it != null) {
- if (it.hasNext()) {
+ private boolean canPullMore() {
+ if (sourceIterator == null && cachedElements == null) {
+ sourceIterator = source.iterator();
+ if (createCache()) {
return true;
}
- iterator = null;
+ }
+ if (sourceIterator != null) {
+ if (sourceIterator.hasNext()) {
+ return true;
+ }
+ sourceIterator = null;
}
return false;
}
@@ -136,8 +176,8 @@ public final class LazySet<E> extends Ab
* @return {@code true} if this set has no element.
*/
@Override
- public boolean isEmpty() {
- return (position == 0) && !hasNext();
+ public final boolean isEmpty() {
+ return (numCached == 0) && !canPullMore();
}
/**
@@ -147,25 +187,26 @@ public final class LazySet<E> extends Ab
* @return Number of elements in the iterator.
*/
@Override
- public int size() {
- final Iterator<? extends E> it = sourceElements();
- if (it != null) {
- while (it.hasNext()) {
- cache(it.next());
+ public final int size() {
+ if (canPullMore()) {
+ while (sourceIterator.hasNext()) {
+ cache(sourceIterator.next());
}
- iterator = null;
+ sourceIterator = null;
}
- return position;
+ return numCached;
}
/**
- * Adds the given element to the {@link #elements} array.
+ * Adds the given element to the {@link #cachedElements} array.
+ *
+ * @param element The element to add to the cache.
*/
private void cache(final E element) {
- if (position >= elements.length) {
- elements = Arrays.copyOf(elements, position*2);
+ if (numCached >= cachedElements.length) {
+ cachedElements = Arrays.copyOf(cachedElements, numCached << 1);
}
- elements[position++] = element;
+ cachedElements[numCached++] = element;
}
/**
@@ -177,7 +218,7 @@ public final class LazySet<E> extends Ab
* negative index and for skipped elements.</p>
*/
final boolean exists(final int index) {
- return (index < position) || hasNext();
+ return (index < numCached) || canPullMore();
}
/**
@@ -187,14 +228,14 @@ public final class LazySet<E> extends Ab
* @return The element at the requested index.
*/
final E get(final int index) {
- if (index >= position) {
- if (hasNext()) {
- cache(iterator.next());
+ if (index >= numCached) {
+ if (canPullMore()) {
+ cache(sourceIterator.next());
} else {
throw new NoSuchElementException();
}
}
- return elements[index];
+ return cachedElements[index];
}
/**
@@ -204,7 +245,7 @@ public final class LazySet<E> extends Ab
* @return An iterator over the elements in this set.
*/
@Override
- public Iterator<E> iterator() {
+ public final Iterator<E> iterator() {
return new Iterator<E>() {
private int cursor;
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -17,6 +17,7 @@
package org.apache.sis.internal.util;
import org.opengis.metadata.citation.Citation;
+import org.apache.sis.internal.simple.CitationConstant;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.OptionalDependency;
@@ -28,7 +29,7 @@ import org.apache.sis.internal.system.Op
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*/
public class MetadataServices extends OptionalDependency {
@@ -95,7 +96,7 @@ public class MetadataServices extends Op
* @param name The name of one of the citation constants defined in the {@code Citations} class.
* @return The requested citation, or {@code null} if the {@code sis-metadata} module is not available.
*/
- public Citation getCitationConstant(final String name) {
+ public CitationConstant getCitationConstant(final String name) {
return null;
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/DerivedSet.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -18,12 +18,12 @@ package org.apache.sis.util.collection;
import java.util.Set;
import java.util.Iterator;
-import java.util.AbstractSet;
import java.io.Serializable;
-import org.apache.sis.util.ObjectConverter;
import org.apache.sis.math.FunctionProperty;
+import org.apache.sis.util.ObjectConverter;
import org.apache.sis.util.UnconvertibleObjectException;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.SetOfUnknownSize;
/**
@@ -61,7 +61,7 @@ import org.apache.sis.util.resources.Err
* @version 0.3
* @module
*/
-class DerivedSet<S,E> extends AbstractSet<E> implements CheckedContainer<E>, Serializable {
+class DerivedSet<S,E> extends SetOfUnknownSize<E> implements CheckedContainer<E>, Serializable {
/**
* Serial number for inter-operability with different versions.
*/