sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1452389 [1/2] - in /sis/branches/JDK6: ./ ide-project/NetBeans/nbproject/ sis-metadata/ sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/test/ sis-metadata/sr...
Date Mon, 04 Mar 2013 16:48:48 GMT
Author: desruisseaux
Date: Mon Mar  4 16:48:47 2013
New Revision: 1452389

URL: http://svn.apache.org/r1452389
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
      - copied from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/KeyNamePolicy.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/KeyNamePolicy.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
    sis/branches/JDK6/sis-metadata/src/test/
      - copied from r1452374, sis/branches/JDK7/sis-metadata/src/test/
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/ValueRange.java
      - copied unchanged from r1452374, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/ValueRange.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/simple/
      - copied from r1452374, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/simple/
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/CodeListSetTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java
      - copied, changed from r1452374, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/iso/LargeCodeList.java
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/ide-project/NetBeans/nbproject/build-impl.xml
    sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties
    sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
    sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml
    sis/branches/JDK6/sis-metadata/pom.xml
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/UnmodifiableMetadataException.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
    sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java
    sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
    sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
    sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractInternationalString.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/ResourceInternationalString.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/NumbersTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1449668-1452374

Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/build-impl.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/build-impl.xml?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/build-impl.xml (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/build-impl.xml Mon Mar  4 16:48:47 2013
@@ -136,6 +136,7 @@ is divided into following sections:
         <condition property="have.tests">
             <or>
                 <available file="${test.referencing.dir}"/>
+                <available file="${test.metadata.dir}"/>
                 <available file="${test.utility.dir}"/>
             </or>
         </condition>
@@ -241,6 +242,7 @@ is divided into following sections:
         <fail unless="src.metadata.dir">Must set src.metadata.dir</fail>
         <fail unless="src.utility.dir">Must set src.utility.dir</fail>
         <fail unless="test.referencing.dir">Must set test.referencing.dir</fail>
+        <fail unless="test.metadata.dir">Must set test.metadata.dir</fail>
         <fail unless="test.utility.dir">Must set test.utility.dir</fail>
         <fail unless="build.dir">Must set build.dir</fail>
         <fail unless="dist.dir">Must set dist.dir</fail>
@@ -424,6 +426,9 @@ is divided into following sections:
                         <fileset dir="${test.referencing.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
                         </fileset>
+                        <fileset dir="${test.metadata.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
                         <fileset dir="${test.utility.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
                         </fileset>
@@ -459,6 +464,9 @@ is divided into following sections:
                     <fileset dir="${test.referencing.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
                         <filename name="@{testincludes}"/>
                     </fileset>
+                    <fileset dir="${test.metadata.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
+                        <filename name="@{testincludes}"/>
+                    </fileset>
                     <fileset dir="${test.utility.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
                         <filename name="@{testincludes}"/>
                     </fileset>
@@ -574,6 +582,9 @@ is divided into following sections:
                         <fileset dir="${test.referencing.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
                         </fileset>
+                        <fileset dir="${test.metadata.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
                         <fileset dir="${test.utility.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
                         </fileset>
@@ -1298,12 +1309,13 @@ is divided into following sections:
         <!-- You can override this target in the ../build.xml file. -->
     </target>
     <target if="do.depend.true" name="-compile-test-depend">
-        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
     </target>
     <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
-        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
         <copy todir="${build.test.classes.dir}">
             <fileset dir="${test.referencing.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+            <fileset dir="${test.metadata.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
             <fileset dir="${test.utility.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
     </target>
@@ -1319,9 +1331,10 @@ is divided into following sections:
     <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
         <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
         <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
-        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.referencing.dir}:${test.utility.dir}" srcdir="${test.referencing.dir}:${test.utility.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}" srcdir="${test.referencing.dir}:${test.metadata.dir}:${test.utility.dir}"/>
         <copy todir="${build.test.classes.dir}">
             <fileset dir="${test.referencing.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+            <fileset dir="${test.metadata.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
             <fileset dir="${test.utility.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
     </target>

Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Mon Mar  4 16:48:47 2013
@@ -3,6 +3,6 @@
 build.xml.data.CRC32=58e6b21c
 build.xml.script.CRC32=462eaba0
 build.xml.stylesheet.CRC32=28e38971@1.53.1.46
-nbproject/build-impl.xml.data.CRC32=e8191a2a
-nbproject/build-impl.xml.script.CRC32=2ddb9051
+nbproject/build-impl.xml.data.CRC32=af14ca0b
+nbproject/build-impl.xml.script.CRC32=d26a4b87
 nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Mon Mar  4 16:48:47 2013
@@ -7,6 +7,7 @@ application.vendor   = Apache
 application.homepage = http://sis.apache.org/
 application.desc     = Apache SIS is a toolkit for describing location information, including points, bounding boxes, polygons, and for computing distances on that information.
 
+file.reference.site-resources=../../../JDK6/sis-metadata/src/site/resources
 #
 # Some global configuration.
 #
@@ -31,6 +32,7 @@ src.app.dir          = ${project.root}/s
 src.referencing.dir  = ${project.root}/sis-referencing/src/main/java
 test.referencing.dir = ${project.root}/sis-referencing/src/test/java
 src.metadata.dir     = ${project.root}/sis-metadata/src/main/java
+test.metadata.dir    = ${project.root}/sis-metadata/src/test/java
 src.utility.dir      = ${project.root}/sis-utility/src/main/java
 test.utility.dir     = ${project.root}/sis-utility/src/test/java
 

Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/project.xml Mon Mar  4 16:48:47 2013
@@ -14,12 +14,14 @@
             </source-roots>
             <test-roots>
                 <root id="test.referencing.dir" name="Referencing tests"/>
+                <root id="test.metadata.dir" name="Metadata tests"/>
                 <root id="test.utility.dir" name="Utility tests"/>
             </test-roots>
         </data>
         <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
             <word>bitmask</word>
             <word>classname</word>
+            <word>classnames</word>
             <word>classpath</word>
             <word>deserialization</word>
             <word>deserialized</word>

Modified: sis/branches/JDK6/sis-metadata/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/pom.xml?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/pom.xml (original)
+++ sis/branches/JDK6/sis-metadata/pom.xml Mon Mar  4 16:48:47 2013
@@ -112,6 +112,15 @@ Implementations of metadata derived from
       <groupId>org.opengis</groupId>
       <artifactId>geoapi-conformance</artifactId>
     </dependency>
+
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>org.apache.sis</groupId>
+      <artifactId>sis-utility</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java (from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/Cloner.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -115,7 +115,7 @@ final class Cloner extends org.apache.si
          *          by their unmodifiable variant. The keys are assumed already immutable.
          */
         if (object instanceof Map<?,?>) {
-            final Map<Object,Object> map = new LinkedHashMap<>((Map<?,?>) object);
+            final Map<Object,Object> map = new LinkedHashMap<Object,Object>((Map<?,?>) object);
             for (final Iterator<Map.Entry<Object,Object>> it=map.entrySet().iterator(); it.hasNext();) {
                 final Map.Entry<Object,Object> entry = it.next();
                 entry.setValue(clone(entry.getValue()));

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java (from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -165,7 +165,7 @@ public class MetadataStandard {
         ensureNonNull("interfacePackage", interfacePackage);
         this.citation         = citation;
         this.interfacePackage = interfacePackage.getName() + '.';
-        this.accessors        = new IdentityHashMap<>();
+        this.accessors        = new IdentityHashMap<Class<?>,Object>();
     }
 
     /**
@@ -178,7 +178,7 @@ public class MetadataStandard {
     MetadataStandard(final Citation citation, final String interfacePackage) {
         this.citation         = citation;
         this.interfacePackage = interfacePackage;
-        this.accessors        = new IdentityHashMap<>();
+        this.accessors        = new IdentityHashMap<Class<?>,Object>();
     }
 
     /**
@@ -323,7 +323,7 @@ public class MetadataStandard {
                  * Gets every interfaces from the supplied package in declaration order,
                  * including the ones declared in the super-class.
                  */
-                final Set<Class<?>> interfaces = new LinkedHashSet<>();
+                final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
                 do {
                     getInterfaces(type, interfaces);
                     type = type.getSuperclass();

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -23,8 +23,11 @@ import java.util.Collections;
 import java.util.NoSuchElementException;
 import net.jcip.annotations.ThreadSafe;
 import org.opengis.util.CodeList;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.CheckedHashSet;
 import org.apache.sis.util.collection.CheckedArrayList;
+import org.apache.sis.internal.jaxb.MarshalContext;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
@@ -44,29 +47,33 @@ import static org.apache.sis.util.collec
  * <p>For singleton value:</p>
  *
  * {@preformat java
- *     private Foo property;
+ *     public class MyMetadata {
+ *         private Foo property;
  *
- *     public synchronized Foo getProperty() {
- *         return property;
- *     }
+ *         public synchronized Foo getProperty() {
+ *             return property;
+ *         }
  *
- *     public synchronized void setProperty(Foo newValue) {
- *         checkWritePermission();
- *         property = newValue;
+ *         public synchronized void setProperty(Foo newValue) {
+ *             checkWritePermission();
+ *             property = newValue;
+ *         }
  *     }
  * }
  *
  * For collections (note that the call to {@link #checkWritePermission()} is implicit):
  *
  * {@preformat java
- *     private Collection<Foo> properties;
+ *     public class MyMetadata {
+ *         private Collection<Foo> properties;
  *
- *     public synchronized Collection<Foo> getProperties() {
- *         return properties = nonNullCollection(properties, Foo.class);
- *     }
+ *         public synchronized Collection<Foo> getProperties() {
+ *             return properties = nonNullCollection(properties, Foo.class);
+ *         }
  *
- *     public synchronized void setProperties(Collection<Foo> newValues) {
- *         properties = copyCollection(newValues, properties, Foo.class);
+ *         public synchronized void setProperties(Collection<Foo> newValues) {
+ *             properties = copyCollection(newValues, properties, Foo.class);
+ *         }
  *     }
  * }
  *
@@ -76,7 +83,31 @@ import static org.apache.sis.util.collec
  * @module
  */
 @ThreadSafe
-public abstract class ModifiableMetadata {
+public abstract class ModifiableMetadata extends AbstractMetadata implements Cloneable {
+    /**
+     * A null implementation for the {@link #FREEZING} constant.
+     */
+    private static final class Null extends ModifiableMetadata {
+        @Override public MetadataStandard getStandard() {
+            return null;
+        }
+    }
+
+    /**
+     * A flag used for {@link #unmodifiable} in order to specify that
+     * {@link #freeze()} is under way.
+     */
+    private static final ModifiableMetadata FREEZING = new Null();
+
+    /**
+     * An unmodifiable copy of this metadata, created only when first needed.
+     * If {@code null}, then no unmodifiable entity is available.
+     * If {@code this}, then this entity is itself unmodifiable.
+     *
+     * @see #unmodifiable()
+     */
+    private transient ModifiableMetadata unmodifiable;
+
     /**
      * Constructs an initially empty metadata.
      */
@@ -93,8 +124,90 @@ public abstract class ModifiableMetadata
      * @see #freeze()
      * @see #checkWritePermission()
      */
-    public final boolean isModifiable() {
-        return true; // To be implemented later.
+    public final synchronized boolean isModifiable() {
+        return unmodifiable != this;
+    }
+
+    /**
+     * Returns an unmodifiable copy of this metadata. Any attempt to modify a property of the
+     * returned object will throw an {@link UnmodifiableMetadataException}. The state of this
+     * object is not modified.
+     *
+     * <p>This method is useful for reusing the same metadata object as a template.
+     * For example:</p>
+     *
+     * {@preformat java
+     *     DefaultCitation myCitation = new DefaultCitation();
+     *     myCitation.setTitle(new SimpleInternationalString("The title of my book"));
+     *     myCitation.setEdition(new SimpleInternationalString("First edition"));
+     *     final Citation firstEdition = (Citation) myCitation.unmodifiable();
+     *
+     *     myCitation.setEdition(new SimpleInternationalString("Second edition"));
+     *     final Citation secondEdition = (Citation) myCitation.unmodifiable();
+     *     // The title of the second edition is unchanged compared to the first edition.
+     * }
+     *
+     * The default implementation makes the following choice:
+     *
+     * <ul>
+     *   <li>If this metadata is itself unmodifiable, then this method returns {@code this}
+     *       unchanged.</li>
+     *   <li>Otherwise this method {@linkplain #clone() clone} this metadata and
+     *       {@linkplain #freeze() freeze} the clone before to return it.</li>
+     * </ul>
+     *
+     * @return An unmodifiable copy of this metadata.
+     */
+    public synchronized AbstractMetadata unmodifiable() {
+        // Reminder: 'unmodifiable' is reset to null by checkWritePermission().
+        if (unmodifiable == null) {
+            final ModifiableMetadata candidate;
+            try {
+                /*
+                 * Need a SHALLOW copy of this metadata, because some properties
+                 * may already be unmodifiable and we don't want to clone them.
+                 */
+                candidate = clone();
+            } catch (CloneNotSupportedException exception) {
+                /*
+                 * The metadata is not cloneable for some reason left to the user
+                 * (for example it may be backed by some external database).
+                 * Assumes that the metadata is unmodifiable.
+                 */
+                Logging.unexpectedException(LOGGER, getClass(), "unmodifiable", exception);
+                return this;
+            }
+            candidate.freeze();
+            // Set the field only after success. The 'unmodifiable' field must
+            // stay null if an exception occurred during clone() or freeze().
+            unmodifiable = candidate;
+        }
+        assert !unmodifiable.isModifiable();
+        return unmodifiable;
+    }
+
+    /**
+     * Declares this metadata and all its properties as unmodifiable. Any attempt to modify a
+     * property after this method call will throw an {@link UnmodifiableMetadataException}.
+     * If this metadata is already unmodifiable, then this method does nothing.
+     *
+     * <p>Subclasses usually don't need to override this method since the default implementation
+     * performs its work using Java reflection.</p>
+     *
+     * @see #isModifiable()
+     * @see #checkWritePermission()
+     */
+    public synchronized void freeze() {
+        if (isModifiable()) {
+            ModifiableMetadata success = null;
+            try {
+                unmodifiable = FREEZING;
+                getStandard().freeze(this);
+                success = this;
+            } finally {
+                unmodifiable = success;
+            }
+        }
     }
 
     /**
@@ -110,8 +223,9 @@ public abstract class ModifiableMetadata
     protected void checkWritePermission() throws UnmodifiableMetadataException {
         assert Thread.holdsLock(this);
         if (!isModifiable()) {
-            throw new UnmodifiableMetadataException("Unmodifiable metadata"); // TODO: localize
+            throw new UnmodifiableMetadataException(Errors.format(Errors.Keys.UnmodifiableMetadata));
         }
+        unmodifiable = null;
     }
 
     /**
@@ -122,7 +236,7 @@ public abstract class ModifiableMetadata
      *   <li>Invokes {@link #checkWritePermission()} in order to ensure that this metadata is
      *       modifiable.</li>
      *   <li>If {@code source} is null or empty, returns {@code null}
-     *       (meaning that the metadata attribute is not provided).</li>
+     *       (meaning that the metadata property is not provided).</li>
      *   <li>If {@code target} is null, creates a new {@link List}.</li>
      *   <li>Copies the content of the given {@code source} into the target.</li>
      * </ul>
@@ -144,6 +258,9 @@ public abstract class ModifiableMetadata
     {
         // See the comments in copyCollection(...) for implementation notes.
         if (source != target) {
+            if (unmodifiable == FREEZING) {
+                return (List<E>) source;
+            }
             checkWritePermission();
             if (isNullOrEmpty(source)) {
                 target = null;
@@ -167,7 +284,7 @@ public abstract class ModifiableMetadata
      *   <li>Invokes {@link #checkWritePermission()} in order to ensure that this metadata is
      *       modifiable.</li>
      *   <li>If {@code source} is null or empty, returns {@code null}
-     *       (meaning that the metadata attribute is not provided).</li>
+     *       (meaning that the metadata property is not provided).</li>
      *   <li>If {@code target} is null, creates a new {@link Set}.</li>
      *   <li>Copies the content of the given {@code source} into the target.</li>
      * </ul>
@@ -189,6 +306,9 @@ public abstract class ModifiableMetadata
     {
         // See the comments in copyCollection(...) for implementation notes.
         if (source != target) {
+            if (unmodifiable == FREEZING) {
+                return (Set<E>) source;
+            }
             checkWritePermission();
             if (isNullOrEmpty(source)) {
                 target = null;
@@ -212,7 +332,7 @@ public abstract class ModifiableMetadata
      *   <li>Invokes {@link #checkWritePermission()} in order to ensure that this metadata is
      *       modifiable.</li>
      *   <li>If {@code source} is null or empty, returns {@code null}
-     *       (meaning that the metadata attribute is not provided).</li>
+     *       (meaning that the metadata property is not provided).</li>
      *   <li>If {@code target} is null, creates a new {@link Set} or a new {@link List}
      *       depending on the value returned by {@link #collectionType(Class)}.</li>
      *   <li>Copies the content of the given {@code source} into the target.</li>
@@ -244,6 +364,14 @@ public abstract class ModifiableMetadata
          * This optimization is required for efficient working of PropertyAccessor.set(...).
          */
         if (source != target) {
+            if (unmodifiable == FREEZING) {
+                /*
+                 * freeze() method is under progress. The source collection is already
+                 * an unmodifiable instance created by unmodifiable(Object).
+                 */
+                assert collectionType(elementType).isAssignableFrom(source.getClass());
+                return (Collection<E>) source;
+            }
             checkWritePermission();
             if (isNullOrEmpty(source)) {
                 target = null;
@@ -265,6 +393,15 @@ public abstract class ModifiableMetadata
     }
 
     /**
+     * Returns {@code true} if the caller {@code nonNullCollection} method (or list, or set)
+     * is allowed to returns {@code null} instead than an empty list. This happen mostly at
+     * XML marshalling time.
+     */
+    private static boolean isMarshaling() {
+        return MarshalContext.isFlagSet(MarshalContext.current(), MarshalContext.MARSHALING);
+    }
+
+    /**
      * Returns the specified list, or a new one if {@code c} is null.
      * This is a convenience method for implementation of {@code getFoo()}
      * methods.
@@ -278,7 +415,10 @@ public abstract class ModifiableMetadata
     protected final <E> List<E> nonNullList(final List<E> c, final Class<E> elementType) {
         assert Thread.holdsLock(this);
         if (c != null) {
-            return c;
+            return c.isEmpty() && isMarshaling() ? null : c;
+        }
+        if (isMarshaling()) {
+            return null;
         }
         if (isModifiable()) {
             return new MutableList<E>(elementType);
@@ -300,7 +440,10 @@ public abstract class ModifiableMetadata
     protected final <E> Set<E> nonNullSet(final Set<E> c, final Class<E> elementType) {
         assert Thread.holdsLock(this);
         if (c != null) {
-            return c;
+            return c.isEmpty() && isMarshaling() ? null : c;
+        }
+        if (isMarshaling()) {
+            return null;
         }
         if (isModifiable()) {
             return new MutableSet<E>(elementType);
@@ -332,7 +475,10 @@ public abstract class ModifiableMetadata
         assert Thread.holdsLock(this);
         if (c != null) {
             assert collectionType(elementType).isAssignableFrom(c.getClass());
-            return c;
+            return c.isEmpty() && isMarshaling() ? null : c;
+        }
+        if (isMarshaling()) {
+            return null;
         }
         final boolean isModifiable = isModifiable();
         if (useSet(elementType)) {
@@ -426,12 +572,12 @@ public abstract class ModifiableMetadata
         if (List.class.isAssignableFrom(type)) {
             return false;
         }
-        throw new NoSuchElementException("Unsupported data type");
+        throw new NoSuchElementException(Errors.format(Errors.Keys.UnsupportedType_1, type));
     }
 
     /**
      * Returns the type of collection to use for the given type. The current implementation can
-     * return only two values: <code>{@linkplain Set}.class</code> if the attribute should not
+     * return only two values: <code>{@linkplain Set}.class</code> if the property should not
      * accept duplicated values, or <code>{@linkplain List}.class</code> otherwise. Future SIS
      * versions may accept other types.
      *
@@ -444,11 +590,29 @@ public abstract class ModifiableMetadata
      * @param  <E> The type of elements in the collection to be created.
      * @param  elementType The type of elements in the collection to be created.
      * @return {@code List.class} or {@code Set.class} depending on whether the
-     *         attribute shall accept duplicated values or not.
+     *         property shall accept duplicated values or not.
      */
     @SuppressWarnings({"rawtypes","unchecked"})
     protected <E> Class<? extends Collection<E>> collectionType(final Class<E> elementType) {
         return (Class) (CodeList.class.isAssignableFrom(elementType) ||
                             Enum.class.isAssignableFrom(elementType) ? Set.class : List.class);
     }
+
+    /**
+     * Returns a shallow copy of this metadata.
+     *
+     * {@section Usage}
+     * While {@linkplain Cloneable cloneable}, this class do not provides the {@code clone()}
+     * operation as part of the public API. The clone operation is required for the internal
+     * working of the {@link #unmodifiable()} method, which needs <strong>shallow</strong>
+     * copies of metadata entities. The default {@link Object#clone()} implementation is
+     * sufficient in most cases.
+     *
+     * @return A <strong>shallow</strong> copy of this metadata.
+     * @throws CloneNotSupportedException if the clone is not supported.
+     */
+    @Override
+    protected ModifiableMetadata clone() throws CloneNotSupportedException {
+        return (ModifiableMetadata) super.clone();
+    }
 }

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java (from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -105,7 +105,7 @@ final class PropertyAccessor {
      *        less objects since <code>IdentityHashMap</code> implementation doesn't need the chain
      *        of objects created by <code>HashMap</code>.}
      */
-    private static final Map<Class<?>, Method[]> SHARED_GETTERS = new IdentityHashMap<>();
+    private static final Map<Class<?>, Method[]> SHARED_GETTERS = new IdentityHashMap<Class<?>, Method[]>();
 
     /**
      * Additional getter to declare in every list of getter methods that do not already provide
@@ -250,7 +250,7 @@ final class PropertyAccessor {
         /*
          * Compute all information derived from getters: setters, property names, value types.
          */
-        mapping      = new HashMap<>(hashMapCapacity(allCount));
+        mapping      = new HashMap<String,Integer>(hashMapCapacity(allCount));
         names        = new String[allCount];
         elementTypes = new Class<?>[allCount];
         Method[] setters = null;
@@ -378,7 +378,7 @@ final class PropertyAccessor {
                 getters = type.getMethods();
                 // Following is similar in purpose to the PropertyAccessor.mapping field,
                 // but index values are different because of the call to Arrays.sort(...).
-                final Map<String,Integer> mapping = new HashMap<>(hashMapCapacity(getters.length));
+                final Map<String,Integer> mapping = new HashMap<String,Integer>(hashMapCapacity(getters.length));
                 boolean hasExtraGetter = false;
                 int count = 0;
                 for (final Method candidate : getters) {
@@ -659,7 +659,7 @@ final class PropertyAccessor {
             if (range != null) {
                 descriptor = new PropertyDescriptor.Bounded(elementType, standard, name, getter, range);
             } else {
-                descriptor = new PropertyDescriptor<>(elementType, standard, name, getter);
+                descriptor = new PropertyDescriptor(elementType, standard, name, getter);
             }
             descriptors[index] = descriptor;
         }

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java (from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyDescriptor.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -35,7 +35,7 @@ import org.apache.sis.measure.ValueRange
 import org.apache.sis.util.iso.Types;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**
@@ -118,7 +118,7 @@ class PropertyDescriptor<T> extends Simp
                 final String property, final Method getter, final ValueRange range)
         {
             super(type, standard, property, getter);
-            this.range = new NumberRange<>(type, range);
+            this.range = new NumberRange<T>(type, range);
         }
 
         /** Returns the minimum parameter value, assumed inclusive. */

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java (from r1452374, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -83,7 +83,7 @@ final class StandardImplementation exten
         this.implementationPackage = implementationPackage;
         this.prefix                = prefix;
         this.acronyms              = acronyms;
-        this.implementations       = new IdentityHashMap<>();
+        this.implementations       = new IdentityHashMap<Class<?>,Class<?>>();
     }
 
     /**

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/UnmodifiableMetadataException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/UnmodifiableMetadataException.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/UnmodifiableMetadataException.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/UnmodifiableMetadataException.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -18,9 +18,15 @@ package org.apache.sis.metadata;
 
 
 /**
- * Thrown when a setter method is invoked on an initially
- * {@linkplain org.apache.sis.metadata.ModifiableMetadata modifiable metadata},
- * but this metadata has since be declared unmodifiable.
+ * Thrown on attempt to set a read-only value in a metadata object.
+ * This exception may happen in the following scenarios:
+ *
+ * <ul>
+ *   <li>A metadata instance was initially {@linkplain org.apache.sis.metadata.ModifiableMetadata
+ *       modifiable}, but that instance has since be declared unmodifiable.</li>
+ *   <li>A write operation has been attempted on the {@linkplain AbstractMetadata#asMap() map view},
+ *       but the metadata object has no corresponding setter methods.</li>
+ * </ul>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.4)

Modified: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java?rev=1452389&r1=1452374&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -47,7 +47,7 @@ public final strictfp class PropertyDesc
     private static <T> PropertyDescriptor<T> create(final Class<T> elementType, final String method,
             final String property) throws NoSuchMethodException
     {
-        return new PropertyDescriptor<>(elementType, new SimpleCitation("ISO 19115"), property,
+        return new PropertyDescriptor<T>(elementType, new SimpleCitation("ISO 19115"), property,
                 Citation.class.getMethod(method));
     }
 

Modified: sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -37,6 +37,9 @@ public final class Utilities extends Sta
      * Default tolerance threshold for comparing ordinate values in a projected CRS,
      * assuming that the unit of measurement is metre. This is not a tolerance for
      * testing map projection accuracy.
+     *
+     * @see #ANGULAR_TOLERANCE
+     * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD
      */
     public static final double LINEAR_TOLERANCE = 1.0;
 
@@ -44,6 +47,9 @@ public final class Utilities extends Sta
      * Default tolerance threshold for comparing ordinate values in a geographic CRS,
      * assuming that the unit of measurement is decimal degrees and using the standard
      * nautical mile length.
+     *
+     * @see #LINEAR_TOLERANCE
+     * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD
      */
     public static final double ANGULAR_TOLERANCE = LINEAR_TOLERANCE / (1852 * 60);
 

Modified: sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -73,7 +73,7 @@ public final strictfp class GeneralDirec
     }
 
     /**
-     * Tests the {@link GeneralDirectPosition#GeneralDirectPosition(String)} constructor
+     * Tests the {@link GeneralDirectPosition#GeneralDirectPosition(CharSequence)} constructor
      * with invalid input strings.
      */
     @Test

Modified: sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -428,7 +428,7 @@ public final strictfp class GeneralEnvel
     }
 
     /**
-     * Tests the {@link GeneralEnvelope#GeneralEnvelope(String)} constructor.
+     * Tests the {@link GeneralEnvelope#GeneralEnvelope(CharSequence)} constructor.
      */
     @Test
     public void testWktParsing() {
@@ -482,7 +482,8 @@ public final strictfp class GeneralEnvel
     }
 
     /**
-     * Tests the {@link GeneralEnvelope#equals} method.
+     * Tests the {@link GeneralEnvelope#equals(Object)} and
+     * {@link GeneralEnvelope#equals(Envelope, double, boolean)} methods.
      */
     @Test
     public void testEquals() {

Modified: sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -21,7 +21,7 @@ import org.junit.runners.Suite;
 
 
 /**
- * All tests from the {@code sis-utility} module, in approximative dependency order.
+ * All tests from the {@code sis-referencing} module, in approximative dependency order.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -171,10 +171,10 @@ public final class CodeListProxy {
         codeList = schema(context, "gmxCodelists.xml", classID);
         /*
          * Get the localized name of the field identifier, if possible.
-         * This code partially duplicates Types.getCodeTitle(CodeList, Locale).
+         * This code partially duplicates Types.getCodeTitle(CodeList).
          * This duplication exists because this constructor stores more information in
          * an opportunist way. If this constructor is updated, please consider updating
-         * the Types.getCodeTitle(CodeList, Locale) method accordingly.
+         * the Types.getCodeTitle(CodeList) method accordingly.
          */
         final Locale locale = context.getLocale();
         if (locale != null) {
@@ -192,7 +192,7 @@ public final class CodeListProxy {
             // Fallback when no value is defined for the code list. Build a value from the
             // most descriptive name (excluding the field name), which is usually the UML
             // name except for CharacterSet in which case it is a string like "UTF-8".
-            value = Types.getCodeTitle(code);
+            value = Types.getCodeLabel(code);
         }
         codeListValue = fieldID;
     }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -28,9 +28,11 @@ import org.opengis.metadata.citation.Pre
 import org.opengis.metadata.citation.ResponsibleParty;
 import org.opengis.metadata.citation.Series;
 import org.opengis.util.InternationalString;
-
 import org.apache.sis.util.iso.SimpleInternationalString;
 
+// Related to JDK7
+import org.apache.sis.internal.util.Objects;
+
 
 /**
  * A trivial implementation of {@link Citation}.
@@ -87,6 +89,28 @@ public class SimpleCitation implements C
     @Override public String                           getISSN()                    {return null;}
 
     /**
+     * Compares the given object with this citation for equality.
+     *
+     * @param  obj The object to compare with this citation.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj != null && obj.getClass() == getClass()) {
+            return Objects.equals(title, ((SimpleCitation) obj).title);
+        }
+        return false;
+    }
+
+    /**
+     * Returns a hash code value for this citation.
+     */
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(title) ^ (int) serialVersionUID;
+    }
+
+    /**
      * Returns a string representation of this citation.
      */
     @Override

Copied: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java (from r1452374, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?p2=sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java&r1=1452374&r2=1452389&rev=1452389&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -27,7 +27,7 @@ import org.apache.sis.util.Classes;
 import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -18,6 +18,7 @@ package org.apache.sis.internal.util;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
+import net.jcip.annotations.NotThreadSafe;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.resources.Errors;
 
@@ -31,15 +32,18 @@ import org.apache.sis.util.resources.Err
  * @version 0.3
  * @module
  */
+@NotThreadSafe
 @Workaround(library="JDK", version="1.7")
-public final class Cloner {
+public class Cloner {
     /**
      * The type of the object to clone, or {@code null} if not yet specified.
+     * Used for checking if the cached {@linkplain #method} is still valid.
      */
     private Class<?> type;
 
     /**
      * The {@code clone()} method, or {@code null} if not yet determined.
+     * This is cached for better performance if many instances of the same type are cloned.
      */
     private Method method;
 
@@ -50,7 +54,30 @@ public final class Cloner {
     }
 
     /**
-     * Clones the given object.
+     * Invoked when the given object can not be cloned because no public {@code clone()} method
+     * has been found. If this method returns {@code true}, then the {@link #clone(Object)}
+     * method in this class will throw a {@link CloneNotSupportedException}. Otherwise the
+     * {@code clone(Object)} method will return the original object.
+     *
+     * <p>The default implementation returns {@code true} in every cases.
+     * Subclasses can override this method if they need a different behavior.</p>
+     *
+     * @param  object The object that can not be cloned.
+     * @return {@code true} if the problem shall be considered a clone failure.
+     */
+    protected boolean isCloneRequired(final Object object) {
+        return true;
+    }
+
+    /**
+     * Clones the given object. If the given object does not provide a public {@code clone()}
+     * method, then there is a choice:
+     *
+     * <ul>
+     *   <li>If {@code isCloneRequired(object)} returns {@code true} (the default),
+     *       then a {@link CloneNotSupportedException} is thrown.</li>
+     *   <li>Otherwise the given object is returned.</li>
+     * </ul>
      *
      * @param  object The object to clone, or {@code null}.
      * @return A clone of the given object, or {@code null} if {@code object} was null.
@@ -66,7 +93,9 @@ public final class Cloner {
                 method = valueType.getMethod("clone", (Class<?>[]) null);
                 type = valueType; // Set only if the above line succeed.
             }
-            return method.invoke(object, (Object[]) null);
+            if (method != null) { // May be null if previous call threw NoSuchMethodException.
+                return method.invoke(object, (Object[]) null);
+            }
         } catch (InvocationTargetException e) {
             final Throwable cause = e.getCause();
             if (cause instanceof CloneNotSupportedException) {
@@ -79,9 +108,16 @@ public final class Cloner {
                 throw (Error) cause;
             }
             throw fail(e);
+        } catch (NoSuchMethodException e) {
+            if (isCloneRequired(object)) {
+                throw fail(e);
+            }
+            method = null;
+            type = valueType;
         } catch (Exception e) { // (ReflectiveOperationException) on JDK7
             throw fail(e);
         }
+        return object;
     }
 
     /**
@@ -91,7 +127,7 @@ public final class Cloner {
      * @param  cause The cause for the failure to clone an object.
      * @return An exception with an error message and the given cause.
      */
-    public CloneNotSupportedException fail(final Throwable cause) {
+    private CloneNotSupportedException fail(final Throwable cause) {
         CloneNotSupportedException e = new CloneNotSupportedException(
                 Errors.format(Errors.Keys.CloneNotSupported_1, type));
         e.initCause(cause);

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -21,6 +21,9 @@ import java.util.FormattableFlags;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 
+import static java.lang.Math.abs;
+import static java.lang.Math.max;
+
 
 /**
  * Miscellaneous utilities which should not be put in public API.
@@ -32,6 +35,31 @@ import org.apache.sis.util.CharSequences
  */
 public final class Utilities extends Static {
     /**
+     * Relative difference tolerated when comparing floating point numbers using
+     * {@link org.apache.sis.util.ComparisonMode#APPROXIMATIVE}.
+     *
+     * <p>Historically, this was the relative tolerance threshold for considering two
+     * matrixes as equal. This value has been determined empirically in order to allow
+     * {@link org.apache.sis.referencing.operation.transform.ConcatenatedTransform} to
+     * detect the cases where two {@link org.apache.sis.referencing.operation.transform.LinearTransform}
+     * are equal for practical purpose. This threshold can be used as below:</p>
+     *
+     * {@preformat java
+     *     Matrix m1 = ...;
+     *     Matrix m2 = ...;
+     *     if (Matrices.epsilonEqual(m1, m2, EQUIVALENT_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
+     */
+    public static final double COMPARISON_THRESHOLD = 1E-14;
+
+    /**
      * Bit mask to isolate the sign bit of non-{@linkplain Double#isNaN(double) NaN} values in a
      * {@code double}. For any real value, the following code evaluate to 0 if the given value is
      * positive:
@@ -57,6 +85,38 @@ public final class Utilities extends Sta
     }
 
     /**
+     * Returns {@code true} if the given values are approximatively equal,
+     * up to the {@linkplain #COMPARISON_THRESHOLD comparison threshold}.
+     *
+     * @param  v1 The first value to compare.
+     * @param  v2 The second value to compare.
+     * @return {@code true} If both values are approximatively equal.
+     */
+    public static boolean epsilonEqual(final double v1, final double v2) {
+        final double threshold = COMPARISON_THRESHOLD * max(abs(v1), abs(v2));
+        if (threshold == Double.POSITIVE_INFINITY || Double.isNaN(threshold)) {
+            return Double.doubleToLongBits(v1) == Double.doubleToLongBits(v2);
+        }
+        return abs(v1 - v2) <= threshold;
+    }
+
+    /**
+     * Returns {@code true} if the following objects are floating point numbers ({@link Float} or
+     * {@link Double} types) and approximatively equal. If the given object are not floating point
+     * numbers, then this method returns {@code false} unconditionally on the assumption that
+     * strict equality has already been checked before this method call.
+     *
+     * @param  v1 The first value to compare.
+     * @param  v2 The second value to compare.
+     * @return {@code true} If both values are real number and approximatively equal.
+     */
+    public static boolean floatEpsilonEqual(final Object v1, final Object v2) {
+        return (v1 instanceof Float || v1 instanceof Double) &&
+               (v2 instanceof Float || v2 instanceof Double) &&
+               epsilonEqual(((Number) v1).doubleValue(), ((Number) v2).doubleValue());
+    }
+
+    /**
      * Formats the given character sequence to the given formatter. This method takes in account
      * the {@link FormattableFlags#UPPERCASE} and {@link FormattableFlags#LEFT_JUSTIFY} flags.
      *

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -17,7 +17,7 @@
 package org.apache.sis.io;
 
 import java.util.Map;
-import java.util.HashMap;
+import java.util.IdentityHashMap;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.Date;
@@ -95,7 +95,7 @@ public abstract class CompoundFormat<T> 
      * The formats for smaller unit of information.
      * Will be created only when first needed.
      */
-    private transient Map<Class<?>,Format> formats;
+    private transient Map<Class<?>, Format> formats;
 
     /**
      * Creates a new format for the given locale. The given locale can be {@code null} or
@@ -328,7 +328,7 @@ public abstract class CompoundFormat<T> 
             format = createFormat(type);
             if (format != null) {
                 if (formats == null) {
-                    this.formats = formats = new HashMap<Class<?>,Format>(4);
+                    this.formats = formats = new IdentityHashMap<Class<?>,Format>(4);
                 }
                 formats.put(type, format);
                 break;
@@ -399,7 +399,7 @@ public abstract class CompoundFormat<T> 
         @SuppressWarnings("unchecked")
         final CompoundFormat<T> clone = (CompoundFormat<T>) super.clone();
         if (clone.formats != null) {
-            clone.formats = new HashMap<Class<?>,Format>(clone.formats);
+            clone.formats = new IdentityHashMap<Class<?>,Format>(clone.formats);
             for (final Map.Entry<Class<?>,Format> entry : clone.formats.entrySet()) {
                 entry.setValue((Format) entry.getValue().clone());
             }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -97,7 +97,7 @@ final class DefaultFormat extends Format
      * @throws NumberFormatException If the parsing failed.
      */
     private Object valueOf(final String source) throws NumberFormatException {
-        return (type != Number.class) ? Numbers.valueOf(type, source) : Numbers.narrowestNumber(source);
+        return (type != Number.class) ? Numbers.valueOf(source, type) : Numbers.narrowestNumber(source);
     }
 
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -141,6 +141,25 @@ public class MeasurementRange<E extends 
     }
 
     /**
+     * Constructs a range of the given type with values from the given annotation.
+     * This constructor does not verify if the given type is wide enough for the values of
+     * the given annotation, because those information are usually static. If nevertheless
+     * the given type is not wide enough, then the values are truncated in the same way
+     * than the Java language casts primitive types.
+     *
+     * @param  type  The element type, restricted to one of {@link Byte}, {@link Short},
+     *               {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
+     * @param  range The range of values.
+     * @param  unit  The unit of measurement, or {@code null} if unknown.
+     * @throws IllegalArgumentException If the given type is not one of the primitive
+     *         wrappers for numeric types.
+     */
+    public MeasurementRange(final Class<E> type, final ValueRange range, final Unit<?> unit) throws IllegalArgumentException {
+        super(type, range);
+        this.unit = unit;
+    }
+
+    /**
      * Constructs a range of {@link Number} objects.
      *
      * @param type          The element type, usually one of {@link Float} or {@link Double}.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -270,6 +270,24 @@ public class NumberRange<E extends Numbe
     }
 
     /**
+     * Constructs a range of the given type with values from the given annotation.
+     * This constructor does not verify if the given type is wide enough for the values of
+     * the given annotation, because those information are usually static. If nevertheless
+     * the given type is not wide enough, then the values are truncated in the same way
+     * than the Java language casts primitive types.
+     *
+     * @param  type  The element type, restricted to one of {@link Byte}, {@link Short},
+     *               {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
+     * @param  range The range of values.
+     * @throws IllegalArgumentException If the given type is not one of the primitive
+     *         wrappers for numeric types.
+     */
+    public NumberRange(final Class<E> type, final ValueRange range) throws IllegalArgumentException {
+        super(type, Numbers.cast(valueOf("minimum", range.minimum(), Double.NEGATIVE_INFINITY), type), range.isMinIncluded(),
+                    Numbers.cast(valueOf("maximum", range.maximum(), Double.POSITIVE_INFINITY), type), range.isMaxIncluded());
+    }
+
+    /**
      * Constructs a range of {@link Number} objects.
      *
      * @param type           The element type, usually one of {@link Byte}, {@link Short},

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -182,7 +182,7 @@ public class RangeFormat extends Format 
     // All "character" fields below are code point values.
     /**
      * The character opening an empty range or a range containing only one element.
-     * The default value is {@code '{'}.
+     * The default value is <code>'&#123;'</code>.
      */
     private final int openSet;
 
@@ -208,7 +208,7 @@ public class RangeFormat extends Format 
 
     /**
      * The character closing an empty range or a range containing only one element.
-     * The default value is {@code '}'}.
+     * The default value is <code>'&#125;'</code>.
      */
     private final int closeSet;
 

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/package-info.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/package-info.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -26,7 +26,8 @@
  *       {@link org.apache.sis.measure.Latitude})</li>
  *   <li>{@link org.apache.sis.measure.Range} and its subclasses
  *      ({@link org.apache.sis.measure.NumberRange},
- *       {@link org.apache.sis.measure.MeasurementRange})</li>
+ *       {@link org.apache.sis.measure.MeasurementRange}) or annotation
+ *      ({@link org.apache.sis.measure.ValueRange}</li>
  *   <li>Formatters
  *      ({@link org.apache.sis.measure.AngleFormat},
  *       {@link org.apache.sis.measure.CoordinateFormat},

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -44,7 +44,7 @@ import static org.apache.sis.util.collec
  *       ({@link #findCommonClass(Class, Class) findCommonClass},
  *        {@link #findCommonInterfaces(Class, Class) findCommonInterfaces})</li>
  *   <li>Getting the bounds of a parameterized field or method
- *       ({@link #boundOfParameterizedAttribute(Method) boundOfParameterizedAttribute})</li>
+ *       ({@link #boundOfParameterizedProperty(Method) boundOfParameterizedProperty})</li>
  *   <li>Getting a short class name ({@link #getShortName(Class) getShortName},
  *       {@link #getShortClassName(Object) getShortClassName})</li>
  * </ul>
@@ -137,8 +137,8 @@ public final class Classes extends Stati
     }
 
     /**
-     * Returns the upper bounds of the parameterized type of the given attribute.
-     * If the attribute does not have a parameterized type, returns {@code null}.
+     * Returns the upper bounds of the parameterized type of the given property.
+     * If the property does not have a parameterized type, returns {@code null}.
      *
      * <p>This method is typically used for fetching the type of elements in a collection.
      * We do not provide a method working from a {@link Class} instance because of the way
@@ -162,14 +162,14 @@ public final class Classes extends Stati
      * @return The upper bound of parameterized type, or {@code null} if the given field
      *         is not of a parameterized type.
      */
-    public static Class<?> boundOfParameterizedAttribute(final Field field) {
+    public static Class<?> boundOfParameterizedProperty(final Field field) {
         return getActualTypeArgument(field.getGenericType());
     }
 
     /**
-     * If the given method is a getter or a setter for a parameterized attribute, returns the
+     * If the given method is a getter or a setter for a parameterized property, returns the
      * upper bounds of the parameterized type. Otherwise returns {@code null}. This method
-     * provides the same semantic than {@link #boundOfParameterizedAttribute(Field)}, but
+     * provides the same semantic than {@link #boundOfParameterizedProperty(Field)}, but
      * works on a getter or setter method rather then the field. See the javadoc of above
      * method for more details.
      *
@@ -181,7 +181,7 @@ public final class Classes extends Stati
      * @return The upper bound of parameterized type, or {@code null} if the given method
      *         do not operate on an object of a parameterized type.
      */
-    public static Class<?> boundOfParameterizedAttribute(final Method method) {
+    public static Class<?> boundOfParameterizedProperty(final Method method) {
         Class<?> c = getActualTypeArgument(method.getGenericReturnType());
         if (c == null) {
             final Type[] parameters = method.getGenericParameterTypes();
@@ -636,7 +636,7 @@ cmp:    for (final Class<?> c : c1) {
     }
 
     /**
-     * Returns {@code true} if the given method may possibly be the getter method for an attribute.
+     * Returns {@code true} if the given method may possibly be the getter method for a property.
      * This method implements the algorithm used by SIS in order to identify getter methods in
      * {@linkplain org.opengis.metadata metadata} interfaces. We do not rely on naming convention
      * (method names starting with "{@code get}" or "{@code is}" prefixes) because not every methods

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -17,7 +17,7 @@
 package org.apache.sis.util;
 
 import java.util.Map;
-import java.util.HashMap;
+import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Queue;
 import java.util.Set;
@@ -51,8 +51,16 @@ public final class Numbers extends Stati
 
     /**
      * Mapping between a primitive type and its wrapper, if any.
+     *
+     * {@note In the particular case of <code>Class</code> keys, <code>IdentityHashMap</code> and
+     *        <code>HashMap</code> have identical behavior since <code>Class</code> is final and
+     *        does not override the <code>equals(Object)</code> and <code>hashCode()</code> methods.
+     *        The <code>IdentityHashMap</code> Javadoc claims that it is faster than the regular
+     *        <code>HashMap</code>. But maybe the most interesting property is that it allocates
+     *        less objects since <code>IdentityHashMap</code> implementation doesn't need the chain
+     *        of objects created by <code>HashMap</code>.}
      */
-    private static final Map<Class<?>,Numbers> MAPPING = new HashMap<Class<?>,Numbers>(16);
+    private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(16);
     static {
         new Numbers(BigDecimal.class, true, false, (byte) (DOUBLE+2)); // Undocumented enum.
         new Numbers(BigInteger.class, false, true, (byte) (DOUBLE+1)); // Undocumented enum.
@@ -275,6 +283,7 @@ public final class Numbers extends Stati
         }
         if (c1 == null) return c2;
         if (c2 == null) return c1;
+        // At this point, m1 and m2 can not be null.
         return (m1.ordinal >= m2.ordinal) ? c1 : c2;
     }
 
@@ -336,6 +345,7 @@ public final class Numbers extends Stati
         }
         if (c1 == null) return c2;
         if (c2 == null) return c1;
+        // At this point, m1 and m2 can not be null.
         return (m1.ordinal < m2.ordinal) ? c1 : c2;
     }
 
@@ -511,9 +521,9 @@ public final class Numbers extends Stati
      *
      * <ul>
      *   <li>If the given type is {@code Double.class}, then this method returns
-     *       <code>{@linkplain Double#valueOf(double) Double.valueOf}(n.doubleValue())</code>;</li>
+     *       <code>{@linkplain Double#valueOf(double) Double.valueOf}(number.doubleValue())</code>;</li>
      *   <li>If the given type is {@code Float.class}, then this method returns
-     *       <code>{@linkplain Float#valueOf(float) Float.valueOf}(n.floatValue())</code>;</li>
+     *       <code>{@linkplain Float#valueOf(float) Float.valueOf}(number.floatValue())</code>;</li>
      *   <li>And likewise for all remaining known types.</li>
      * </ul>
      *
@@ -527,27 +537,60 @@ public final class Numbers extends Stati
      * then the behavior depends on the implementation of the corresponding
      * {@code Number.fooValue()} method - typically, the value is just rounded or truncated.
      *
-     * @param  <N> The class to cast to.
-     * @param  n The number to cast.
-     * @param  c The destination type.
-     * @return The number casted to the given type.
+     * @param  <N>    The class to cast to.
+     * @param  number The number to cast, or {@code null}.
+     * @param  type   The destination type.
+     * @return The number casted to the given type, or {@code null} if the given value was null.
      * @throws IllegalArgumentException If the given type is not one of the primitive
      *         wrappers for numeric types.
      */
     @SuppressWarnings("unchecked")
-    public static <N extends Number> N cast(final Number n, final Class<N> c)
+    public static <N extends Number> N cast(final Number number, final Class<N> type)
             throws IllegalArgumentException
     {
-        if (n == null || n.getClass() == c) {
-            return (N) n;
+        if (number == null || number.getClass() == type) {
+            return (N) number;
         }
-        if (c == Byte   .class) return (N) Byte   .valueOf(n.  byteValue());
-        if (c == Short  .class) return (N) Short  .valueOf(n. shortValue());
-        if (c == Integer.class) return (N) Integer.valueOf(n.   intValue());
-        if (c == Long   .class) return (N) Long   .valueOf(n.  longValue());
-        if (c == Float  .class) return (N) Float  .valueOf(n. floatValue());
-        if (c == Double .class) return (N) Double .valueOf(n.doubleValue());
-        throw unknownType(c);
+        if (type == Double .class) return (N) Double .valueOf(number.doubleValue());
+        if (type == Float  .class) return (N) Float  .valueOf(number. floatValue());
+        if (type == Long   .class) return (N) Long   .valueOf(number.  longValue());
+        if (type == Integer.class) return (N) Integer.valueOf(number.   intValue());
+        if (type == Short  .class) return (N) Short  .valueOf(number. shortValue());
+        if (type == Byte   .class) return (N) Byte   .valueOf(number.  byteValue());
+        throw unknownType(type);
+    }
+
+    /**
+     * Wraps the given value in a {@code Number} of the specified class.
+     * The given type shall be one of {@link Byte}, {@link Short}, {@link Integer},
+     * {@link Long}, {@link Float} or {@link Double} classes. Furthermore, the given
+     * value shall be convertible to the given class without precision lost,
+     * otherwise an {@link IllegalArgumentException} will be thrown.
+     *
+     * @param  <N> The wrapper class.
+     * @param  value The value to wrap.
+     * @param  type The desired wrapper class.
+     * @return The value wrapped in an object of the given class.
+     * @throws IllegalArgumentException If the given type is not one of the primitive
+     *         wrappers for numeric types, or if the given value can not be wrapped in
+     *         an instance of the given class without precision lost.
+     */
+    @SuppressWarnings("unchecked")
+    public static <N extends Number> N wrap(final double value, final Class<N> type)
+            throws IllegalArgumentException
+    {
+        final N number;
+             if (type == Double .class) return   (N) Double .valueOf(value); // No need to verify.
+        else if (type == Float  .class) number = (N) Float  .valueOf((float) value);
+        else if (type == Long   .class) number = (N) Long   .valueOf((long)  value);
+        else if (type == Integer.class) number = (N) Integer.valueOf((int)   value);
+        else if (type == Short  .class) number = (N) Short  .valueOf((short) value);
+        else if (type == Byte   .class) number = (N) Byte   .valueOf((byte)  value);
+        else throw unknownType(type);
+        if (Double.doubleToLongBits(number.doubleValue()) != Double.doubleToLongBits(value)) {
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.CanNotConvertValue_2, value, type));
+        }
+        return number;
     }
 
     /**
@@ -570,15 +613,15 @@ public final class Numbers extends Stati
      *        <code>ConverterRegistry</code> class for a more generic method.}
      *
      * @param  <T> The requested type.
-     * @param  type The requested type.
      * @param  value the value to parse.
+     * @param  type The requested type.
      * @return The value object, or {@code null} if {@code value} was null.
      * @throws IllegalArgumentException if {@code type} is not a recognized type.
      * @throws NumberFormatException if {@code type} is a subclass of {@link Number} and the
      *         string value is not parseable as a number of the specified type.
      */
     @SuppressWarnings("unchecked")
-    public static <T> T valueOf(final Class<T> type, String value)
+    public static <T> T valueOf(String value, final Class<T> type)
             throws IllegalArgumentException, NumberFormatException
     {
         if (value == null || type == String.class) {

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java?rev=1452389&r1=1452388&r2=1452389&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java [UTF-8] Mon Mar  4 16:48:47 2013
@@ -19,6 +19,7 @@ package org.apache.sis.util;
 import java.util.Map;
 import java.util.Set;
 import org.apache.sis.util.collection.CollectionsExt;
+import org.apache.sis.util.resources.Errors;
 
 
 /**
@@ -49,6 +50,23 @@ public final class ObjectConverters exte
     }
 
     /**
+     * Returns a converter for the specified source and target classes.
+     *
+     * @param  <S> The source class.
+     * @param  <T> The target class.
+     * @param  source The source class.
+     * @param  target The target class, or {@code Object.class} for any.
+     * @return The converter from the specified source class to the target class.
+     * @throws UnconvertibleObjectException if no converter is found.
+     */
+    public static <S,T> ObjectConverter<S,T> find(final Class<S> source, final Class<T> target)
+            throws UnconvertibleObjectException
+    {
+        // TODO: port the implementation from Geotk
+        throw new UnconvertibleObjectException(Errors.format(Errors.Keys.CanNotConvertFromType_2, source, target));
+    }
+
+    /**
      * Returns a set whose elements are derived <cite>on-the-fly</cite> from the given set.
      * Conversions from the original elements to the derived elements are performed when needed
      * by invoking the {@link ObjectConverter#convert(Object)} method on the given converter.



Mime
View raw message