You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/03/12 19:44:07 UTC

svn commit: r1576850 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/...

Author: desruisseaux
Date: Wed Mar 12 18:44:07 2014
New Revision: 1576850

URL: http://svn.apache.org/r1576850
Log:
ParameterGroup.toString() now delegate to ParameterFormat.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ColorsTest.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -49,15 +49,15 @@ public class Colors implements Cloneable
     private static final long serialVersionUID = 256160285861027191L;
 
     /**
-     * A map of colors for outputs to the {@link java.io.Console}.
-     * Those colors give better results on a black background.
+     * The default colors used by {@link FormattableObject#print(Convention)}.
+     * Those colors give better results on a {@link java.io.Console} with black background.
      * This map is immutable.
      *
      * @see FormattableObject#print(Convention)
      */
-    public static final Colors CONSOLE = new Colors();
+    public static final Colors DEFAULT = new Colors();
     static {
-        final EnumMap<ElementKind,X364> map = CONSOLE.map;
+        final EnumMap<ElementKind,X364> map = DEFAULT.map;
         map.put(ElementKind.NUMBER,     X364.FOREGROUND_YELLOW);
         map.put(ElementKind.INTEGER,    X364.FOREGROUND_YELLOW);
         map.put(ElementKind.UNIT,       X364.FOREGROUND_YELLOW);
@@ -71,7 +71,21 @@ public class Colors implements Cloneable
         map.put(ElementKind.EXTENT,     X364.BACKGROUND_GRAY);
         map.put(ElementKind.CITATION,   X364.BACKGROUND_GRAY);
         map.put(ElementKind.REMARKS,    X364.BACKGROUND_GRAY);
-        CONSOLE.isImmutable = true;
+        DEFAULT.isImmutable = true;
+    }
+
+    /**
+     * Emphases on identification information
+     * ({@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() name} and
+     *  {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getIdentifiers() identifiers}) only.
+     * This map is immutable.
+     */
+    public static final Colors NAMING = new Colors();
+    static {
+        final EnumMap<ElementKind,X364> map = NAMING.map;
+        map.put(ElementKind.NAME,       X364.FOREGROUND_GREEN);
+        map.put(ElementKind.IDENTIFIER, X364.FOREGROUND_YELLOW);
+        NAMING.isImmutable = true;
     }
 
     /**
@@ -197,9 +211,9 @@ public class Colors implements Cloneable
     }
 
     /**
-     * Replaces the deserialized instance by {@link #CONSOLE} one if possible.
+     * Replaces the deserialized instance by {@link #DEFAULT} one if possible.
      */
     final Object readResolve() {
-        return isImmutable && map.equals(CONSOLE.map) ? CONSOLE : this;
+        return isImmutable && map.equals(DEFAULT.map) ? DEFAULT : this;
     }
 }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -42,6 +42,11 @@ public enum ElementKind {
     NAME,
 
     /**
+     * Object identifier, typically written almost last just before remarks.
+     */
+    IDENTIFIER,
+
+    /**
      * Floating point numbers (excluding integer types).
      */
     NUMBER,

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -129,23 +129,18 @@ public abstract class FormattableObject 
     }
 
     /**
-     * Prints a WKT representation of this object to the {@linkplain System#out standard output stream}.
+     * Prints a string representation of this object to the {@linkplain System#out standard output stream}.
      * If a {@linkplain Console console} is attached to the running JVM (i.e. if the application is run
      * from the command-line and the output is not redirected to a file) and if Apache SIS thinks that
      * the console supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
      *
      * <p>This is a convenience method for debugging purpose and for console applications.</p>
-     *
-     * @param convention The WKT convention to use.
-     *
-     * @see Colors#CONSOLE
      */
     @Debug
-    public void print(final Convention convention) {
-        ArgumentChecks.ensureNonNull("convention", convention);
+    public void print() {
         final Console console = System.console();
         final PrintWriter out = (console != null) ? console.writer() : null;
-        final String wkt = formatWKT(convention, (out != null) && X364.isAnsiSupported(), false);
+        final String wkt = formatWKT(Convention.WKT2_SIMPLIFIED, (out != null) && X364.isAnsiSupported(), false);
         if (out != null) {
             out.println(wkt);
         } else {
@@ -171,7 +166,7 @@ public abstract class FormattableObject 
         if (formatter == null) {
             formatter = new Formatter();
         }
-        formatter.configure(convention, null, colorize ? Colors.CONSOLE : null,
+        formatter.configure(convention, null, colorize ? Colors.DEFAULT : null,
                 convention.majorVersion() == 1, WKTFormat.DEFAULT_INDENTATION);
         final String wkt;
         try {

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -243,7 +243,7 @@ public class WKTFormat extends CompoundF
      * This property applies only when formatting text.
      *
      * <p>Newly created {@code WKTFormat}s have no syntax coloring. If a non-null argument like
-     * {@link Colors#CONSOLE} is given to this method, then the {@link #format(Object, Appendable) format(…)}
+     * {@link Colors#DEFAULT} is given to this method, then the {@link #format(Object, Appendable) format(…)}
      * method tries to highlight most of the elements that are relevant to
      * {@link org.apache.sis.util.Utilities#equalsIgnoreMetadata(Object, Object)}.</p>
      *

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -562,11 +562,11 @@ public class ImmutableIdentifier extends
                 final Convention convention = formatter.getConvention();
                 if (convention.majorVersion() == 1) {
                     keyword = "Authority";
-                    formatter.append(cs, null);
-                    formatter.append(code, null);
+                    formatter.append(cs, ElementKind.IDENTIFIER);
+                    formatter.append(code, ElementKind.IDENTIFIER);
                 } else {
                     keyword = "Id";
-                    formatter.append(cs, null);
+                    formatter.append(cs, ElementKind.IDENTIFIER);
                     appendCode(formatter, code);
                     if (version != null) {
                         appendCode(formatter, version);
@@ -607,7 +607,7 @@ public class ImmutableIdentifier extends
             try {
                 n = Long.parseLong(text);
             } catch (NumberFormatException e) {
-                formatter.append(text, null);
+                formatter.append(text, ElementKind.IDENTIFIER);
                 return;
             }
             formatter.append(n);

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ColorsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ColorsTest.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ColorsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ColorsTest.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -37,7 +37,7 @@ public final strictfp class ColorsTest e
      */
     @Test
     public void testGetName() {
-        final Colors colors = Colors.CONSOLE;
+        final Colors colors = Colors.DEFAULT;
         assertEquals("cyan",  colors.getName(ElementKind.CODE_LIST));
         assertEquals("green", colors.getName(ElementKind.DATUM));
         assertEquals("red",   colors.getName(ElementKind.ERROR));
@@ -49,7 +49,7 @@ public final strictfp class ColorsTest e
     @Test
     @DependsOnMethod("testGetName")
     public void testSetName() {
-        final Colors colors = new Colors(Colors.CONSOLE);
+        final Colors colors = new Colors(Colors.DEFAULT);
         assertEquals("green", colors.getName(ElementKind.DATUM));
         colors.setName(ElementKind.DATUM, "blue");
         assertEquals("blue", colors.getName(ElementKind.DATUM));
@@ -61,7 +61,7 @@ public final strictfp class ColorsTest e
     @Test
     public void testImmutability() {
         try {
-            Colors.CONSOLE.setName(ElementKind.DATUM, "blue");
+            Colors.DEFAULT.setName(ElementKind.DATUM, "blue");
             fail("Constant shall be immutable.");
         } catch (UnsupportedOperationException e) {
             // This is the expected exception.
@@ -75,8 +75,8 @@ public final strictfp class ColorsTest e
      */
     @Test
     public void testSerialization() {
-        assertSame(Colors.CONSOLE, assertSerializedEquals(Colors.CONSOLE));
-        final Colors colors = new Colors(Colors.CONSOLE);
+        assertSame(Colors.DEFAULT, assertSerializedEquals(Colors.DEFAULT));
+        final Colors colors = new Colors(Colors.DEFAULT);
         colors.setName(ElementKind.DATUM, "blue");
         final Colors c = assertSerializedEquals(colors);
         assertNotSame(colors, c); // Expect a new instance.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -32,6 +32,7 @@ import org.apache.sis.internal.util.Unmo
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -373,4 +374,30 @@ public class DefaultParameterDescriptorG
     protected long computeHashCode() {
         return super.computeHashCode() + descriptors.hashCode();
     }
+
+    /**
+     * Returns a string representation of this descriptor.
+     * The default implementation delegates to {@link ParameterFormat}.
+     *
+     * <p>This method is for information purpose only and may change in future SIS version.</p>
+     */
+    @Debug
+    @Override
+    public String toString() {
+        return ParameterFormat.sharedFormat(this);
+    }
+
+    /**
+     * Prints a string representation of this descriptor to the {@linkplain System#out standard output stream}.
+     * If a {@linkplain java.io.Console console} is attached to the running JVM (i.e. if the application is run
+     * from the command-line and the output is not redirected to a file) and if Apache SIS thinks that the console
+     * supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
+     *
+     * <p>This is a convenience method for debugging purpose and for console applications.</p>
+     */
+    @Debug
+    @Override
+    public void print() {
+        ParameterFormat.print(this);
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -29,6 +29,7 @@ import org.opengis.parameter.ParameterNo
 import org.opengis.parameter.InvalidParameterCardinalityException;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Debug;
 
 import static org.apache.sis.referencing.IdentifiedObjects.isHeuristicMatchForName;
 
@@ -354,4 +355,29 @@ public class DefaultParameterValueGroup 
         copy.values = new ParameterValueList(copy.values);
         return copy;
     }
+
+    /**
+     * Returns a string representation of this group.
+     * The default implementation delegates to {@link ParameterFormat}.
+     *
+     * <p>This method is for information purpose only and may change in future SIS version.</p>
+     */
+    @Debug
+    @Override
+    public String toString() {
+        return ParameterFormat.sharedFormat(this);
+    }
+
+    /**
+     * Prints a string representation of this group to the {@linkplain System#out standard output stream}.
+     * If a {@linkplain java.io.Console console} is attached to the running JVM (i.e. if the application
+     * is run from the command-line and the output is not redirected to a file) and if Apache SIS thinks
+     * that the console supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
+     *
+     * <p>This is a convenience method for debugging purpose and for console applications.</p>
+     */
+    @Debug
+    public void print() {
+        ParameterFormat.print(this);
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -30,6 +30,8 @@ import java.text.Format;
 import java.text.FieldPosition;
 import java.text.ParsePosition;
 import java.text.ParseException;
+import java.io.Console;
+import java.util.concurrent.atomic.AtomicReference;
 import javax.measure.unit.Unit;
 
 import org.opengis.parameter.*;
@@ -109,6 +111,11 @@ public class ParameterFormat extends Tab
     private static final long serialVersionUID = -1345231739800152411L;
 
     /**
+     * An instance created when first needed and potentially shared.
+     */
+    private static final AtomicReference<ParameterFormat> INSTANCE = new AtomicReference<>();
+
+    /**
      * The default column separator. User can change the separator
      * by a call to {@link #setColumnSeparatorPattern(String)}.
      */
@@ -554,7 +561,7 @@ public class ParameterFormat extends Tab
          * First, formats the table header (i.e. the column names).
          */
         final Vocabulary resources = Vocabulary.getResources(displayLocale);
-        header.writeIdentifiers(out, true, hasColors, false, lineSeparator);
+        header.writeIdentifiers(out, true, colors, false, lineSeparator);
         out.append(lineSeparator);
         final char horizontalBorder = isBrief ? '─' : '═';
         final TableAppender table = (isBrief || !columnSeparator.equals(SEPARATOR)) ?
@@ -596,7 +603,7 @@ public class ParameterFormat extends Tab
             horizontalLine = isBrief ? 0 : '─';
             final ParameterTableRow row = entry.getValue();
             row.codespaceWidth = codespaceWidth;
-            row.writeIdentifiers(table, writeCodespaces, false, hasColors, lineSeparator);
+            row.writeIdentifiers(table, writeCodespaces, null, hasColors, lineSeparator);
             table.append(beforeFill);
             table.nextColumn(fillCharacter);
             final GeneralParameterDescriptor generalDescriptor = entry.getKey();
@@ -841,6 +848,44 @@ public class ParameterFormat extends Tab
     }
 
     /**
+     * Returns a shared instance of {@code ParameterFormat} if possible, or a new one otherwise.
+     */
+    private static ParameterFormat getSharedInstance(final Colors colors) {
+        ParameterFormat f = INSTANCE.getAndSet(null);
+        if (f == null) {
+            f = new ParameterFormat();
+        }
+        f.setColors(colors);
+        return f;
+    }
+
+    /**
+     * Formats the given object using a shared instance of {@code ParameterFormat}.
+     * This is used for {@link DefaultParameterDescriptorGroup#toString()} implementation.
+     */
+    static String sharedFormat(final Object object) {
+        final ParameterFormat f = getSharedInstance(null);
+        final String s = f.format(object);
+        INSTANCE.set(f);
+        return s;
+    }
+
+    /**
+     * Writes the given object to the console using a shared instance of {@code ParameterFormat}.
+     */
+    static void print(final Object object) {
+        final Console console = System.console();
+        final Appendable out = (console != null) ? console.writer() : System.out;
+        final ParameterFormat f = getSharedInstance(Colors.NAMING);
+        try {
+            f.format(object, out);
+        } catch (IOException e) {
+            throw new AssertionError(e); // Should never happen, since we are writing to stdout.
+        }
+        INSTANCE.set(f);
+    }
+
+    /**
      * Not yet supported.
      *
      * @return Currently never return.
@@ -848,6 +893,7 @@ public class ParameterFormat extends Tab
      */
     @Override
     public Object parse(final CharSequence text, final ParsePosition pos) throws ParseException {
-        throw new ParseException("Not supported yet.", 0);
+        throw new ParseException(Errors.getResources(displayLocale)
+                .getString(Errors.Keys.UnsupportedOperation_1, "parse"), 0);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -34,6 +34,8 @@ import org.opengis.util.GenericName;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.util.NameSpace;
+import org.apache.sis.io.wkt.Colors;
+import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.RangeFormat;
 import org.apache.sis.internal.referencing.NameToIdentifier;
@@ -264,6 +266,20 @@ final class ParameterTableRow {
     }
 
     /**
+     * Writes the color for the given type if {@code colors} is non-null.
+     */
+    private static void writeColor(final Appendable out, final Colors colors, final ElementKind type)
+            throws IOException
+    {
+        if (colors != null) {
+            final String name = colors.getName(type);
+            if (name != null) {
+                out.append(X364.forColorName(name).sequence());
+            }
+        }
+    }
+
+    /**
      * Writes the given color if {@code colorEnabled} is {@code true}.
      */
     private static void writeColor(final Appendable out, final X364 color, final boolean colorEnabled)
@@ -275,21 +291,21 @@ final class ParameterTableRow {
     }
 
     /**
-     * Writes the identifiers. At most one of {@code colorsForTitle} and {@code colorsForRows}
-     * can be set to {@code true}.
+     * Writes the identifiers. At most one of {@code colors != null} and {@code colorsForRows}
+     * can be {@code true}.
      *
      * <p><b>This method can be invoked only once per {@code ParameterTableRow} instance</b>,
      * at its implementation destroys the internal list of identifiers.</p>
      *
      * @param  out             Where to write.
      * @param  writeCodespaces {@code true} for writing codespaces, or {@code false} for omitting them.
-     * @param  colorsForTitle  {@code true} if syntax coloring should be applied for table title.
+     * @param  colors          Non null if syntax coloring should be applied for table title.
      * @param  colorsForRows   {@code true} if syntax coloring should be applied for table rows.
      * @param  lineSeparator   The system-dependent line separator.
      * @throws IOException     If an exception occurred while writing.
      */
     final void writeIdentifiers(final Appendable out, final boolean writeCodespaces,
-            final boolean colorsForTitle, final boolean colorsForRows, final String lineSeparator) throws IOException
+            final Colors colors, final boolean colorsForRows, final String lineSeparator) throws IOException
     {
         boolean isNewLine = false;
         for (final Map.Entry<String,Set<Object>> entry : identifiers.entrySet()) {
@@ -305,7 +321,7 @@ final class ParameterTableRow {
                  * Write the codespace. More than one name may exist for the same codespace,
                  * in which case the code space will be repeated on a new line each time.
                  */
-                writeColor(out, FOREGROUND_GREEN, colorsForTitle);
+                writeColor(out, colors, ElementKind.NAME);
                 if (writeCodespaces) {
                     int pad = codespaceWidth + 1;
                     if (codespace != null) {
@@ -320,9 +336,9 @@ final class ParameterTableRow {
                  * Write the name or alias after the codespace. We remove what we wrote,
                  * because we may iterate over the 'identifiers' set more than once.
                  */
-                writeColor(out, BOLD, colorsForTitle);
+                writeColor(out, BOLD, colors != null);
                 out.append(toString(it.next()));
-                writeColor(out, RESET, colorsForTitle);
+                writeColor(out, RESET, colors != null);
                 it.remove();
                 /*
                  * Write all identifiers between parenthesis after the firt name only.
@@ -334,9 +350,9 @@ final class ParameterTableRow {
                     final Object id = it.next();
                     if (id instanceof ReferenceIdentifier) {
                         out.append(hasIdentifiers ? ", " : " (");
-                        writeColor(out, FOREGROUND_YELLOW, colorsForTitle);
+                        writeColor(out, colors, ElementKind.IDENTIFIER);
                         out.append(toString(id));
-                        writeColor(out, FOREGROUND_DEFAULT, colorsForTitle);
+                        writeColor(out, FOREGROUND_DEFAULT, colors != null);
                         hasIdentifiers = true;
                         it.remove();
                     } else {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java?rev=1576850&r1=1576849&r2=1576850&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] Wed Mar 12 18:44:07 2014
@@ -208,7 +208,7 @@ search:     do {
                 return buffer.append(text, fromIndex, toIndex);
             }
         }
-        return text;
+        return text.subSequence(fromIndex, toIndex);
     }
 
     /**