Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 245F3200CE7 for ; Wed, 2 Aug 2017 18:45:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 23706169C7D; Wed, 2 Aug 2017 16:45:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 69489169C80 for ; Wed, 2 Aug 2017 18:45:28 +0200 (CEST) Received: (qmail 43452 invoked by uid 500); 2 Aug 2017 16:45:27 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 43400 invoked by uid 99); 2 Aug 2017 16:45:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 16:45:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 49AB3DF97C; Wed, 2 Aug 2017 16:45:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Date: Wed, 02 Aug 2017 16:45:26 -0000 Message-Id: In-Reply-To: <3f31b94eb1814ec0bd4a7b70704302f0@git.apache.org> References: <3f31b94eb1814ec0bd4a7b70704302f0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] cxf git commit: [CXF-7165] Fix mapping of XML names containing _ to class names archived-at: Wed, 02 Aug 2017 16:45:29 -0000 [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/e899c32e Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e899c32e Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e899c32e Branch: refs/heads/3.1.x-fixes Commit: e899c32e0cd342b7b6f2a965d5c5f3dc8dfd6b9c Parents: a907531 Author: Daniel Kulp Authored: Tue Aug 1 16:30:45 2017 -0400 Committer: Daniel Kulp Committed: Wed Aug 2 12:44:52 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/e899c32e/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 46d0db0..0ffcac6 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 @@ -403,10 +403,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); @@ -414,7 +416,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/e899c32e/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 62f9070..e4c3254 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 @@ -89,7 +89,7 @@ public class JAXBUtilsTest extends Assert { @Test public void testNameToIdentifier() { - assertEquals("_return", + assertEquals("_return", JAXBUtils.nameToIdentifier("return", JAXBUtils.IdentifierType.VARIABLE)); assertEquals("getReturn", JAXBUtils.nameToIdentifier("return", JAXBUtils.IdentifierType.GETTER)); @@ -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