sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1679623 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
Date Fri, 15 May 2015 18:49:18 GMT
Author: desruisseaux
Date: Fri May 15 18:49:18 2015
New Revision: 1679623

URL: http://svn.apache.org/r1679623
Log:
Metadata: FormattableObject.toString() do not convert Unicode characters to ASCII, since 'toString()'
method is often used for debugging.
If the user wants a more ISO 19162 conformant string (including replacement of some non-ASCII
characters), (s)he should invoke FormattableObject.toWKT() instead.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java?rev=1679623&r1=1679622&r2=1679623&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
[UTF-8] Fri May 15 18:49:18 2015
@@ -35,7 +35,7 @@ import org.apache.sis.internal.util.X364
  * representation of this object:</p>
  *
  * <ul>
- *   <li>{@link #toWKT()} returns a strictly compliant WKT or throws {@link UnformattableObjectException}
+ *   <li>{@link #toWKT()} tries to return a strictly compliant WKT or throws {@link
UnformattableObjectException}
  *       if this object contains elements not defined by the ISO 19162 standard.</li>
  *   <li>{@link #toString()} returns a WKT with some redundant information omitted
and some constraints relaxed.
  *       This method never throw {@code UnformattableObjectException};
@@ -59,7 +59,7 @@ import org.apache.sis.internal.util.X364
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html">WKT 2 specification</a>
@@ -111,7 +111,8 @@ public abstract class FormattableObject
      * If this object can not be represented in a standard way, then this method fallbacks
on a non-standard
      * representation.
      *
-     * <p>By default this method formats this object according the {@link Convention#WKT2_SIMPLIFIED}
rules.</p>
+     * <p>By default this method formats this object according the {@link Convention#WKT2_SIMPLIFIED}
rules,
+     * except that Unicode characters are kept <i>as-is</i> (they are not converted
to ASCII).</p>
      *
      * @return The Well Known Text (WKT) or an alternative representation of this object.
      */
@@ -122,6 +123,7 @@ public abstract class FormattableObject
 
     /**
      * Returns a <cite>Well Known Text</cite> (WKT) for this object using the
specified convention.
+     * Unicode characters are kept <i>as-is</i> (they are not converted to ASCII).
      *
      * @param  convention The WKT convention to use.
      * @return The Well Known Text (WKT) or a pseudo-WKT representation of this object.
@@ -162,7 +164,7 @@ public abstract class FormattableObject
      * @return The Well Known Text (WKT) or a pseudo-WKT representation of this object.
      * @throws UnformattableObjectException If {@code strict} is {@code true} and this object
can not be formatted.
      */
-    final String formatWKT(final Convention convention, final boolean colorize, final boolean
strict)
+    private String formatWKT(final Convention convention, final boolean colorize, final boolean
strict)
              throws UnformattableObjectException
     {
         Formatter formatter = FORMATTER.getAndSet(null);
@@ -171,6 +173,9 @@ public abstract class FormattableObject
         }
         formatter.configure(convention, null, colorize ? Colors.DEFAULT : null,
                 convention.majorVersion() == 1, WKTFormat.DEFAULT_INDENTATION);
+        if (!strict) {
+            formatter.encoding = CharEncoding.UNICODE;
+        }
         final String wkt;
         try {
             formatter.append(this);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1679623&r1=1679622&r2=1679623&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] Fri May 15 18:49:18 2015
@@ -108,8 +108,8 @@ public final strictfp class AbstractRefe
                 new DefaultTemporalExtent()))); // TODO: needs sis-temporal module for testing
that one.
         final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
 
-        assertEquals( // Quotes (at least the closing one) conservatively omitted for WKT
1.
-                "ReferenceSystem[\"My object.\", AUTHORITY[\"EPSG\", \"4326\"]]",
+        assertEquals(
+                "ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]",
                 object.toString(Convention.WKT1));
 
         assertWktEquals(Convention.WKT1,



Mime
View raw message