sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1767561 - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/ co...
Date Tue, 01 Nov 2016 20:21:02 GMT
Author: desruisseaux
Date: Tue Nov  1 20:21:01 2016
New Revision: 1767561

URL: http://svn.apache.org/viewvc?rev=1767561&view=rev
Log:
Merge units of measurement cleanup from JDK8 branch.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  1 20:21:01 2016
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1767108
+/sis/branches/JDK8:1584960-1767556
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -143,12 +143,12 @@ abstract class AbstractParser implements
     /**
      * Constructs a parser using the specified set of symbols.
      *
-     * @param symbols       The set of symbols to use.
-     * @param fragments     Reference to the {@link WKTFormat#fragments} map, or an empty map if none.
-     * @param numberFormat  The number format provided by {@link WKTFormat}, or {@code null} for a default format.
-     * @param dateFormat    The date format provided by {@link WKTFormat}, or {@code null} for a default format.
-     * @param unitFormat    The unit format provided by {@link WKTFormat}, or {@code null} for a default format.
-     * @param errorLocale   The locale for error messages (not for parsing), or {@code null} for the system default.
+     * @param  symbols       the set of symbols to use.
+     * @param  fragments     reference to the {@link WKTFormat#fragments} map, or an empty map if none.
+     * @param  numberFormat  the number format provided by {@link WKTFormat}, or {@code null} for a default format.
+     * @param  dateFormat    the date format provided by {@link WKTFormat}, or {@code null} for a default format.
+     * @param  unitFormat    the unit format provided by {@link WKTFormat}, or {@code null} for a default format.
+     * @param  errorLocale   the locale for error messages (not for parsing), or {@code null} for the system default.
      */
     AbstractParser(final Symbols symbols, final Map<String,Element> fragments, NumberFormat numberFormat,
             final DateFormat dateFormat, final UnitFormat unitFormat, final Locale errorLocale)
@@ -201,8 +201,8 @@ abstract class AbstractParser implements
      * Creates the object from a string. This method is for implementation of {@code createFromWKT(String)}
      * method is SIS factories only.
      *
-     * @param  text Coordinate system encoded in Well-Known Text format (version 1 or 2).
-     * @return The result of parsing the given text.
+     * @param  text  coordinate system encoded in Well-Known Text format (version 1 or 2).
+     * @return the result of parsing the given text.
      * @throws FactoryException if the object creation failed.
      *
      * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createFromWKT(String)
@@ -256,9 +256,9 @@ abstract class AbstractParser implements
     /**
      * Parses a <cite>Well Know Text</cite> (WKT).
      *
-     * @param  text The text to be parsed.
-     * @param  position The position to start parsing from.
-     * @return The parsed object.
+     * @param  text      the text to be parsed.
+     * @param  position  the position to start parsing from.
+     * @return the parsed object.
      * @throws ParseException if the string can not be parsed.
      */
     public Object parseObject(final String text, final ParsePosition position) throws ParseException {
@@ -289,8 +289,8 @@ abstract class AbstractParser implements
     /**
      * Parses the next element in the specified <cite>Well Know Text</cite> (WKT) tree.
      *
-     * @param  element The element to be parsed.
-     * @return The parsed object.
+     * @param  element  the element to be parsed.
+     * @return the parsed object.
      * @throws ParseException if the element can not be parsed.
      */
     abstract Object parseObject(final Element element) throws ParseException;
@@ -333,7 +333,7 @@ abstract class AbstractParser implements
     /**
      * Parses the given unit symbol.
      */
-    final Unit<?> parseUnit(final String text) throws ParseException, ParserException {
+    final Unit<?> parseUnit(final String text) throws ParserException {
         if (unitFormat == null) {
             final Locale locale = symbols.getLocale();
             if (locale == Locale.ROOT) {
@@ -348,10 +348,10 @@ abstract class AbstractParser implements
     /**
      * Reports a non-fatal warning that occurred while parsing a WKT.
      *
-     * @param parent  The parent element, or {@code null} if unknown.
-     * @param element The element that we can not parse, or {@code null} if unknown.
-     * @param message The message. Can be {@code null} only if {@code ex} is non-null.
-     * @param ex      The non-fatal exception that occurred while parsing the element, or {@code null}.
+     * @param  parent   the parent element, or {@code null} if unknown.
+     * @param  element  the element that we can not parse, or {@code null} if unknown.
+     * @param  message  the message. Can be {@code null} only if {@code ex} is non-null.
+     * @param  ex       the non-fatal exception that occurred while parsing the element, or {@code null}.
      */
     final void warning(final Element parent, final Element element, final InternationalString message, final Exception ex) {
         warning(parent, (element != null) ? element.keyword : null, message, ex);
@@ -360,10 +360,10 @@ abstract class AbstractParser implements
     /**
      * Reports a non-fatal warning that occurred while parsing a WKT.
      *
-     * @param parent  The parent element, or {@code null} if unknown.
-     * @param element The name of the element that we can not parse, or {@code null} if unknown.
-     * @param message The message. Can be {@code null} only if {@code ex} is non-null.
-     * @param ex      The non-fatal exception that occurred while parsing the element, or {@code null}.
+     * @param  parent   the parent element, or {@code null} if unknown.
+     * @param  element  the name of the element that we can not parse, or {@code null} if unknown.
+     * @param  message  the message. Can be {@code null} only if {@code ex} is non-null.
+     * @param  ex       the non-fatal exception that occurred while parsing the element, or {@code null}.
      */
     final void warning(final Element parent, final String element, final InternationalString message, final Exception ex) {
         if (warnings == null) {
@@ -380,7 +380,7 @@ abstract class AbstractParser implements
      * <p>The returned object is valid only before a new parsing starts. If a longer lifetime is desired,
      * then the caller <strong>must</strong> invokes {@link Warnings#publish()}.</p>
      *
-     * @param object The object that resulted from the parsing operation, or {@code null}.
+     * @param  object  the object that resulted from the parsing operation, or {@code null}.
      */
     final Warnings getAndClearWarnings(final Object object) {
         Warnings w = warnings;

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -633,7 +633,7 @@ class GeodeticObjectParser extends MathT
         }
         final String name   = element.pullString("name");
         final double factor = element.pullDouble("factor");
-        Unit<Q> unit   = Units.multiply(baseUnit, factor);
+        Unit<Q> unit   = baseUnit.multiply(factor);
         Unit<?> verify = parseUnitID(element);
         element.close(ignoredElements);
         /*
@@ -660,7 +660,7 @@ class GeodeticObjectParser extends MathT
         if (verify == null) {
             try {
                 verify = parseUnit(name);
-            } catch (ParserException | ParseException e) {
+            } catch (ParserException e) {
                 log(new LogRecord(Level.FINE, e.toString()));
             }
             if (verify != null) try {

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -242,7 +242,7 @@ class MathTransformParser extends Abstra
             return unit;
         }
         if (index >= 0 && index < BASE_UNITS.length) {
-            return Units.multiply(BASE_UNITS[index], factor);
+            return BASE_UNITS[index].multiply(factor);
         }
         // If we can not infer the base type, we have to rely on the name.
         try {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -273,7 +273,7 @@ public class CommonAuthorityFactory exte
      * of that authority is set to {@code "OGC"}. Apache SIS does that for consistency with the namespace used
      * in URNs (for example {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}).</p>
      *
-     * @return The <cite>"Web Map Service"</cite> authority.
+     * @return the <cite>"Web Map Service"</cite> authority.
      *
      * @see #getCodeSpaces()
      * @see Citations#WMS
@@ -301,7 +301,7 @@ public class CommonAuthorityFactory exte
      * {@code "AUTO1"} or {@code "AUTO2"} namespaces if present. If a namespace is found and is a legacy one, then
      * this {@link #LEGACY_MASK} bit will be set.
      *
-     * @return Index where the code begin, possibly with the {@link #LEGACY_MASK} bit set.
+     * @return index where the code begin, possibly with the {@link #LEGACY_MASK} bit set.
      * @throws NoSuchAuthorityCodeException if an authority is present but is not one of the recognized authorities.
      */
     private static int skipNamespace(final String code) throws NoSuchAuthorityCodeException {
@@ -358,8 +358,8 @@ public class CommonAuthorityFactory exte
      * The returned set contains a namespace followed by numeric identifiers
      * like {@code "CRS:84"}, {@code "CRS:27"}, {@code "AUTO2:42001"}, <i>etc</i>.
      *
-     * @param  type The spatial reference objects type.
-     * @return The set of authority codes for spatial reference objects of the given type.
+     * @param  type  the spatial reference objects type.
+     * @return the set of authority codes for spatial reference objects of the given type.
      * @throws FactoryException if this method failed to provide the set of codes.
      */
     @Override
@@ -412,7 +412,7 @@ public class CommonAuthorityFactory exte
      *       but its scope is wider than the above-cited namespaces.</li>
      * </ul>
      *
-     * @return A set containing at least the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} strings.
+     * @return a set containing at least the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} strings.
      *
      * @see #getAuthority()
      * @see Citations#WMS
@@ -437,8 +437,8 @@ public class CommonAuthorityFactory exte
      *   <tr><td>{@code AUTO2:42001,1,-100,45}</td> <td>WGS 84 / UTM zone 47N</td></tr>
      * </table>
      *
-     * @param  code Value in the CRS or AUTO(2) code space.
-     * @return A description of the object.
+     * @param  code  value in the CRS or AUTO(2) code space.
+     * @return a description of the object.
      * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
      * @throws FactoryException if an error occurred while fetching the description.
      */
@@ -491,8 +491,8 @@ public class CommonAuthorityFactory exte
      *       Note that some codes require coma-separated parameters after the integer value.</li>
      * </ol>
      *
-     * @param  code Value allocated by OGC.
-     * @return The coordinate reference system for the given code.
+     * @param  code  value allocated by OGC.
+     * @return the coordinate reference system for the given code.
      * @throws FactoryException if the object creation failed.
      */
     @Override
@@ -564,13 +564,13 @@ public class CommonAuthorityFactory exte
     /**
      * Creates a projected CRS from parameters in the {@code AUTO(2)} namespace.
      *
-     * @param  code        The user-specified code, used only for error reporting.
-     * @param  projection  The projection code (e.g. 42001).
+     * @param  code        the user-specified code, used only for error reporting.
+     * @param  projection  the projection code (e.g. 42001).
      * @param  isLegacy    {@code true} if the code was found in {@code "AUTO"} or {@code "AUTO1"} namespace.
-     * @param  factor      The multiplication factor for the unit of measurement.
-     * @param  longitude   A longitude in the desired projection zone.
-     * @param  latitude    A latitude in the desired projection zone.
-     * @return The projected CRS for the given projection and parameters.
+     * @param  factor      the multiplication factor for the unit of measurement.
+     * @param  longitude   a longitude in the desired projection zone.
+     * @param  latitude    a latitude in the desired projection zone.
+     * @return the projected CRS for the given projection and parameters.
      */
     @SuppressWarnings("null")
     private ProjectedCRS createAuto(final String code, final int projection, final boolean isLegacy,
@@ -625,11 +625,12 @@ public class CommonAuthorityFactory exte
              * At this point we got a coordinate system with axes in metres.
              * If the user asked for another unit of measurement, change the axes now.
              */
-            final Unit<Length> unit;
+            Unit<Length> unit;
             if (isLegacy) {
                 unit = createUnitFromEPSG(factor).asType(Length.class);
             } else {
-                unit = (factor != 1) ? Units.multiply(Units.METRE, factor) : Units.METRE;
+                unit = Units.METRE;
+                if (factor != 1) unit = unit.multiply(factor);
             }
             if (!Units.METRE.equals(unit)) {
                 cs = (CartesianCS) CoordinateSystems.replaceLinearUnit(cs, unit);
@@ -706,10 +707,10 @@ public class CommonAuthorityFactory exte
     /**
      * Creates an exception for an unknown authority code.
      *
-     * @param  localCode  The unknown authority code, without namespace.
-     * @param  code       The unknown authority code as specified by the user (may include namespace).
-     * @param  cause      The failure cause, or {@code null} if none.
-     * @return An exception initialized with an error message built from the specified informations.
+     * @param  localCode  the unknown authority code, without namespace.
+     * @param  code       the unknown authority code as specified by the user (may include namespace).
+     * @param  cause      the failure cause, or {@code null} if none.
+     * @return an exception initialized with an error message built from the specified informations.
      */
     private static NoSuchAuthorityCodeException noSuchAuthorityCode(String localCode, String code, Exception cause) {
         return (NoSuchAuthorityCodeException) new NoSuchAuthorityCodeException(Resources.format(Resources.Keys.NoSuchAuthorityCode_3,

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -160,7 +160,7 @@ import org.apache.sis.internal.util.Stan
  * @author  Andrea Aime (TOPP)
  * @author  Johann Sorel (Geomatys)
  * @since   0.7
- * @version 0.7
+ * @version 0.8
  * @module
  *
  * @see <a href="http://sis.apache.org/tables/CoordinateReferenceSystems.html">List of authority codes</a>
@@ -2406,7 +2406,7 @@ addURIs:    for (int i=0; ; i++) {
                 if (unit == null) {
                     final Unit<?> base = Units.valueOfEPSG(target);
                     if (base != null && !Double.isNaN(b) && !Double.isNaN(c)) {     // May be NaN if the conversion is non-linear.
-                        unit = Units.multiply(base, b/c);
+                        unit = Units.multiply(base, b, c);
                     } else try {
                         unit = Units.valueOf(getString(code, result, 5));           // Try parsing the unit symbol as a fallback.
                     } catch (ParserException e) {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -17,7 +17,6 @@
 package org.apache.sis.test.integration;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 import java.text.ParseException;
@@ -55,7 +54,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final strictfp class ConsistencyTest extends TestCase {
@@ -68,15 +67,6 @@ public final strictfp class ConsistencyT
     ));
 
     /**
-     * Codes to exclude from the {@link #lookup(CoordinateReferenceSystem, CoordinateReferenceSystem)} test.
-     * The reason why those tests are excluded now is related to the way JSR-275 parse units. We may resolve
-     * those issues when we will replace JSR-275 by another library.
-     */
-    private static final Set<String> LOOKUP_EXCLUDES = Collections.singleton(
-            "EPSG:5754"         // Poolbeg height. Uses British foot (1936).
-    );
-
-    /**
      * Verifies the WKT consistency of all CRS instances.
      *
      * @throws FactoryException if an error other than "unsupported operation method" occurred.
@@ -227,9 +217,6 @@ public final strictfp class ConsistencyT
             throws FactoryException
     {
         final Identifier id = IdentifiedObjects.getIdentifier(crs, null);
-        if (LOOKUP_EXCLUDES.contains(IdentifiedObjects.toString(id))) {
-            return;
-        }
         /*
          * Lookup operation is not going to work if the CRS are not approximatively equal.
          */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -83,8 +83,8 @@ abstract class StringConverter<T> extend
     /**
      * Creates a new converter for the given target class.
      *
-     * @param targetClass The {@linkplain #getTargetClass() target class}.
-     * @param inverse The inverse converter from the target to the source class.
+     * @param  targetClass  the {@linkplain #getTargetClass() target class}.
+     * @param  inverse      the inverse converter from the target to the source class.
      */
     @SuppressWarnings("OverridableMethodCallDuringObjectConstruction")
     StringConverter(final Class<T> targetClass) {
@@ -122,7 +122,7 @@ abstract class StringConverter<T> extend
      * This method verifies that the given string is non-null and non-empty,
      * then delegates to {@link #doConvert(String)}.
      *
-     * @param  source The string to convert, or {@code null}.
+     * @param  source  the string to convert, or {@code null}.
      * @return The converted value, or {@code null} if the given string was null or empty.
      * @throws UnconvertibleObjectException If an error occurred during the conversion.
      */
@@ -145,7 +145,7 @@ abstract class StringConverter<T> extend
      * Invoked by {@link #apply(String)} for converting the given string to the target
      * type of this converter.
      *
-     * @param  source The string to convert, guaranteed to be non-null and non-empty.
+     * @param  source  the string to convert, guaranteed to be non-null and non-empty.
      * @return The converted value.
      * @throws Exception If an error occurred during the conversion.
      */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -105,7 +105,7 @@ public final class DecimalFunctions exte
      * public {@link MathFunctions#pow10(int)} method, defined here in order to allow the
      * JVM to initialize the {@link #POW10} table only when first needed.
      *
-     * @param x The exponent.
+     * @param  x  the exponent.
      * @return 10 raised to the given exponent.
      */
     static double pow10(int x) {
@@ -146,7 +146,7 @@ public final class DecimalFunctions exte
          */
         final int e = Math.getExponent(value) - Numerics.SIGNIFICAND_SIZE_OF_FLOAT;
         if (e >= 0) {
-            return value; // Integer, infinity or NaN.
+            return value;                               // Integer, infinity or NaN.
         }
         final int m = Numerics.getSignificand(value);
         assert Math.scalb((float) m, e) == Math.abs(value) : value;
@@ -162,9 +162,9 @@ public final class DecimalFunctions exte
          *
          * Note: the conversation factor c is also equals to 1 ULP converted to the units of (m × c).
          */
-        final int    e10 = -Numerics.toExp10(e);        // Range: [0 … 45] inclusive.
-        final double c   = Math.scalb(pow10(e10), e);   // Range: (1 … 10) exclusive.
-        final double mc  = m * c;                       // Only integer part is meaningful.
+        final int    e10 = -Numerics.toExp10(e);                // Range: [0 … 45] inclusive.
+        final double c   = Math.scalb(pow10(e10), e);           // Range: (1 … 10) exclusive.
+        final double mc  = m * c;                               // Only integer part is meaningful.
         /*
          * First, presume that our representation in base 10 has one extranous digit, so we will round
          * to the tens instead of unities. If the difference appears to not be smaller than half a ULP,
@@ -212,8 +212,8 @@ public final class DecimalFunctions exte
      * threshold, this method returns {@code NaN} because of insufficient algorithm accuracy.
      * This limitation may change in any future SIS version if we find a better algorithm.
      *
-     * @param  value The value for which to get the delta compared to its base 10 representation.
-     * @return The delta that would need to be added to the given {@code double} value for getting a result
+     * @param  value  the value for which to get the delta compared to its base 10 representation.
+     * @return the delta that would need to be added to the given {@code double} value for getting a result
      *         closer to its base 10 representation, or {@link Double#NaN NaN} if it can not be computed.
      */
     public static double deltaForDoubleToDecimal(final double value) {
@@ -225,18 +225,18 @@ public final class DecimalFunctions exte
          */
         final int e = Math.getExponent(value) - SIGNIFICAND_SIZE;
         if (e >= 0) {
-            return 0; // Integer, infinity or NaN.
+            return 0;                                   // Integer, infinity or NaN.
         }
-        if (e < -24 - SIGNIFICAND_SIZE) {         // 2.9802322E-8 threshold found empirically.
-            return (e == -1075) ? 0 : Double.NaN; // Returns 0 for the 0 value, NaN for all others.
+        if (e < -24 - SIGNIFICAND_SIZE) {               // 2.9802322E-8 threshold found empirically.
+            return (e == -1075) ? 0 : Double.NaN;       // Returns 0 for the 0 value, NaN for all others.
         }
         final long m = Numerics.getSignificand(value);
         assert Math.scalb((double) m, e) == Math.abs(value) : value;
-        final int e10 = -Numerics.toExp10(e); // Range: [0 … 324] inclusive.
+        final int e10 = -Numerics.toExp10(e);           // Range: [0 … 324] inclusive.
         /*
          * If we were continuing with the same strategy than in floatToDouble(float), we would compute:
          *
-         *    c = Math.scalb(pow10(e10), e);  // Range: (1 … 10) exclusive.
+         *    c = Math.scalb(pow10(e10), e);            // Range: (1 … 10) exclusive.
          *
          * Unfortunately this would require a floating point type with twice the accuracy of 'double',
          * which we don't have. Instead, we will apply a trick with integer arithmetic. But before to
@@ -249,8 +249,8 @@ public final class DecimalFunctions exte
          * will be equals or greater than 2^52. At that threshold, 'double' values can not have
          * fraction digits.
          */
-        final int PRECISION = SIGNIFICAND_SIZE + 4;            // Number of bits to use for scaling to integers.
-        double cs = Math.scalb(pow10(e10 - 1), e + PRECISION); // Range: (0.1 × 2^56  …  2^56) exclusive.
+        final int PRECISION = SIGNIFICAND_SIZE + 4;               // Number of bits to use for scaling to integers.
+        double cs = Math.scalb(pow10(e10 - 1), e + PRECISION);    // Range: (0.1 × 2^56  …  2^56) exclusive.
         /*
          * This is where magic happen: the following multiplication overflow (we would need a 128 bits integer
          * for representing it), but we don't care because we are interrested only in the fraction digits (the
@@ -269,8 +269,8 @@ public final class DecimalFunctions exte
          * The above digit is guaranteed to be in the [0 … 9] range. We will wraparound in the [-5 … 4] range
          * because the delta must be no more than ±0.5 ULP of the 'value' argument.
          */
-        if (mc >= (5L << PRECISION) / 10) { // The  0.5 × 2^56  threshold.
-            mc -= (1L << PRECISION);        // Shift [5 … 9] digits to [-5 … -1].
+        if (mc >= (5L << PRECISION) / 10) {                 // The  0.5 × 2^56  threshold.
+            mc -= (1L << PRECISION);                        // Shift [5 … 9] digits to [-5 … -1].
         }
         /*
          * At this point, 'mc' is less than 0.5 ULP if the last decimal digits were zero.
@@ -283,8 +283,8 @@ public final class DecimalFunctions exte
          * we care only about the remainder after we removed the effet of that last digit.
          */
         if (Math.abs(mc) >= ci/2) {
-            mc %= (1L << PRECISION) / 10; // Remove the effect of last decimal digit.
-            if (mc >= 0) {                // Check if changing the sign would make it smaller.
+            mc %= (1L << PRECISION) / 10;               // Remove the effect of last decimal digit.
+            if (mc >= 0) {                              // Check if changing the sign would make it smaller.
                 if (mc >= (1L << PRECISION) / 20) {
                     mc -= (1L << PRECISION) / 10;
                 }
@@ -351,11 +351,11 @@ public final class DecimalFunctions exte
      * -{@linkplain Math#floor(double) floor}({@linkplain Math#log10(double) log10}(accuracy))</code>
      * except for the 0, {@code NaN}, infinities and {@code 0.…95} special cases.
      *
-     * @param  accuracy The desired accuracy of numbers to format in base 10.
+     * @param  accuracy  the desired accuracy of numbers to format in base 10.
      * @param  strict {@code true} for checking the {@code 0.…95} special case.
      *         If {@code false}, then the difference between adjacent formatted numbers is not
      *         guaranteed to be smaller than {@code accuracy} in every cases.
-     * @return Number of fraction digits needed for formatting numbers with the given accuracy.
+     * @return number of fraction digits needed for formatting numbers with the given accuracy.
      *         May be negative.
      *
      * @see java.text.NumberFormat#setMaximumFractionDigits(int)
@@ -364,7 +364,7 @@ public final class DecimalFunctions exte
         accuracy = Math.abs(accuracy);
         int i = MathFunctions.getExponent(accuracy);
         if (i == Double.MAX_EXPONENT + 1) {
-            return 0; // NaN or infinities.
+            return 0;                                       // NaN or infinities.
         }
         i = Numerics.toExp10(i);
         if (accuracy >= pow10(i+1)) {
@@ -374,7 +374,7 @@ public final class DecimalFunctions exte
         if (strict) {
             double scale = pow10(i);
             while ((accuracy *= scale) >= 9.5) {
-                i++; // The 0.…95 special case.
+                i++;                                        // The 0.…95 special case.
                 accuracy -= Math.floor(accuracy);
                 scale = 10;
             }
@@ -409,8 +409,8 @@ public final class DecimalFunctions exte
      * This method is useful with {@link java.text.NumberFormat} for formatting all significant digits of a
      * {@code double} value, padding with trailing zeros if necessary, but no more than necessary.</div>
      *
-     * @param  value The value for which to get the number of significant fraction digits.
-     * @return The number of significant fraction digits (may be negative), or 0 if {@code value} is NaN or infinity.
+     * @param  value  the value for which to get the number of significant fraction digits.
+     * @return the number of significant fraction digits (may be negative), or 0 if {@code value} is NaN or infinity.
      *
      * @see java.text.NumberFormat#setMinimumFractionDigits(int)
      */
@@ -423,7 +423,7 @@ public final class DecimalFunctions exte
          * normal numbers (in order to reproduce the Math.ulp behavior).
          */
         final int exponent = Math.getExponent(value);
-        if (exponent <= Double.MAX_EXPONENT) { // Exclude NaN and ±∞ cases.
+        if (exponent <= Double.MAX_EXPONENT) {                          // Exclude NaN and ±∞ cases.
             return -Numerics.toExp10(exponent - SIGNIFICAND_SIZE);
         }
         return 0;
@@ -459,9 +459,9 @@ public final class DecimalFunctions exte
      * </ul>
      * </div>
      *
-     * @param  value The value for which to get the number of significant fraction fraction digits minus rounding error.
-     * @param  uncertainDigits Number of trailing fraction digits which may be rounding error artefacts.
-     * @return Suggested number of significant digits (may be negative), or 0 if {@code value} is NaN or infinity.
+     * @param  value  the value for which to get the number of significant fraction fraction digits minus rounding error.
+     * @param  uncertainDigits  number of trailing fraction digits which may be rounding error artefacts.
+     * @return suggested number of significant digits (may be negative), or 0 if {@code value} is NaN or infinity.
      */
     public static int fractionDigitsForValue(double value, final int uncertainDigits) {
         ArgumentChecks.ensurePositive("uncertainDigits", uncertainDigits);

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -242,7 +242,7 @@ abstract class AbstractUnit<Q extends Qu
         if (Math.abs(multiplier) < 1) {
             final double inverse = 1 / multiplier;
             final double r = Math.rint(inverse);
-            if (Math.abs(inverse - r) <= Math.ulp(inverse)) {
+            if (epsilonEquals(inverse, r)) {
                 return r;
             }
         }
@@ -250,6 +250,14 @@ abstract class AbstractUnit<Q extends Qu
     }
 
     /**
+     * Returns {@code true} if the given floating point numbers are considered equal.
+     * The tolerance factor used in this method is arbitrary and may change in any future version.
+     */
+    static boolean epsilonEquals(final double expected, final double actual) {
+        return Math.abs(expected - actual) <= Math.scalb(Math.ulp(expected), 4);
+    }
+
+    /**
      * Returns the inverse of this unit.
      *
      * @return 1 / {@code this}
@@ -299,15 +307,15 @@ abstract class AbstractUnit<Q extends Qu
 
     /**
      * Returns {@code true} if the given Unicode code point is a valid character for a unit symbol.
-     * Current implementation accepts only letters and subscripts, but the set of legal characters
-     * may be expanded in any future SIS version. The most important goal is to avoid confusion with
-     * exponents.
+     * Current implementation accepts only letters, subscripts and the degree sign, but the set of
+     * legal characters may be expanded in any future SIS version.
+     * The most important goal is to avoid confusion with exponents.
      *
      * <p>Note that some units defined in the {@link Units} class break this rule. But the hard-coded
      * symbols in that class are known to be consistent with SI usage or with {@link UnitFormat} work.</p>
      */
     static boolean isSymbolChar(final int c) {
-        return Character.isLetter(c) || Characters.isSubScript(c);
+        return Character.isLetter(c) || Characters.isSubScript(c) || c == '°';
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -219,7 +219,7 @@ final class ConventionalUnit<Q extends Q
     @SuppressWarnings("null")
     static char prefix(final double scale) {
         final int n = Numerics.toExp10(Math.getExponent(scale)) + 1;
-        if (Math.abs(MathFunctions.pow10(n) - scale) <= Math.ulp(scale)) {
+        if (epsilonEquals(MathFunctions.pow10(n), scale)) {
             int i = Math.abs(n);
             switch (i) {
                 case 0:  return 0;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -445,9 +445,8 @@ final class LinearConverter extends Abst
      * except for rounding errors.
      */
     boolean equivalent(final LinearConverter other) {
-        double r;
-        return Math.abs((r = scale  * other.divisor) - other.scale  * divisor) <= Math.ulp(r) &&
-               Math.abs((r = offset * other.divisor) - other.offset * divisor) <= Math.ulp(r);
+        return AbstractUnit.epsilonEquals(scale  * other.divisor, other.scale  * divisor) &&
+               AbstractUnit.epsilonEquals(offset * other.divisor, other.offset * divisor);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -682,7 +682,7 @@ public class RangeFormat extends Format
      * {@link #parse(String)} with no additional work.
      *
      * @param  source  the text, part of which should be parsed.
-     * @return a range parsed from the string, or {@code null} in case of error.
+     * @return a range parsed from the string.
      * @throws ParseException if the given string can not be fully parsed.
      */
     @Override
@@ -954,8 +954,7 @@ public class RangeFormat extends Format
                 // At this point we found a character that could be
                 // the beginning of a unit symbol. Try to parse that.
                 pos.setIndex(index);
-// TODO: Uncomment when we have upgrated JSR-275 dependency.
-//              unit = unitFormat.parse(source, pos);
+                unit = unitFormat.parse(source, pos);
                 break;
             }
         }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -25,6 +25,7 @@ import java.util.Locale;
 import java.text.Format;
 import java.text.FieldPosition;
 import java.text.ParsePosition;
+import java.text.ParseException;
 import java.util.ResourceBundle;
 import java.util.MissingResourceException;
 import java.io.IOException;
@@ -370,7 +371,8 @@ public class UnitFormat extends Format i
      *
      * <div class="section">Restriction on character set</div>
      * Current implementation accepts only {@linkplain Character#isLetter(int) letters},
-     * {@linkplain Characters#isSubScript(int) subscripts} and {@linkplain Character#isWhitespace(int) whitespaces},
+     * {@linkplain Characters#isSubScript(int) subscripts}, {@linkplain Character#isWhitespace(int) whitespaces}
+     * and the degree sign (°),
      * but the set of legal characters may be expanded in future Apache SIS versions.
      * However the following restrictions are likely to remain:
      *
@@ -912,17 +914,34 @@ public class UnitFormat extends Format i
                      * If the first character is a digit, presume that the term is a multiplication factor.
                      * The "*" character is used for raising the number on the left to the power on the right.
                      * Example: "10*6" is equal to one million.
+                     *
+                     * In principle, spaces are not allowed in unit symbols (in particular, UCUM specifies that
+                     * spaces should not be interpreted as multication operators).  However in practice we have
+                     * sometime units written in a form like "100 feet".
                      */
                     final char c = uom.charAt(0);
                     if (isDigit(c) || isSign(c)) {
                         final double multiplier;
-                        final int s = uom.lastIndexOf('*');
-                        if (s >= 0) {
-                            final int base = Integer.parseInt(uom.substring(0, s));
-                            final int exp  = Integer.parseInt(uom.substring(s+1));
-                            multiplier = Math.pow(base, exp);
-                        } else {
-                            multiplier = Double.parseDouble(uom);
+                        try {
+                            int s = uom.lastIndexOf(' ');
+                            if (s >= 0) {
+                                final int next = CharSequences.skipLeadingWhitespaces(uom, s, length);
+                                if (next < length && AbstractUnit.isSymbolChar(uom.codePointAt(next))) {
+                                    multiplier = Double.parseDouble(uom.substring(0, s));
+                                    return parseSymbol(uom, s, length).multiply(multiplier);
+                                }
+                            }
+                            s = uom.lastIndexOf('*');
+                            if (s >= 0) {
+                                final int base = Integer.parseInt(uom.substring(0, s));
+                                final int exp  = Integer.parseInt(uom.substring(s+1));
+                                multiplier = Math.pow(base, exp);
+                            } else {
+                                multiplier = Double.parseDouble(uom);
+                            }
+                        } catch (NumberFormatException e) {
+                            throw (ParserException) new ParserException(Errors.format(
+                                    Errors.Keys.UnknownUnit_1, uom), symbols, lower).initCause(e);
                         }
                         return Units.UNITY.multiply(multiplier);
                     }
@@ -1046,17 +1065,16 @@ public class UnitFormat extends Format i
      * @return the unit parsed from the specified symbols.
      * @throws ParserException if a problem occurred while parsing the given symbols.
      */
-    @Override
-    public Object parseObject(final String symbols, final ParsePosition pos) {
+    public Unit<?> parse(final CharSequence symbols, final ParsePosition pos) {
         final int start = pos.getIndex();
         int stop = start;
         while (stop < symbols.length()) {
-            final int c = symbols.codePointAt(stop);
-            if (Character.isWhitespace(c) || c == ']') break;       // Temporary hack before we implement our own parser.
+            final int c = Character.codePointAt(symbols, stop);
+            if (Character.isWhitespace(c) || c == ']') break;       // Temporary hack before we complete the JSR-275 replacement.
             stop += Character.charCount(c);
         }
         try {
-            final Unit<?> unit = parse(symbols.substring(start, stop));
+            final Unit<?> unit = parse(symbols.subSequence(start, stop));
             pos.setIndex(stop);
             return unit;
         } catch (ParserException e) {
@@ -1064,4 +1082,34 @@ public class UnitFormat extends Format i
             return null;
         }
     }
+
+    /**
+     * Parses text from a string to produce a unit. The default implementation delegates to {@link #parse(CharSequence)}
+     * and wraps the {@link ParserException} into a {@link ParseException} for compatibility with {@code java.text} API.
+     *
+     * @param  source  the text, part of which should be parsed.
+     * @return a unit parsed from the string.
+     * @throws ParseException if the given string can not be fully parsed.
+     */
+    @Override
+    public Object parseObject(final String source) throws ParseException {
+        try {
+            return parse(source);
+        } catch (ParserException e) {
+            throw (ParseException) new ParseException(e.getLocalizedMessage(), e.getPosition()).initCause(e);
+        }
+    }
+
+    /**
+     * Parses text from a string to produce a unit. The default implementation delegates to
+     * {@link #parse(CharSequence, ParsePosition)} with no additional work.
+     *
+     * @param  source  the text, part of which should be parsed.
+     * @param  pos     index and error index information as described above.
+     * @return a unit parsed from the string, or {@code null} in case of error.
+     */
+    @Override
+    public Object parseObject(final String source, final ParsePosition pos) {
+        return parse(source, pos);
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -996,6 +996,24 @@ public final class Units extends Static
     }
 
     /**
+     * Multiplies the given unit by the given ratio. For example multiplying {@link #CENTIMETRE} by 254/100 gives
+     * {@link #INCH}. Invoking this method is equivalent to invoking <code>{@linkplain Unit#multiply(double)
+     * Unit.multiply}(numerator / denominator)</code> except that the use of a ration of integer values help
+     * Apache SIS to improve accuracy when more than one arithmetic operation are chained.
+     *
+     * @param  <Q>          the quantity measured by the unit.
+     * @param  unit         the unit to multiply.
+     * @param  numerator    the numerator of the multiplication factor.
+     * @param  denominator  the denominator of the multiplication factor.
+     * @return the unit multiplied by the given factor.
+     *
+     * @since 0.8
+     */
+    public static <Q extends Quantity<Q>> Unit<Q> multiply(Unit<Q> unit, double numerator, double denominator) {
+        return unit.transform(LinearConverter.scale(numerator, denominator));
+    }
+
+    /**
      * Multiplies the given unit by the given factor. For example multiplying {@link #METRE}
      * by 1000 gives {@link #KILOMETRE}. Invoking this method is equivalent to invoking
      * {@link Unit#multiply(double)} except for the following:
@@ -1012,7 +1030,10 @@ public final class Units extends Static
      * @param  unit    the unit to multiply.
      * @param  factor  the multiplication factor.
      * @return the unit multiplied by the given factor.
+     *
+     * @deprecated Replaced by Apache SIS implementation of {@link Unit#multiply(double)}.
      */
+    @Deprecated
     @Workaround(library="JSR-275", version="0.9.3")
     @SuppressWarnings("unchecked")
     public static <Q extends Quantity<Q>> Unit<Q> multiply(Unit<Q> unit, final double factor) {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -96,14 +96,14 @@ public class ValueConverter {
      * {@code toXXX(…)} methods, like the example provided in this <a href="#skip-navbar_top">class
      * javadoc</a>.</p>
      *
-     * @param  <T> The compile-time type of the {@code sourceType} argument.
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The value that can't be converted.
-     * @param  sourceType The base type of the value to convert. This is determined by the argument
-     *         type of the method that caught the exception. For example the source type is always
-     *         {@code URI.class} if the exception has been caught by the {@link #toURL(MarshalContext, URI)} method.
-     * @param  targetType The expected type of the converted object.
-     * @param  exception The exception that occurred during the conversion attempt.
+     * @param  <T>         the compile-time type of the {@code sourceType} argument.
+     * @param  context     context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value       the value that can't be converted.
+     * @param  sourceType  the base type of the value to convert. This is determined by the argument type of the method
+     *                     that caught the exception. For example the source type is always {@code URI.class}
+     *                     if the exception has been caught by the {@link #toURL(MarshalContext, URI)} method.
+     * @param  targetType  the expected type of the converted object.
+     * @param  exception   the exception that occurred during the conversion attempt.
      * @return {@code true} if the (un)marshalling process should continue despite this error,
      *         or {@code false} (the default) if the exception should be propagated, thus causing
      *         the (un)marshalling to fail.
@@ -132,10 +132,10 @@ public class ValueConverter {
      *   </ul></li>
      * </ul>
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The locale to convert to a language code, or {@code null}.
-     * @return The language code, or {@code null} if the given value was null or does not contains a language code.
-     * @throws MissingResourceException If no language code can be found for the given locale.
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the locale to convert to a language code, or {@code null}.
+     * @return the language code, or {@code null} if the given value was null or does not contains a language code.
+     * @throws MissingResourceException if no language code can be found for the given locale.
      *
      * @see Locale#getISO3Language()
      * @see Locale#getLanguage()
@@ -164,10 +164,10 @@ public class ValueConverter {
      *
      * <p>The default implementation returns {@link Locale#getCountry()} if non-empty, or {@code null} otherwise.</p>
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The locale to convert to a country code, or {@code null}.
-     * @return The country code, or {@code null} if the given value was null or does not contains a country code.
-     * @throws MissingResourceException If no country code can be found for the given locale.
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the locale to convert to a country code, or {@code null}.
+     * @return the country code, or {@code null} if the given value was null or does not contains a country code.
+     * @throws MissingResourceException if no country code can be found for the given locale.
      *
      * @see Locale#getISO3Country()
      * @see Locale#getCountry()
@@ -230,9 +230,9 @@ public class ValueConverter {
      *   </tr>
      * </table>
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The locale to convert to a character set code, or {@code null}.
-     * @return The country code, or {@code null} if the given value was null.
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the locale to convert to a character set code, or {@code null}.
+     * @return the country code, or {@code null} if the given value was null.
      *
      * @see Charset#name()
      *
@@ -251,11 +251,11 @@ public class ValueConverter {
      * character and the country code (again either as 2 or 3 letters), optionally followed
      * by {@code '_'} and the variant.
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a locale, or {@code null}.
-     * @return The converted locale, or {@code null} if the given value was null or empty, or
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a locale, or {@code null}.
+     * @return the converted locale, or {@code null} if the given value was null or empty, or
      *         if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws IllformedLocaleException If the given string can not be converted to a locale.
+     * @throws IllformedLocaleException if the given string can not be converted to a locale.
      *
      * @see Locales#parse(String)
      */
@@ -276,11 +276,11 @@ public class ValueConverter {
      * <a href="http://www.iana.org/assignments/character-sets">IANA</a> identifier,
      * or one of the ISO 19115:2003 {@code MD_CharacterSetCode} identifier.
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a character set, or {@code null}.
-     * @return The converted character set, or {@code null} if the given value was null or empty, or
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a character set, or {@code null}.
+     * @return the converted character set, or {@code null} if the given value was null or empty, or
      *         if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws IllegalCharsetNameException If the given string can not be converted to a character set.
+     * @throws IllegalCharsetNameException if the given string can not be converted to a character set.
      *
      * @see Charset#forName(String)
      *
@@ -310,11 +310,11 @@ public class ValueConverter {
      *     return Units.valueOf(value);
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a unit, or {@code null}.
-     * @return The converted unit, or {@code null} if the given value was null or empty, or
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a unit, or {@code null}.
+     * @return the converted unit, or {@code null} if the given value was null or empty, or
      *         if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws IllegalArgumentException If the given string can not be converted to a unit.
+     * @throws IllegalArgumentException if the given string can not be converted to a unit.
      *
      * @see Units#valueOf(String)
      */
@@ -339,11 +339,11 @@ public class ValueConverter {
      *     return UUID.fromString(value);
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a UUID, or {@code null}.
-     * @return The converted UUID, or {@code null} if the given value was null or empty, or
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a UUID, or {@code null}.
+     * @return the converted UUID, or {@code null} if the given value was null or empty, or
      *         if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws IllegalArgumentException If the given string can not be converted to a UUID.
+     * @throws IllegalArgumentException if the given string can not be converted to a UUID.
      *
      * @see UUID#fromString(String)
      */
@@ -368,11 +368,11 @@ public class ValueConverter {
      *     return new URI(value);
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a URI, or {@code null}.
-     * @return The converted URI, or {@code null} if the given value was null or empty, or if
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a URI, or {@code null}.
+     * @return the converted URI, or {@code null} if the given value was null or empty, or if
      *         an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws URISyntaxException If the given string can not be converted to a URI.
+     * @throws URISyntaxException if the given string can not be converted to a URI.
      *
      * @see URI#URI(String)
      */
@@ -397,11 +397,11 @@ public class ValueConverter {
      *     return value.toURI();
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The URL to convert to a URI, or {@code null}.
-     * @return The converted URI, or {@code null} if the given value was null or if an
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the URL to convert to a URI, or {@code null}.
+     * @return the converted URI, or {@code null} if the given value was null or if an
      *         exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws URISyntaxException If the given URL can not be converted to a URI.
+     * @throws URISyntaxException if the given URL can not be converted to a URI.
      *
      * @see URL#toURI()
      */
@@ -425,11 +425,11 @@ public class ValueConverter {
      *     return value.toURL();
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The URI to convert to a URL, or {@code null}.
-     * @return The converted URL, or {@code null} if the given value was null or if an
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the URI to convert to a URL, or {@code null}.
+     * @return the converted URL, or {@code null} if the given value was null or if an
      *         exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws MalformedURLException If the given URI can not be converted to a URL.
+     * @throws MalformedURLException if the given URI can not be converted to a URL.
      *
      * @see URI#toURL()
      */
@@ -453,11 +453,11 @@ public class ValueConverter {
      *     return NilReason.valueOf(value);
      * }
      *
-     * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
-     * @param  value The string to convert to a nil reason, or {@code null}.
-     * @return The converted nil reason, or {@code null} if the given value was null or empty, or
+     * @param  context  context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
+     * @param  value    the string to convert to a nil reason, or {@code null}.
+     * @return the converted nil reason, or {@code null} if the given value was null or empty, or
      *         if an exception was thrown and {@code exceptionOccured(…)} returned {@code true}.
-     * @throws URISyntaxException If the given string can not be converted to a nil reason.
+     * @throws URISyntaxException if the given string can not be converted to a nil reason.
      *
      * @see NilReason#valueOf(String)
      */

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -341,5 +341,6 @@ public final strictfp class UnitFormatTe
         ConventionalUnitTest.verify(Units.METRE, f.parse("10*-6.m"),   "µm", 1E-6);
         ConventionalUnitTest.verify(Units.METRE, f.parse( "1000*m"),   "km", 1E+3);
         ConventionalUnitTest.verify(Units.METRE, f.parse( "1000.0*m"), "km", 1E+3);
+        ConventionalUnitTest.verify(Units.METRE, f.parse( "100 feet"), null, 30.48);
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1767561&r1=1767560&r2=1767561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] Tue Nov  1 20:21:01 2016
@@ -184,15 +184,6 @@ public final strictfp class UnitsTest ex
     }
 
     /**
-     * Tests {@link Units#multiply(Unit, double)}.
-     */
-    @Test
-    public void testMultiply() {
-        assertSame(KILOMETRE, multiply(METRE, 1000));
-        assertSame(DEGREE, multiply(RADIAN, 0.017453292519943295));
-    }
-
-    /**
      * Tests getting a unit for a given quantity type.
      */
     @Test



Mime
View raw message