sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1688645 - in /sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt: FormattableObject.java Formatter.java KeywordCase.java WKTFormat.java
Date Wed, 01 Jul 2015 13:19:32 GMT
Author: desruisseaux
Date: Wed Jul  1 13:19:31 2015
New Revision: 1688645

URL: http://svn.apache.org/r1688645
Log:
Add a KeywordCase.LOWER_CASE enum for completness with the UPPER_CASE enum.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.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=1688645&r1=1688644&r2=1688645&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] Wed Jul  1 13:19:31 2015
@@ -173,7 +173,7 @@ public abstract class FormattableObject
             formatter = new Formatter();
         }
         formatter.configure(convention, null, colorize ? Colors.DEFAULT : null,
-                convention.majorVersion() == 1, WKTFormat.DEFAULT_INDENTATION);
+                (convention.majorVersion() == 1) ? (byte) 1 : 0, WKTFormat.DEFAULT_INDENTATION);
         if (!strict) {
             formatter.transliterator = Transliterator.IDENTITY;
         }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1688645&r1=1688644&r2=1688645&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Wed Jul  1 13:19:31 2015
@@ -245,11 +245,11 @@ public class Formatter implements Locali
     private int elementStart;
 
     /**
-     * {@code true} if keywords shall be converted to upper cases.
+     * {@code 1} if keywords shall be converted to upper cases, or {@code -1} for lower cases.
      *
      * @see #configure(Convention, Citation, Colors, boolean, byte)
      */
-    private boolean toUpperCase;
+    private byte toUpperCase;
 
     /**
      * Incremented when {@link #setColor(ElementKind)} is invoked, and decremented when {@link
#resetColor()}
@@ -382,7 +382,7 @@ public class Formatter implements Locali
      *                    or {@link WKTFormat#SINGLE_LINE}.
      */
     final void configure(Convention convention, final Citation authority, final Colors colors,
-            final boolean toUpperCase, final byte indentation)
+            final byte toUpperCase, final byte indentation)
     {
         this.convention     = convention;
         this.authority      = (authority != null) ? authority : convention.getNameAuthority();
@@ -540,8 +540,9 @@ public class Formatter implements Locali
             newLine();
         }
         appendSeparator();
-        if (toUpperCase) {
-            keyword = keyword.toUpperCase(symbols.getLocale());
+        if (toUpperCase != 0) {
+            final Locale locale = symbols.getLocale();
+            keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale);
         }
         elementStart = buffer.append(keyword).appendCodePoint(symbols.getOpeningBracket(0)).length();
     }
@@ -630,8 +631,9 @@ public class Formatter implements Locali
                 setInvalidWKT(object.getClass(), null);
                 keyword = invalidElement;
             }
-        } else if (toUpperCase) {
-            keyword = keyword.toUpperCase(symbols.getLocale());
+        } else if (toUpperCase != 0) {
+            final Locale locale = symbols.getLocale();
+            keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale);
         }
         if (highlightError && colors != null) {
             final String color = colors.getAnsiSequence(ElementKind.ERROR);

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java?rev=1688645&r1=1688644&r2=1688645&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/KeywordCase.java
[UTF-8] Wed Jul  1 13:19:31 2015
@@ -18,9 +18,9 @@ package org.apache.sis.io.wkt;
 
 
 /**
- * Whether WKT keywords shall be written with upper case or CamelCase styles.
+ * Whether WKT keywords shall be written with lower, upper or camel case styles.
  * The most common usage for WKT keywords is upper case.
- * However with version 2 of Well Known Text, CamelCase keywords may be easier to read
+ * However with version 2 of Well Known Text, camel case keywords may be easier to read
  * because WKT 2 has more keywords made by combination of words. Examples:
  *
  * <table class="sis">
@@ -39,20 +39,20 @@ package org.apache.sis.io.wkt;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public enum KeywordCase {
     /**
-     * Keywords case is determined by the WKT {@linkplain Convention convention}.
-     * The current mapping is:
-     *
-     * <ul>
-     *   <li>Well Known Text version 2 uses camel case.</li>
-     *   <li>Well Known Text version 1 uses upper case.</li>
-     * </ul>
+     * WKT formatting uses lower case keywords.
      */
-    DEFAULT,
+    LOWER_CASE,
+
+    /**
+     * WKT formatting uses upper case keywords.
+     * This is the most usual case in WKT 1 strings.
+     */
+    UPPER_CASE,
 
     /**
      * WKT formatting uses CamelCase keywords. This is more useful in WKT 2 strings, which
@@ -61,8 +61,13 @@ public enum KeywordCase {
     CAMEL_CASE,
 
     /**
-     * WKT formatting uses upper case keywords.
-     * This is the most usual case in WKT 1 strings.
+     * Keywords case is determined by the WKT {@linkplain Convention convention}.
+     * The current mapping is:
+     *
+     * <ul>
+     *   <li>Well Known Text version 2 uses camel case.</li>
+     *   <li>Well Known Text version 1 uses upper case.</li>
+     * </ul>
      */
-    UPPER_CASE
+    DEFAULT
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1688645&r1=1688644&r2=1688645&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Wed Jul  1 13:19:31 2015
@@ -446,11 +446,12 @@ public class WKTFormat extends CompoundF
      */
     private void updateFormatter(final Formatter formatter) {
         if (formatter != null) {
-            final boolean toUpperCase;
+            final byte toUpperCase;
             switch (keywordCase) {
-                case UPPER_CASE: toUpperCase = true;  break;
-                case CAMEL_CASE: toUpperCase = false; break;
-                default: toUpperCase = (convention.majorVersion() == 1); break;
+                case LOWER_CASE: toUpperCase = -1; break;
+                case UPPER_CASE: toUpperCase = +1; break;
+                case CAMEL_CASE: toUpperCase =  0; break;
+                default: toUpperCase = (convention.majorVersion() == 1) ? (byte) 1 : 0; break;
             }
             formatter.configure(convention, authority, colors, toUpperCase, indentation);
             if (transliterator != null) {



Mime
View raw message