empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benni...@apache.org
Subject svn commit: r1027582 - /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
Date Tue, 26 Oct 2010 14:47:01 GMT
Author: benniven
Date: Tue Oct 26 14:47:00 2010
New Revision: 1027582

URL: http://svn.apache.org/viewvc?rev=1027582&view=rev
Log:
fixes EMPIREDB-88 (CodeGenerator generates uppercase fieldnames where empire code expects
lowercase names)

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java?rev=1027582&r1=1027581&r2=1027582&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
Tue Oct 26 14:47:00 2010
@@ -294,7 +294,22 @@ public class WriterService {
 		attribute = deriveAttributeName(attribute);
 		StringBuilder attributeName = new StringBuilder();
 		attributeName.append(Character.toUpperCase(attribute.charAt(0)));
-		attributeName.append(attribute.substring(1));
+		
+		// convert the method's name to CamelCase
+		boolean nextCharacterUppercase = false;
+		for (int i = 1; i < attribute.length(); i++) 
+		{
+			char c = attribute.charAt(i);
+			if (c == '_') {
+				nextCharacterUppercase = true;
+				continue;
+			}
+			if (nextCharacterUppercase)
+				attributeName.append(Character.toUpperCase(c));
+			else
+				attributeName.append(Character.toLowerCase(c));
+			nextCharacterUppercase = false;
+		}
 		
 		StringBuilder sbGet = new StringBuilder(getGetterPrefix(type));
 		sbGet.append(attributeName);



Mime
View raw message