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/07/30 22:22:15 UTC
svn commit: r1614757 -
/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java
Author: desruisseaux
Date: Wed Jul 30 20:22:14 2014
New Revision: 1614757
URL: http://svn.apache.org/r1614757
Log:
Minor simplification.
Modified:
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java?rev=1614757&r1=1614756&r2=1614757&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] Wed Jul 30 20:22:14 2014
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.jaxb.gmd;
-import java.util.Locale;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.opengis.util.Enumerated;
import org.apache.sis.util.iso.Types;
@@ -56,21 +55,19 @@ public abstract class EnumAdapter<ValueT
* @return The presumed enumeration constant name.
*/
protected static String name(String value) {
- value = value.toUpperCase(Locale.ROOT);
/*
* Replace space ! " # $ % & ' ( ) * + , - . / punction characters by '_'.
* For example this replace "in/out" by "IN_OUT" in ParameterDirection.
+ *
+ * Note: we do not use codepoint API because this method is mostly for
+ * GeoAPI programmatic constant names, which are written in English.
*/
- StringBuilder replaced = null;
- for (int i=value.length(); --i>=0;) {
- if (value.charAt(i) < '0') {
- if (replaced == null) {
- replaced = new StringBuilder(value);
- }
- replaced.setCharAt(i, '_');
- }
+ final char[] ca = value.toCharArray();
+ for (int i=0; i<ca.length; i++) {
+ final char c = ca[i];
+ ca[i] = (c >= '0') ? Character.toUpperCase(c) : '_';
}
- return (replaced != null) ? replaced.toString() : value;
+ return String.valueOf(ca);
}
/**