sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Documentation cleaning and adjustement in minor logging messages.
Date Fri, 01 Mar 2019 09:55:55 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new b47d01b  Documentation cleaning and adjustement in minor logging messages.
b47d01b is described below

commit b47d01b44f7ca6e1bd1f6d00064ca14e94c058f5
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Mar 1 10:55:06 2019 +0100

    Documentation cleaning and adjustement in minor logging messages.
---
 .../main/java/org/apache/sis/util/iso/Types.java   |  2 +-
 .../referencing/ServicesForMetadataTest.java       |  6 +++---
 .../org/apache/sis/math/ConcatenatedVector.java    |  9 +++++++++
 .../src/main/java/org/apache/sis/math/Vector.java  | 10 +++++-----
 .../java/org/apache/sis/measure/AbstractUnit.java  |  3 +++
 .../java/org/apache/sis/measure/UnitFormat.java    |  3 +++
 .../src/main/java/org/apache/sis/setup/About.java  | 12 +++--------
 .../java/org/apache/sis/util/logging/Logging.java  | 23 +++++++++++++++++++++-
 8 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
index a9edf8f..930e1c0 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
@@ -386,7 +386,7 @@ public final class Types extends Static {
             try {
                 return super.toString(locale);
             } catch (MissingResourceException e) {
-                Logging.recoverableException(Logging.getLogger(Loggers.LOCALIZATION), ResourceInternationalString.class,
"toString", e);
+                Logging.ignorableException(Logging.getLogger(Loggers.LOCALIZATION), ResourceInternationalString.class,
"toString", e);
                 return fallback();
             }
         }
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
index 22eb03d..610d382 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
@@ -102,7 +102,7 @@ public final strictfp class ServicesForMetadataTest extends TestCase {
     }
 
     /**
-     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
boolean)}
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
String)}
      * from a three-dimensional envelope.
      *
      * @throws TransformException should never happen.
@@ -115,7 +115,7 @@ public final strictfp class ServicesForMetadataTest extends TestCase {
     }
 
     /**
-     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
boolean)}
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
String)}
      * from a for-dimensional envelope.
      *
      * @throws TransformException should never happen.
@@ -168,7 +168,7 @@ public final strictfp class ServicesForMetadataTest extends TestCase {
     }
 
     /**
-     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
boolean)}
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
String)}
      * from an envelope spanning the antimeridian.
      *
      * @throws TransformException should never happen.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java b/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
index eda92f1..5cdb748 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
@@ -295,4 +295,13 @@ final class ConcatenatedVector extends Vector implements Serializable
{
     Vector createConcatenate(final Vector toAppend) {
         return first.concatenate(second.concatenate(toAppend));
     }
+
+    /**
+     * Delegates to the backing vectors since there is a chance that they override
+     * their {@code transform} method with a more efficient implementation.
+     */
+    @Override
+    Vector createTransform(final double scale, final double offset) {
+        return first.transform(scale, offset).concatenate(second.transform(scale, offset));
+    }
 }
diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java b/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
index 521be6a..1c724ae 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
@@ -1019,9 +1019,10 @@ search:     for (;;) {
     }
 
     /**
-     * If this vector is a view over another vector, returns the backing vector.
-     * Otherwise returns {@code this}. If this method is overridden, it should be
-     * together with the {@link #toBacking(int[])} method.
+     * If this vector is a view over a subset of another vector, returns the backing vector.
+     * Otherwise returns {@code this}. If this method is overridden, it should be together
+     * with the {@link #toBacking(int[])} method. This method shall not be overridden when
+     * the view transform the values.
      */
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
     Vector backingVector() {
@@ -1033,7 +1034,7 @@ search:     for (;;) {
      * If there is no such backing vector, then returns a clone of the given array.
      * This method must also check index validity.
      *
-     * <p>Only subclasses that are views of this vector will override this method.</p>
+     * <p>Only subclasses that are views over a subset of this vector will override
this method.</p>
      *
      * @param  indices  the indexes given by the user.
      * @return the indexes to use. Must be a new array in order to protect it from user changes.
@@ -1279,7 +1280,6 @@ search:     for (;;) {
         return new LinearlyDerivedVector(this, scale, offset);
     }
 
-
     /**
      * Returns a vector with the same data than this vector but encoded in a more compact
way,
      * or {@code this} if this method can not do better than current {@code Vector} instance.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java b/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
index 8892e85..7cb7ef0 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
@@ -30,6 +30,8 @@ import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.LenientComparable;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.internal.system.Loggers;
 
 
 /**
@@ -298,6 +300,7 @@ abstract class AbstractUnit<Q extends Quantity<Q>> implements
Unit<Q>, LenientCo
         if (symbol != null) try {
             return UnitFormat.getBundle(Locale.getDefault()).getString(symbol);
         } catch (MissingResourceException e) {
+            Logging.ignorableException(Logging.getLogger(Loggers.MEASURE), AbstractUnit.class,
"getName", e);
             // Ignore as per this method contract.
         }
         return null;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
index c9c30cb..0f1ec56 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
@@ -34,6 +34,7 @@ import java.security.AccessController;
 import javax.measure.Dimension;
 import javax.measure.Unit;
 import javax.measure.format.ParserException;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.DefinitionURI;
@@ -48,6 +49,7 @@ import org.apache.sis.util.Localized;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CorruptedObjectException;
 import org.apache.sis.util.collection.WeakValueHashMap;
+import org.apache.sis.util.logging.Logging;
 
 
 /**
@@ -647,6 +649,7 @@ appPow: if (unit == null) {
                     try {
                         label = names.getString(label);
                     } catch (MissingResourceException e) {
+                        Logging.ignorableException(Logging.getLogger(Loggers.MEASURE), UnitFormat.class,
"format", e);
                         // Name not found; use the symbol as a fallback.
                     }
                     return toAppendTo.append(label);
diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
index d118673..b80340f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
@@ -328,7 +328,8 @@ fill:   for (int i=0; ; i++) {
                                 .getMethod("providers", Locale.class, Vocabulary.class).invoke(null,
locale, resources);
                         value = resources.getString(Vocabulary.Keys.EntryCount_1, children.length
/ 2);
                     } catch (ClassNotFoundException e) {
-                        recoverableException(Modules.STORAGE, e);       // sis-storage module
not in the classpath.
+                        // sis-storage module not in the classpath.
+                        Logging.recoverableException(Logging.getLogger(Modules.STORAGE),
About.class, "configuration", e);
                     } catch (ReflectiveOperationException e) {
                         value = Exceptions.unwrap(e).toString();
                     }
@@ -739,7 +740,7 @@ pathTree:   for (int j=0; ; j++) {
         try {
             return country ? locale.getCountry() : locale.getISO3Language();
         } catch (MissingResourceException e) {
-            recoverableException(Loggers.LOCALIZATION, e);
+            Logging.ignorableException(Logging.getLogger(Loggers.LOCALIZATION), About.class,
"configuration", e);
             return null;
         }
     }
@@ -789,11 +790,4 @@ pathTree:   for (int j=0; ; j++) {
         }
         return new File(parent, file.getName());
     }
-
-    /**
-     * Logs a recoverable exception that happened (directly or indirectly) in the {@link
#configuration()} method.
-     */
-    private static void recoverableException(final String logger, final Exception e) {
-        Logging.recoverableException(Logging.getLogger(logger), About.class, "configuration",
e);
-    }
 }
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
index dbbef43..119a6f7 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
@@ -48,7 +48,7 @@ import org.apache.sis.internal.system.Modules;
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -443,6 +443,27 @@ public final class Logging extends Static {
     }
 
     /**
+     * Invoked when an ignorable error occurred. This method is similar to
+     * {@link #recoverableException(Logger,Class,String,Throwable) unexpectedException(…)}
+     * except that it uses a lower logging level.
+     *
+     * @param  logger  where to log the error, or {@code null} for inferring a default value
from other arguments.
+     * @param  classe  the class where the error occurred, or {@code null} for inferring
a default value from other arguments.
+     * @param  method  the method name where the error occurred, or {@code null} for inferring
a default value from other arguments.
+     * @param  error   the error, or {@code null} if none.
+     * @return {@code true} if the error has been logged, or {@code false} if the given {@code
error}
+     *         was null or if the logger does not log anything at {@link Level#FINER}.
+     *
+     * @since 1.0
+     */
+    public static boolean ignorableException(final Logger logger, final Class<?> classe,
+                                               final String method, final Throwable error)
+    {
+        final String classname = (classe != null) ? classe.getName() : null;
+        return unexpectedException(logger, classname, method, error, Level.FINER);
+    }
+
+    /**
      * Invoked when a severe error occurred. This method is similar to
      * {@link #unexpectedException(Logger,Class,String,Throwable) unexpectedException}
      * except that it logs the message at the {@link Level#SEVERE SEVERE} level.


Mime
View raw message