sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1724528 [10/15] - in /sis/branches/JDK6: ./ application/sis-console/src/main/artifact/bin/ application/sis-console/src/main/artifact/log/ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org...
Date Wed, 13 Jan 2016 23:25:42 GMT
Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/InvalidPathException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/InvalidPathException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java [iso-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -21,6 +21,7 @@ import java.sql.Connection;
 import java.sql.Statement;
 import java.sql.ResultSet;
 import javax.imageio.stream.ImageInputStream;
+import java.lang.reflect.InvocationTargetException;
 
 
 /**
@@ -29,7 +30,7 @@ import javax.imageio.stream.ImageInputSt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from GeoAPI)
- * @version 0.3
+ * @version 0.7
  * @module
  */
 public final class JDK7 {
@@ -93,14 +94,26 @@ public final class JDK7 {
     }
 
     /**
+     * Compares to integer values.
+     *
+     * @param x First value to compare.
+     * @param y Second value to compare.
+     * @return Comparison result.
+     */
+    public static int compare(final int x, final int y) {
+        return (x < y) ? -1 : (x == y) ? 0 : 1;
+    }
+
+    /**
      * Simulates the {@code object instanceof AutoCloseable} code.
      *
      * @param  object The object to check, or {@code null}.
      * @return {@code true} if the given object is closeable.
      */
     public static boolean isAutoCloseable(final Object object) {
-        return (object instanceof AutoCloseable) || (object instanceof Closeable) || (object instanceof ImageInputStream) ||
-                (object instanceof Connection) || (object instanceof Statement) || (object instanceof ResultSet);
+        return (object instanceof Closeable) || (object instanceof ImageInputStream) ||
+               (object instanceof Connection) || (object instanceof Statement) || (object instanceof ResultSet) ||
+               (object != null && object.getClass().isAnnotationPresent(AutoCloseable.class));
     }
 
     /**
@@ -117,6 +130,15 @@ public final class JDK7 {
         else if (object instanceof Connection)       ((Connection)       object).close();
         else if (object instanceof Statement)        ((Statement)        object).close();
         else if (object instanceof ResultSet)        ((ResultSet)        object).close();
-        else ((AutoCloseable) object).close(); // Intentionally no 'instanceof' check.
+        else try {
+            object.getClass().getMethod("close", (Class<?>[]) null).invoke(object, (Object[]) null);
+        } catch (InvocationTargetException e) {
+            final Throwable cause = e.getTargetException();
+            if (cause instanceof Exception) {
+                throw (Exception) cause;
+            } else {
+                throw e;
+            }
+        }
     }
 }

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/JDK7.java
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Wed Jan 13 23:25:38 2016
@@ -1 +1 @@
-text/plain
+text/plain;charset=UTF-8

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Objects.java
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Wed Jan 13 23:25:38 2016
@@ -1 +1 @@
-text/plain
+text/plain;charset=UTF-8

Added: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java?rev=1724528&view=auto
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java (added)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jdk7;
+
+import java.io.File;
+import java.net.URI;
+
+
+/**
+ * Place holder for {@link java.nio.file.Path}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+@SuppressWarnings("serial")
+public final class Path extends File {
+    /**
+     * Creates a path for the given file.
+     */
+    Path(final String path) {
+        super(path);
+    }
+
+    /**
+     * Creates a path for the given URI.
+     */
+    Path(final URI path) throws IllegalArgumentException {
+        super(path);
+    }
+
+    /**
+     * For {@link #resolve(String)} implementation.
+     */
+    Path(final File path, final String other) {
+        super(path, other);
+    }
+
+    /**
+     * For inter-operability.
+     *
+     * @param file The file to cast or copy.
+     * @return The given file as a path.
+     */
+    public static Path castOrCopy(final File file) {
+        return (file == null || file instanceof Path) ? (Path) file : new Path(file.getPath());
+    }
+
+    /**
+     * Returns the last element in the path.
+     *
+     * @return Last element in the path.
+     */
+    public Path getFileName() {
+        return new Path(getName());
+    }
+
+    /**
+     * Unimplemented.
+     *
+     * @return this.
+     */
+    public Path normalize() {
+        return this;
+    }
+
+    /**
+     * Returns a sub-directory of this path, or the given path if it is absolute.
+     *
+     * @param other The sub-directory name.
+     * @return The path with the sub-directory.
+     */
+    public Path resolve(final Path other) {
+        if (other.isAbsolute()) {
+            return other;
+        }
+        return new Path(this, other.toString());
+    }
+
+    /**
+     * Returns a sub-directory of this path, provided that the given path is not absolute.
+     *
+     * @param other The sub-directory name.
+     * @return The path with the sub-directory.
+     */
+    public Path resolve(final String other) {
+        return resolve(new Path(other));
+    }
+
+    /**
+     * Resolves the given path against the parent of this path.
+     *
+     * @param other The sub-directory name.
+     * @return The path with the sub-directory.
+     */
+    public Path resolveSibling(final Path other) {
+        if (other.isAbsolute()) {
+            return other;
+        }
+        return new Path(getParentFile(), other.toString());
+    }
+
+    /**
+     * Resolves the given path against the parent of this path.
+     *
+     * @param other The sub-directory name.
+     * @return The path with the sub-directory.
+     */
+    public Path resolveSibling(final String other) {
+        return resolveSibling(new Path(other));
+    }
+
+    /**
+     * Returns the given path relative to this path.
+     *
+     * @param other The path to make relative to this path.
+     * @return The relative path (if possible).
+     */
+    public Path relativize(final Path other) {
+        final String start = getAbsolutePath();
+        final String full  = other.getAbsolutePath();
+        if (full.startsWith(start)) {
+            final int length = start.length();
+            if (full.length() > length && full.charAt(length) == separatorChar) {
+                return new Path(full.substring(length + 1));
+            }
+        }
+        return other;
+    }
+
+
+    /**
+     * Returns this path as a URI.
+     *
+     * @return The URI for this path.
+     */
+    public URI toUri() {
+        return toURI();
+    }
+
+    /**
+     * Returns the path as an absolute path.
+     *
+     * @return The absolute path.
+     */
+    public Path toAbsolutePath() {
+        return isAbsolute() ? this : new Path(getAbsolutePath());
+    }
+}

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Path.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java?rev=1724528&view=auto
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java (added)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jdk7;
+
+import java.net.URI;
+
+
+/**
+ * Place holder for {@link java.nio.file.Paths}.
+ * This class exists only on the JDK6 branch of SIS.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+public final class Paths {
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private Paths() {
+    }
+
+    /**
+     * Creates a path.
+     *
+     * @param first First element of the path.
+     * @param more Additional element of the path.
+     * @return The path.
+     * @throws InvalidPathException if the path can not be created.
+     */
+    public static Path get(final String first, final String... more) throws InvalidPathException {
+        try {
+            Path path = new Path(first);
+            for (final String other : more) {
+                path = new Path(path, other);
+            }
+            return path;
+        } catch (RuntimeException e) {
+            throw new InvalidPathException(e);
+        }
+    }
+
+    /**
+     * Returns a path for the given URI.
+     *
+     * @param uri The URI
+     * @return The path.
+     * @throws IllegalArgumentException if the path can not be created.
+     */
+    public static Path get(final URI uri) throws IllegalArgumentException {
+        return new Path(uri);
+    }
+}

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk7/Paths.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -26,8 +26,18 @@ import java.util.Locale;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicReference;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
 import javax.xml.bind.DatatypeConverter;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
+import org.apache.sis.internal.jdk7.Objects;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.StandardCharsets;
+
 
 /**
  * Place holder for some functionalities defined only in JDK8.
@@ -35,7 +45,7 @@ import javax.xml.bind.DatatypeConverter;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class JDK8 {
@@ -53,6 +63,74 @@ public final class JDK8 {
     }
 
     /**
+     * Compares two numbers as unsigned.
+     *
+     * @param  x First unsigned value.
+     * @param  y Second unsigned value.
+     * @return Comparison result.
+     *
+     * @since 0.7
+     */
+    public static int compareUnsigned(final int x, final int y) {
+        return JDK7.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
+    }
+
+    /**
+     * Returns the given byte as an unsigned integer.
+     *
+     * @param x The byte to return as an unsigned integer.
+     * @return The unsigned value of the given byte.
+     *
+     * @since 0.7
+     */
+    public static int toUnsignedInt(final byte x) {
+        return x & 0xFF;
+    }
+
+    /**
+     * Returns the given short as an unsigned integer.
+     *
+     * @param x The short to return as an unsigned integer.
+     * @return The unsigned value of the given short.
+     *
+     * @since 0.7
+     */
+    public static int toUnsignedInt(final short x) {
+        return x & 0xFFFF;
+    }
+
+    /**
+     * Safe cast of the given long to integer.
+     *
+     * @param value The value to cast.
+     * @return The casted value.
+     * @throws ArithmeticException if the value overflows.
+     *
+     * @since 0.7
+     */
+    public static int toIntExact(final long value) {
+        final int vi = (int) value;
+        if (vi != value) {
+            throw new ArithmeticException();
+        }
+        return vi;
+    }
+
+    /**
+     * Safe product of the arguments.
+     *
+     * @param x The first value.
+     * @param y The second value.
+     * @return The product.
+     * @throws ArithmeticException if the value overflows.
+     *
+     * @since 0.7
+     */
+    public static int multiplyExact(final int x, final int y) {
+        return toIntExact(x * (long) y);
+    }
+
+    /**
      * Returns the floating-point value adjacent to {@code value} in the direction of negative infinity.
      *
      * @param  value The value for which to get the adjacent value.
@@ -102,6 +180,27 @@ public final class JDK8 {
     }
 
     /**
+     * Removes the entry for the given key, provided that it is currently mapped to the given value.
+     *
+     * @param  <K>   The type of keys.
+     * @param  <V>   The type of values.
+     * @param  map   The map from where to remove the value.
+     * @param  key   The key for the value to remove.
+     * @param  value The value that must exist for allowing removal.
+     * @return {@code true} if the entry has been removed.
+     *
+     * @since 0.7
+     */
+    public static <K,V> boolean remove(final Map<K,V> map, final Object key, final Object value) {
+        final Object current = map.get(key);
+        final boolean c = Objects.equals(current, value) && (current != null || map.containsKey(key));
+        if (c) {
+            map.remove(key);
+        }
+        return c;
+    }
+
+    /**
      * Removes all elements for which the given filter returns {@code true}.
      *
      * @param  <E>        The type of elements in the given collection.
@@ -193,7 +292,33 @@ public final class JDK8 {
         }
         calendar.setTime(date);
         final String text = DatatypeConverter.printDateTime(calendar);
-        CALENDAR.set(calendar); // Recycle for future usage.
+        CALENDAR.set(calendar);                                                 // Recycle for future usage.
         return text;
     }
+
+    /**
+     * Creates a buffered reader using UTF-8 encoding.
+     *
+     * @param path The file to open.
+     * @return The reader.
+     * @throws IOException if an error occurred while opening the reader.
+     *
+     * @since 0.7
+     */
+    public static BufferedReader newBufferedReader(final Path path) throws IOException {
+        return Files.newBufferedReader(path, StandardCharsets.UTF_8);
+    }
+
+    /**
+     * Creates a buffered writer using UTF-8 encoding.
+     *
+     * @param path The file to open.
+     * @return The writer.
+     * @throws IOException if an error occurred while opening the writer.
+     *
+     * @since 0.7
+     */
+    public static BufferedWriter newBufferedWriter(final Path path) throws IOException {
+        return Files.newBufferedWriter(path, StandardCharsets.UTF_8);
+    }
 }

Copied: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java (from r1724479, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java?p2=sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java&p1=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -23,10 +23,10 @@ import org.apache.sis.util.logging.Loggi
 import org.apache.sis.util.resources.Messages;
 
 // Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.InvalidPathException;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
+import org.apache.sis.internal.jdk7.InvalidPathException;
 
 
 /**

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -24,97 +24,49 @@ import org.apache.sis.util.logging.Loggi
 
 /**
  * A thread executing short tasks after some (potentially zero nanosecond) delay.
- * This thread is reserved to internal SIS usage - no user code shall be executed here.
- * All submitted tasks shall be very quick, since there is only one thread shared by everyone.
+ * This class should be reserved to internal SIS usage without user's code.
+ * In practice some user code may be indirectly executed through SIS tasks invoking overrideable methods.
+ * But all submitted tasks shall be very quick, since there is only one thread shared by everyone.
  *
- * <div class="note"><b>Note:</b>
- * In practice some user code may be indirectly executed, since some SIS tasks invoke overrideable methods.
- * We may need to revisit the {@code DelayedExecutor} design in a future version if the above happens to be
- * a problem. For example we may allow the user to specify an application-wide scheduled executor and delegate
- * the tasks to that executor.</div>
- *
- * The methods for use in this class are:
+ * <p>The methods for use in this class are:</p>
  * <ul>
- *   <li>{@link #executeDaemonTask(DelayedRunnable)}</li>
- *   <li>{@link #schedule(DelayedRunnable)}</li>
+ *   <li>{@link #schedule(Runnable, long)}</li>
  * </ul>
  *
  * <div class="section">Comparison with {@code java.util.concurrent}</div>
- * We tried to use {@link java.util.concurrent.ScheduledThreadPoolExecutor} in a previous version,
- * but it seems more suitable to heavier tasks in applications controlling their own executor. For
- * example {@code ScheduledThreadPoolExecutor} acts as a fixed-sized pool, thus forcing us to use
- * only one thread if we don't want to waste resources (profiling shows that even a single thread
- * has very low activity). The {@code ThreadPoolExecutor} super-class is more flexible but still
- * have a quite aggressive policy on threads creation, and doesn't handle delayed tasks by itself.
- * We could combine both worlds with a {@code ThreadPoolExecutor} using a {@code DelayedQueue},
- * but it forces us to declare a core pool size of 0 otherwise {@code ThreadPoolExecutor} tries
- * to execute the tasks immediately without queuing them. Combined with the {@code DelayedQueue}
- * characteristics (being an unbounded queue), this result in {@code ThreadPoolExecutor} never
- * creating more than one thread (because it waits for the queue to reject a task before to create
- * more threads than the pool size).
+ * We tried to use {@link java.util.concurrent.ScheduledThreadPoolExecutor} in a previous SIS version,
+ * but its "fixed-sized pool" design forces us to use only one thread if we do not want to waste resources
+ * (profiling shows that even a single thread has very low activity), which reduces the interest of that class.
+ * Combination of {@code ThreadPoolExecutor} super-class with {@code DelayedQueue} were not successful neither.
  *
- * <p>Given that it seems difficult to configure {@code (Scheduled)ThreadPoolExecutor} in such
- * a way that two or more threads are created only when really needed, given that using those
- * thread pools seems an overkill when the pool size is fixed to one thread, given that our
- * profiling has show very low activity for that single thread anyway, and given that we do
- * not need cancellation and shutdown services for house keeping tasks (this is a daemon thread),
+ * <p>Given that it:</p>
+ * <ul>
+ *   <li>it seems difficult to configure {@code (Scheduled)ThreadPoolExecutor} in such a way
+ *       that two or more threads are created only when really needed,</li>
+ *   <li>using those executor services seems an overkill when the pool size is fixed to one thread,</li>
+ *   <li>our profiling has show very low activity for that single thread anyway,</li>
+ *   <li>we do not need cancellation and shutdown services for house keeping tasks (this is a daemon thread),</li>
+ * </ul>
  * a more lightweight solution seems acceptable here. Pseudo-benchmarking using the
- * {@code CacheTest.stress()} tests suggests that the lightweight solution is faster.</p>
- *
- * <div class="section">Future evolution</div>
- * We may remove (again) this class in a future SIS evolution if we happen to need an executor anyway.
- * However it may be better to wait and see what are the executor needs. Setting up an executor implies
- * choosing many arbitrary parameter values like the number of core threads, maximum threads, idle time,
- * queue capacity, etc. Furthermore some platforms (e.g. MacOS) provide OS-specific implementations
- * integrating well in their environment. We may want to let the user provides the executor of his
- * choice, or we way want to have more profiling data for choosing an appropriate executor. But we
- * may need to find some way to give priority to SIS tasks, since most of them are for releasing
- * resources - in which case quick execution probably help the system to run faster.
- * However before to switch from the lightweight solution to a more heavy solution,
- * micro-benchmarking is desirable. The {@code CacheTest.stress()} tests can be used
- * in first approximation.
+ * {@code CacheTest.stress()} tests suggests that the lightweight solution is faster.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  *
  * @see <a href="https://issues.apache.org/jira/browse/SIS-76">SIS-76</a>
  */
 public final class DelayedExecutor extends DaemonThread {
     /**
-     * Executes the given short task in a daemon thread. This method shall be invoked for
-     * Apache SIS tasks only, <strong>not</strong> for arbitrary user task. The task must
-     * completes quickly, because we will typically use only one thread for all submitted
-     * tasks. Completion of the task shall not be critical, since the JVM is allowed to
-     * shutdown before task completion.
-     *
-     * <div class="section">Future evolution</div>
-     * If {@code DelayedExecutor} is removed in a future SIS version in favor of JDK6 executors,
-     * then the method signature will probably be {@code Executors.execute(Runnable)}.
-     *
-     * @param task The task to execute.
-     */
-    public static void executeDaemonTask(final DelayedRunnable task) {
-        QUEUE.add(task);
-    }
-
-    /**
      * Schedules the given short task for later execution in a daemon thread.
-     * The task will be executed after the delay specified by {@link DelayedRunnable#getDelay}
-     * The task must completes quickly, because we will typically use only one thread for all
-     * submitted tasks. Completion of the task shall not be critical, since the JVM is allowed
-     * to shutdown before task completion.
-     *
-     * <div class="section">Future evolution</div>
-     * If {@code DelayedExecutor} is removed in a future SIS version in favor of JDK6 executors,
-     * then the method signature will probably be {@code Executors.schedule(Runnable, long, TimeUnit)}.
+     * The task will be executed after the delay specified by {@link DelayedRunnable#getDelay(TimeUnit)}
+     * The task must completes quickly, because we will typically use only one thread for all submitted tasks.
+     * Completion of the task shall not be critical, since the JVM is allowed to shutdown before task completion.
      *
      * @param task The task to schedule for later execution.
      */
     public static void schedule(final DelayedRunnable task) {
-        // For now the implementation is identical to 'execute'. However it may become
-        // different if we choose to use a library-wide executor in a future SIS version.
         QUEUE.add(task);
     }
 

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedRunnable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedRunnable.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedRunnable.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedRunnable.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -39,6 +39,12 @@ public abstract class DelayedRunnable im
      * Time of execution of this task, in nanoseconds provided by {@link System#nanoTime()}.
      * In the particular case of the {@link Immediate} subclass, the meaning of this field is
      * modified: it is rather an ordinal value used for preserving task order.
+     *
+     * <div class="note"><b>Note:</b>
+     * we use {@link System#nanoTime()} instead than {@link System#currentTimeMillis()} because
+     * the later is not guaranteed to be monotonic: {@code currentTimeMillis} may change abruptly
+     * for example if the user adjusts the clock of his operating system.
+     * </div>
      */
     final long timestamp;
 
@@ -74,7 +80,7 @@ public abstract class DelayedRunnable im
     @Override
     public int compareTo(final Delayed other) {
         if (other instanceof Immediate) {
-            return +1; // "Immediate" tasks always have precedence over delayed ones.
+            return +1;                      // "Immediate" tasks always have precedence over delayed ones.
         }
         return Long.signum(timestamp - ((DelayedRunnable) other).timestamp);
     }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,6 +16,18 @@
  */
 package org.apache.sis.internal.system;
 
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.logging.Handler;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import org.apache.sis.util.Static;
+import org.apache.sis.util.logging.Logging;
+
 
 /**
  * Names of loggers used in SIS other than the "module-wide" loggers. We often use approximatively one logger
@@ -24,10 +36,15 @@ package org.apache.sis.internal.system;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
-public final class Loggers {
+public final class Loggers extends Static {
+    /**
+     * The root logger.
+     */
+    public static final String ROOT = "org.apache.sis";
+
     /**
      * The logger for Apache SIS internal operations. The name of this logger does not match the package name
      * of the classes using it, because this logger name does not have the {@code "internal"} part in it.
@@ -35,6 +52,11 @@ public final class Loggers {
     public static final String SYSTEM = "org.apache.sis.system";
 
     /**
+     * The logger for operations related to JDBC operations.
+     */
+    public static final String SQL = "org.apache.sis.sql";
+
+    /**
      * The logger for operations related to XML marshalling or unmarshalling.
      */
     public static final String XML = "org.apache.sis.xml";
@@ -74,8 +96,105 @@ public final class Loggers {
     public static final String LOCALIZATION = "org.apache.sis.util.resources";
 
     /**
+     * The logger name for operation related to application (console, GUI or web).
+     */
+    public static final String APPLICATION = "org.apache.sis.application";
+
+    /**
      * Do not allow instantiation of this class.
      */
     private Loggers() {
     }
+
+    /**
+     * Returns a map of effective logging levels for SIS loggers. The effective logging level take in account the level
+     * of parent loggers and the level of handlers. For example if a logger level is set to {@link Level#FINE} but no
+     * handler have a level finer than {@link Level#INFO}, then the effective logging level will be {@link Level#INFO}.
+     *
+     * <p>This method does not report the loggers that have an effective level identical to its parent logger.</p>
+     *
+     * @return The effective logging levels of SIS loggers.
+     */
+    public static SortedMap<String,Level> getEffectiveLevels() {
+        final SortedMap<String,Level> levels = new TreeMap<String,Level>();
+        for (final Field field : Loggers.class.getDeclaredFields()) {
+            if (Modifier.isStatic(field.getModifiers()) && field.getType() == String.class) try {
+                levels.put((String) field.get(null), null);
+            } catch (IllegalAccessException e) {
+                /*
+                 * Should never happen, unless we added some fields and forgot to update this method.
+                 * In such case forget the problematic fields and search the next one. This is okay
+                 * since this method is only for information purpose.
+                 */
+                Logging.unexpectedException(Logging.getLogger(SYSTEM), Loggers.class, "getEffectiveLevels", e);
+            }
+        }
+        /*
+         * Process the loggers in alphabetical order. The intend is to process parent loggers before child.
+         * The first logger in the map should be the SIS root logger, "org.apache.sis".
+         */
+        final Iterator<Map.Entry<String,Level>> it = levels.entrySet().iterator();
+        while (it.hasNext()) {
+            final Map.Entry<String,Level> entry = it.next();
+            final String name = entry.getKey();
+            final Logger logger = Logging.getLogger(name);
+            Level level = getEffectiveLevel(logger);
+            final Level h = getHandlerLevel(logger);
+            if (h.intValue() > level.intValue()) {
+                level = h;                              // Take in account the logging level of handlers.
+            }
+            entry.setValue(level);
+            /*
+             * Now verify if the level is identical to the effective level of parent logger.
+             * If they are identical, then we remove the entry in order to report only the changes.
+             */
+            Logger parent = logger;
+            while ((parent = parent.getParent()) != null) {
+                final Level p = levels.get(parent.getName());
+                if (p != null) {
+                    if (p.equals(level)) {
+                        it.remove();
+                    }
+                    break;
+                }
+            }
+        }
+        return levels;
+    }
+
+    /**
+     * Returns the effective level of the given logger, searching in the parent loggers if needed.
+     * This method does not verify if handlers have higher level.
+     */
+    private static Level getEffectiveLevel(Logger logger) {
+        while (logger != null) {
+            final Level level = logger.getLevel();
+            if (level != null) {
+                return level;
+            }
+            logger = logger.getParent();
+        }
+        return Level.INFO;      // Default value specified by the java.util.logging framework.
+    }
+
+    /**
+     * Returns the finest level of registered handlers for the given logger.
+     * This method verifies also in the parent handlers if the logger use them.
+     */
+    private static Level getHandlerLevel(Logger logger) {
+        Level level = Level.OFF;
+        while (logger != null) {
+            for (final Handler handler : logger.getHandlers()) {
+                final Level c = handler.getLevel();
+                if (c != null && c.intValue() < level.intValue()) {
+                    level = c;
+                }
+            }
+            if (!logger.getUseParentHandlers()) {
+                break;
+            }
+            logger = logger.getParent();
+        }
+        return level;
+    }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.system;
 
-import javax.management.JMException;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleEvent;
@@ -30,7 +29,7 @@ import org.osgi.framework.BundleListener
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  *
  * @see ServletListener
@@ -50,6 +49,7 @@ public final class OSGiActivator impleme
     @Override
     public void start(final BundleContext context) {
         context.addBundleListener(this);
+        Shutdown.setContainer("OSGi");
     }
 
     /**
@@ -57,10 +57,10 @@ public final class OSGiActivator impleme
      * This method shutdowns the {@code sis-utility} threads.
      *
      * @param  context The execution context of the bundle being stopped.
-     * @throws JMException If an error occurred during unregistration of the supervisor MBean.
+     * @throws Exception If an error occurred during unregistration of the supervisor MBean or resource disposal.
      */
     @Override
-    public void stop(final BundleContext context) throws JMException {
+    public void stop(final BundleContext context) throws Exception {
         context.removeBundleListener(this);
         Shutdown.stop(getClass());
     }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -36,7 +36,7 @@ public final class Semaphores {
      * {@code AbstractDerivedCRS} objects contain a {@code conversionFromBase} field, which contains a
      * {@code DefaultConversion.targetCRS} field referencing back the {@code AbstractDerivedCRS} object.
      */
-    public static final byte COMPARING = 1;
+    public static final byte CONVERSION_AND_CRS = 1;
 
     /**
      * A flag to indicate that {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation}
@@ -71,7 +71,7 @@ public final class Semaphores {
     /**
      * Returns {@code true} if the given flag is set.
      *
-     * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
+     * @param flag One of {@link #CONVERSION_AND_CRS}, {@link #ENCLOSED_IN_OPERATION} or other constants.
      * @return {@code true} if the given flag is set.
      */
     public static boolean query(final byte flag) {
@@ -82,7 +82,7 @@ public final class Semaphores {
     /**
      * Sets the given flag.
      *
-     * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
+     * @param flag One of {@link #CONVERSION_AND_CRS}, {@link #ENCLOSED_IN_OPERATION} or other constants.
      * @return {@code true} if the given flag was already set.
      */
     public static boolean queryAndSet(final byte flag) {
@@ -99,7 +99,7 @@ public final class Semaphores {
     /**
      * Clears the given flag.
      *
-     * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
+     * @param flag One of {@link #CONVERSION_AND_CRS}, {@link #ENCLOSED_IN_OPERATION} or other constants.
      */
     public static void clear(final byte flag) {
         final Semaphores s = FLAGS.get();

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/ServletListener.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/ServletListener.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/ServletListener.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/ServletListener.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.system;
 
-import javax.management.JMException;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 import javax.servlet.annotation.WebListener;
@@ -28,7 +27,7 @@ import javax.servlet.annotation.WebListe
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  *
  * @see OSGiActivator
@@ -42,6 +41,8 @@ public final class ServletListener imple
      */
     @Override
     public void contextInitialized(final ServletContextEvent event) {
+        final String env = event.getServletContext().getServerInfo();
+        Shutdown.setContainer(env != null ? env : "Servlet");
     }
 
     /**
@@ -53,7 +54,7 @@ public final class ServletListener imple
     public void contextDestroyed(final ServletContextEvent event) {
         try {
             Shutdown.stop(getClass());
-        } catch (JMException e) {
+        } catch (Exception e) {
             event.getServletContext().log(e.toString(), e);
         }
     }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,48 +16,177 @@
  */
 package org.apache.sis.internal.system;
 
-import javax.management.JMException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
 import org.apache.sis.util.logging.Logging;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
 
 /**
  * A central place where to manage SIS shutdown process.
- * For now this class is not yet registered as a shutdown hock,
- * but it will be in a future version.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
-public final class Shutdown {
+public final class Shutdown extends Thread {
+    /**
+     * Non-null if a shutdown hook is already registered. That shutdown hook is not necessarily {@link #hook}.
+     * It may be an OSGi or Servlet shutdown hook instead, as notified by {@link #setContainer(String)}.
+     */
+    private static String container;
+
+    /**
+     * The shutdown hook to be registered to the JVM {@link Runtime}, created when first needed.
+     */
+    private static Shutdown hook;
+
     /**
-     * Do not allow instantiation of this class.
+     * The resources to dispose. Most recently added resources are last.
+     */
+    private static final List<Callable<?>> resources = new ArrayList<Callable<?>>();
+
+    /**
+     * Creates the thread to be executed at shutdown time.
      */
     private Shutdown() {
+        super(Threads.SIS, "Shutdown");
     }
 
     /**
-     * Shutdowns the {@code sis-utility} threads and unregister the supervisor MBean.
+     * Invoked at JVM shutdown time.
+     */
+    @Override
+    @SuppressWarnings("CallToPrintStackTrace")
+    public void run() {
+        try {
+            Shutdown.stop((Class<?>) null);
+        } catch (Exception e) {
+            /*
+             * Too late for logging since we are in process of shutting down the Java Virtual Machine.
+             * It is still possible to write the stack trace to System.err, but this is about all we can do.
+             */
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Returns the value set by the last call to {@link #setContainer(String)}.
+     *
+     * @return Typically {@code "OSGi"}, {@code "Servlet"} or {@code null}.
+     */
+    public static String getContainer() {
+        synchronized (resources) {
+            return container;
+        }
+    }
+
+    /**
+     * Invoked if the Apache SIS library is executed from an environment that provide its own shutdown hook.
+     * Example of such environments are OSG and servlet containers. In such case, the shutdown hook will not
+     * be registered to the JVM {@link Runtime}.
      *
-     * @param  caller The class invoking this method, to be used only for logging purpose,
-     *         or {@code null} if the logging system is not available anymore (i.e. the JVM
-     *         itself is shutting down).
-     * @throws JMException If an error occurred during unregistration of the supervisor MBean.
+     * @param env A description of the container. Should contain version information if possible.
+     *            Example: {@code "OSGi"} or {@code "JavaServer Web Dev Kit/1.0"}.
      */
-    public static void stop(final Class<?> caller) throws JMException {
+    public static void setContainer(final String env) {
+        Objects.requireNonNull(env);
+        synchronized (resources) {
+            removeShutdownHook();       // Should not be needed but we are paranoiac.
+            container = env;
+        }
+    }
+
+    /**
+     * Registers a code to execute at JVM shutdown time. The resources will be disposed at
+     * shutdown time in reverse order (most recently added resources will be disposed first).
+     *
+     * <p>The same resource shall not be added twice.</p>
+     *
+     * @param resource The resource disposal to register for execution at shutdown time.
+     */
+    public static void register(final Callable<?> resource) {
+        synchronized (resources) {
+            assert !resources.contains(resource);
+            resources.add(resource);
+            if (hook == null && container == null) {
+                hook = new Shutdown();
+                Runtime.getRuntime().addShutdownHook(hook);
+            }
+        }
+    }
+
+    /**
+     * Removes the shutdown hook, if any.
+     */
+    private static void removeShutdownHook() {
+        assert Thread.holdsLock(resources);
+        if (hook != null) {
+            Runtime.getRuntime().removeShutdownHook(hook);
+            hook = null;
+        }
+    }
+
+    /**
+     * Unregisters a code from execution at JVM shutdown time.
+     * This method uses identity comparison (it does not use {@link Object#equals(Object)}).
+     *
+     * @param resource The resource disposal to cancel execution.
+     */
+    public static void unregister(final Callable<?> resource) {
+        synchronized (resources) {
+            for (int i = resources.size(); --i>=0;) {       // Check most recently added resources first.
+                if (resources.get(i) == resource) {
+                    resources.remove(i);
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Unregister the supervisor MBean, executes the disposal tasks and shutdowns the {@code sis-utility} threads.
+     *
+     * @param  caller The class invoking this method, to be used only for logging purpose, or {@code null}
+     *         if the logging system is not available anymore (i.e. the JVM itself is shutting down).
+     * @throws Exception If an error occurred during unregistration of the supervisor MBean
+     *         or during a resource disposal.
+     */
+    public static void stop(final Class<?> caller) throws Exception {
+        synchronized (resources) {
+            container = "Shutdown";
+            if (caller != null) {
+                removeShutdownHook();
+            }
+        }
         /*
          * Unregister the MBean before to stop the threads, in order to avoid false alerts
          * in the superviror 'warnings()' method. Failure to unregister the MBean is worth
          * to report, but we will do that only after we completed the other shutdown steps.
          */
-        JMException exception = null;
+        Exception exception = null;
         if (Supervisor.ENABLED) try {
             Supervisor.unregister();
-        } catch (JMException deferred) {
+        } catch (Exception deferred) {
             exception = deferred;
         }
         /*
+         * Dispose resources, if any, starting with most recently registered. The disposal code should not
+         * invoke Shutdown.[un]register(Disposable), but we nevertheless make the loop robust to this case.
+         */
+        synchronized (resources) {
+            int i;
+            while ((i = resources.size()) != 0) try {       // In case run() modifies the resources list.
+                resources.remove(i - 1).call();             // Dispose most recently added resources first.
+            } catch (Exception e) {
+                exception = e;
+            }
+        }
+        /*
          * Following is usually fast, but may potentially take a little while.
          * If an other thread invoked Thread.interrupt() while we were waiting
          * for the threads to terminate, maybe not all threads have terminated

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -37,7 +37,6 @@ import javax.management.InstanceAlreadyE
 import java.lang.management.ManagementFactory;
 
 import org.apache.sis.setup.About;
-import org.apache.sis.util.Localized;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Messages;
@@ -52,10 +51,10 @@ import org.apache.sis.util.collection.Tr
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
-public final class Supervisor extends StandardMBean implements SupervisorMBean, Localized {
+public final class Supervisor extends StandardMBean implements SupervisorMBean {
     /**
      * Whatever JMX agent is enabled. Setting this variable to {@code false} allows the
      * Java compiler to omit any dependency to this {@code Supervisor} class.
@@ -82,13 +81,13 @@ public final class Supervisor extends St
      * and the MBean will not be registered. This method does not propagate the exception
      * because the MBean is not a mandatory part of SIS library.</p>
      */
-    static synchronized void register() {
+    public static synchronized void register() {
         if (name == null) {
             name = ObjectName.WILDCARD; // In case of failure.
             final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
             try {
                 final ObjectName n = new ObjectName(NAME);
-                server.registerMBean(new Supervisor(null, null), n);
+                server.registerMBean(new Supervisor(), n);
                 name = n; // Store only on success.
             } catch (InstanceAlreadyExistsException e) {
                 final LogRecord record = Messages.getResources(null)
@@ -119,34 +118,12 @@ public final class Supervisor extends St
     }
 
     /**
-     * The locale for producing the messages, or {@code null} for the default.
-     */
-    private final Locale locale;
-
-    /**
-     * The timezone for formatting the dates, or {@code null} for the default.
-     */
-    private final TimeZone timezone;
-
-    /**
-     * Creates a new {@code Supervisor} which will report messages in the given locale.
+     * Creates a new {@code Supervisor}.
      *
-     * @param  locale The locale to use for reporting messages, or {@code null} for the default.
-     * @param  timezone The timezone for formatting the dates, or {@code null} for the default.
      * @throws NotCompliantMBeanException Should never happen.
      */
-    public Supervisor(final Locale locale, final TimeZone timezone) throws NotCompliantMBeanException {
+    public Supervisor() throws NotCompliantMBeanException {
         super(SupervisorMBean.class);
-        this.locale   = locale;
-        this.timezone = timezone;
-    }
-
-    /**
-     * Returns the supervisor locale, or {@code null} for the default locale.
-     */
-    @Override
-    public Locale getLocale() {
-        return locale;
     }
 
     /**
@@ -210,7 +187,7 @@ public final class Supervisor extends St
      */
     private String getDescription(final String resourceKey) {
         return ResourceBundle.getBundle("org.apache.sis.internal.system.Descriptions",
-                (locale != null) ? locale : Locale.getDefault(),
+                Locale.getDefault(),
                 Supervisor.class.getClassLoader()).getString(resourceKey);
     }
 
@@ -222,15 +199,15 @@ public final class Supervisor extends St
      * {@inheritDoc}
      */
     @Override
-    public TreeTable configuration() {
-        return About.configuration(EnumSet.allOf(About.class), locale, timezone);
+    public TreeTable configuration(final EnumSet<About> sections, final Locale locale, final TimeZone timezone) {
+        return About.configuration(sections, locale, timezone);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public String[] warnings() {
+    public String[] warnings(final Locale locale) {
         final DaemonThread lastCreatedDaemon;
         synchronized (Threads.class) {
             lastCreatedDaemon = Threads.lastCreatedDaemon;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,6 +16,10 @@
  */
 package org.apache.sis.internal.system;
 
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.TimeZone;
+import org.apache.sis.setup.About;
 import org.apache.sis.util.collection.TreeTable;
 
 
@@ -24,7 +28,7 @@ import org.apache.sis.util.collection.Tr
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 public interface SupervisorMBean {
@@ -35,15 +39,19 @@ public interface SupervisorMBean {
      * Apache SIS version, Java version and operation system version; a "Classpath"
      * section containing bootstrap, extension and user classpath, <i>etc</i>.
      *
+     * @param  sections The section for which information are desired.
+     * @param  locale   The locale to use for formatting the texts in the tree, or {@code null} for the default.
+     * @param  timezone The timezone to use for formatting the dates, or {@code null} for the default.
      * @return Configuration information, as a tree for grouping some configuration by sections.
      */
-    TreeTable configuration();
+    TreeTable configuration(EnumSet<About> sections, Locale locale, TimeZone timezone);
 
     /**
      * If there is something wrong with the current Apache SIS status,
      * returns descriptions of the problems. Otherwise returns {@code null}.
      *
+     * @param  locale The locale to use for reporting messages, or {@code null} for the default.
      * @return A description of a problems in the library, or {@code null} if none.
      */
-    String[] warnings();
+    String[] warnings(Locale locale);
 }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Threads.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Threads.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Threads.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/Threads.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,8 +16,6 @@
  */
 package org.apache.sis.internal.system;
 
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.ExecutorService;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.logging.Logging;
 
@@ -34,7 +32,7 @@ import org.apache.sis.util.logging.Loggi
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 final class Threads extends Static {
@@ -83,19 +81,6 @@ final class Threads extends Static {
     static DaemonThread lastCreatedDaemon;
 
     /**
-     * Executor to shutdown. This is a copy of the {@code <removed class>} executor static final
-     * field, copied here only when the {@code <removed class>} class is loaded and initialized.
-     * We proceed that way for avoiding dependency from {@code Threads} to {@code <removed class>}.
-     *
-     * <p>This field has been temporarily fixed to {@code null} since we removed executor as of
-     * <a href="https://issues.apache.org/jira/browse/SIS-76">SIS-76</a>. However we may revert
-     * to a modifiable field in a future version if we choose to use executor again. In the main
-     * time, we declare this field as {@code final} for allowing the Javac compiler to omit all
-     * compiled code inside {@code if (executor != null)} block.</p>
-     */
-    private static final ExecutorService executor = null;
-
-    /**
      * Do not allows instantiation of this class.
      */
     private Threads() {
@@ -114,20 +99,6 @@ final class Threads extends Static {
      *         we were waiting for the daemon threads to die.
      */
     static synchronized void shutdown(final long stopWaitingAt) throws InterruptedException {
-        if (executor != null) {
-            executor.shutdown();
-            /*
-             * Wait for work completion. In theory this is not necessary since the daemon
-             * tasks are only house-cleaning work. We nevertheless wait for their completion
-             * as a safety. There tasks are supposed to be short.
-             */
-            final long delay = stopWaitingAt - System.nanoTime();
-            if (delay > 0) {
-                executor.awaitTermination(delay, TimeUnit.NANOSECONDS);
-                // Even if the tasks didn't completed, continue without waiting for them.
-                // We can not log at this point, since the logging framework may be shutdown.
-            }
-        }
         DaemonThread.killAll(lastCreatedDaemon, stopWaitingAt);
     }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/package-info.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/package-info.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -25,7 +25,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 package org.apache.sis.internal.system;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -374,6 +374,29 @@ public abstract class AbstractMap<K,V> i
                 final EntryIterator<K,V> it = entryIterator();
                 return (it != null) ? new Keys<K,V>(it) : Collections.<K>emptySet().iterator();
             }
+
+            /** Overridden for the same reason than {@link AbstractMap#equals(Object). */
+            @Override public boolean equals(final Object object) {
+                if (object == this) {
+                    return true;
+                }
+                if (!(object instanceof Set<?>)) {
+                    return false;
+                }
+                final Set<?> that = (Set<?>) object;
+                final EntryIterator<K,V> it = entryIterator();
+                if (it == null) {
+                    return that.isEmpty();
+                }
+                int size = 0;
+                while (it.next()) {
+                    if (!that.contains(it.getKey())) {
+                        return false;
+                    }
+                    size++;
+                }
+                return size == that.size();
+            }
         };
     }
 
@@ -433,6 +456,29 @@ public abstract class AbstractMap<K,V> i
                 final EntryIterator<K,V> it = entryIterator();
                 return (it != null) ? new Entries<K,V>(it) : Collections.<Entry<K,V>>emptySet().iterator();
             }
+
+            /** Overridden for the same reason than {@link AbstractMap#equals(Object). */
+            @Override public boolean equals(final Object object) {
+                if (object == this) {
+                    return true;
+                }
+                if (!(object instanceof Set<?>)) {
+                    return false;
+                }
+                final Set<?> that = (Set<?>) object;
+                final EntryIterator<K,V> it = entryIterator();
+                if (it == null) {
+                    return that.isEmpty();
+                }
+                int size = 0;
+                while (it.next()) {
+                    if (!that.contains(it.getEntry())) {
+                        return false;
+                    }
+                    size++;
+                }
+                return size == that.size();
+            }
         };
     }
 
@@ -543,27 +589,27 @@ public abstract class AbstractMap<K,V> i
         if (object == this) {
             return true;
         }
-        if (object instanceof Map) {
-            final Map<?,?> map = (Map<?,?>) object;
-            final EntryIterator<K,V> it = entryIterator();
-            if (it == null) {
-                return map.isEmpty();
-            }
-            /*
-             * We do not check if map.size() == size() because in some Apache SIS implementations,
-             * the size() method have to scan through all map entries. We presume that if the maps
-             * are not equal, we will find a mismatched entry soon anyway.
-             */
-            int size = 0;
-            while (it.next()) {
-                if (!it.getValue().equals(map.get(it.getKey()))) {
-                    return false;
-                }
-                size++;
+        if (!(object instanceof Map<?,?>)) {
+            return false;
+        }
+        final Map<?,?> that = (Map<?,?>) object;
+        final EntryIterator<K,V> it = entryIterator();
+        if (it == null) {
+            return that.isEmpty();
+        }
+        /*
+         * We do not check if map.size() == size() because in some Apache SIS implementations,
+         * the size() method have to scan through all map entries. We presume that if the maps
+         * are not equal, we will find a mismatched entry soon anyway.
+         */
+        int size = 0;
+        while (it.next()) {
+            if (!it.getValue().equals(that.get(it.getKey()))) {
+                return false;
             }
-            return size == map.size();
+            size++;
         }
-        return false;
+        return size == that.size();
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -32,7 +32,7 @@ import org.apache.sis.util.Static;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class Constants extends Static {
@@ -78,6 +78,16 @@ public final class Constants extends Sta
     public static final byte CRS84 = 84;
 
     /**
+     * The {@code CRS:88} identifier for a coordinate reference system.
+     */
+    public static final byte CRS88 = 88;
+
+    /**
+     * The {@code CRS:1} identifier for a coordinate reference system.
+     */
+    public static final byte CRS1 = 1;
+
+    /**
      * The NetCDF parameter name for the Earth radius.
      */
     public static final String EARTH_RADIUS = "earth_radius";
@@ -101,6 +111,11 @@ public final class Constants extends Sta
     public static final String CENTRAL_MERIDIAN = "central_meridian";
 
     /**
+     * The OGC parameter name for the latitude of origin.
+     */
+    public static final String LATITUDE_OF_ORIGIN = "latitude_of_origin";
+
+    /**
      * The NetCDF parameter name for the standard parallels.
      */
     public static final String STANDARD_PARALLEL = "standard_parallel";
@@ -169,6 +184,21 @@ public final class Constants extends Sta
     public static final short EPSG_B0 = 8639;
 
     /**
+     * The EPSG code for metres.
+     */
+    public static final short EPSG_METRE = 9001;
+
+    /**
+     * The EPSG code for degrees when used in parameters.
+     */
+    public static final short EPSG_PARAM_DEGREES = 9102;
+
+    /**
+     * The EPSG code for degrees when used in axes.
+     */
+    public static final short EPSG_AXIS_DEGREES = 9122;
+
+    /**
      * Do not allow instantiation of this class.
      */
     private Constants() {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -21,6 +21,9 @@ import org.apache.sis.math.MathFunctions
 import org.apache.sis.math.DecimalFunctions;
 // No BigDecimal dependency - see class javadoc
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * Basic arithmetic methods for extended precision numbers using the <cite>double-double</cite> algorithm.
@@ -284,7 +287,7 @@ public final class DoubleDouble extends
     @Override public double doubleValue() {return value;}
     @Override public float  floatValue()  {return (float) value;}
     @Override public long   longValue()   {return Math.round(value);}
-    @Override public int    intValue()    {return (int) longValue();}
+    @Override public int    intValue()    {return JDK8.toIntExact(longValue());}
 
     /**
      * Suggests an {@link #error} for the given value. The {@code DoubleDouble} class contains a hard-coded list

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -25,6 +25,9 @@ import org.apache.sis.util.ComparisonMod
 import static java.lang.Math.max;
 import static java.lang.Math.abs;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * Miscellaneous utilities methods working on floating point numbers.
@@ -180,7 +183,7 @@ public final class Numerics extends Stat
         if (data == null) return null;
         final int[] result = new int[data.length];
         for (int i=0; i<data.length; i++) {
-            result[i] = (int) Math.round(data[i]);
+            result[i] = JDK8.toIntExact(Math.round(data[i]));
         }
         return result;
     }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -120,6 +120,7 @@ public enum X364 {
      * @param code  The X.364 numerical code.
      * @param color The color name, or {@code null} if none.
      */
+    @SuppressWarnings("ThisEscapedInObjectConstruction")
     private X364(final byte code, final String color) {
         this.code  = code;
         this.color = color;
@@ -132,6 +133,7 @@ public enum X364 {
      *
      * @param foreground The X.364 code for a foreground color.
      */
+    @SuppressWarnings("ThisEscapedInObjectConstruction")
     private X364(final X364 foreground) {
         this((byte) (foreground.code + 10), foreground.color);
         this.foreground = foreground;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Line.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Line.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Line.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Line.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -28,8 +28,8 @@ import static java.lang.Double.*;
 
 /**
  * Equation of a line in a two dimensional space (<var>x</var>,<var>y</var>).
- * A line can be expressed by the <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y</var>₀ equation
- * where <var>y</var>₀ is the value of <var>y</var> at <var>x</var> = 0.
+ * A line can be expressed by the <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y₀</var> equation
+ * where <var>y₀</var> is the value of <var>y</var> at <var>x</var> = 0.
  *
  * <p>The equation parameters for a {@code Line} object can be set at construction time or using one
  * of the {@code setLine(…)} methods. The <var>y</var> value can be computed for a given <var>x</var>
@@ -37,8 +37,8 @@ import static java.lang.Double.*;
  * work even if the line is vertical.</p>
  *
  * <div class="note"><b>Comparison with Java2D geometries:</b>
- * At the difference of {@link java.awt.geom.Line2D} which is bounded by (<var>x</var>₁,<var>y</var>₁)
- * and (<var>x</var>₂,<var>y</var>₂) points, {@code Line} objects extend toward infinity.</div>
+ * At the difference of {@link java.awt.geom.Line2D} which is bounded by (<var>x₁</var>,<var>y₁</var>)
+ * and (<var>x₂</var>,<var>y₂</var>) points, {@code Line} objects extend toward infinity.</div>
  *
  * @author  Martin Desruisseaux (MPO, IRD)
  * @since   0.5
@@ -84,7 +84,7 @@ public class Line implements Cloneable,
 
     /**
      * Constructs a line with the specified slope and offset.
-     * The linear equation will be <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y</var>₀.
+     * The linear equation will be <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y₀</var>.
      *
      * @param slope The slope.
      * @param y0 The <var>y</var> value at <var>x</var> = 0.
@@ -111,7 +111,7 @@ public class Line implements Cloneable,
 
     /**
      * Returns the <var>x</var> value for <var>y</var> = 0.
-     * Coordinate (<var>x</var>₀, 0) is the intersection point with the <var>x</var> axis.
+     * Coordinate (<var>x₀</var>, 0) is the intersection point with the <var>x</var> axis.
      *
      * @return The <var>x</var> value for <var>y</var> = 0.
      *
@@ -137,7 +137,7 @@ public class Line implements Cloneable,
 
     /**
      * Returns the <var>y</var> value for <var>x</var> = 0.
-     * Coordinate (0, <var>y</var>₀) is the intersection point with the <var>y</var> axis.
+     * Coordinate (0, <var>y₀</var>) is the intersection point with the <var>y</var> axis.
      *
      * @return The <var>y</var> value for <var>x</var> = 0.
      *
@@ -179,7 +179,7 @@ public class Line implements Cloneable,
 
     /**
      * Sets this line to the specified slope and offset.
-     * The linear equation will be <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y</var>₀.
+     * The linear equation will be <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y₀</var>.
      *
      * @param slope The slope.
      * @param y0 The <var>y</var> value at <var>x</var> = 0.
@@ -218,7 +218,7 @@ public class Line implements Cloneable,
 
     /**
      * Given a set of data points <var>x</var>[0 … <var>n</var>-1], <var>y</var>[0 … <var>n</var>-1],
-     * fits them to a straight line <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y</var>₀ in a
+     * fits them to a straight line <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y₀</var> in a
      * least-squares senses. This method assume that the <var>x</var> values are precise and all uncertainty
      * is in <var>y</var>.
      *
@@ -235,7 +235,7 @@ public class Line implements Cloneable,
 
     /**
      * Given a sequence of points, fits them to a straight line <var>y</var> = <var>slope</var>⋅<var>x</var> +
-     * <var>y</var>₀ in a least-squares senses. This method assume that the <var>x</var> values are precise and
+     * <var>y₀</var> in a least-squares senses. This method assume that the <var>x</var> values are precise and
      * all uncertainty is in <var>y</var>.
      *
      * <p>Points shall be two dimensional with ordinate values in the (<var>x</var>,<var>y</var>) order.
@@ -382,7 +382,7 @@ public class Line implements Cloneable,
 
     /**
      * Returns a string representation of this line. This method returns the linear equation
-     * in the form <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y</var>₀.
+     * in the form <var>y</var> = <var>slope</var>⋅<var>x</var> + <var>y₀</var>.
      *
      * @return A string representation of this line.
      */

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -35,7 +35,7 @@ import static java.lang.Math.ulp;
  *
  * <blockquote>
  *   <var>{@linkplain #z(double, double) z}</var>(<var>x</var>,<var>y</var>) =
- *   <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z</var>₀
+ *   <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z₀</var>
  * </blockquote>
  *
  * Those coefficients can be set directly, or computed by a linear regression of this plane
@@ -83,19 +83,19 @@ public class Plane implements Cloneable,
 
     /**
      * The slope along the <var>x</var> values. This coefficient appears in the plane equation
-     * <var><b><u>sx</u></b></var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z</var>₀.
+     * <var><b><u>sx</u></b></var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z₀</var>.
      */
     private double sx;
 
     /**
      * The slope along the <var>y</var> values. This coefficient appears in the plane equation
-     * <var>sx</var>⋅<var>x</var> + <var><b><u>sy</u></b></var>⋅<var>y</var> + <var>z</var>₀.
+     * <var>sx</var>⋅<var>x</var> + <var><b><u>sy</u></b></var>⋅<var>y</var> + <var>z₀</var>.
      */
     private double sy;
 
     /**
      * The <var>z</var> value at (<var>x</var>,<var>y</var>) = (0,0). This coefficient appears in the plane equation
-     * <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <b><u><var>z</var>₀</u></b>.
+     * <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <b><u><var>z₀</var></u></b>.
      */
     private double z0;
 
@@ -123,7 +123,7 @@ public class Plane implements Cloneable,
 
     /**
      * Returns the slope along the <var>x</var> values. This coefficient appears in the plane equation
-     * <var><b><u>sx</u></b></var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z</var>₀.
+     * <var><b><u>sx</u></b></var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <var>z₀</var>.
      *
      * @return The <var>sx</var> term.
      */
@@ -133,7 +133,7 @@ public class Plane implements Cloneable,
 
     /**
      * Returns the slope along the <var>y</var> values. This coefficient appears in the plane equation
-     * <var>sx</var>⋅<var>x</var> + <var><b><u>sy</u></b></var>⋅<var>y</var> + <var>z</var>₀.
+     * <var>sx</var>⋅<var>x</var> + <var><b><u>sy</u></b></var>⋅<var>y</var> + <var>z₀</var>.
      *
      * @return The <var>sy</var> term.
      */
@@ -143,9 +143,9 @@ public class Plane implements Cloneable,
 
     /**
      * Returns the <var>z</var> value at (<var>x</var>,<var>y</var>) = (0,0). This coefficient appears in the
-     * plane equation <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <b><var>z</var>₀</b>.
+     * plane equation <var>sx</var>⋅<var>x</var> + <var>sy</var>⋅<var>y</var> + <b><var>z₀</var></b>.
      *
-     * @return The <var>z</var>₀ term.
+     * @return The <var>z₀</var> term.
      *
      * @see #z(double, double)
      */

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -429,7 +429,7 @@ public class Statistics implements Doubl
     /**
      * Returns the standard deviation. If the sample values given to the {@code accept(…)}
      * methods have a uniform distribution, then the returned value should be close to
-     * <code>sqrt({@linkplain #span() span}<sup>2</sup> / 12)</code>. If they have a
+     * <code>sqrt({@linkplain #span() span}² / 12)</code>. If they have a
      * Gaussian distribution (which is the most common case), then the returned value
      * is related to the <a href="http://en.wikipedia.org/wiki/Error_function">error
      * function</a>.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -43,6 +43,7 @@ import static org.apache.sis.math.Decima
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.Objects;
+import org.apache.sis.internal.jdk8.JDK8;
 
 
 /**
@@ -1044,12 +1045,12 @@ public class AngleFormat extends Format
                 }
                 final Number userObject;
                 if (hasMore) {
-                    userObject = Integer.valueOf((int) Math.round(value));
+                    userObject = JDK8.toIntExact(Math.round(value));
                 } else {
                     // Use Float instead of Double because we don't want to give a false impression of accuracy
                     // (when formatting the seconds field, at least the 10 last bits of the 'double' value are
                     // non-significant).
-                    userObject = Float.valueOf((float) value);
+                    userObject = (float) value;
                 }
                 it.addFieldLimit(Field.forCode(field), userObject, startPosition);
             } else {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -110,6 +110,8 @@ public final class Longitude extends Ang
      *   <li>±0 are returned unchanged (i.e. the sign of negative and positive zero is preserved)</li>
      * </ul>
      *
+     * Note that the given value should not be greater than 4×10⁸ degrees if a centimetric precision is desired.
+     *
      * @param  λ The longitude value in decimal degrees.
      * @return The given value normalized to the [-180 … 180)° range, or NaN if the given value was NaN of infinite.
      *



Mime
View raw message