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/09/19 22:01:26 UTC
svn commit: r1524816 [1/3] - in /sis/branches/JDK6: ./
core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/
core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/ co...
Author: desruisseaux
Date: Thu Sep 19 20:01:25 2013
New Revision: 1524816
URL: http://svn.apache.org/r1524816
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/
- copied from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
- copied, changed from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
- copied unchanged from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/VerticalDatumTypes.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
- copied, changed from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
- copied, changed from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
- copied, changed from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/Sphere.java
- copied unchanged from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/Sphere.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/
- copied from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/
- copied from r1524814, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Supplier.java
- copied unchanged from r1524814, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Supplier.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/NOTICE
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ImageryMarshallingTest.java
sis/branches/JDK6/core/sis-referencing/pom.xml
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Function.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/ExceptionsTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml
sis/branches/JDK6/pom.xml
sis/branches/JDK6/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java
sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageInputStreamTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1519811-1524814
Modified: sis/branches/JDK6/NOTICE
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/NOTICE?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/NOTICE (original)
+++ sis/branches/JDK6/NOTICE Thu Sep 19 20:01:25 2013
@@ -8,6 +8,9 @@ The Javadoc contains documentation from
(OGC®) specifications (http://www.opengeospatial.org/standards/), also
known as OpenGIS.
+The matrix package contains code adapted from JAMA Java Matrix Package
+(http://math.nist.gov/javanumerics/jama/)
+
Some modules use the Esri Geometry API developed by ESRI
(http://github.com/Esri/geometry-api-java/)
Modified: sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -24,7 +24,8 @@ import com.sun.tools.doclets.formats.htm
/**
* The <code>@preformat</code> tag for inserting a pre-formatted code in a javadoc comment.
- * The first word after the tag must be the format name ("java", "math", "wkt" or "text").
+ * The first word after the tag must be the format name ("java", "math", "wkt", "xml", "sql",
+ * "shell" or "text").
* The remaining is the text to format.
*
* <p>This taglet will automatically replace {@code &}, {@code <} and {@code >} by their HTML entities.
@@ -38,6 +39,15 @@ import com.sun.tools.doclets.formats.htm
*/
public final class Preformat extends InlineTaglet {
/**
+ * The set of legal words after {@code preformat}. We write them in lower-cases even if this is not
+ * conform to the Java convention for enumeration constants, because we will use {@link Enum#name()}
+ * for getting the string to look for after {@code preformat}.
+ */
+ private static enum Style {
+ java, math, wkt, xml, sql, shell, text
+ }
+
+ /**
* Special characters to replace by HTML entities.
*/
private static final String[] SPECIAL_CHARS = new String[] {
@@ -104,14 +114,12 @@ public final class Preformat extends Inl
break;
}
}
- final boolean java = format.equals("java");
- final boolean math = format.equals("math");
- final boolean wkt = format.equals("wkt");
- final boolean xml = format.equals("xml");
- final boolean sql = format.equals("sql");
- final boolean shell = format.equals("shell");
- if (!java && !math && !wkt && !xml && !sql && !shell && !format.equals("text")) {
+ Style style;
+ try {
+ style = Style.valueOf(format);
+ } catch (IllegalArgumentException e) {
ConfigurationImpl.getInstance().root.printWarning(tag.position(), "Unknown format: " + format);
+ style = Style.text;
}
/*
* Counts the minimal amount of spaces in the margin.
@@ -150,9 +158,9 @@ all: while (tk.hasMoreTokens()) {
for (int i=0; i<SPECIAL_CHARS.length;) {
line = line.replace(SPECIAL_CHARS[i++], SPECIAL_CHARS[i++]);
}
- if (java) {
- colorJava(line, buffer);
- continue;
+ switch (style) {
+ case java: colorJava(line, buffer); continue;
+ case math: styleMath(line, buffer); continue;
}
}
buffer.append(line);
@@ -235,6 +243,26 @@ all: while (tk.hasMoreTokens()) {
}
/**
+ * Adds italic on variables in a math formulas.
+ * We will put in italic only the single latin letters.
+ */
+ private static void styleMath(final String line, final StringBuilder buffer) {
+ final int length = line.length();
+ for (int i=0; i<length; i++) {
+ final char c = line.charAt(i);
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
+ if ((i == 0 || !Character.isLetterOrDigit(line.codePointBefore(i))) &&
+ (i+1 >= length || !Character.isLetterOrDigit(line.codePointAt(i+1))))
+ {
+ buffer.append("<var>").append(c).append("</var>");
+ continue;
+ }
+ }
+ buffer.append(c);
+ }
+ }
+
+ /**
* Removes the leading and trailing linefeeds (but not other kind of spaces).
*/
private static String trim(final String line) {
Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -325,7 +325,7 @@ public class ImmutableIdentifier impleme
*
* @return The code, never {@code null}.
*
- * @see NamedIdentifier#tip()
+ * @see org.apache.sis.referencing.NamedIdentifier#tip()
*/
@Override
public String getCode() {
@@ -337,8 +337,8 @@ public class ImmutableIdentifier impleme
*
* @return The code space, or {@code null} if not available.
*
- * @see NamedIdentifier#head()
- * @see NamedIdentifier#scope()
+ * @see org.apache.sis.referencing.NamedIdentifier#head()
+ * @see org.apache.sis.referencing.NamedIdentifier#scope()
*/
@Override
public String getCodeSpace() {
@@ -418,7 +418,7 @@ public class ImmutableIdentifier impleme
*
* <p>The default implementation returns {@code false} in all cases.</p>
*
- * @see AbstractIdentifiedObject#isDeprecated()
+ * @see org.apache.sis.referencing.AbstractIdentifiedObject#isDeprecated()
*
* @return {@code true} if this code is deprecated.
*/
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -25,6 +25,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.datatype.DatatypeConfigurationException;
import org.apache.sis.xml.XML;
+import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.MarshallerPool;
import org.apache.sis.internal.jaxb.XmlUtilities;
import org.apache.sis.test.XMLTestCase;
@@ -111,7 +112,7 @@ public final strictfp class TimePeriodTe
final TimeInstant instant = createTimeInstant("1992-01-01 00:00:00");
final String actual = marshal(marshaller, instant);
assertXmlEquals(
- "<gml:TimeInstant>\n" +
+ "<gml:TimeInstant xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:timePosition>1992-01-01T01:00:00.000+01:00</gml:timePosition>\n" +
"</gml:TimeInstant>\n", actual, "xmlns:*");
@@ -135,7 +136,7 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML2(new DummyInstant(date("2007-12-31 00:00:00")));
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
+ "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:begin>\n" +
" <gml:TimeInstant>\n" +
" <gml:timePosition>1992-01-01T01:00:00+01:00</gml:timePosition>\n" +
@@ -188,7 +189,7 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-31 00:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
+ "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition>1992-01-01T01:00:00+01:00</gml:beginPosition>\n" +
" <gml:endPosition>2007-12-31T01:00:00+01:00</gml:endPosition>\n" +
"</gml:TimePeriod>\n", true);
@@ -207,7 +208,7 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
+ "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
" <gml:endPosition>2007-12-31</gml:endPosition>\n" +
"</gml:TimePeriod>\n", false);
@@ -226,7 +227,7 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
+ "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition indeterminatePosition=\"before\"/>\n" +
" <gml:endPosition>2007-12-31</gml:endPosition>\n" +
"</gml:TimePeriod>\n", false);
@@ -245,7 +246,7 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(null, "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
+ "<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
" <gml:endPosition indeterminatePosition=\"after\"/>\n" +
"</gml:TimePeriod>\n", false);
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -175,7 +175,7 @@ public abstract strictfp class MetadataT
*/
@Test
public void testPropertyValues() {
- random = TestUtilities.createRandomNumberGenerator("testPropertyValues");
+ random = TestUtilities.createRandomNumberGenerator();
for (final Class<?> type : types) {
if (!CodeList.class.isAssignableFrom(type)) {
final Class<?> impl = getImplementation(type);
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -240,7 +240,7 @@ public final strictfp class TreeNodeChil
public void testRemoveWithoutCollections() {
final DefaultCitation citation = metadataWithoutCollections();
final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
- testRemove(createRandomNumberGenerator("testRemoveWithoutCollections"), children);
+ testRemove(createRandomNumberGenerator(), children);
}
/**
@@ -255,7 +255,7 @@ public final strictfp class TreeNodeChil
public void testRemoveWithSingletonInCollections() {
final DefaultCitation citation = metadataWithSingletonInCollections();
final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
- testRemove(createRandomNumberGenerator("testRemoveWithSingletonInCollections"), children);
+ testRemove(createRandomNumberGenerator(), children);
}
/**
@@ -270,7 +270,7 @@ public final strictfp class TreeNodeChil
public void testRemoveWithMultiOccurrences() {
final DefaultCitation citation = metadataWithSingletonInCollections();
final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
- testRemove(createRandomNumberGenerator("testRemoveWithMultiOccurrences"), children);
+ testRemove(createRandomNumberGenerator(), children);
}
/**
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -55,7 +55,8 @@ public final strictfp class DefaultBrows
browse.setFileType("image/tiff");
final String xml = XML.marshal(browse);
assertXmlEquals(
- "<gmd:MD_BrowseGraphic>\n" +
+ "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gmx=\"" + Namespaces.GMX + "\">\n" +
" <gmd:fileType>\n" +
" <gmx:MimeFileType type=\"image/tiff\">image/tiff</gmx:MimeFileType>\n" +
" </gmd:fileType>\n" +
@@ -77,7 +78,8 @@ public final strictfp class DefaultBrows
final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(uri);
final String xml = XML.marshal(browse);
assertXmlEquals(
- "<gmd:MD_BrowseGraphic>\n" +
+ "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gmx=\"" + Namespaces.GMX + "\">\n" +
" <gmd:fileName>\n" +
" <gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>\n" +
" </gmd:fileName>\n" +
@@ -120,7 +122,8 @@ public final strictfp class DefaultBrows
browse.setFileType("image/tiff");
final String xml = XML.marshal(browse);
assertXmlEquals(
- "<gmd:MD_BrowseGraphic>\n" +
+ "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gmx=\"" + Namespaces.GMX + "\">\n" +
" <gmd:fileName>\n" +
" <gmx:FileName src=\"file:/catalog/image.png\">image.png</gmx:FileName>\n" +
" </gmd:fileName>\n" +
@@ -151,7 +154,8 @@ public final strictfp class DefaultBrows
singletonMap(XML.STRING_SUBSTITUTES, new String[] {"filename", "mimetype"}));
final String xml = buffer.toString();
assertXmlEquals(
- "<gmd:MD_BrowseGraphic>\n" +
+ "<gmd:MD_BrowseGraphic xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
" <gmd:fileName>\n" +
" <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n" +
" </gmd:fileName>\n" +
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -18,6 +18,7 @@ package org.apache.sis.metadata.iso.iden
import javax.xml.bind.JAXBException;
import org.apache.sis.xml.XML;
+import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -59,7 +60,9 @@ public final strictfp class DefaultRepre
fraction.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "scale");
final String xml = XML.marshal(fraction);
assertXmlEquals(
- "<gmd:MD_RepresentativeFraction id=\"scale\">\n" +
+ "<gmd:MD_RepresentativeFraction xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + '"' +
+ " id=\"scale\">\n" +
" <gmd:denominator>\n" +
" <gco:Integer>8</gco:Integer>\n" +
" </gmd:denominator>\n" +
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -18,6 +18,7 @@ package org.apache.sis.metadata.iso.iden
import javax.xml.bind.JAXBException;
import org.apache.sis.xml.XML;
+import org.apache.sis.xml.Namespaces;
import org.apache.sis.metadata.iso.LoggingWatcher;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -131,7 +132,8 @@ public final strictfp class DefaultResol
* an unknown reason.
*/
assertXmlEquals(
- "<gmd:MD_Resolution>\n" +
+ "<gmd:MD_Resolution xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
" <gmd:distance>\n" +
" <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n" +
" </gmd:distance>\n" +
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ImageryMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ImageryMarshallingTest.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ImageryMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ImageryMarshallingTest.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -56,7 +56,8 @@ public final strictfp class ImageryMarsh
*/
String actual = XML.marshal(lineage);
assertXmlEquals(
- "<gmd:LI_Lineage xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
+ "<gmd:LI_Lineage xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
" <gmd:source>\n" +
" <gmd:LI_Source>\n" +
" <gmd:description>\n" +
@@ -71,7 +72,9 @@ public final strictfp class ImageryMarsh
source.setProcessedLevel(new DefaultIdentifier("DummyLevel"));
actual = XML.marshal(lineage);
assertXmlEquals(
- "<gmd:LI_Lineage xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
+ "<gmd:LI_Lineage xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gmi=\"" + Namespaces.GMI + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
" <gmd:source>\n" +
" <gmi:LE_Source>\n" +
" <gmd:description>\n" +
Modified: sis/branches/JDK6/core/sis-referencing/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/pom.xml?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/pom.xml (original)
+++ sis/branches/JDK6/core/sis-referencing/pom.xml Thu Sep 19 20:01:25 2013
@@ -132,6 +132,11 @@ Implementations of Coordinate Reference
<artifactId>geoapi-conformance</artifactId>
</dependency>
<dependency>
+ <groupId>gov.nist.math</groupId>
+ <artifactId>jama</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
<version>${project.version}</version>
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -190,9 +190,9 @@ class ArrayEnvelope extends AbstractEnve
box.getNorthBoundLatitude()
};
if (Boolean.FALSE.equals(box.getInclusion())) {
- swap(0);
+ ArraysExt.swap(ordinates, 0, ordinates.length >>> 1);
if (!isPoleToPole(ordinates[1], ordinates[3])) {
- swap(1);
+ ArraysExt.swap(ordinates, 1, (ordinates.length >>> 1) + 1);
}
}
try {
@@ -321,16 +321,6 @@ scanNumber: while ((i += Character.charC
}
/**
- * Swaps two ordinate values.
- */
- private void swap(final int i) {
- final int m = i + (ordinates.length >>> 1);
- final double t = ordinates[i];
- ordinates[i] = ordinates[m];
- ordinates[m] = t;
- }
-
- /**
* Returns the index of the first valid ordinate value of the lower corner in the {@link #ordinates} array.
* This is always 0, unless this envelope is a {@link SubEnvelope}.
*
Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java (from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java&r1=1524814&r2=1524816&rev=1524816&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -25,7 +25,7 @@ import org.apache.sis.util.Static;
import static org.opengis.referencing.cs.AxisDirection.*;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -46,7 +46,7 @@ public final class AxisDirections extend
/**
* For each direction, the opposite direction.
*/
- private static final Map<AxisDirection,AxisDirection> opposites = new HashMap<>(35);
+ private static final Map<AxisDirection,AxisDirection> opposites = new HashMap<AxisDirection,AxisDirection>(35);
static {
opposites.put(OTHER, OTHER);
final AxisDirection[] dir = {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -20,6 +20,7 @@ import org.apache.sis.util.Static;
import org.apache.sis.measure.Latitude;
import static java.lang.Math.*;
+import static org.apache.sis.math.MathFunctions.atanh;
/**
@@ -28,8 +29,8 @@ import static java.lang.Math.*;
* do not want to expose publicly those arbitrary values (or at least not in a too direct way).
*
* @author Martin Desruisseaux (Geomatys)
- * @since 0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @since 0.4 (derived from geotk-3.00)
+ * @version 0.4
* @module
*/
public final class Formulas extends Static {
@@ -39,7 +40,7 @@ public final class Formulas extends Stat
* testing map projection accuracy.
*
* @see #ANGULAR_TOLERANCE
- * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD
+ * @see org.apache.sis.internal.util.Numerics#COMPARISON_THRESHOLD
*/
public static final double LINEAR_TOLERANCE = 1.0;
@@ -49,7 +50,7 @@ public final class Formulas extends Stat
* nautical mile length.
*
* @see #LINEAR_TOLERANCE
- * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD
+ * @see org.apache.sis.internal.util.Numerics#COMPARISON_THRESHOLD
*/
public static final double ANGULAR_TOLERANCE = LINEAR_TOLERANCE / (1852 * 60);
@@ -70,4 +71,22 @@ public final class Formulas extends Stat
return abs(ymin - Latitude.MIN_VALUE) <= ANGULAR_TOLERANCE &&
abs(ymax - Latitude.MAX_VALUE) <= ANGULAR_TOLERANCE;
}
+
+ /**
+ * Returns the radius of a hypothetical sphere having the same surface than the ellipsoid
+ * specified by the given axis length. This method does not verify if {@code a == b}
+ * (in which case {@code a} could be returned directly); it is up to the caller to perform
+ * such optimization if desired.
+ *
+ * @param a The semi-major axis length.
+ * @param b The semi-minor axis length.
+ * @return The radius of a sphere having the same surface than the specified ellipsoid.
+ *
+ * @see org.apache.sis.referencing.datum.DefaultEllipsoid#getAuthalicRadius()
+ */
+ public static double getAuthalicRadius(final double a, final double b) {
+ final double f = 1 - b/a;
+ final double e = sqrt(2*f - f*f);
+ return sqrt(0.5 * (a*a + b*b*atanh(e)/e));
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -184,8 +184,6 @@ public enum Convention {
* SIS separates the linear from the non-linear parameters.
*
* <p>This convention is used only for debugging purpose.</p>
- *
- * @see Formatter#isInternalWKT()
*/
@Debug
INTERNAL(Citations.OGC, null, false) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -261,7 +261,7 @@ public class Formatter {
* @return The convention (never {@code null}).
*
* @see WKTFormat#setConvention(Convention)
- * @see FormattableObject#toWKT(Convention)
+ * @see FormattableObject#toString(Convention)
*/
public Convention getConvention() {
return convention;
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -564,18 +564,18 @@ public class AbstractIdentifiedObject ex
* This method accepts only the following enumeration values:
*
* <ul>
- * <li>{@link ComparisonMode#STRICT} (the default): this method may use any property,
+ * <li>{@link ComparisonMode#STRICT STRICT}: this method may use any property,
* including implementation-specific ones if any, at implementation choice.</li>
- * <li>{@link ComparisonMode#BY_CONTRACT}: this method can use any property defined
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}: this method can use any property defined
* in the implemented interface (typically a GeoAPI interface).</li>
- * <li>{@link ComparisonMode#IGNORE_METADATA}: this method ignores the metadata that do not affect
- * coordinate operations. By default, the ignored properties are the {@linkplain #getName() name},
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}: this method ignores the metadata that do not
+ * affect coordinate operations. By default, the ignored properties are the {@linkplain #getName() name},
* {@linkplain #getIdentifiers() identifiers} and {@linkplain #getRemarks() remarks}.
* However subclasses may ignore a different list of properties.</li>
* </ul>
*
* In the later case, two identified objects will return the same hash value if they are equal in the sense of
- * <code>{@linkplain #equals(Object, ComparisonMode) equals}(object, {@linkplain ComparisonMode#IGNORE_METADATA})</code>.
+ * <code>{@linkplain #equals(Object, ComparisonMode) equals}(object, IGNORE_METADATA)</code>.
* This feature allows users to implement metadata-insensitive {@link java.util.HashMap}.
*
* @param mode Specifies the set of properties that can be used for hash code computation.
@@ -612,6 +612,8 @@ public class AbstractIdentifiedObject ex
* return equals(other, ComparisonMode.STRICT);
* }
*
+ * Subclasses shall override {@link #equals(Object, ComparisonMode)} instead than this method.
+ *
* @param object The other object (may be {@code null}).
* @return {@code true} if both objects are equal.
*/
@@ -625,8 +627,14 @@ public class AbstractIdentifiedObject ex
/**
* Returns a hash value for this identified object.
- * This method invokes <code>{@linkplain #hashCode(ComparisonMode) hashCode}(ComparisonMode.STRICT)</code>
- * when first needed and caches the value for future invocations.
+ * This method derives a value from <code>{@linkplain #hashCode(ComparisonMode) hashCode}(STRICT)</code>.
+ * Notes:
+ *
+ * <ul>
+ * <li>The derived value may be different than {@code hashCode(STRICT)}.</li>
+ * <li>This method may cache the hash code value.</li>
+ * </ul>
+ *
* Subclasses shall override {@link #hashCode(ComparisonMode)} instead than this method.
*
* @return The hash code value. This value may change between different execution of the Apache SIS library.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -192,6 +192,10 @@ public class AbstractReferenceSystem ext
*/
@Override
public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+ /*
+ * The "^ (int) serialVersionUID" is an arbitrary change applied to the hash code value in order to
+ * differentiate this ReferenceSystem implementation from implementations of other GeoAPI interfaces.
+ */
int code = super.hashCode(mode) ^ (int) serialVersionUID;
switch (mode) {
case STRICT: {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -251,7 +251,7 @@ public class AbstractDatum extends Abstr
* Compares the specified object with this datum for equality.
* If the {@code mode} argument value is {@link ComparisonMode#STRICT STRICT} or
* {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then all available properties are compared including the
- * {@linkplain #getAnchorPoint() anchor point}, {@link #getRealizationEpoch() realization epoch},
+ * {@linkplain #getAnchorPoint() anchor point}, {@linkplain #getRealizationEpoch() realization epoch},
* {@linkplain #getDomainOfValidity() domain of validity} and the {@linkplain #getScope() scope}.
*
* @param object The object to compare to {@code this}.
@@ -299,12 +299,16 @@ public class AbstractDatum extends Abstr
/**
* Computes a hash value consistent with the given comparison mode.
* If the given argument is {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}, then the
- * {@linkplain #getAnchorPoint() anchor point}, {@link #getRealizationEpoch() realization epoch},
+ * {@linkplain #getAnchorPoint() anchor point}, {@linkplain #getRealizationEpoch() realization epoch},
* {@linkplain #getDomainOfValidity() domain of validity} and the {@linkplain #getScope() scope}
* properties are ignored.
*/
@Override
public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+ /*
+ * The "^ (int) serialVersionUID" is an arbitrary change applied to the hash code value in order to
+ * differentiate this Datum implementation from implementations of other GeoAPI interfaces.
+ */
int code = super.hashCode(mode) ^ (int) serialVersionUID;
switch (mode) {
case STRICT: {
Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java (from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java&r1=1524814&r2=1524816&rev=1524816&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -52,7 +52,7 @@ import static org.apache.sis.util.Argume
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -107,7 +107,7 @@ public class DefaultEllipsoid extends Ab
* This is used for the creation of default ellipsoid constants.
*/
private static Map<String,?> properties(final String name, final int code, final Object alias) {
- final Map<String,Object> map = new HashMap<>(8);
+ final Map<String,Object> map = new HashMap<String,Object>(8);
map.put(NAME_KEY, name);
map.put(IDENTIFIERS_KEY, new NamedIdentifier(Citations.EPSG, String.valueOf(code)));
if (alias != null) {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -33,8 +33,8 @@ import org.apache.sis.io.wkt.Formatter;
* or be a defined point on a moving vehicle (such as on a ship or satellite).
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @since 0.3 (derived from geotk-1.2)
- * @version 0.3
+ * @since 0.4 (derived from geotk-1.2)
+ * @version 0.4
* @module
*/
@Immutable
@@ -115,6 +115,10 @@ public class DefaultEngineeringDatum ext
*/
@Override
public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+ /*
+ * The "^ (int) serialVersionUID" is an arbitrary change applied to the hash code value in order to
+ * differentiate this EngineeringDatum implementation from implementations of other GeoAPI interfaces.
+ */
return super.hashCode(mode) ^ (int) serialVersionUID;
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -38,8 +38,8 @@ import org.apache.sis.internal.jdk7.Obje
* or the corner of the image.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @since 0.3 (derived from geotk-2.0)
- * @version 0.3
+ * @since 0.4 (derived from geotk-2.0)
+ * @version 0.4
* @module
*/
@Immutable
@@ -153,6 +153,10 @@ public class DefaultImageDatum extends A
*/
@Override
public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+ /*
+ * The "^ (int) serialVersionUID" is an arbitrary change applied to the hash code value in order to
+ * differentiate this ImageDatum implementation from implementations of other GeoAPI interfaces.
+ */
int code = super.hashCode(mode) ^ (int) serialVersionUID;
switch (mode) {
case STRICT: {
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -46,8 +46,8 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
- * @since 0.3 (derived from geotk-1.2)
- * @version 0.3
+ * @since 0.4 (derived from geotk-1.2)
+ * @version 0.4
* @module
*/
@Immutable
@@ -245,6 +245,10 @@ public class DefaultPrimeMeridian extend
*/
@Override
public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+ /*
+ * The "^ (int) serialVersionUID" is an arbitrary change applied to the hash code value in order to
+ * differentiate this PrimeMeridian implementation from implementations of other GeoAPI interfaces.
+ */
int code = super.hashCode(mode) ^ (int) serialVersionUID;
switch (mode) {
case STRICT: {
Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java&r1=1524814&r2=1524816&rev=1524816&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java Thu Sep 19 20:01:25 2013
@@ -30,7 +30,7 @@ import static org.apache.sis.internal.ut
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java (from r1524814, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java&r1=1524814&r2=1524816&rev=1524816&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -34,7 +34,7 @@ import org.apache.sis.internal.referenci
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java?rev=1524816&r1=1524814&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -31,7 +31,8 @@ import org.apache.sis.internal.util.Nume
import org.apache.sis.internal.referencing.AxisDirections;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.JDK7;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -885,7 +886,7 @@ public final class Matrices extends Stat
* Now append the formatted elements with the appropriate amount of spaces
* and trailling zeros for each column.
*/
- final String lineSeparator = System.lineSeparator();
+ final String lineSeparator = JDK7.lineSeparator();
final CharSequence whiteLine = CharSequences.spaces(totalWidth);
final StringBuffer buffer = new StringBuffer((totalWidth + 2 + lineSeparator.length()) * (numRow + 2));
buffer.append('┌').append(whiteLine).append('┐').append(lineSeparator);
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=1524816&r1=1524815&r2=1524816&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] Thu Sep 19 20:01:25 2013
@@ -30,12 +30,24 @@ import org.junit.BeforeClass;
* @module
*/
@Suite.SuiteClasses({
+ // Test matrix first because they may be used in about every SIS corners.
+ org.apache.sis.referencing.operation.matrix.SolverTest.class,
+ org.apache.sis.referencing.operation.matrix.Matrix1Test.class,
+ org.apache.sis.referencing.operation.matrix.Matrix2Test.class,
+ org.apache.sis.referencing.operation.matrix.Matrix3Test.class,
+ org.apache.sis.referencing.operation.matrix.Matrix4Test.class,
+ org.apache.sis.referencing.operation.matrix.GeneralMatrixTest.class,
+ org.apache.sis.referencing.operation.matrix.NonSquareMatrixTest.class,
+ org.apache.sis.referencing.operation.matrix.MatricesTest.class,
+ org.apache.sis.referencing.operation.matrix.AffineTransforms2DTest.class,
+
org.apache.sis.io.wkt.ConventionTest.class,
org.apache.sis.io.wkt.SymbolsTest.class,
org.apache.sis.io.wkt.FormatterTest.class,
org.apache.sis.referencing.NamedIdentifierTest.class,
org.apache.sis.referencing.AbstractIdentifiedObjectTest.class,
org.apache.sis.referencing.AbstractReferenceSystemTest.class,
+
org.apache.sis.geometry.AbstractDirectPositionTest.class,
org.apache.sis.geometry.GeneralDirectPositionTest.class,
org.apache.sis.geometry.DirectPosition1DTest.class,
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/converter/FallbackConverter.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -93,7 +93,7 @@ final class FallbackConverter<S,T> exten
final ObjectConverter<S, ? extends T> fallback)
{
super(sourceClass, targetClass);
- if (swap(primary, fallback.getClass())) {
+ if (needSwap(primary, fallback.getClass())) {
this.primary = fallback;
this.fallback = primary;
} else {
@@ -110,11 +110,11 @@ final class FallbackConverter<S,T> exten
* @param fallbackClass The target class of the fallback converter to test.
* @return {@code true} if the given primary and fallback converters should be interchanged.
*/
- private static <S> boolean swap(final ObjectConverter<S,?> primary, final Class<?> fallbackClass) {
+ private static <S> boolean needSwap(final ObjectConverter<S,?> primary, final Class<?> fallbackClass) {
if (primary instanceof FallbackConverter<?,?>) {
final FallbackConverter<S,?> candidate = (FallbackConverter<S,?>) primary;
- return swap(candidate.primary, fallbackClass) &&
- swap(candidate.fallback, fallbackClass);
+ return needSwap(candidate.primary, fallbackClass) &&
+ needSwap(candidate.fallback, fallbackClass);
} else {
final Class<?> targetClass = primary.getTargetClass();
return fallbackClass.isAssignableFrom(targetClass) && // This condition is more likely to fail first.
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -19,6 +19,8 @@ package org.apache.sis.internal.jaxb.gco
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
import javax.measure.unit.Unit;
import javax.measure.unit.NonSI;
import javax.xml.bind.annotation.XmlValue;
@@ -27,6 +29,7 @@ import org.apache.sis.internal.jaxb.gmd.
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.xml.ValueConverter;
import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.resources.Errors;
/**
@@ -150,4 +153,24 @@ public final class Measure {
}
unit = converter.toUnit(context, uom);
}
+
+ /**
+ * Sets the unit to the given value, with a warning logged if the user specified an other unit.
+ *
+ * {@example Some users wrongly assign the "m" unit to <code>Ellipsoid.inverseFlattening</code>.
+ * The SIS adapter force the unit to <code>Unit.ONE</code>, but we want to let the user
+ * know that he probably did something wrong.}
+ *
+ * @param newUnit The new unit (can not be null).
+ */
+ public void setUnit(final Unit<?> newUnit) {
+ if (unit != null && !unit.equals(newUnit)) {
+ final LogRecord record = Errors.getResources(null)
+ .getLogRecord(Level.WARNING, Errors.Keys.IncompatiblePropertyValue_1, unit);
+ record.setSourceClassName(getClass().getName());
+ record.setSourceMethodName("setUnit");
+ Context.warningOccured(Context.current(), this, record);
+ }
+ unit = newUnit;
+ }
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Function.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Function.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Function.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Function.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -18,7 +18,7 @@ package org.apache.sis.internal.jdk8;
/**
- * Placeholder for the {@link ava.util.function.Function} interface.
+ * Placeholder for the {@link java.util.function.Function} interface.
*
* @param <T> The type of parameters (source type).
* @param <R> The type of return values (target type).
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -45,15 +45,15 @@ public final class Numerics extends Stat
* {@preformat java
* Matrix m1 = ...;
* Matrix m2 = ...;
- * if (Matrices.epsilonEqual(m1, m2, EQUIVALENT_THRESHOLD, true)) {
+ * if (Matrices.epsilonEqual(m1, m2, COMPARISON_THRESHOLD, true)) {
* // Consider that matrixes are equal.
* }
* }
*
* By extension, the same threshold value is used for comparing other floating point values.
*
- * @see org.apache.sis.internal.referencing.Utilities#LINEAR_TOLERANCE
- * @see org.apache.sis.internal.referencing.Utilities#ANGULAR_TOLERANCE
+ * @see org.apache.sis.internal.referencing.Formulas#LINEAR_TOLERANCE
+ * @see org.apache.sis.internal.referencing.Formulas#ANGULAR_TOLERANCE
*/
public static final double COMPARISON_THRESHOLD = 1E-14;
@@ -90,6 +90,39 @@ public final class Numerics extends Stat
}
/**
+ * Returns a copy of the given array where each value has been casted to the {@code float} type.
+ *
+ * @param data The array to copy, or {@code null}.
+ * @return A copy of the given array with values casted to the {@code float} type, or
+ * {@code null} if the given array was null.
+ */
+ public static float[] copyAsFloats(final double[] data) {
+ if (data == null) return null;
+ final float[] result = new float[data.length];
+ for (int i=0; i<data.length; i++) {
+ result[i] = (float) data[i];
+ }
+ return result;
+ }
+
+ /**
+ * Returns a copy of the given array where each value has been
+ * {@linkplain Math#round(double) rounded} to the {@code int} type.
+ *
+ * @param data The array to copy, or {@code null}.
+ * @return A copy of the given array with values rounded to the {@code int} type, or
+ * {@code null} if the given array was null.
+ */
+ public static int[] copyAsInts(final double[] data) {
+ if (data == null) return null;
+ final int[] result = new int[data.length];
+ for (int i=0; i<data.length; i++) {
+ result[i] = (int) Math.round(data[i]);
+ }
+ return result;
+ }
+
+ /**
* Returns {@code true} if the given floats are equals. Positive and negative zero are
* considered different, while a NaN value is considered equal to all other NaN values.
*
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -91,7 +91,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* The {@code ?} modifier specifies that the preceding field can be omitted if its value is zero.
* Any field can be omitted for {@link Angle} object, but only trailing fields are omitted for
- * {@li{@link Longitude} and {@link Latitude}.
+ * {@link Longitude} and {@link Latitude}.
*
* {@example "<code>DD°MM′?SS″?</code>" will format an angle of 12.01° as <code>12°36″</code>,
* but a longitude of 12.01°N as <code>12°00′36″N</code> (not <code>12°36″N</code>).}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -69,7 +69,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-2.0)
- * @version 0.3
+ * @version 0.4
* @module
*
* @see Arrays
@@ -1395,14 +1395,13 @@ public final class ArraysExt extends Sta
* @param data The array to copy, or {@code null}.
* @return A copy of the given array with values casted to the {@code float} type, or
* {@code null} if the given array was null.
+ *
+ * @deprecated Will be removed since we do not plan to provide static converter methods for every possible
+ * type combination, and user should probably control himself the rounding behavior.
*/
+ @Deprecated
public static float[] copyAsFloats(final double[] data) {
- if (data == null) return null;
- final float[] result = new float[data.length];
- for (int i=0; i<data.length; i++) {
- result[i] = (float) data[i];
- }
- return result;
+ return org.apache.sis.internal.util.Numerics.copyAsFloats(data);
}
/**
@@ -1412,14 +1411,13 @@ public final class ArraysExt extends Sta
* @param data The array to copy, or {@code null}.
* @return A copy of the given array with values rounded to the {@code int} type, or
* {@code null} if the given array was null.
+ *
+ * @deprecated Will be removed since we do not plan to provide static converter methods for every possible
+ * type combination, and user should probably control himself the rounding behavior.
*/
+ @Deprecated
public static int[] copyAsInts(final double[] data) {
- if (data == null) return null;
- final int[] result = new int[data.length];
- for (int i=0; i<data.length; i++) {
- result[i] = (int) Math.round(data[i]);
- }
- return result;
+ return org.apache.sis.internal.util.Numerics.copyAsInts(data);
}
/**
@@ -1717,6 +1715,117 @@ public final class ArraysExt extends Sta
}
/**
+ * Swaps the elements at the given indices in the given array of {@code double} values.
+ *
+ * {@note While trivial, this method is provided because its need occurs relatively often
+ * and the availability of a <code>swap</code> method makes the code easier to read.}
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final double[] data, final int i0, final int i1) {
+ final double t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code float} values.
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final float[] data, final int i0, final int i1) {
+ final float t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code long} values.
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final long[] data, final int i0, final int i1) {
+ final long t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code int} values.
+ *
+ * {@note While trivial, this method is provided because its need occurs relatively often
+ * and the availability of a <code>swap</code> method makes the code easier to read.}
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final int[] data, final int i0, final int i1) {
+ final int t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code short} values.
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final short[] data, final int i0, final int i1) {
+ final short t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code byte} values.
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final byte[] data, final int i0, final int i1) {
+ final byte t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
+ * Swaps the elements at the given indices in the given array of {@code char} values.
+ *
+ * @param data The array in which to swap elements.
+ * @param i0 Index of one element to be swapped.
+ * @param i1 Index of the other element to be swapped.
+ *
+ * @since 0.4
+ */
+ public static void swap(final char[] data, final int i0, final int i1) {
+ final char t = data[i0];
+ data[i0] = data[i1];
+ data[i1] = t;
+ }
+
+ /**
* Returns {@code true} if all values in the specified array are equal to the specified
* value, which may be {@link Double#NaN}.
*
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -82,7 +82,7 @@ package org.apache.sis.util;
* difference is tolerated in floating point numbers.</li>
* </ol>
* </li>
- * <li>{@link org.apache.sis.referencing.operation.matrix.XMatrix} and
+ * <li>{@link org.apache.sis.referencing.operation.matrix.MatrixSIS} and
* {@link org.apache.sis.referencing.operation.transform.LinearTransform} implementations
* <ol>
* <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class, matrixes
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -37,6 +37,9 @@ import org.apache.sis.internal.system.Re
import static org.apache.sis.internal.system.DelayedExecutor.executeDaemonTask;
+// Related to JDK8
+import org.apache.sis.internal.jdk8.Supplier;
+
/**
* A concurrent cache mechanism. This implementation is thread-safe and supports concurrency.
@@ -135,7 +138,7 @@ import static org.apache.sis.internal.sy
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
* @module
*/
@ThreadSafe
@@ -143,7 +146,7 @@ public class Cache<K,V> extends Abstract
/**
* The map that contains the cached values. If a value is under the process of being
* calculated, then the value will be a temporary instance of {@link Handler}. The
- * value may also be weak of soft {@link Reference} objects.
+ * value may also be weak or soft {@link Reference} objects.
*/
private final ConcurrentMap<K,Object> map;
@@ -277,22 +280,11 @@ public class Cache<K,V> extends Abstract
return ((Reference<V>) value).get();
}
if (value instanceof Handler<?>) {
- final Handler<V> handler = (Handler<V>) value;
- final ReentrantLock lock = (ReentrantLock) value;
+ return ((Supplier<V>) value).get();
/*
* A ClassCastException on the above line would be a bug in this class.
- * See the comment in Cache.lock(K) method for more explanations. The
- * remainder of this block is an adaptation of Cache.Work.get().
+ * See the comment in Cache.lock(K) method for more explanations.
*/
- if (lock.isHeldByCurrentThread()) {
- return null;
- }
- lock.lock();
- try {
- return handler.peek();
- } finally {
- lock.unlock();
- }
}
return (V) value;
}
@@ -446,6 +438,7 @@ public class Cache<K,V> extends Abstract
*/
public Handler<V> lock(final K key) {
final Work handler = new Work(key);
+ boolean unlock = true;
handler.lock.lock();
Object value;
try {
@@ -459,15 +452,15 @@ public class Cache<K,V> extends Abstract
/*
* We succeed in adding the handler in the map (we know that because all our
* map.put(...) or map.replace(...) operations are guaranteed to put non-null
- * values). We are done. But before to leave, lock again for canceling the
- * effect of unlock in the finally clause (we want the lock to still active).
+ * values). We are done. But before to leave, declare that we do not want to
+ * unlock in the finally clause (we want the lock to still active).
*/
- handler.lock.lock();
+ unlock = false;
return handler;
}
/*
- * If the value is a valid reference (strong, soft or weak), stop the loop and
- * release the lock. We will process that value after the finally block.
+ * If the value is a strong reference or other handler, stop the loop and release the lock.
+ * We will process that value after the finally block.
*/
if (!(value instanceof Reference<?>)) {
break;
@@ -495,13 +488,15 @@ public class Cache<K,V> extends Abstract
* handler.
*/
if (map.replace(key, ref, handler)) {
- handler.lock.lock();
+ unlock = false;
return handler;
}
// The map content changed. Try again.
} while (true);
} finally {
- handler.lock.unlock();
+ if (unlock) {
+ handler.lock.unlock();
+ }
}
/*
* From this point, we abandon our handler.
@@ -640,7 +635,7 @@ public class Cache<K,V> extends Abstract
* A handler implementation used for telling to other threads that the current thread is
* computing a value.
*/
- final class Work extends DelayedRunnable.Immediate implements Handler<V> {
+ final class Work extends DelayedRunnable.Immediate implements Handler<V>, Supplier<V> {
/**
* The synchronization lock.
*/
@@ -669,9 +664,10 @@ public class Cache<K,V> extends Abstract
* Waits for the completion of the value computation and returns this result. This
* method should be invoked only from an other thread than the one doing the calculation.
*/
- final V get() {
+ @Override
+ public V get() {
if (lock.isHeldByCurrentThread()) {
- throw new IllegalStateException();
+ return null;
}
final V v;
lock.lock();
@@ -736,12 +732,12 @@ public class Cache<K,V> extends Abstract
* Do nothing (except checking for programming error), since we don't hold any lock.
*
* {@note An alternative would have been to store the result in the map anyway.
- * But doing so is unsafe because we have no lock; we have no guarantee and
+ * But doing so is unsafe because we have no lock; we have no guarantee that
* nothing has happened in an other thread between peek and putAndUnlock.}
*/
@Override
public void putAndUnlock(final V result) throws IllegalStateException {
- if (result != get() && !isKeyCollisionAllowed()) {
+ if (result != null && !isKeyCollisionAllowed() && result != get()) {
throw new IllegalStateException(Errors.format(Errors.Keys.KeyCollision_1, key));
}
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -50,8 +50,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* {@section <code>Comparable</code> ordering}
* This class has a natural ordering that is inconsistent with {@link #equals(Object)}.
- * The natural ordering is case-insensitive and ignores the character separator between
- * name elements.
+ * See {@link #compareTo(GenericName)} for more information.
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-2.1)
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -255,7 +255,7 @@ public class DefaultLocalName extends Ab
/**
* Compares this name with the specified object for order. Returns a negative integer,
* zero, or a positive integer as this name lexicographically precedes, is equal to,
- * or follows the specified object. The comparison is case-insensitive.
+ * or follows the specified object.
*
* @param name The other name to compare with this name.
* @return -1 if this name precedes the given one, +1 if it follows, 0 if equals.
@@ -263,7 +263,14 @@ public class DefaultLocalName extends Ab
@Override
public int compareTo(final GenericName name) {
if (name instanceof LocalName) {
- return toString().compareToIgnoreCase(name.toString());
+ /*
+ * Note: a previous version was using String.compareToIgnoreCase(String).
+ * However it is slightly slower than String.compareTo(String), increase
+ * the inconsistency with equals(Object), may be more suprising to the
+ * developer and result in unsatisfactory ordering for certain locales
+ * anyway (we are supposed to use Collator instead).
+ */
+ return toString().compareTo(name.toString());
} else {
return super.compareTo(name);
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java?rev=1524816&r1=1524815&r2=1524816&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java [UTF-8] Thu Sep 19 20:01:25 2013
@@ -216,10 +216,10 @@ public class DefaultRecordType implement
/**
* Returns the type associated to the given attribute name, or {@code null} if none.
- * This method is functionally equivalent to:
+ * This method is functionally equivalent to (omitting the check for null value):
*
* {@preformat java
- * getMemberTypes().get(name);
+ * getMemberTypes().get(memberName).getTypeName();
* }
*
* {@section Comparison with Java reflection}