cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/3] cxf git commit: [CXF-7165] Fix mapping of XML names containing _ to class names
Date Wed, 02 Aug 2017 15:49:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 894c0a357 -> 598a45d5b


[CXF-7165] Fix mapping of XML names containing _ to class names


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/88489dd6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/88489dd6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/88489dd6

Branch: refs/heads/master
Commit: 88489dd691f08d1721fe497c833d600eaa813cb4
Parents: 0db60be
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Aug 1 16:30:45 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Aug 2 11:32:02 2017 -0400

----------------------------------------------------------------------
 core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java | 8 ++++++--
 .../src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java     | 6 +++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/88489dd6/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index 76d2f38..74b2fe2 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -402,10 +402,12 @@ public final class JAXBUtils {
 
         boolean legalIdentifier = false;
         StringBuilder buf = new StringBuilder(name);
+        boolean hasUnderscore = false;
         legalIdentifier = Character.isJavaIdentifierStart(buf.charAt(0));
 
         for (int i = 1; i < name.length() && legalIdentifier; i++) {
-            legalIdentifier = legalIdentifier && Character.isJavaIdentifierPart(buf.charAt(i));
+            legalIdentifier &= Character.isJavaIdentifierPart(buf.charAt(i));
+            hasUnderscore |= '_' == buf.charAt(i);
         }
 
         boolean conventionalIdentifier = isConventionalIdentifier(buf, type);
@@ -413,7 +415,9 @@ public final class JAXBUtils {
             if (JAXBUtils.isJavaKeyword(name) && type == IdentifierType.VARIABLE)
{
                 name = normalizePackageNamePart(name);
             }
-            return name;
+            if (!hasUnderscore || IdentifierType.CLASS != type) {
+                return name;
+            }
         }
 
         // split into words

http://git-wip-us.apache.org/repos/asf/cxf/blob/88489dd6/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
index 3263825..4b7cd14 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
@@ -88,7 +88,7 @@ public class JAXBUtilsTest extends Assert {
     }
 
     @Test
-    public void testNameToIdentifier() {
+    public void testNameToIdentifier() {        
         assertEquals("_return",
                      JAXBUtils.nameToIdentifier("return", JAXBUtils.IdentifierType.VARIABLE));
         assertEquals("getReturn",
@@ -146,6 +146,10 @@ public class JAXBUtilsTest extends Assert {
                      JAXBUtils.nameToIdentifier("other_punct-chars", JAXBUtils.IdentifierType.GETTER));
         assertEquals("OTHER_PUNCT_CHARS",
                      JAXBUtils.nameToIdentifier("other_punct-chars", JAXBUtils.IdentifierType.CONSTANT));
+        
+        assertEquals("XMLTransfer",
+                     JAXBUtils.nameToIdentifier("XMLTransfer", JAXBUtils.IdentifierType.CLASS));
+
     }
 
     @Test


Mime
View raw message