sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1425592 [2/2] - in /sis/trunk: ./ sis-referencing/src/main/java/org/apache/sis/geometry/ sis-referencing/src/test/java/org/apache/sis/geometry/ sis-utility/src/main/java/org/apache/sis/io/ sis-utility/src/main/java/org/apache/sis/math/ sis...
Date Mon, 24 Dec 2012 05:58:29 GMT
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java Mon Dec 24 05:58:28 2012
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.util;
 
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
 
@@ -165,10 +168,10 @@ public final class ArgumentChecks extend
                 final Object[] args;
                 if (name != null) {
                     key = Errors.Keys.IllegalArgumentClass_3;
-                    args = new Object[] {name, valueClass, expectedType};
+                    args = new Object[] {name, expectedType, valueClass};
                 } else {
                     key = Errors.Keys.IllegalClass_2;
-                    args = new Object[] {valueClass, expectedType};
+                    args = new Object[] {expectedType, valueClass};
                 }
                 throw new IllegalArgumentException(Errors.format(key, args));
             }
@@ -438,7 +441,7 @@ public final class ArgumentChecks extend
     {
         if (value < min || value > max) {
             throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.ValueOutOfRange_4, name, value, min, max));
+                    Errors.Keys.ValueOutOfRange_4, name, min, max, value));
         }
     }
 
@@ -456,7 +459,7 @@ public final class ArgumentChecks extend
     {
         if (value < min || value > max) {
             throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.ValueOutOfRange_4, name, value, min, max));
+                    Errors.Keys.ValueOutOfRange_4, name, min, max, value));
         }
     }
 
@@ -475,7 +478,7 @@ public final class ArgumentChecks extend
         if (!(value >= min && value <= max)) { // Use '!' for catching NaN.
             throw new IllegalArgumentException(Float.isNaN(value) ?
                     Errors.format(Errors.Keys.NotANumber_1, name) :
-                    Errors.format(Errors.Keys.ValueOutOfRange_4, name, value, min, max));
+                    Errors.format(Errors.Keys.ValueOutOfRange_4, name, min, max, value));
         }
     }
 
@@ -494,7 +497,7 @@ public final class ArgumentChecks extend
         if (!(value >= min && value <= max)) { // Use '!' for catching NaN.
             throw new IllegalArgumentException(Double.isNaN(value) ?
                     Errors.format(Errors.Keys.NotANumber_1, name)  :
-                    Errors.format(Errors.Keys.ValueOutOfRange_4, name, value, min, max));
+                    Errors.format(Errors.Keys.ValueOutOfRange_4, name, min, max, value));
         }
     }
 
@@ -531,7 +534,54 @@ public final class ArgumentChecks extend
     }
 
     /**
-     * Ensures that the given direct position has the expected number of dimensions.
+     * Ensures that the given CRS, if non-null, has the expected number of dimensions.
+     * This method does nothing if the given coordinate reference system is null.
+     *
+     * @param  name     The name of the argument to be checked. Used only if an exception is thrown.
+     * @param  expected The expected number of dimensions.
+     * @param  crs      The coordinate reference system to check for its dimension, or {@code null}.
+     * @throws MismatchedDimensionException If the given coordinate reference system is non-null
+     *         and does not have the expected number of dimensions.
+     */
+    public static void ensureDimensionMatches(final String name, final int expected,
+            final CoordinateReferenceSystem crs) throws MismatchedDimensionException
+    {
+        if (crs != null) {
+            final CoordinateSystem cs = crs.getCoordinateSystem();
+            if (cs != null) { // Should never be null, but let be safe.
+                final int dimension = cs.getDimension();
+                if (dimension != expected) {
+                    throw new MismatchedDimensionException(Errors.format(
+                            Errors.Keys.MismatchedDimension_3, name, expected, dimension));
+                }
+            }
+        }
+    }
+
+    /**
+     * Ensures that the given vector, if non-null, has the expected number of dimensions
+     * (taken as its length). This method does nothing if the given vector is null.
+     *
+     * @param  name     The name of the argument to be checked. Used only if an exception is thrown.
+     * @param  expected The expected number of dimensions.
+     * @param  vector   The vector to check for its number of dimensions, or {@code null}.
+     * @throws MismatchedDimensionException If the given vector is non-null and does not have the
+     *         expected number of dimensions (taken as its length).
+     */
+    public static void ensureDimensionMatches(final String name, final int expected, final double[] vector)
+            throws MismatchedDimensionException
+    {
+        if (vector != null) {
+            final int dimension = vector.length;
+            if (dimension != expected) {
+                throw new MismatchedDimensionException(Errors.format(
+                        Errors.Keys.MismatchedDimension_3, name, expected, dimension));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the given direct position, if non-null, has the expected number of dimensions.
      * This method does nothing if the given direct position is null.
      *
      * @param  name     The name of the argument to be checked. Used only if an exception is thrown.
@@ -547,7 +597,29 @@ public final class ArgumentChecks extend
             final int dimension = position.getDimension();
             if (dimension != expected) {
                 throw new MismatchedDimensionException(Errors.format(
-                        Errors.Keys.UnexpectedArgumentDimension_3, name, dimension, expected));
+                        Errors.Keys.MismatchedDimension_3, name, expected, dimension));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the given envelope, if non-null, has the expected number of dimensions.
+     * This method does nothing if the given envelope is null.
+     *
+     * @param  name     The name of the argument to be checked. Used only if an exception is thrown.
+     * @param  expected The expected number of dimensions.
+     * @param  envelope The envelope to check for its dimension, or {@code null}.
+     * @throws MismatchedDimensionException If the given envelope is non-null and does
+     *         not have the expected number of dimensions.
+     */
+    public static void ensureDimensionMatches(final String name, final int expected, final Envelope envelope)
+            throws MismatchedDimensionException
+    {
+        if (envelope != null) {
+            final int dimension = envelope.getDimension();
+            if (dimension != expected) {
+                throw new MismatchedDimensionException(Errors.format(
+                        Errors.Keys.MismatchedDimension_3, name, expected, dimension));
             }
         }
     }

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java Mon Dec 24 05:58:28 2012
@@ -1702,7 +1702,7 @@ cmp:    while (ia < lga) {
     public static boolean regionMatches(final CharSequence text, final int fromIndex, final CharSequence part) {
         if (text instanceof String && part instanceof String) {
             // It is okay to delegate to String implementation since we do not ignore cases.
-            return ((String) text).regionMatches(fromIndex, (String) part, 0, part.length());
+            return ((String) text).startsWith((String) part, fromIndex);
         }
         final int length;
         if (fromIndex < 0 || fromIndex + (length = part.length()) > text.length()) {

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Characters.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Characters.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Characters.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Characters.java Mon Dec 24 05:58:28 2012
@@ -33,7 +33,7 @@ import org.apache.sis.util.resources.Err
 public final class Characters extends Static {
     /**
      * Hyphen character ('\u2010', Unicode {@code 2010}).
-     * This code tells to {@link org.apache.sis.io.LineFormatter}
+     * This code tells to {@link org.apache.sis.io.LineAppender}
      * that a line break is allowed to be inserted after this character.
      *
      * <p>For non-breaking hyphen, use the Unicode {@code 2011} character.</p>

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java Mon Dec 24 05:58:28 2012
@@ -124,7 +124,7 @@ public class CheckedArrayList<E> extends
     protected void ensureValid(final E element) throws IllegalArgumentException {
         if (element != null && !type.isInstance(element)) {
             throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalArgumentClass_3, "element", element.getClass(), type));
+                    Errors.Keys.IllegalArgumentClass_3, "element", type, element.getClass()));
         }
     }
 

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java Mon Dec 24 05:58:28 2012
@@ -105,7 +105,7 @@ public class CheckedHashMap<K,V> extends
     {
         if (element!=null && !type.isInstance(element)) {
             throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalArgumentClass_3, "element", element.getClass(), type));
+                    Errors.Keys.IllegalArgumentClass_3, "element", type, element.getClass()));
         }
     }
 

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java Mon Dec 24 05:58:28 2012
@@ -123,7 +123,7 @@ public class CheckedHashSet<E> extends L
     protected void ensureValid(final E element) throws IllegalArgumentException {
         if (element != null && !type.isInstance(element)) {
             throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalArgumentClass_3, "element", element.getClass(), type));
+                    Errors.Keys.IllegalArgumentClass_3, "element", type, element.getClass()));
         }
     }
 

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java Mon Dec 24 05:58:28 2012
@@ -374,7 +374,7 @@ public class DefaultTreeTable implements
             protected void setParentOf(final TreeTable.Node node, final int mode) throws IllegalArgumentException {
                 if (!(node instanceof Node)) {
                     throw new IllegalArgumentException(Errors.format(
-                            Errors.Keys.IllegalArgumentClass_3, "node", node.getClass(), Node.class));
+                            Errors.Keys.IllegalArgumentClass_3, "node", Node.class, node.getClass()));
                 }
                 final TreeTable.Node p;
                 switch (mode) {

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java Mon Dec 24 05:58:28 2012
@@ -25,15 +25,14 @@ import java.io.IOException;
 import java.text.Format;
 import java.text.ParsePosition;
 import java.text.ParseException;
-import java.util.regex.Pattern;
 import java.util.regex.Matcher;
 import net.jcip.annotations.NotThreadSafe;
-import org.apache.sis.io.LineFormatter;
-import org.apache.sis.io.TableFormatter;
+import org.apache.sis.io.LineAppender;
+import org.apache.sis.io.TableAppender;
+import org.apache.sis.io.TabularFormat;
 import org.apache.sis.io.CompoundFormat;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.StringBuilders;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.LocalizedParseException;
@@ -70,18 +69,23 @@ import org.apache.sis.internal.util.JDK7
  *
  * This representation can be printed to the {@linkplain java.io.Console#writer() console output}
  * (for example) if the stream uses a monospaced font and supports Unicode characters.
+ *
+ * {@section Customization}
  * Some formatting characteristics (indentation width, column where to draw the vertical line
  * below nodes) can be modified by calls to the setter methods defined in this formatter.
+ * In particular, the dots joining the node labels to their values can be specified by the
+ * {@linkplain #setColumnSeparatorPattern(String) column separator pattern}.
+ * The default pattern is {@code "?……[…] "}, which means "<cite>If the next value is non-null,
+ * then insert the {@code "……"} string, repeat the {@code '…'} character as many time as needed
+ * (may be zero), and finally insert a space</cite>".
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.0)
  * @version 0.3
  * @module
- *
- * @see org.apache.sis.io.TableFormatter
  */
 @NotThreadSafe
-public class TreeTableFormat extends CompoundFormat<TreeTable> {
+public class TreeTableFormat extends TabularFormat<TreeTable> {
     /**
      * For cross-version compatibility.
      */
@@ -117,45 +121,6 @@ public class TreeTableFormat extends Com
     private int verticalLinePosition;
 
     /**
-     * The string to write before and after the {@link #columnSeparator},
-     * or an empty string if none.
-     */
-    String separatorPrefix, separatorSuffix;
-
-    /**
-     * The column separator to use at formatting time if there is more than one column.
-     * This character will be repeated as many time as needed.
-     *
-     * @see #getColumnSeparatorPattern()
-     * @see #setColumnSeparatorPattern(String)
-     */
-    char columnSeparator;
-
-    /**
-     * {@code true} if the trailing {@code null} values shall be omitted at formatting time.
-     */
-    boolean omitTrailingNulls;
-
-    /**
-     * {@code true} if the user defined the parsing pattern explicitely.
-     */
-    boolean isParsePatternDefined;
-
-    /**
-     * The pattern used at parsing time for finding the column separators, or {@code null}
-     * if not yet constructed. This field is serialized because it may be a user-specified pattern.
-     */
-    private Pattern parsePattern;
-
-    /**
-     * The line separator to use for formatting the tree.
-     *
-     * @see #getLineSeparator()
-     * @see #setLineSeparator(String)
-     */
-    String lineSeparator;
-
-    /**
      * The tree symbols to write in the left margin, or {@code null} if not yet computed.
      * The default symbols are as below:
      *
@@ -180,11 +145,9 @@ public class TreeTableFormat extends Com
     public TreeTableFormat(final Locale locale, final TimeZone timezone) {
         super(locale, timezone);
         indentation       = 4;
-        separatorPrefix   = "……";
-        columnSeparator   = '…';
-        separatorSuffix   = " ";
+        beforeFill        = "……";
+        fillCharacter     = '…';
         omitTrailingNulls = true;
-        lineSeparator     = JDK7.lineSeparator();
     }
 
     /**
@@ -243,171 +206,6 @@ public class TreeTableFormat extends Com
     }
 
     /**
-     * Returns the pattern of characters used in column separators. Those characters will be used
-     * only if more than one column is formatted. See {@link #setColumnSeparatorPattern(String)}
-     * for a description of the pattern syntax.
-     *
-     * <p>The default pattern is {@code "?……[…] "}, which means "<cite>If the next value is
-     * non-null, then insert the {@code "……"} string, repeat the {@code '…'} character as many
-     * time as needed (may be zero), and finally insert a space</cite>".</p>
-     *
-     * @return The pattern of the current column separator.
-     */
-    public String getColumnSeparatorPattern() {
-        final StringBuilder buffer = new StringBuilder(8);
-        buffer.append(separatorPrefix).append('\uFFFF').append(separatorSuffix);
-        StringBuilders.replace(buffer, "\\", "\\\\");
-        StringBuilders.replace(buffer, "?",  "\\?");
-        StringBuilders.replace(buffer, "[",  "\\[");
-        StringBuilders.replace(buffer, "]",  "\\]");
-        StringBuilders.replace(buffer, "/",  "\\/");
-        if (omitTrailingNulls) {
-            buffer.insert(0, '?');
-        }
-        final int insertAt = buffer.indexOf("\uFFFF");
-        buffer.replace(insertAt, insertAt+1, "[\uFFFF]").setCharAt(insertAt+1, columnSeparator);
-        if (isParsePatternDefined) {
-            buffer.append('/').append(parsePattern.pattern());
-        }
-        return buffer.toString();
-    }
-
-    /**
-     * Sets the pattern of the characters to insert between the columns. The pattern shall contain
-     * exactly one occurrence of the {@code "[ ]"} pair of bracket, with exactly one character
-     * between them. This character will be repeated as many time as needed for columns alignment.
-     *
-     * <p>The formatting pattern can optionally be followed by a regular expression to be used at
-     * parsing time. If omitted, the parsing pattern will be inferred from the formatting pattern.
-     * If specified, then the {@link #parse(CharSequence, ParsePosition) parse} method will invoke
-     * the {@link Matcher#find()} method for determining the column boundaries.</p>
-     *
-     * <p>The characters listed below have special meaning in the pattern.
-     * Other characters are appended <cite>as-is</cite> between the columns.</p>
-     *
-     * <table class="sis">
-     *   <tr><th>Character(s)</th> <th>Meaning</th></tr>
-     *   <tr><td>{@code '?'}</td>  <td>Omit the column separator for trailing null values.</td></tr>
-     *   <tr><td>{@code "[ ]"}</td><td>Repeat the character between bracket as needed.</td></tr>
-     *   <tr><td>{@code '/'}</td>  <td>Separate the formatting pattern from the parsing pattern.</td></tr>
-     *   <tr><td>{@code '\\'}</td> <td>Escape any of the characters listed in this table.</td></tr>
-     * </table>
-     *
-     * Restrictions:
-     * <ul>
-     *   <li>If present, {@code '?'} shall be the first character in the pattern.</li>
-     *   <li>The repeated character (specified inside the pair of brackets) is mandatory.</li>
-     *   <li>In the current implementation, the repeated character must be in the
-     *       {@linkplain Character#isBmpCodePoint(int) Basic Multilanguage Plane}.</li>
-     *   <li>If {@code '/'} is present, anything on its right must be compliant
-     *       with the {@link Pattern} syntax.</li>
-     * </ul>
-     *
-     * @param  pattern The pattern of the new column separator.
-     * @throws IllegalArgumentException If the given pattern is illegal.
-     */
-    public void setColumnSeparatorPattern(final String pattern) throws IllegalArgumentException {
-        ArgumentChecks.ensureNonEmpty("pattern", pattern);
-        final int length = pattern.length();
-        final StringBuilder buffer = new StringBuilder(length);
-        boolean escape  = false;
-        boolean trim    = false;
-        String  prefix  = null;
-        String  regex   = null;
-        int separatorIndex = -1;
-scan:   for (int i=0; i<length; i++) {
-            final char c = pattern.charAt(i);
-            switch (c) {
-                case '\uFFFF': { // This "character" is reserved.
-                    prefix = null;
-                    break scan; // This will cause IllegalArgumentException to be thrown.
-                }
-                case '\\': {
-                    if (i != separatorIndex) {
-                        if (escape) break;
-                        escape = true;
-                    }
-                    continue;
-                }
-                case '?': {
-                    if (i != 0) {
-                        prefix = null;
-                        break scan;
-                    }
-                    trim = true;
-                    continue;
-                }
-                case '[': {
-                    if (escape) break;
-                    if (i != separatorIndex) {
-                        if (separatorIndex >= 0) {
-                            prefix = null;
-                            break scan; // This will cause IllegalArgumentException to be thrown.
-                        }
-                        separatorIndex = i+1;
-                    }
-                    continue;
-                }
-                case ']': {
-                    if (escape) break;
-                    switch (i - separatorIndex) {
-                        case 0:  continue;
-                        case 1:  prefix = buffer.toString(); buffer.setLength(0); continue;
-                        default: prefix = null; break scan;
-                    }
-                }
-                case '/': {
-                    if (escape) break;
-                    regex = pattern.substring(i+1);
-                    break scan;
-                }
-            }
-            if (i != separatorIndex) {
-                buffer.append(c);
-            }
-        }
-        if (prefix == null) {
-            throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalFormatPatternForClass_2, pattern, TreeTable.class));
-        }
-        /*
-         * Finally store the result. The parsing pattern must be first because the call to
-         * Pattern.compile(regex) may thrown PatternSyntaxException. In such case, we want
-         * it to happen before we modified anything else.
-         */
-        if (regex != null) {
-            parsePattern = Pattern.compile(regex);
-            isParsePatternDefined = true;
-        } else {
-            parsePattern = null;
-            isParsePatternDefined = false;
-        }
-        omitTrailingNulls = trim;
-        separatorPrefix   = prefix;
-        separatorSuffix   = buffer.toString();
-        columnSeparator   = pattern.charAt(separatorIndex);
-    }
-
-    /**
-     * Returns the current line separator. The default value is system-dependent.
-     *
-     * @return The current line separator.
-     */
-    public String getLineSeparator() {
-        return lineSeparator;
-    }
-
-    /**
-     * Sets the line separator.
-     *
-     * @param separator The new line separator.
-     */
-    public void setLineSeparator(final String separator) {
-        ArgumentChecks.ensureNonEmpty("separator", separator);
-        lineSeparator = separator;
-    }
-
-    /**
      * Returns the number of spaces to add on the left margin for each indentation level.
      * The default value is 4.
      *
@@ -511,13 +309,7 @@ scan:   for (int i=0; i<length; i++) {
      */
     @Override
     public TreeTable parse(final CharSequence text, final ParsePosition pos) throws ParseException {
-        if (parsePattern == null) {
-            parsePattern = Pattern.compile(
-                    Pattern.quote(separatorPrefix)
-                  + Pattern.quote(String.valueOf(columnSeparator)) + '*'
-                  + Pattern.quote(separatorSuffix));
-        }
-        final Matcher matcher = parsePattern.matcher(text);
+        final Matcher matcher   = getColumnSeparatorMatcher(text);
         final int length        = text.length();
         int indexOfLineStart    = pos.getIndex();
         int indentationLevel    = 0;                // Current index in the 'indentations' array.
@@ -714,17 +506,23 @@ scan:   for (int i=0; i<length; i++) {
     }
 
     /**
+     * Writes the column separator to the given appendable. This is a helper method for the
+     * {@link Writer} inner class,  defined here because it uses many protected fields from
+     * the superclass.  Accessing those fields from the inner class generate many synthetic
+     * methods, so we are better to define only one method here doing the work.
+     */
+    final void writeColumnSeparator(final Appendable out) throws IOException {
+        // We have a TableAppender instance if and only if there is 2 or more columns.
+        ((TableAppender) out.append(beforeFill)).nextColumn(fillCharacter);
+        out.append(columnSeparator);
+    }
+
+    /**
      * Creates string representation of the node values. Tabulations are replaced by spaces,
      * and line feeds are replaced by the Pilcrow character. This is necessary in order to
-     * avoid conflict with the characters expected by {@link TableFormatter}.
+     * avoid conflict with the characters expected by {@link TableAppender}.
      */
-    private final class Writer extends LineFormatter {
-        /**
-         * For each indentation level, {@code true} if the previous levels are writing the last node.
-         * This array will growth as needed.
-         */
-        private boolean[] isLast;
-
+    private final class Writer extends LineAppender {
         /**
          * The columns to write.
          */
@@ -741,14 +539,20 @@ scan:   for (int i=0; i<length; i++) {
         private final Object[] values;
 
         /**
+         * For each indentation level, {@code true} if the previous levels are writing the last node.
+         * This array will growth as needed.
+         */
+        private boolean[] isLast;
+
+        /**
          * Creates a new instance which will write in the given appendable.
          */
         Writer(final Appendable out, final TableColumn<?>[] columns) {
-            super(columns.length >= 2 ? new TableFormatter(out, "") : out);
-            this.columns  = columns;
-            this.formats  = getFormats(columns, false);
-            this.values   = new Object[columns.length];
-            this.isLast   = new boolean[8];
+            super(columns.length >= 2 ? new TableAppender(out, "") : out);
+            this.columns = columns;
+            this.formats = getFormats(columns, false);
+            this.values  = new Object[columns.length];
+            this.isLast  = new boolean[8];
             setTabulationExpanded(true);
             setLineSeparator(" ¶ ");
         }
@@ -805,9 +609,7 @@ scan:   for (int i=0; i<length; i++) {
             }
             for (int i=0; i<=n; i++) {
                 if (i != 0) {
-                    // We have a TableFormatter instance if and only if there is 2 or more columns.
-                    ((TableFormatter) out.append(separatorPrefix)).nextColumn(columnSeparator);
-                    out.append(separatorSuffix);
+                    writeColumnSeparator(out);
                 }
                 formatValue(formats[i], values[i]);
                 clear();

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java Mon Dec 24 05:58:28 2012
@@ -24,6 +24,14 @@ import org.opengis.util.InternationalStr
 /**
  * Locale-dependent resources for error messages.
  *
+ * {@section Argument order convention}
+ * This resource bundle applies the same convention than JUnit: for every {@code format(…)} method,
+ * the first arguments provide information about the context in which the error occurred (e.g. the
+ * name of a method argument or the range of valid values), while the erroneous values that caused
+ * the error are last. Note that being the last programmatic parameter does not means that the value
+ * will appears last in the formatted text, since every localized message can reorder the parameters
+ * as they want.
+ *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.2)
  * @version 0.3
@@ -114,7 +122,7 @@ public final class Errors extends Indexe
         public static final int IllegalArgumentClass_2 = 17;
 
         /**
-         * Argument ‘{0}’ can not be an instance of ‘{1}’. Expected an instance of ‘{2}’ or derived
+         * Argument ‘{0}’ can not be an instance of ‘{2}’. Expected an instance of ‘{1}’ or derived
          * type.
          */
         public static final int IllegalArgumentClass_3 = 2;
@@ -136,12 +144,12 @@ public final class Errors extends Indexe
         public static final int IllegalBitsPattern_1 = 16;
 
         /**
-         * Class ‘{0}’ is illegal. It must be ‘{1}’ or a derived class.
+         * Class ‘{1}’ is illegal. It must be ‘{0}’ or a derived class.
          */
         public static final int IllegalClass_2 = 3;
 
         /**
-         * The “{0}” pattern can not be applied to formating of objects of type ‘{1}’.
+         * The “{1}” pattern can not be applied to formating of objects of type ‘{0}’.
          */
         public static final int IllegalFormatPatternForClass_2 = 29;
 
@@ -151,6 +159,11 @@ public final class Errors extends Indexe
         public static final int IllegalLanguageCode_1 = 12;
 
         /**
+         * The [{0} … {1}] range of ordinate values is not valid for the “{2}” axis.
+         */
+        public static final int IllegalOrdinateRange_3 = 5;
+
+        /**
          * Property ‘{0}’ can be associated to an instance of ‘{1}’.
          */
         public static final int IllegalPropertyClass_2 = 62;
@@ -211,7 +224,7 @@ public final class Errors extends Indexe
         public static final int MismatchedDimension_2 = 60;
 
         /**
-         * Argument ‘{0}’ has {1} dimension{1,choice,1#|2#s}, while {2} was expected.
+         * Argument ‘{0}’ has {2} dimension{2,choice,1#|2#s}, while {1} was expected.
          */
         public static final int MismatchedDimension_3 = 58;
 
@@ -296,11 +309,6 @@ public final class Errors extends Indexe
         public static final int RequireDecimalSeparator = 33;
 
         /**
-         * Argument ‘{0}’ has {1} dimensions, while {2} was expected.
-         */
-        public static final int UnexpectedArgumentDimension_3 = 5;
-
-        /**
          * Unexpected change in ‘{0}’.
          */
         public static final int UnexpectedChange_1 = 56;
@@ -366,7 +374,7 @@ public final class Errors extends Indexe
         public static final int ValueNotGreaterThanZero_2 = 7;
 
         /**
-         * Value ‘{0}’={1} is invalid. Expected a value in the [{2} … {3}] range.
+         * Value ‘{0}’={3} is invalid. Expected a value in the [{1} … {2}] range.
          */
         public static final int ValueOutOfRange_4 = 6;
     }

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties Mon Dec 24 05:58:28 2012
@@ -14,6 +14,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
+# Argument numbering convention
+# -----------------------------
+# This resource bundle applies the same convention than JUnit: the first programmatic parameters
+# (those having lowest numbers like {0} or {1}) provide information about the context in which the
+# error occurred (e.g. the parameter name or the range of valid values), while the last parameters
+# (those having highest numbers) are the erroneous values that caused the error. Note that last
+# programmatic parameters do not have to be last in the formatted text, since each localized message
+# can reorder the parameters as they want.
+#
+
 CanNotComputeDerivative         = Can not compute the derivative.
 CloneNotSupported_1             = Can not clone an object of type \u2018{0}\u2019.
 DeadThread_1                    = Thread \u201c{0}\u201d is dead.
@@ -25,13 +36,14 @@ EmptyProperty_1                 = Proper
 ExcessiveArgumentSize_3         = Argument \u2018{0}\u2019 shall not contain more than {1} elements. A number of {2} is excessive.
 ForbiddenAttribute_2            = Attribute \u201c{0}\u201d is not allowed for an object of type \u2018{1}\u2019.
 IllegalArgumentClass_2          = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019.
-IllegalArgumentClass_3          = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019. Expected an instance of \u2018{2}\u2019 or derived type.
+IllegalArgumentClass_3          = Argument \u2018{0}\u2019 can not be an instance of \u2018{2}\u2019. Expected an instance of \u2018{1}\u2019 or derived type.
 IllegalArgumentField_4          = Argument \u2018{0}\u2019 can not take the \u201c{1}\u201d value, because the \u2018{2}\u2019 field can not take the \u201c{3}\u201d value.
 IllegalArgumentValue_2          = Argument \u2018{0}\u2019 can not take the \u201c{1}\u201d value.
 IllegalBitsPattern_1            = Illegal bits pattern: {0}.
-IllegalClass_2                  = Class \u2018{0}\u2019 is illegal. It must be \u2018{1}\u2019 or a derived class.
-IllegalFormatPatternForClass_2  = The \u201c{0}\u201d pattern can not be applied to formating of objects of type \u2018{1}\u2019.
+IllegalClass_2                  = Class \u2018{1}\u2019 is illegal. It must be \u2018{0}\u2019 or a derived class.
+IllegalFormatPatternForClass_2  = The \u201c{1}\u201d pattern can not be applied to formating of objects of type \u2018{0}\u2019.
 IllegalLanguageCode_1           = The \u201c{0}\u201d language is not recognized.
+IllegalOrdinateRange_3          = The [{0} \u2026 {1}] range of ordinate values is not valid for the \u201c{2}\u201d axis.
 IllegalPropertyClass_2          = Property \u2018{0}\u2019 can be associated to an instance of \u2018{1}\u2019.
 IllegalRange_2                  = Range [{0} \u2026 {1}] is not valid.
 InconsistentAttribute_2         = Value \u201c{1}\u201d of attribute \u2018{0}\u2019 is inconsistent with other attributes.
@@ -45,7 +57,7 @@ KeyCollision_1                  = A diff
 MandatoryAttribute_2            = Attribute \u201c{0}\u201d is mandatory for an object of type \u2018{1}\u2019.
 MismatchedCRS                   = The coordinate reference system must be the same for all objects.
 MismatchedDimension_2           = Mismatched object dimension: {0}D and {1}D.
-MismatchedDimension_3           = Argument \u2018{0}\u2019 has {1} dimension{1,choice,1#|2#s}, while {2} was expected.
+MismatchedDimension_3           = Argument \u2018{0}\u2019 has {2} dimension{2,choice,1#|2#s}, while {1} was expected.
 NegativeArgument_2              = Argument \u2018{0}\u2019 shall not be negative. The given value was {1}.
 NodeChildOfItself_1             = Node \u201c{0}\u201d can not be a child of itself.
 NodeHasAnotherParent_1          = Node \u201c{0}\u201d already has another parent.
@@ -62,7 +74,6 @@ NullArgument_1                  = Argume
 OddArrayLength_1                = Array length is {0}, while we expected an even length.
 RecursiveCreateCallForKey_1     = Recursive call while creating an object for the \u201c{0}\u201d key.
 RequireDecimalSeparator         = A decimal separator is required.
-UnexpectedArgumentDimension_3   = Argument \u2018{0}\u2019 has {1} dimensions, while {2} was expected.
 UnexpectedChange_1              = Unexpected change in \u2018{0}\u2019.
 UnexpectedEndOfString_1         = More characters were expected at the end of \u201c{0}\u201d.
 UnmodifiableAffineTransform     = This affine transform is unmodifiable.
@@ -76,4 +87,4 @@ UnsupportedImplementation_1     = Can no
 UnsupportedOperation_1          = The \u2018{0}\u2019 operation is unsupported.
 ValueAlreadyDefined_1           = A value is already defined for \u201c{0}\u201d.
 ValueNotGreaterThanZero_2       = Value \u2018{0}\u2019={1} is invalid. Expected a number greater than 0.
-ValueOutOfRange_4               = Value \u2018{0}\u2019={1} is invalid. Expected a value in the [{2} \u2026 {3}] range.
+ValueOutOfRange_4               = Value \u2018{0}\u2019={3} is invalid. Expected a value in the [{1} \u2026 {2}] range.

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties Mon Dec 24 05:58:28 2012
@@ -25,13 +25,14 @@ EmptyProperty_1                 = La pro
 ExcessiveArgumentSize_3         = L\u2019argument \u2018{0}\u2019 ne peut pas contenir plus de {1} \u00e9l\u00e9ments. Un nombre de {2} est excessif.
 ForbiddenAttribute_2            = L\u2019attribut \u201c{0}\u201d n\u2019est pas autoris\u00e9 pour un objet de type \u2018{1}\u2019.
 IllegalArgumentClass_2          = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019.
-IllegalArgumentClass_3          = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019. Une instance de \u2018{2}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.
+IllegalArgumentClass_3          = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{2}\u2019. Une instance de \u2018{1}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.
 IllegalArgumentField_4          = L\u2019argument \u2018{0}\u2019 n\u2019accepte pas la valeur \u201c{1}\u201d parce que le champs \u2018{2}\u2019 ne peut pas prendre la valeur \u201c{3}\u201d.
 IllegalArgumentValue_2          = L\u2019argument \u2018{0}\u2019 n\u2019accepte pas la valeur \u201c{1}\u201d.
 IllegalBitsPattern_1            = Pattern de bits invalide: {0}.
-IllegalClass_2                  = La classe \u2018{0}\u2019 est ill\u00e9gale. Il doit s\u2019agir d\u2019une classe \u2018{1}\u2019 ou d\u00e9riv\u00e9e.
-IllegalFormatPatternForClass_2  = Le mod\u00e8le \u201c{0}\u201d ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{1}\u2019.
+IllegalClass_2                  = La classe \u2018{1}\u2019 est ill\u00e9gale. Il doit s\u2019agir d\u2019une classe \u2018{0}\u2019 ou d\u00e9riv\u00e9e.
+IllegalFormatPatternForClass_2  = Le mod\u00e8le \u201c{1}\u201d ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{0}\u2019.
 IllegalLanguageCode_1           = Le code de langue \u201c{0}\u201d n\u2019est pas reconnu.
+IllegalOrdinateRange_3          = La plage de valeurs de coordonn\u00e9es [{1} \u2026 {2}] n\u2019est pas valide pour l\u2019axe \u201c{0}\u201d.
 IllegalPropertyClass_2          = La propri\u00e9t\u00e9 \u2018{0}\u2019 ne peut pas \u00eatre associ\u00e9e \u00e0 une valeur de type \u2018{1}\u2019.
 IllegalRange_2                  = La plage [{0} \u2026 {1}] n\u2019est pas valide.
 InconsistentAttribute_2         = La valeur \u201c{1}\u201d de l\u2019attribut \u2018{0}\u2019 n\u2019est pas coh\u00e9rente avec celles des autres attributs.
@@ -45,7 +46,7 @@ KeyCollision_1                  = Une va
 MandatoryAttribute_2            = L\u2019attribut \u201c{0}\u201d est obligatoire pour un objet de type \u2018{1}\u2019.
 MismatchedCRS                   = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es doit \u00eatre le m\u00eame pour tous les objets.
 MismatchedDimension_2           = Les dimensions des objets ({0}D et {1}D) ne concordent pas.
-MismatchedDimension_3           = L\u2019argument \u2018{0}\u2019 a {1} dimension{1,choice,1#|2#s}, alors qu\u2019on en attendait {2}.
+MismatchedDimension_3           = L\u2019argument \u2018{0}\u2019 a {2} dimension{2,choice,1#|2#s}, alors qu\u2019on en attendait {1}.
 NegativeArgument_2              = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre n\u00e9gatif. La valeur donn\u00e9e \u00e9tait {1}.
 NodeChildOfItself_1             = Le n\u0153ud \u201c{0}\u201d ne peut pas \u00eatre un enfant de lui-m\u00eame.
 NodeHasAnotherParent_1          = Le n\u0153ud \u201c{0}\u201d a d\u00e9j\u00e0 un autre parent.
@@ -62,7 +63,6 @@ NullArgument_1                  = L\u201
 OddArrayLength_1                = La longueur du tableau est {0}, alors qu\u2019on attendait une longueur paire.
 RecursiveCreateCallForKey_1     = Appel r\u00e9cursif lors de la cr\u00e9ation d\u2019un objet pour la cl\u00e9 \u201c{0}\u201d.
 RequireDecimalSeparator         = Un s\u00e9parateur d\u00e9cimal est requis.
-UnexpectedArgumentDimension_3   = L\u2019argument \u2018{0}\u2019 a {1} dimensions, alors qu\u2019on en attendait {2}.
 UnexpectedChange_1              = Changement inattendu dans \u2018{0}\u2019.
 UnexpectedEndOfString_1         = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0 la fin du texte \u201c{0}\u201d.
 UnmodifiableAffineTransform     = Cette transformation affine n\u2019est pas modifiable.
@@ -76,4 +76,4 @@ UnsupportedImplementation_1     = Les in
 UnsupportedOperation_1          = L\u2019op\u00e9ration \u2018{0}\u2019 n\u2019est pas support\u00e9e.
 ValueAlreadyDefined_1           = Une valeur est d\u00e9j\u00e0 d\u00e9finie pour \u201c{0}\u201d.
 ValueNotGreaterThanZero_2       = La valeur \u2018{0}\u2019={1} n\u2019est pas valide. On attendait un nombre positif non-nul.
-ValueOutOfRange_4               = La valeur \u2018{0}\u2019={1} est invalide. Une valeur dans la plage [{2} \u2026 {3}] \u00e9tait attendue.
+ValueOutOfRange_4               = La valeur \u2018{0}\u2019={3} est invalide. Une valeur dans la plage [{1} \u2026 {2}] \u00e9tait attendue.

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties Mon Dec 24 05:58:28 2012
@@ -24,6 +24,6 @@ Name              = Name
 NumberOfValues    = Number of values
 NumberOfNaN       = Number of \u2018NaN\u2019
 RootMeanSquare    = Root Mean Square
-StandardDeviation = Standard deviation
 Seconds           = Seconds
+StandardDeviation = Standard deviation
 Type              = Type

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/io/EchoAppendable.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/io/EchoAppendable.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/io/EchoAppendable.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/io/EchoAppendable.java Mon Dec 24 05:58:28 2012
@@ -34,7 +34,7 @@ import static org.junit.Assert.*;
  * @module
  */
 @Decorator(Appendable.class)
-public class EchoAppendable extends FilteredAppendable {
+public class EchoAppendable extends Appender {
     /**
      * The echo writer.
      */

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/io/SingleCharAppendable.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/io/SingleCharAppendable.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/io/SingleCharAppendable.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/io/SingleCharAppendable.java Mon Dec 24 05:58:28 2012
@@ -22,14 +22,14 @@ import java.io.IOException;
 /**
  * Delegates calls to {@code append(CharSequence, int, int)} to a sequence of calls
  * to {@code append(char)}. This is used in order to explore more code paths in
- * {@link FilteredAppendable} implementations.
+ * {@link Appender} implementations.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
  * @module
  */
-final class SingleCharAppendable extends FilteredAppendable {
+final class SingleCharAppendable extends Appender {
     /**
      * Constructs a {@code SingleCharAppendable} object delegating to the given {@code Appendable}.
      *

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java Mon Dec 24 05:58:28 2012
@@ -17,7 +17,6 @@
 package org.apache.sis.math;
 
 import java.util.Random;
-import java.util.Locale;
 import java.io.IOException;
 import org.junit.Test;
 import org.apache.sis.test.TestCase;
@@ -47,7 +46,7 @@ public final strictfp class StatisticsTe
      */
     @Test
     public void testInitialState() {
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         assertEquals(0,  statistics.count());
         assertEquals(0,  statistics.countNaN());
         assertTrue(isNaN(statistics.minimum()));
@@ -65,7 +64,7 @@ public final strictfp class StatisticsTe
     @Test
     public void testGaussian() {
         final Random random = new Random(317780561);
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         for (int i=0; i<10000; i++) {
             statistics.add(random.nextGaussian());
         }
@@ -90,7 +89,7 @@ public final strictfp class StatisticsTe
 
         // Now tests.
         final Random random = new Random(309080660);
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         for (int i=0; i<10000; i++) {
             statistics.add(random.nextDouble()*range + lower);
         }
@@ -117,7 +116,7 @@ public final strictfp class StatisticsTe
 
         // Now tests.
         final Random random = new Random(309080660);
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         for (int i=0; i<10000; i++) {
             statistics.add(random.nextInt(range) + lower);
         }
@@ -158,7 +157,7 @@ public final strictfp class StatisticsTe
             1E+20, 0
         };
         final Random random = new Random(223386491);
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         for (int k=0; k<offsetAndTolerancePairs.length; k++) {
             final double offset = offsetAndTolerancePairs[k];
             final double tolerance = offsetAndTolerancePairs[++k];
@@ -184,10 +183,10 @@ public final strictfp class StatisticsTe
     @Test
     public void testConcatenation() {
         final Random random = new Random(429323868);
-        final Statistics global = new Statistics();
-        final Statistics byBlock = new Statistics();
+        final Statistics global = new Statistics(null);
+        final Statistics byBlock = new Statistics(null);
         for (int i=0; i<10; i++) {
-            final Statistics block = new Statistics();
+            final Statistics block = new Statistics(null);
             for (int j=0; j<1000; j++) {
                 final double value;
                 if (random.nextInt(800) == 0) {
@@ -222,7 +221,7 @@ public final strictfp class StatisticsTe
      */
     @Test
     public void testSerialization() throws IOException {
-        final Statistics statistics = new Statistics();
+        final Statistics statistics = new Statistics(null);
         statistics.add(40);
         statistics.add(10);
         statistics.add(NaN);
@@ -238,31 +237,4 @@ public final strictfp class StatisticsTe
         assertEquals(12.472191289246473, after.standardDeviation(true),  EPS);
         assertEquals(15.275252316519468, after.standardDeviation(false), EPS);
     }
-
-    /**
-     * Tests the formatting of {@link Statistics}.
-     * Actually, we will instantiate the {@link StatisticsFormat} directly in order to fix the
-     * locale to a hard-coded value. But except for the localization, the result should be nearly
-     * identical to a call to the {@link Statistics#toString()} method.
-     */
-    @Test
-    public void testFormatting() {
-        final Statistics statistics = Statistics.forSeries(2);
-        statistics.add(10);
-        statistics.add(15);
-        statistics.add(22);
-        statistics.add(17);
-        statistics.add(12);
-        statistics.add( 3);
-
-        final StatisticsFormat format = new StatisticsFormat(Locale.US, null);
-        final String text = format.format(statistics);
-        assertMultilinesEquals(
-                "Number of values:       6     5      4\n" +
-                "Minimum value:       3.00 -9.00 -12.00\n" +
-                "Maximum value:      22.00  7.00   2.00\n" +
-                "Mean value:         13.17 -1.40  -3.50\n" +
-                "Root Mean Square:   14.44  6.40   6.40\n" +
-                "Standard deviation:  6.49  6.99   6.19\n", text);
-    }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Mon Dec 24 05:58:28 2012
@@ -46,6 +46,7 @@ import org.junit.runners.Suite;
     org.apache.sis.util.logging.PerformanceLevelTest.class,
     org.apache.sis.math.MathFunctionsTest.class,
     org.apache.sis.math.StatisticsTest.class,
+    org.apache.sis.math.StatisticsFormatTest.class,
 
     // Collections.
     org.apache.sis.internal.util.ReferenceQueueConsumerTest.class,
@@ -71,8 +72,12 @@ import org.junit.runners.Suite;
     org.apache.sis.measure.AngleFormatTest.class,
     org.apache.sis.measure.AngleTest.class,
     org.apache.sis.internal.util.X364Test.class,
-    org.apache.sis.io.LineFormatterTest.class,
-    org.apache.sis.io.TableFormatterTest.class,
+    org.apache.sis.io.LineAppenderTest.class,
+    org.apache.sis.io.LeftMarginTest.class,
+    org.apache.sis.io.TabulationExpansionTest.class,
+    org.apache.sis.io.WordWrapTest.class,
+    org.apache.sis.io.WordWrapWithLineSeparatorTest.class,
+    org.apache.sis.io.TableAppenderTest.class,
     org.apache.sis.util.collection.TreeTableFormatTest.class,
 
     // XML most basic types.

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java Mon Dec 24 05:58:28 2012
@@ -25,7 +25,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 
 import org.apache.sis.math.Statistics;
-import org.apache.sis.io.TableFormatter;
+import org.apache.sis.math.StatisticsFormat;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
@@ -181,11 +181,12 @@ public final strictfp class CacheTest ex
      * Validates the entries created by the {@link #stress()} test. The check performed in
      * this method shall obviously be consistent with the values created by {@code stress()}.
      *
+     * @param  name  The name of the value being measured.
      * @param  cache The cache to validate.
      * @return Statistics on the key values of the given map.
      */
-    private static Statistics validateStressEntries(final Map<Integer,Integer> cache) {
-        final Statistics statistics = new Statistics();
+    private static Statistics validateStressEntries(final String name, final Map<Integer,Integer> cache) {
+        final Statistics statistics = new Statistics(name);
         for (final Map.Entry<Integer,Integer> entry : cache.entrySet()) {
             final int key = entry.getKey();
             final int value = entry.getValue();
@@ -258,7 +259,7 @@ public final strictfp class CacheTest ex
         /*
          * Verifies the values.
          */
-        final Statistics beforeGC = validateStressEntries(cache);
+        final Statistics beforeGC = validateStressEntries("Before GC", cache);
         assertTrue("Should not have more entries than what we put in.", cache.size() <= count);
         assertFalse("Some entries should be retained by strong references.", cache.isEmpty());
         /*
@@ -304,20 +305,14 @@ public final strictfp class CacheTest ex
          * information in case of failure.
          */
         System.gc();
-        final Statistics afterGC = validateStressEntries(cache);
+        final Statistics afterGC = validateStressEntries("After GC", cache);
         if (out != null) {
-            final TableFormatter table = new TableFormatter(out, " │ ");
-            table.setMultiLinesCells(true);
-            table.append("Statistics on the keys before garbage collection:");
-            table.nextColumn();
-            table.append("Statistics on the keys after garbage collection.\n" +
-                         "The minimum and the mean values should be greater.");
-            table.nextLine();
-            table.append(beforeGC.toString());
-            table.nextColumn();
-            table.append(afterGC.toString());
+            out.println("Statistics on the keys before and after garbage collection.");
+            out.println("The minimum and the mean values should be greater after GC.");
+            final StatisticsFormat format = StatisticsFormat.getInstance();
+            format.setBorderWidth(1);
             try {
-                table.flush();
+                format.format(new Statistics[] {beforeGC, afterGC}, out);
             } catch (IOException e) {
                 throw new AssertionError(e);
             }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TreeTableFormatTest.java Mon Dec 24 05:58:28 2012
@@ -36,7 +36,7 @@ import static org.apache.sis.util.collec
  */
 @DependsOn({
     DefaultTreeTableTest.class,
-    org.apache.sis.io.TableFormatterTest.class
+    org.apache.sis.io.TableAppenderTest.class
 })
 public final strictfp class TreeTableFormatTest extends TestCase {
     /**

Modified: sis/trunk/src/main/docbook/fr/geometry.xml
URL: http://svn.apache.org/viewvc/sis/trunk/src/main/docbook/fr/geometry.xml?rev=1425592&r1=1425591&r2=1425592&view=diff
==============================================================================
--- sis/trunk/src/main/docbook/fr/geometry.xml (original)
+++ sis/trunk/src/main/docbook/fr/geometry.xml Mon Dec 24 05:58:28 2012
@@ -155,17 +155,34 @@
           </para>
         </sidebar>
         <para>
-          Une dernière note: le Java (ou de manière plus générale, la norme <acronym>IEEE</acronym> 754) définit deux valeurs distinctes de zéro:
-          un zéro positif et un zéro négatif. Ces deux valeurs sont considérées égales lorsqu’on les compares avec l’opérateur <literal>==</literal> du Java.
-          Mais dans les enveloppes de <acronym>SIS</acronym>, ils peuvent mener à des résultats opposés pour les axes ayant <constant role="GeoAPI">RangeMeaning.WRAPAROUND</constant>.
-          Une enveloppe dont la plage est [0…0], [-0…-0] ou [-0…+0] sera bien considérée comme une enveloppe vide,
-          mais la page [+0…-0] sera au contraire considérée comme incluant la totalité des valeurs, jusqu’à l’infini.
-          Ce comportement est conforme à la définition de <function role="SIS">lowerCorner</function> et <function role="SIS">upperCorner</function>
-          qui considère +0 comme le point de départ, et -0 comme le point d’arrivé après avoir fait le tour des valeurs possibles.
-          Un tel comportement ne se produit que pour la paire de valeurs +0 et -0, et seulement dans cet ordre.
-          Pour toutes les autres valeurs réelles, si la condition <literal>lower</literal> <literal>==</literal> <literal>upper</literal>
-          est vrai, alors il est garanti que l’enveloppe est vide.
+          Pour que les fonctions telles que <function role="SIS">add(…)</function> fonctionnent correctement,
+          tous les objets impliqués doivent utiliser le même système de référence des coordonnées, y compris
+          la même plage de valeurs. Ainsi, une enveloppe exprimant les longitudes dans la plage [-180 … +180]°
+          n’est pas compatible avec une enveloppe exprimant les longitudes dans la plage [0 … 360]°.
+          Les conversions, si nécessaires, sont à la charge de l’utilisateur
+          (la classe <classname role="SIS">Envelopes</classname> fournit des méthodes de commodités pour ce faire).
+          En outre, les coordonnées de l’enveloppe doivent être comprises dans les limites du système de coordonnées,
+          sauf si le développeur souhaite volontairement considérer (par exemple) 300° de longitude
+          comme un position distincte de -60°. La classe <classname role="SIS">GeneralEnvelope</classname>
+          fournit une méthode <function role="SIS">normalize()</function> pour ramener les coordonnées
+          dans les limites attendues, au prix parfois de valeurs <quote><foreignphrase>lower</foreignphrase></quote>
+          supérieures à la valeur <quote><foreignphrase>upper</foreignphrase></quote>.
         </para>
+        <sidebar>
+          <title>Le cas particulier de la plage [+0 … -0]</title>
+          <para>
+            le Java (ou de manière plus générale, la norme <acronym>IEEE</acronym> 754) définit deux valeurs distinctes de zéro:
+            un zéro positif et un zéro négatif. Ces deux valeurs sont considérées égales lorsqu’on les compares avec l’opérateur <literal>==</literal> du Java.
+            Mais dans les enveloppes de <acronym>SIS</acronym>, ils peuvent mener à des résultats opposés pour les axes ayant <constant role="GeoAPI">RangeMeaning.WRAPAROUND</constant>.
+            Une enveloppe dont la plage est [0 … 0], [-0 … -0] ou [-0 … +0] sera bien considérée comme une enveloppe vide,
+            mais la page [+0 … -0] sera au contraire considérée comme incluant la totalité des valeurs, jusqu’à l’infini.
+            Ce comportement est conforme à la définition de <function role="SIS">lowerCorner</function> et <function role="SIS">upperCorner</function>
+            qui considère +0 comme le point de départ, et -0 comme le point d’arrivé après avoir fait le tour des valeurs possibles.
+            Un tel comportement ne se produit que pour la paire de valeurs +0 et -0, et seulement dans cet ordre.
+            Pour toutes les autres valeurs réelles, si la condition <literal>lower</literal> <literal>==</literal> <literal>upper</literal>
+            est vrai, alors il est garanti que l’enveloppe est vide.
+          </para>
+        </sidebar>
       </section>
     </section>
   </section>



Mime
View raw message