Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 94EF417BD2 for ; Thu, 23 Apr 2015 16:17:26 +0000 (UTC) Received: (qmail 72369 invoked by uid 500); 23 Apr 2015 16:17:23 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 72337 invoked by uid 500); 23 Apr 2015 16:17:23 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 72328 invoked by uid 99); 23 Apr 2015 16:17:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Apr 2015 16:17:23 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Apr 2015 16:17:17 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id C1DAE455C1 for ; Thu, 23 Apr 2015 16:12:42 +0000 (UTC) Received: (qmail 43155 invoked by uid 99); 23 Apr 2015 16:12:42 -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; Thu, 23 Apr 2015 16:12:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 00675E17B1; Thu, 23 Apr 2015 16:12:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 23 Apr 2015 16:12:56 -0000 Message-Id: <6c729da3ecdc4dadadf544ef5d7b4fee@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/50] incubator-ignite git commit: # IGNITE-748 Fixed split by dot. X-Virus-Checked: Checked by ClamAV on apache.org # IGNITE-748 Fixed split by dot. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6d165b08 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6d165b08 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6d165b08 Branch: refs/heads/ignite-646 Commit: 6d165b08dc0c15163935729508161b2d4f93480f Parents: 94b2fa7 Author: AKuznetsov Authored: Wed Apr 22 11:01:06 2015 +0700 Committer: AKuznetsov Committed: Wed Apr 22 11:01:06 2015 +0700 ---------------------------------------------------------------------- .../ignite/schema/generator/CodeGenerator.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6d165b08/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java index de02bcd..c4fe111 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java @@ -63,15 +63,19 @@ public class CodeGenerator { * Checks if string is a valid java identifier. * * @param identifier String to check. + * @param split If {@code true} then identifier will be split by dots. * @param msg Identifier type. * @param type Checked type. * @throws IllegalStateException If passed string is not valid java identifier. */ - private static void checkValidJavaIdentifier(String identifier, String msg, String type) throws IllegalStateException{ + private static void checkValidJavaIdentifier(String identifier, boolean split, String msg, String type) + throws IllegalStateException{ if (identifier.isEmpty()) throw new IllegalStateException(msg + " could not be empty!"); - for (String part : identifier.split("\\.")) { + String[] parts = split ? identifier.split("\\.") : new String[] {identifier}; + + for (String part : parts) { if (javaKeywords.contains(part)) throw new IllegalStateException(msg + " could not contains reserved keyword:" + " [type = " + type + ", identifier=" + identifier + ", keyword=" + part + "]"); @@ -254,8 +258,8 @@ public class CodeGenerator { File out = new File(pkgFolder, type + ".java"); - checkValidJavaIdentifier(pkg, "Package", type); - checkValidJavaIdentifier(type, "Type", type); + checkValidJavaIdentifier(pkg, true, "Package", type); + checkValidJavaIdentifier(type, false, "Type", type); if (out.exists()) { MessageBox.Result choice = askOverwrite.confirm(out.getName()); @@ -281,7 +285,7 @@ public class CodeGenerator { for (PojoField field : fields) { String fldName = field.javaName(); - checkValidJavaIdentifier(fldName, "Field", type); + checkValidJavaIdentifier(fldName, false, "Field", type); add1(src, "/** Value for " + fldName + ". */"); @@ -539,7 +543,7 @@ public class CodeGenerator { * @param varName Variable name to generate. * @param mtdName Method name to generate. * @param comment Commentary text. - * @param first {@code true} if varable should be declared. + * @param first {@code true} if variable should be declared. */ private static void addQueryFields(Collection src, Collection fields, String varName, String mtdName, String comment, boolean first) {