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 2013/04/17 16:46:14 UTC
svn commit: r1468942 - in /sis/trunk: ./ ide-project/NetBeans/nbproject/
ide-project/eclipse/ sis-metadata/src/main/java/org/apache/sis/metadata/
sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/
sis-metadata/src/test/java/org/apache/sis/m...
Author: desruisseaux
Date: Wed Apr 17 14:46:14 2013
New Revision: 1468942
URL: http://svn.apache.org/r1468942
Log:
Merge from the JDK6 branch.
Added:
sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
- copied unchanged from r1468939, sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/ServletListener.java
- copied unchanged from r1468939, sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/ServletListener.java
Modified:
sis/trunk/ (props changed)
sis/trunk/ide-project/NetBeans/nbproject/project.properties
sis/trunk/ide-project/eclipse/classpath
sis/trunk/pom.xml
sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
sis/trunk/sis-utility/pom.xml
sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsFormatTest.java
sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
sis/trunk/sis-webapp/pom.xml
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1467942-1468921
Merged /sis/branches/JDK6:r1468116-1468939
Modified: sis/trunk/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/trunk/ide-project/NetBeans/nbproject/project.properties?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original)
+++ sis/trunk/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Wed Apr 17 14:46:14 2013
@@ -48,7 +48,7 @@ vecmath.version = 1.5.2
georss.version = 0.9.8
rome.version = 0.9
jdom.version = 1.0
-servlet.version = 2.4
+jee.version = 6.0
jcip.version = 1.0
osgi.version = 5.0.0
junit.version = 4.10
@@ -67,7 +67,7 @@ javac.classpath=\
${maven.repository}/org/geonames/georss-rome/${georss.version}/georss-rome-${georss.version}.jar:\
${maven.repository}/rome/rome/${rome.version}/rome-${rome.version}.jar:\
${maven.repository}/jdom/jdom/${jdom.version}/jdom-${jdom.version}.jar:\
- ${maven.repository}/javax/servlet/servlet-api/${servlet.version}/servlet-api-${servlet.version}.jar:\
+ ${maven.repository}/javax/javaee-api/${jee.version}/javaee-api-${jee.version}.jar:\
${maven.repository}/net/jcip/jcip-annotations/${jcip.version}/jcip-annotations-${jcip.version}.jar:\
${maven.repository}/org/osgi/org.osgi.core/${osgi.version}/org.osgi.core-${osgi.version}.jar
javac.processorpath=\
Modified: sis/trunk/ide-project/eclipse/classpath
URL: http://svn.apache.org/viewvc/sis/trunk/ide-project/eclipse/classpath?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/ide-project/eclipse/classpath (original)
+++ sis/trunk/ide-project/eclipse/classpath Wed Apr 17 14:46:14 2013
@@ -16,7 +16,7 @@
<classpathentry kind="var" path="M2_REPO/org/geonames/georss-rome/0.9.8/georss-rome-0.9.8.jar"/>
<classpathentry kind="var" path="M2_REPO/rome/rome/0.9/rome-0.9.jar"/>
<classpathentry kind="var" path="M2_REPO/jdom/jdom/1.0/jdom-1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/javaee-api/6.0/javaee-api-6.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/org/opengis/geoapi/3.0.0/geoapi-3.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/opengis/geoapi-conformance/3.0.0/geoapi-conformance-3.0.0.jar"/>
Modified: sis/trunk/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/pom.xml?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/pom.xml (original)
+++ sis/trunk/pom.xml Wed Apr 17 14:46:14 2013
@@ -311,9 +311,10 @@ Apache SIS is a toolkit for describing l
<!-- Libraries (language, XML, network) -->
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.geonames</groupId>
Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -553,10 +553,10 @@ public class MetadataStandard {
}
/**
- * Computes a hash code for the specified metadata. The hash code is defined as the
- * sum of hash code values of all non-empty properties. This is a similar contract
- * than {@link java.util.Set#hashCode()} and ensures that the hash code value is
- * insensitive to the ordering of properties.
+ * Computes a hash code for the specified metadata. The hash code is defined as the sum
+ * of hash code values of all non-empty properties, plus the hash code of the interface.
+ * This is a similar contract than {@link java.util.Set#hashCode()} (except for the interface)
+ * and ensures that the hash code value is insensitive to the ordering of properties.
*
* @param metadata The metadata object to compute hash code.
* @return A hash code value for the specified metadata.
Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -990,16 +990,16 @@ final class PropertyAccessor {
}
/**
- * Computes a hash code for the specified metadata. The hash code is defined as the
- * sum of hash code values of all non-empty properties. This is a similar contract
- * than {@link java.util.Set#hashCode()} and ensures that the hash code value is
- * insensitive to the ordering of properties.
+ * Computes a hash code for the specified metadata. The hash code is defined as the sum
+ * of hash code values of all non-empty properties, plus the hash code of the interface.
+ * This is a similar contract than {@link java.util.Set#hashCode()} (except for the interface)
+ * and ensures that the hash code value is insensitive to the ordering of properties.
*
* @throws BackingStoreException If the implementation threw a checked exception.
*/
public int hashCode(final Object metadata) throws BackingStoreException {
assert type.isInstance(metadata) : metadata;
- int code = 0;
+ int code = type.hashCode();
for (int i=0; i<standardCount; i++) {
final Object value = get(getters[i], metadata);
if (!isNullOrEmpty(value)) {
Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -32,6 +32,8 @@ import static org.apache.sis.internal.me
* @since 0.3 (derived from geotk-2.2)
* @version 0.3
* @module
+ *
+ * @see org.apache.sis.geometry.Envelopes
*/
public final class Extents extends Static {
/**
Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -176,10 +176,10 @@ public final strictfp class PropertyAcce
final Class<?> type = GeographicCRS.class;
assertMappingEquals(new PropertyAccessor(HardCodedCitations.ISO, type, type),
//……Declaring type……………………………Method……………………………………………JavaBeans……………………………UML identifier………………Sentence…………………………………Type…………………………………………………………
-/*Required*/GeographicCRS.class, "getCoordinateSystem", "coordinateSystem", "coordinateSystem", "Coordinate system", EllipsoidalCS.class, // Covariant return type
+ GeographicCRS.class, "getCoordinateSystem", "coordinateSystem", "coordinateSystem", "Coordinate system", EllipsoidalCS.class, // Covariant return type
GeodeticCRS.class, "getDatum", "datum", "datum", "Datum", GeodeticDatum.class, // Covariant return type
IdentifiedObject.class, "getName", "name", "name", "Name", ReferenceIdentifier.class,
-/*Optional*/IdentifiedObject.class, "getAlias", "alias", "alias", "Alias", GenericName[].class,
+ IdentifiedObject.class, "getAlias", "alias", "alias", "Alias", GenericName[].class,
ReferenceSystem.class, "getDomainOfValidity", "domainOfValidity", "domainOfValidity", "Domain of validity", Extent.class,
IdentifiedObject.class, "getIdentifiers", "identifiers", "identifier", "Identifiers", ReferenceIdentifier[].class,
IdentifiedObject.class, "getRemarks", "remarks", "remarks", "Remarks", InternationalString.class,
@@ -203,23 +203,23 @@ public final strictfp class PropertyAcce
@Test
@DependsOnMethod("testConstructor")
public void testGet() {
- final Citation citation = HardCodedCitations.ISO;
+ final DefaultCitation instance = HardCodedCitations.ISO;
final PropertyAccessor accessor = createPropertyAccessor();
// Singleton value (not a collection)
- final Object title = accessor.get(accessor.indexOf("title", true), citation);
+ final Object title = accessor.get(accessor.indexOf("title", true), instance);
assertInstanceOf("title", InternationalString.class, title);
- assertEquals("International Organization for Standardization", title.toString());
+ assertEquals("title", "International Organization for Standardization", title.toString());
// Collection of InternationalStrings
- final Object alternateTitles = accessor.get(accessor.indexOf("alternateTitles", true), citation);
+ final Object alternateTitles = accessor.get(accessor.indexOf("alternateTitles", true), instance);
assertInstanceOf("alternateTitles", Collection.class, alternateTitles);
- assertEquals("ISO", getSingleton((Collection<?>) alternateTitles).toString());
+ assertEquals("alternateTitles", "ISO", getSingleton((Collection<?>) alternateTitles).toString());
// Collection of Identifiers
- final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), citation);
+ final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), instance);
assertInstanceOf("identifiers", Collection.class, identifiers);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) identifiers);
+ HardCodedCitations.assertIdentifiersFor("ISO", (Collection<?>) identifiers);
}
/**
@@ -229,24 +229,22 @@ public final strictfp class PropertyAcce
@Test
@DependsOnMethod("testGet")
public void testSet() {
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- {
- final Object newValue = new SimpleInternationalString("Some title");
- final int index = accessor.indexOf("title", true);
- final Object oldValue = accessor.set(index, citation, newValue, true);
- assertNull(oldValue);
- assertSame(newValue, accessor.get(index, citation));
- assertSame(newValue, citation.getTitle());
- }
- if (false) { // TODO
- final Object newValue = "Some ISBN code";
- final int index = accessor.indexOf("ISBN", true);
- final Object oldValue = accessor.set(index, citation, newValue, true);
- assertNull(oldValue);
- assertSame(newValue, accessor.get(index, citation));
- assertSame(newValue, citation.getISBN());
- }
+ Object newValue;
+ int index;
+
+ newValue = new SimpleInternationalString("Some title");
+ index = accessor.indexOf("title", true);
+ assertNull("title", accessor.set(index, instance, newValue, true));
+ assertSame("title", newValue, accessor.get(index, instance));
+ assertSame("title", newValue, instance.getTitle());
+
+ newValue = "Some ISBN code";
+ index = accessor.indexOf("ISBN", true);
+ assertNull("ISBN", accessor.set(index, instance, newValue, true));
+ assertSame("ISBN", newValue, accessor.get(index, instance));
+ assertSame("ISBN", newValue, instance.getISBN());
}
/**
@@ -258,16 +256,16 @@ public final strictfp class PropertyAcce
@DependsOnMethod("testSet")
public void testSetWithConversion() {
final String expected = "Some title";
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
final int index = accessor.indexOf("title", true);
- final Object oldValue = accessor.set(index, citation, expected, true);
- final Object value = accessor.get(index, citation);
+ final Object oldValue = accessor.set(index, instance, expected, true);
+ final Object value = accessor.get(index, instance);
- assertNull(oldValue);
+ assertNull("title", oldValue);
assertInstanceOf("title", InternationalString.class, value);
- assertSame(expected, value.toString());
- assertSame(value, citation.getTitle());
+ assertSame("title", expected, value.toString());
+ assertSame("title", value, instance.getTitle());
}
/**
@@ -299,27 +297,27 @@ public final strictfp class PropertyAcce
final String text2 = "Yet an other title";
final InternationalString title1 = new SimpleInternationalString(text1);
final InternationalString title2 = new SimpleInternationalString(text2);
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- final int index = accessor.indexOf("alternateTitle", true);
+ final int index = accessor.indexOf("alternateTitles", true);
// Insert the first value. Old collection shall be empty.
- Object oldValue = accessor.set(index, citation, conversion ? text1 : title1, true);
- assertInstanceOf("alternateTitle", Collection.class, oldValue);
- assertTrue(((Collection<?>) oldValue).isEmpty());
+ Object oldValue = accessor.set(index, instance, conversion ? text1 : title1, true);
+ assertInstanceOf("alternateTitles", Collection.class, oldValue);
+ assertTrue("alternateTitles", ((Collection<?>) oldValue).isEmpty());
// Insert the second value. Old collection shall contains the first value.
- oldValue = accessor.set(index, citation, conversion ? text2 : title2, true);
- assertInstanceOf("alternateTitle", Collection.class, oldValue);
+ oldValue = accessor.set(index, instance, conversion ? text2 : title2, true);
+ assertInstanceOf("alternateTitles", Collection.class, oldValue);
oldValue = getSingleton((Collection<?>) oldValue);
- assertSame(text1, oldValue.toString());
+ assertSame("alternateTitles", text1, oldValue.toString());
if (!conversion) {
assertSame("InternationalString should have been stored as-is.", title1, oldValue);
}
// Check final collection content.
final List<InternationalString> expected = Arrays.asList(title1, title2);
- assertEquals(expected, accessor.get(index, citation));
+ assertEquals("alternateTitles", expected, accessor.get(index, instance));
}
/**
@@ -327,8 +325,8 @@ public final strictfp class PropertyAcce
*/
@Test
public void testShallowCopy() {
- final Citation original = HardCodedCitations.ISO;
- final Citation copy = new DefaultCitation();
+ final DefaultCitation original = HardCodedCitations.ISO;
+ final DefaultCitation copy = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
assertTrue("The copy should have modified the destination.", accessor.shallowCopy(original, copy));
assertEquals("International Organization for Standardization", copy.getTitle().toString());
@@ -346,35 +344,29 @@ public final strictfp class PropertyAcce
* Tests the equals methods.
*/
@Test
- @DependsOnMethod("testShallowCopy")
public void testEquals() {
- Citation citation = HardCodedCitations.EPSG;
+ DefaultCitation citation = HardCodedCitations.EPSG;
final PropertyAccessor accessor = createPropertyAccessor();
assertFalse(accessor.equals(citation, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
assertTrue (accessor.equals(citation, HardCodedCitations.EPSG, ComparisonMode.STRICT));
- /*
- * Same test than above, but on a copy of the EPSG constant.
- */
- citation = new DefaultCitation();
- assertTrue (accessor.shallowCopy(HardCodedCitations.EPSG, citation));
+
+ // Same test than above, but on a copy of the EPSG constant.
+ citation = new DefaultCitation(HardCodedCitations.EPSG);
assertFalse(accessor.equals(citation, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
assertTrue (accessor.equals(citation, HardCodedCitations.EPSG, ComparisonMode.STRICT));
- /*
- * Identifiers shall be stored in different collection instances with equal content.
- */
+
+ // Identifiers shall be stored in different collection instances with equal content.
final int index = accessor.indexOf("identifiers", true);
final Object source = accessor.get(index, HardCodedCitations.EPSG);
final Object target = accessor.get(index, citation);
assertInstanceOf("identifiers", Collection.class, source);
assertInstanceOf("identifiers", Collection.class, target);
-// assertNotSame(source, target); // TODO: require non-empty collection.
- assertEquals (source, target);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) source);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) target);
- /*
- * Set the identifiers to null, which should clear the collection.
- */
-// TODO assertEquals("Expected the previous value.", source, accessor.set(index, citation, null, true));
+ assertNotSame("Distinct objects shall have distinct collections.", source, target);
+ assertEquals ("The two collections shall have the same content.", source, target);
+ HardCodedCitations.assertIdentifiersFor("EPSG", (Collection<?>) target);
+
+ // Set the identifiers to null, which should clear the collection.
+ assertEquals("Expected the previous value.", source, accessor.set(index, citation, null, true));
final Object value = accessor.get(index, citation);
assertNotNull("Should have replaced null by an empty collection.", value);
assertTrue("Should have replaced null by an empty collection.", ((Collection<?>) value).isEmpty());
@@ -385,19 +377,20 @@ public final strictfp class PropertyAcce
*/
@Test
public void testHashCode() {
- final DefaultCitation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- int hashCode = accessor.hashCode(citation);
- assertEquals("Empty metadata.", 0, hashCode);
+ final int baseCode = Citation.class.hashCode();
+ int hashCode = accessor.hashCode(instance);
+ assertEquals("Empty metadata.", baseCode, hashCode);
final InternationalString title = new SimpleInternationalString("Some title");
- citation.setTitle(title);
- hashCode = accessor.hashCode(citation);
- assertEquals("Metadata with a single value.", title.hashCode(), hashCode);
+ instance.setTitle(title);
+ hashCode = accessor.hashCode(instance);
+ assertEquals("Metadata with a single value.", baseCode + title.hashCode(), hashCode);
final InternationalString alternateTitle = new SimpleInternationalString("An other title");
- citation.setAlternateTitles(singleton(alternateTitle));
- hashCode = accessor.hashCode(citation);
- assertEquals("Metadata with two values.", title.hashCode() + Arrays.asList(alternateTitle).hashCode(), hashCode);
+ instance.setAlternateTitles(singleton(alternateTitle));
+ hashCode = accessor.hashCode(instance);
+ assertEquals("Metadata with two values.", baseCode + title.hashCode() + Arrays.asList(alternateTitle).hashCode(), hashCode);
}
}
Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -20,6 +20,7 @@ import java.util.Collection;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.PresentationForm;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.util.Static;
@@ -29,6 +30,10 @@ import static java.util.Collections.sing
/**
* Hard-coded citation constants used for testing purpose only.
+ * We use those hard-coded constants instead than the ones defined in the
+ * {@link org.apache.sis.metadata.iso.citation.Citations} class in order
+ * to protect the test suite against any change in the definition of the
+ * above-cited public constants.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.4)
@@ -41,12 +46,12 @@ public final strictfp class HardCodedCit
* organization. An {@linkplain Citation#getAlternateTitles() alternate title} for this
* citation is "ISO" (according ISO 19115, alternate titles often contain abbreviations).
*/
- public static final Citation ISO;
+ public static final DefaultCitation ISO;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("International Organization for Standardization"));
+ final DefaultCitation c = new DefaultCitation("International Organization for Standardization");
c.setAlternateTitles(singleton(new SimpleInternationalString("ISO")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
+ c.getIdentifiers().add(new DefaultIdentifier("ISO"));
c.freeze();
ISO = c;
}
@@ -54,10 +59,9 @@ public final strictfp class HardCodedCit
/**
* The ISO 19115 standard.
*/
- public static final Citation ISO_19115;
+ public static final DefaultCitation ISO_19115;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("ISO 19115"));
+ final DefaultCitation c = new DefaultCitation("ISO 19115");
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
c.freeze();
ISO_19115 = c;
@@ -69,12 +73,12 @@ public final strictfp class HardCodedCit
* "EPSG" (according ISO 19115, alternate titles often contain abbreviations). In
* addition, this citation contains the "EPSG" {@linkplain Citation#getIdentifiers identifier}.
*/
- public static final Citation EPSG;
+ public static final DefaultCitation EPSG;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("European Petroleum Survey Group"));
+ final DefaultCitation c = new DefaultCitation("European Petroleum Survey Group");
c.setAlternateTitles(singleton(new SimpleInternationalString("EPSG")));
c.setPresentationForms(singleton(PresentationForm.TABLE_DIGITAL));
+ c.getIdentifiers().add(new DefaultIdentifier("EPSG"));
c.freeze();
EPSG = c;
}
@@ -82,10 +86,9 @@ public final strictfp class HardCodedCit
/**
* The <a href="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</a> specification.
*/
- public static final Citation GEOTIFF;
+ public static final DefaultCitation GEOTIFF;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("GeoTIFF"));
+ final DefaultCitation c = new DefaultCitation("GeoTIFF");
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
c.freeze();
GEOTIFF = c;
@@ -98,15 +101,21 @@ public final strictfp class HardCodedCit
}
/**
- * Asserts that the given identifiers are for the {@link HardCodedCitations#EPSG} constant.
+ * Asserts that the given {@linkplain Identifier#getCode() identifier code}
+ * is found in the collection of identifiers.
*
+ * @param expected The expected identifier code (typically {@code "ISO"} or {@code "EPSG"}).
* @param identifiers The collection to validate. Should be a collection of {@link Identifier}.
*/
- public static void assertIdentifiersForEPSG(final Collection<?> identifiers) {
+ public static void assertIdentifiersFor(final String expected, final Collection<?> identifiers) {
assertNotNull("identifiers", identifiers);
+ int count = 0;
for (final Object id : identifiers) {
assertInstanceOf("identifier", Identifier.class, id);
- // TODO: check for EPSG identifiers here.
+ if (((Identifier) id).getCode().equals(expected)) {
+ count++;
+ }
}
+ assertEquals("Unexpected amount of identifiers.", 1, count);
}
}
Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -31,7 +31,8 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
org.apache.sis.metadata.PropertyDescriptorTest.class,
- org.apache.sis.metadata.PropertyAccessorTest.class
+ org.apache.sis.metadata.PropertyAccessorTest.class,
+ org.apache.sis.metadata.MetadataStandardTest.class
})
public final strictfp class MetadataTestSuite extends TestSuite {
}
Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -40,6 +40,7 @@ import static org.apache.sis.util.String
* @version 0.3
* @module
*
+ * @see org.apache.sis.metadata.iso.extent.Extents
* @see CRS
*/
public final class Envelopes extends Static {
@@ -76,7 +77,7 @@ public final class Envelopes extends Sta
* <li>{@code GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(3 8,7 10))}</li>
* </ul>
*
- * See {@link GeneralEnvelope#GeneralEnvelope(String)} for more information about the
+ * See {@link GeneralEnvelope#GeneralEnvelope(CharSequence)} for more information about the
* parsing rules.
*
* @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse.
@@ -87,7 +88,7 @@ public final class Envelopes extends Sta
* @see CRS#fromWKT(String)
* @see org.apache.sis.io.wkt
*/
- public static Envelope fromWKT(final String wkt) throws FactoryException {
+ public static Envelope fromWKT(final CharSequence wkt) throws FactoryException {
ensureNonNull("wkt", wkt);
try {
return new GeneralEnvelope(wkt);
@@ -108,13 +109,13 @@ public final class Envelopes extends Sta
* {@note The <code>BOX</code> element is not part of the standard <cite>Well Known Text</cite>
* (WKT) format. However it is understood by many softwares, for example GDAL and PostGIS.}
*
- * The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(String)
+ * The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(CharSequence)
* parsed} by the {@code GeneralEnvelope} constructor.
*
* @param envelope The envelope to format.
* @return The envelope as a {@code BOX} or {@code BOX3D} in WKT format.
*
- * @see #fromWKT(String)
+ * @see #fromWKT(CharSequence)
* @see org.apache.sis.io.wkt
*/
public static String toString(final Envelope envelope) {
@@ -126,7 +127,7 @@ public final class Envelopes extends Sta
* (WKT) format. {@code POLYGON} can be used as an alternative to {@code BOX} when the element
* needs to be considered as a standard WKT geometry.
*
- * <p>The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(String)
+ * <p>The string returned by this method can be {@linkplain GeneralEnvelope#GeneralEnvelope(CharSequence)
* parsed} by the {@code GeneralEnvelope} constructor.</p>
*
* @param envelope The envelope to format.
Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] (original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -227,7 +227,7 @@ public class GeneralEnvelope extends Arr
* @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse.
* @throws IllegalArgumentException If the given string can not be parsed.
*
- * @see Envelopes#fromWKT(String)
+ * @see Envelopes#fromWKT(CharSequence)
* @see Envelopes#toString(Envelope)
*/
public GeneralEnvelope(final CharSequence wkt) throws IllegalArgumentException {
@@ -905,13 +905,13 @@ public class GeneralEnvelope extends Arr
* For example in order to expand only the horizontal component of a four dimensional
* (<var>x</var>,<var>y</var>,<var>z</var>,<var>t</var>) envelope, one can use:</p>
*
- * {@preformat
+ * {@preformat java
* envelope.subEnvelope(0, 2).add(myPosition2D);
* }
*
* If the sub-envelope needs to be independent from the original envelope, use the following idiom:
*
- * {@preformat
+ * {@preformat java
* GeneralEnvelope copy = envelope.subEnvelope(0, 2).clone();
* }
*
Modified: sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -480,10 +480,10 @@ public strictfp class GeneralEnvelopeTes
assertEquals( 40, envelope.getUpper(1), STRICT);
validate(envelope);
- assertEquals("BOX(6 10, 6 10)", new GeneralEnvelope("POINT(6 10)").toString());
+ assertEquals("BOX(6 10, 6 10)", new GeneralEnvelope("POINT(6 10)").toString());
assertEquals("BOX3D(6 10 3, 6 10 3)", new GeneralEnvelope("POINT M [ 6 10 3 ] ").toString());
- assertEquals("BOX(3 4, 20 50)", new GeneralEnvelope("LINESTRING(3 4,10 50,20 25)").toString());
- assertEquals("BOX(1 1, 6 5)", new GeneralEnvelope(
+ assertEquals("BOX(3 4, 20 50)", new GeneralEnvelope("LINESTRING(3 4,10 50,20 25)").toString());
+ assertEquals("BOX(1 1, 6 5)", new GeneralEnvelope(
"MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2)),((3 3,6 2,6 4,3 3)))").toString());
assertEquals("BOX(3 6, 7 10)", new GeneralEnvelope("GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(3 8,7 10))").toString());
assertEquals(0, new GeneralEnvelope("BOX()").getDimension());
Modified: sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] (original)
+++ sis/trunk/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -27,7 +27,7 @@ import static org.apache.sis.geometry.Ge
/**
- * Tests the {@link SubEnvelopeTest} class. This method leverage the tests written for
+ * Tests the {@link SubEnvelope} class. This method leverage the tests written for
* {@link GeneralEnvelope}, but using a sub-envelope instead than a full envelope.
*
* @author Martin Desruisseaux (IRD, Geomatys)
@@ -44,13 +44,14 @@ public final strictfp class SubEnvelopeT
@Override
GeneralEnvelope create(final double xmin, final double ymin, final double xmax, final double ymax) {
final GeneralEnvelope envelope = new GeneralEnvelope(5);
- envelope.setCoordinateReferenceSystem(WGS84);
envelope.setEnvelope(1, 4, xmin, ymin, 5,
2, 7, xmax, ymax, 9);
if (PENDING_NEXT_GEOAPI_RELEASE) {
validate(envelope);
}
- return envelope.subEnvelope(2, 4);
+ final GeneralEnvelope sub = envelope.subEnvelope(2, 4);
+ sub.setCoordinateReferenceSystem(WGS84);
+ return sub;
}
/**
Modified: sis/trunk/sis-utility/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/pom.xml?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/pom.xml (original)
+++ sis/trunk/sis-utility/pom.xml Wed Apr 17 14:46:14 2013
@@ -178,11 +178,14 @@ Miscellaneous utilities.
<artifactId>jcip-annotations</artifactId>
</dependency>
- <!-- Optional dependencies -->
+ <!-- Optional dependencies (provided scope) -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -25,12 +25,15 @@ import org.osgi.framework.BundleListener
/**
* Bundle activator for OSGi environment.
- * This class should not be used directly.
+ * This class is declared in the {@code maven-bundle-plugin} configuration in the
+ * {@code sis-utility/pom.xml} file. This class should not be used directly.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
* @version 0.3
* @module
+ *
+ * @see ServletListener
*/
public final class OSGiActivator implements BundleActivator, BundleListener {
/**
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -115,6 +115,9 @@ public class UnmodifiableArrayList<E> ex
* specified sub-region of the given array shall not be modified after construction if the
* returned list is intended to be immutable.
*
+ * <p>This method does not check the validity of the given index.
+ * The check must be done by the caller.</p>
+ *
* {@section WARNING! Type safety hole}
* Callers <strong>must</strong> ensure that the type of array elements in exactly {@code E},
* not a subtype of {@code E}. If the caller is okay with {@code List<? extends E>}, then (s)he
@@ -126,13 +129,10 @@ public class UnmodifiableArrayList<E> ex
* @param lower Low endpoint (inclusive) of the sublist.
* @param upper High endpoint (exclusive) of the sublist.
* @return The given array wrapped in an unmodifiable list.
- * @throws IndexOutOfBoundsException If the lower or upper value are out of bounds.
*/
public static <E> UnmodifiableArrayList<E> wrap(final E[] array, final int lower, final int upper)
throws IndexOutOfBoundsException
{
- ArgumentChecks.ensureNonNull("array", array);
- ArgumentChecks.ensureValidIndexRange(array.length, lower, upper);
if (lower == 0 && upper == array.length) {
return new UnmodifiableArrayList<E>(array);
}
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -54,7 +54,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* <p>An instance of {@code Statistics} is initially empty: the {@linkplain #count() count} of
* values is set to zero, and all above-cited statistical values are set to {@link Double#NaN NaN}.
- * The statistics are updated every time an {@link #add(double)} method is invoked with a non-NaN
+ * The statistics are updated every time an {@link #accept(double)} method is invoked with a non-NaN
* value.</p>
*
* {@section Examples}
@@ -64,7 +64,7 @@ import org.apache.sis.internal.jdk7.Obje
* {@preformat java
* Statistics stats = new Statistics("y");
* for (int i=0; i<numberOfValues; i++) {
- * stats.add(f(i));
+ * stats.accept(f(i));
* }
* System.out.println(stats);
* }
@@ -77,7 +77,7 @@ import org.apache.sis.internal.jdk7.Obje
* final double Δx = ...; // Put here the interval between x values
* Statistics stats = Statistics.forSeries("y", "∂y/∂x", "∂²y/∂x²");
* for (int i=0; i<numberOfValues; i++) {
- * stats.add(f(x₀ + i*Δx));
+ * stats.accept(f(x₀ + i*Δx));
* }
* stats.differences().scale(1/Δx);
* System.out.println(stats);
@@ -104,22 +104,22 @@ public class Statistics implements Clone
private final InternationalString name;
/**
- * The minimal value given to the {@link #add(double)} method.
+ * The minimal value given to the {@link #accept(double)} method.
*/
private double minimum = NaN;
/**
- * The maximal value given to the {@link #add(double)} method.
+ * The maximal value given to the {@link #accept(double)} method.
*/
private double maximum = NaN;
/**
- * The sum of all values given to the {@link #add(double)} method.
+ * The sum of all values given to the {@link #accept(double)} method.
*/
private double sum;
/**
- * The sum of square of all values given to the {@link #add(double)} method.
+ * The sum of square of all values given to the {@link #accept(double)} method.
*/
private double squareSum;
@@ -136,12 +136,12 @@ public class Statistics implements Clone
private transient double squareLowBits;
/**
- * Number of non-NaN values given to the {@link #add(double)} method.
+ * Number of non-NaN values given to the {@link #accept(double)} method.
*/
private int count;
/**
- * Number of NaN values given to the {@link #add(double)} method.
+ * Number of NaN values given to the {@link #accept(double)} method.
* Those value are ignored in the computation of all above values.
*/
private int countNaN;
@@ -165,8 +165,8 @@ public class Statistics implements Clone
/**
* Constructs a new {@code Statistics} object which will also compute finite differences
- * up to the given order. If the values to be given to the {@code add(…)} methods are the
- * <var>y</var> values of some <var>y</var>=<var>f</var>(<var>x</var>) function for
+ * up to the given order. If the values to be given to the {@code accept(…)} methods are
+ * the <var>y</var> values of some <var>y</var>=<var>f</var>(<var>x</var>) function for
* <var>x</var> values increasing or decreasing at a constant interval Δ<var>x</var>,
* then the finite differences are proportional to discrete derivatives.
*
@@ -245,23 +245,26 @@ public class Statistics implements Clone
* {@link Double#NaN NaN} values increment the {@linkplain #countNaN() NaN count},
* but are otherwise ignored.
*
+ * {@note This method is named <code>accept</code> for compatibility with the
+ * <code>java.util.function.DoubleConsumer</code> interface in JDK8.}
+ *
* @param sample The sample value (may be NaN).
*
- * @see #add(long)
- * @see #add(Statistics)
+ * @see #accept(long)
+ * @see #combine(Statistics)
*/
- public void add(final double sample) {
+ public void accept(final double sample) {
if (isNaN(sample)) {
countNaN++;
} else {
- addReal(sample);
+ real(sample);
}
}
/**
- * Implementation of {@link #add(double)} for real (non-NaN) numbers.
+ * Implementation of {@link #accept(double)} for real (non-NaN) numbers.
*/
- private void addReal(double sample) {
+ private void real(double sample) {
// Two next lines use !(a >= b) instead than
// (a < b) in order to take NaN in account.
if (!(minimum <= sample)) minimum = sample;
@@ -282,25 +285,28 @@ public class Statistics implements Clone
/**
* Updates statistics for the specified integer sample value.
* For very large integer values (greater than 2<sup>52</sup> in magnitude),
- * this method may be more accurate than the {@link #add(double)} version.
+ * this method may be more accurate than the {@link #accept(double)} version.
+ *
+ * {@note This method is named <code>accept</code> for compatibility with the
+ * <code>java.util.function.LongConsumer</code> interface in JDK8.}
*
* @param sample The sample value.
*
- * @see #add(double)
- * @see #add(Statistics)
+ * @see #accept(double)
+ * @see #combine(Statistics)
*/
- public void add(final long sample) {
- addReal(sample);
+ public void accept(final long sample) {
+ real(sample);
}
/**
* Updates statistics with all samples from the specified {@code stats}.
* Invoking this method is equivalent (except for rounding errors) to invoking
- * {@link #add(double) add} for all samples that were added to {@code stats}.
+ * {@link #accept(double) accept(…)} for all samples that were added to {@code stats}.
*
* @param stats The statistics to be added to {@code this}.
*/
- public void add(final Statistics stats) {
+ public void combine(final Statistics stats) {
ArgumentChecks.ensureNonNull("stats", stats);
// "if (a < b)" is equivalent to "if (!isNaN(a) && a < b)".
@@ -321,7 +327,7 @@ public class Statistics implements Clone
* Multiplies the statistics by the given factor. The given scale factory is also applied
* recursively on the {@linkplain #differences() differences} statistics, if any.
* Invoking this method transforms the statistics as if every values given to the
- * {@code add(…)} had been first multiplied by the given factor.
+ * {@code accept(…)} had been first multiplied by the given factor.
*
* <p>This method is useful for computing discrete derivatives from the differences between
* sample values. See {@link #differences()} or {@link #forSeries forSeries(…)} for more
@@ -423,7 +429,7 @@ public class Statistics implements Clone
}
/**
- * Returns the standard deviation. If the sample values given to the {@code add(…)}
+ * Returns the standard deviation. If the sample values given to the {@code accept(…)}
* methods have a uniform distribution, then the returned value should be close to
* <code>sqrt({@linkplain #span() span}<sup>2</sup> / 12)</code>. If they have a
* Gaussian distribution (which is the most common case), then the returned value
@@ -445,7 +451,7 @@ public class Statistics implements Clone
* </table>
*
* @param allPopulation
- * {@code true} if sample values given to {@code add(…)} methods were the totality
+ * {@code true} if sample values given to {@code accept(…)} methods were the totality
* of the population under study, or {@code false} if they were only a sampling.
* @return The standard deviation.
*/
@@ -455,7 +461,7 @@ public class Statistics implements Clone
/**
* Returns the statistics on the differences between sample values, or {@code null} if none.
- * For example if the sample values given to the {@code add(…)} methods were <var>y₀</var>,
+ * For example if the sample values given to the {@code accept(…)} methods were <var>y₀</var>,
* <var>y₁</var>, <var>y₂</var> and <var>y₃</var>, then this method returns statistics on
* <var>y₁</var>-<var>y₀</var>, <var>y₂</var>-<var>y₁</var> and <var>y₃</var>-<var>y₂</var>.
*
@@ -582,13 +588,13 @@ public class Statistics implements Clone
private Statistics delta;
/**
- * Last value given to an {@link #add(double) add} method as
- * a {@code double}, or {@link Double#NaN NaN} if none.
+ * Last value given to an {@link #accept(double)} method as
+ * a {@code double}, or {@link Double#NaN} if none.
*/
private double last = NaN;
/**
- * Last value given to an {@link #add(long) add}
+ * Last value given to an {@link #accept(long)}
* method as a {@code long}, or 0 if none.
*/
private long lastAsLong;
@@ -632,31 +638,31 @@ public class Statistics implements Clone
* Updates statistics for the specified sample value and its discrete derivatives.
* The {@link #delta} statistics are updated with <code>sample - sample<sub>last</sub></code>
* value, where <code>sample<sub>last</sub></code> is the value given to the previous call of
- * an {@code add(…)} method.
+ * an {@code accept(…)} method.
*/
@Override
- public void add(final double sample) {
- super.add(sample);
- delta.add(sample - last);
+ public void accept(final double sample) {
+ super.accept(sample);
+ delta.accept(sample - last);
last = sample;
lastAsLong = (long) sample;
}
/**
- * Performs the same work than {@link #add(double)}, but with greater precision for
+ * Performs the same work than {@link #accept(double)}, but with greater precision for
* very large integer values (greater than 2<sup>52</sup> in magnitude),
*/
@Override
- public void add(final long sample) {
- super.add(sample);
+ public void accept(final long sample) {
+ super.accept(sample);
if (last == (double) lastAsLong) {
// 'lastAsLong' may have more precision than 'last' since the cast to the
- // 'double' type may loose some digits. Invoke the 'delta.add(long)' version.
- delta.add(sample - lastAsLong);
+ // 'double' type may loose some digits. Invoke the 'delta.accept(long)' version.
+ delta.accept(sample - lastAsLong);
} else {
// The sample value is either fractional, outside 'long' range,
- // infinity or NaN. Invoke the 'delta.add(double)' version.
- delta.add(sample - last);
+ // infinity or NaN. Invoke the 'delta.accept(double)' version.
+ delta.accept(sample - last);
}
last = sample;
lastAsLong = sample;
@@ -669,10 +675,10 @@ public class Statistics implements Clone
* {@code Statistics.Delta}.
*/
@Override
- public void add(final Statistics stats) throws ClassCastException {
+ public void combine(final Statistics stats) throws ClassCastException {
ArgumentChecks.ensureNonNull("stats", stats);
- delta.add(stats.differences());
- super.add(stats);
+ delta.combine(stats.differences());
+ super.combine(stats);
if (stats instanceof WithDelta) {
final WithDelta toAdd = (WithDelta) stats;
last = toAdd.last;
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -78,7 +78,7 @@ public class StatisticsFormat extends Ta
private byte borderWidth;
/**
- * {@code true} if the sample values given to {@code Statistics.add(…)} methods were the
+ * {@code true} if the sample values given to {@code Statistics.accept(…)} methods were the
* totality of the population under study, or {@code false} if they were only a sampling.
*
* @see #isForAllPopulation()
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -116,6 +116,8 @@ public final class Containers extends St
* @throws IndexOutOfBoundsException If the lower or upper value are out of bounds.
*/
public static <E> List<? extends E> unmodifiableList(final E[] array, final int lower, final int upper) {
+ ArgumentChecks.ensureNonNull("array", array);
+ ArgumentChecks.ensureValidIndexRange(array.length, lower, upper);
return UnmodifiableArrayList.wrap(array, lower, upper);
}
@@ -209,12 +211,12 @@ public final class Containers extends St
}
/**
- * Returns the capacity to be given to the {@link HashMap#HashMap(int) HashMap}
+ * Returns the capacity to be given to the {@link java.util.HashMap#HashMap(int) HashMap}
* constructor for holding the given number of elements. This method computes the capacity
* for the default <cite>load factor</cite>, which is 0.75.
*
- * <p>The same calculation can be used for {@link LinkedHashMap} and
- * {@link HashSet} as well, which are built on top of {@code HashMap}.</p>
+ * <p>The same calculation can be used for {@link java.util.LinkedHashMap} and
+ * {@link java.util.HashSet} as well, which are built on top of {@code HashMap}.</p>
*
* @param count The number of elements to be put into the hash map or hash set.
* @return The minimal initial capacity to be given to the hash map constructor.
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsFormatTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsFormatTest.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsFormatTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -42,12 +42,12 @@ public final strictfp class StatisticsFo
@Test
public void testFormattingWithoutHeader() {
final Statistics statistics = Statistics.forSeries(null, null, null);
- statistics.add(10);
- statistics.add(15);
- statistics.add(22);
- statistics.add(17);
- statistics.add(12);
- statistics.add( 3);
+ statistics.accept(10);
+ statistics.accept(15);
+ statistics.accept(22);
+ statistics.accept(17);
+ statistics.accept(12);
+ statistics.accept( 3);
final StatisticsFormat format = StatisticsFormat.getInstance(Locale.US);
final String text = format.format(statistics);
@@ -68,12 +68,12 @@ public final strictfp class StatisticsFo
@DependsOnMethod("testFormattingWithoutHeader")
public void testFormattingWithBorder() {
final Statistics statistics = Statistics.forSeries("Temperature", "∂T/∂t", "∂²T/∂t²");
- statistics.add(10);
- statistics.add(15);
- statistics.add(22);
- statistics.add(17);
- statistics.add(12);
- statistics.add( 3);
+ statistics.accept(10);
+ statistics.accept(15);
+ statistics.accept(22);
+ statistics.accept(17);
+ statistics.accept(12);
+ statistics.accept( 3);
final StatisticsFormat format = StatisticsFormat.getInstance(Locale.US);
format.setBorderWidth(1);
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -76,7 +76,7 @@ public final strictfp class StatisticsTe
final Random random = new Random(317780561); // See class javadoc.
final Statistics statistics = new Statistics(null);
for (int i=0; i<10000; i++) {
- statistics.add(random.nextGaussian());
+ statistics.accept(random.nextGaussian());
}
assertEquals(0, statistics.countNaN());
assertEquals(10000, statistics.count());
@@ -101,7 +101,7 @@ public final strictfp class StatisticsTe
final Random random = new Random(309080660);
final Statistics statistics = new Statistics(null);
for (int i=0; i<10000; i++) {
- statistics.add(random.nextDouble()*range + lower);
+ statistics.accept(random.nextDouble()*range + lower);
}
assertEquals(0, statistics.countNaN());
assertEquals(10000, statistics.count());
@@ -114,7 +114,7 @@ public final strictfp class StatisticsTe
/**
* Same than {@link #testUniform()}, but on integer values.
- * Used for testing {@link Statistics#add(long)}.
+ * Used for testing {@link Statistics#accept(long)}.
*/
@Test
public void testUniformUsingIntegers() {
@@ -128,7 +128,7 @@ public final strictfp class StatisticsTe
final Random random = new Random(309080660);
final Statistics statistics = new Statistics(null);
for (int i=0; i<10000; i++) {
- statistics.add(random.nextInt(range) + lower);
+ statistics.accept(random.nextInt(range) + lower);
}
assertEquals(0, statistics.countNaN());
assertEquals(10000, statistics.count());
@@ -174,15 +174,15 @@ public final strictfp class StatisticsTe
assertTrue("Possible misorder in offsetAndTolerancePairs", offset > 10);
assertTrue("Possible misorder in offsetAndTolerancePairs", tolerance < 0.2);
statistics.reset();
- statistics.add(offset);
+ statistics.accept(offset);
for (int i=0; i<10000; i++) {
- statistics.add(random.nextDouble());
+ statistics.accept(random.nextDouble());
}
final double r = statistics.mean() - offset / statistics.count();
final double expected = (tolerance != 0) ? 0.5 : 0;
assertEquals(expected, r, tolerance);
- statistics.add(-offset); // Accuracy will be better than in previous test.
+ statistics.accept(-offset); // Accuracy will be better than in previous test.
assertEquals(expected, statistics.mean(), min(tolerance, 0.1));
}
}
@@ -204,10 +204,10 @@ public final strictfp class StatisticsTe
} else {
value = random.nextGaussian() + 10*random.nextDouble();
}
- global.add(value);
- block.add(value);
+ global.accept(value);
+ block.accept(value);
}
- byBlock.add(block);
+ byBlock.combine(block);
if (i == 0) {
assertEquals("Adding for the first time; should have the same amount of data.", block, byBlock);
assertEquals("Adding for the first time; should have got exactly the same data.", global, byBlock);
@@ -232,10 +232,10 @@ public final strictfp class StatisticsTe
@Test
public void testSerialization() throws IOException {
final Statistics statistics = new Statistics(null);
- statistics.add(40);
- statistics.add(10);
- statistics.add(NaN);
- statistics.add(20);
+ statistics.accept(40);
+ statistics.accept(10);
+ statistics.accept(NaN);
+ statistics.accept(20);
final Statistics after = assertSerializedEquals(statistics);
assertNotSame(statistics, after);
assertEquals( 3, after.count());
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java [UTF-8] Wed Apr 17 14:46:14 2013
@@ -192,7 +192,7 @@ public final strictfp class CacheTest ex
final int key = entry.getKey();
final int value = entry.getValue();
assertEquals(key*key, value);
- statistics.add(key);
+ statistics.accept(key);
}
return statistics;
}
Modified: sis/trunk/sis-webapp/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/sis-webapp/pom.xml?rev=1468942&r1=1468941&r2=1468942&view=diff
==============================================================================
--- sis/trunk/sis-webapp/pom.xml (original)
+++ sis/trunk/sis-webapp/pom.xml Wed Apr 17 14:46:14 2013
@@ -38,8 +38,8 @@
<dependencies>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
</dependency>
<dependency>
<groupId>org.geonames</groupId>