sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1679383 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing: ./ crs/ cs/ operation/
Date Thu, 14 May 2015 14:36:24 GMT
Author: desruisseaux
Date: Thu May 14 14:36:23 2015
New Revision: 1679383

URL: http://svn.apache.org/r1679383
Log:
Referencing: use the user-supplied Locale for formatting some error messages, when possible.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -327,7 +327,8 @@ public abstract class Builder<B extends
                 return false;
             }
             if (properties.get(IdentifiedObject.NAME_KEY) != null) {
-                throw new IllegalStateException(Errors.format(Errors.Keys.ValueAlreadyDefined_1,
key));
+                throw new IllegalStateException(Errors.getResources(properties)
+                        .getString(Errors.Keys.ValueAlreadyDefined_1, key));
             }
             properties.put(key, value);
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -144,8 +144,8 @@ abstract class AbstractDerivedCRS<C exte
         try {
             return DefaultConversion.castOrCopy(conversion).specialize(getConversionType(),
baseCRS, this, factory);
         } catch (FactoryException e) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2,
-                    "conversionFromBase", conversion.getName()), e);
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                    Errors.Keys.IllegalArgumentValue_2, "conversionFromBase", conversion.getName()),
e);
         }
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -182,7 +182,7 @@ public class DefaultCompoundCRS extends
      * @param components The sequence of coordinate reference systems making this compound
CRS.
      */
     public DefaultCompoundCRS(final Map<String,?> properties, final CoordinateReferenceSystem...
components) {
-        super(properties, createCoordinateSystem(components));
+        super(properties, createCoordinateSystem(properties, components));
         this.components = copy(Arrays.asList(components));
         // 'singles' is computed by the above method call.
     }
@@ -193,10 +193,13 @@ public class DefaultCompoundCRS extends
      * ("Relax constraint on placement of this()/super() call in constructors").
      */
     @Workaround(library="JDK", version="1.7")
-    private static CoordinateSystem createCoordinateSystem(final CoordinateReferenceSystem[]
components) {
+    private static CoordinateSystem createCoordinateSystem(final Map<String,?> properties,
+            final CoordinateReferenceSystem[] components)
+    {
         ensureNonNull("components", components);
         if (components.length < 2) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.TooFewArguments_2,
2, components.length));
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                    Errors.Keys.TooFewArguments_2, 2, components.length));
         }
         final CoordinateSystem[] cs = new CoordinateSystem[components.length];
         for (int i=0; i<components.length; i++) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -129,7 +129,7 @@ public class DefaultCartesianCS extends
                               final CoordinateSystemAxis axis1)
     {
         super(properties, axis0, axis1);
-        ensurePerpendicularAxis();
+        ensurePerpendicularAxis(properties);
     }
 
     /**
@@ -148,7 +148,7 @@ public class DefaultCartesianCS extends
                               final CoordinateSystemAxis axis2)
     {
         super(properties, axis0, axis1, axis2);
-        ensurePerpendicularAxis();
+        ensurePerpendicularAxis(properties);
     }
 
     /**
@@ -164,7 +164,7 @@ public class DefaultCartesianCS extends
      */
     protected DefaultCartesianCS(final CartesianCS cs) {
         super(cs);
-        ensurePerpendicularAxis();
+        ensurePerpendicularAxis(null);
     }
 
     /**
@@ -185,7 +185,7 @@ public class DefaultCartesianCS extends
     /**
      * Ensures that all axes are perpendicular.
      */
-    private void ensurePerpendicularAxis() throws IllegalArgumentException {
+    private void ensurePerpendicularAxis(final Map<String,?> properties) throws IllegalArgumentException
{
         final int dimension = getDimension();
         for (int i=0; i<dimension; i++) {
             final AxisDirection axis0 = getAxis(i).getDirection();
@@ -198,7 +198,7 @@ public class DefaultCartesianCS extends
                  * they are not really for Cartesian CS because we do not know the grid geometry.
                  */
                 if (angle != null && Math.abs(angle.degrees()) != 90) {
-                    throw new IllegalArgumentException(Errors.format(
+                    throw new IllegalArgumentException(Errors.getResources(properties).getString(
                             Errors.Keys.NonPerpendicularDirections_2, axis0, axis1));
                 }
             }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -124,7 +124,7 @@ public class DefaultEllipsoidalCS extend
         for (int i=0; i<2; i++) {
             final AxisDirection direction = super.getAxis(i).getDirection();
             if (AxisDirections.isVertical(direction)) {
-                throw new IllegalArgumentException(Errors.format(
+                throw new IllegalArgumentException(Errors.getResources(properties).getString(
                         Errors.Keys.IllegalAxisDirection_2, "EllipdoicalCS (2D)", direction));
             }
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -201,7 +201,7 @@ public class AbstractCoordinateOperation
         this.domainOfValidity            = definition.getDomainOfValidity();
         this.scope                       = definition.getScope();
         this.transform                   = transform;
-        checkDimensions();
+        checkDimensions(null);
     }
 
     /**
@@ -313,14 +313,14 @@ public class AbstractCoordinateOperation
         } else {
             coordinateOperationAccuracy = (value != null) ? Collections.singleton((PositionalAccuracy)
value) : null;
         }
-        checkDimensions();
+        checkDimensions(properties);
     }
 
     /**
      * Ensures that {@link #sourceCRS}, {@link #targetCRS} and {@link #interpolationCRS}
dimensions
      * are consistent with {@link #transform} input and output dimensions.
      */
-    private void checkDimensions() {
+    private void checkDimensions(final Map<String,?> properties) {
         if (transform != null) {
             final int interpDim = ReferencingUtilities.getDimension(interpolationCRS);
 check:      for (int isTarget=0; ; isTarget++) {        // 0 == source check; 1 == target
check.
@@ -336,12 +336,13 @@ check:      for (int isTarget=0; ; isTar
                     if (actual == expected || actual < interpDim) {
                         // This check is not strictly necessary as the next check below would
catch the error,
                         // but we provide here a hopefully more helpful error message for
a common mistake.
-                        throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingInterpolationOrdinates));
+                        throw new IllegalArgumentException(Errors.getResources(properties)
+                                .getString(Errors.Keys.MissingInterpolationOrdinates));
                     }
                     expected += interpDim;
                 }
                 if (crs != null && actual != expected) {
-                    throw new IllegalArgumentException(Errors.format(
+                    throw new IllegalArgumentException(Errors.getResources(properties).getString(
                             Errors.Keys.MismatchedTransformDimension_3, isTarget, expected,
actual));
                 }
             }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -127,7 +127,8 @@ class AbstractSingleOperation extends Ab
         if (transform != null) {
             checkDimensions(method, 0, transform, properties);
         } else if (parameters == null) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.UnspecifiedParameterValues));
+            throw new IllegalArgumentException(Errors.getResources(properties)
+                    .getString(Errors.Keys.UnspecifiedParameterValues));
         }
         this.method = method;
         this.parameters = (parameters != null) ? parameters.clone() : null;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1679383&r1=1679382&r2=1679383&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
[UTF-8] Thu May 14 14:36:23 2015
@@ -117,7 +117,7 @@ public class DefaultConcatenatedOperatio
                                          final MathTransformFactory factory)
             throws FactoryException
     {
-        this(properties, expand(operations, list, factory, true), list);
+        this(properties, expand(properties, operations, list, factory, true), list);
     }
 
     /**
@@ -148,10 +148,11 @@ public class DefaultConcatenatedOperatio
      * @return The concatenated math transform, or {@code null} if {@code wantTransform}
was {@code false}.
      * @throws FactoryException if the factory can not concatenate the math transforms.
      */
-    private static MathTransform expand(final CoordinateOperation[] operations,
-                                        final List<SingleOperation> target,
-                                        final MathTransformFactory  factory,
-                                        final boolean wantTransform)
+    private static MathTransform expand(final Map<String,?> properties,
+            final CoordinateOperation[] operations,
+            final List<SingleOperation> target,
+            final MathTransformFactory  factory,
+            final boolean wantTransform)
             throws FactoryException
     {
         MathTransform transform = null;
@@ -164,9 +165,9 @@ public class DefaultConcatenatedOperatio
             } else if (op instanceof ConcatenatedOperation) {
                 final ConcatenatedOperation cop = (ConcatenatedOperation) op;
                 final List<SingleOperation> cops = cop.getOperations();
-                expand(cops.toArray(new CoordinateOperation[cops.size()]), target, factory,
false);
+                expand(properties, cops.toArray(new CoordinateOperation[cops.size()]), target,
factory, false);
             } else {
-                throw new IllegalArgumentException(Errors.format(
+                throw new IllegalArgumentException(Errors.getResources(properties).getString(
                         Errors.Keys.IllegalArgumentClass_2, "operations[" + i + ']', op.getClass()));
             }
             /*
@@ -180,8 +181,8 @@ public class DefaultConcatenatedOperatio
                         final int dim1 = previous.getCoordinateSystem().getDimension();
                         final int dim2 = next.getCoordinateSystem().getDimension();
                         if (dim1 != dim2) {
-                            throw new IllegalArgumentException(Errors.format(Errors.Keys.MismatchedDimension_3,
-                                    "operations[" + i + "].sourceCRS", dim1, dim2));
+                            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                                    Errors.Keys.MismatchedDimension_3, "operations[" + i
+ "].sourceCRS", dim1, dim2));
                         }
                     }
                 }
@@ -199,7 +200,7 @@ public class DefaultConcatenatedOperatio
             }
         }
         if (wantTransform && target.size() <= 1) {
-            throw new IllegalArgumentException(Errors.format(
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
                     Errors.Keys.TooFewOccurrences_2, 2, CoordinateOperation.class));
         }
         return transform;



Mime
View raw message