You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/06/04 11:41:34 UTC
svn commit: r1489360 -
/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
Author: adrianc
Date: Tue Jun 4 09:41:34 2013
New Revision: 1489360
URL: http://svn.apache.org/r1489360
Log:
New method for UtilXml.java - convert a DOM node name to a Java field name or Java class name.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=1489360&r1=1489359&r2=1489360&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java Tue Jun 4 09:41:34 2013
@@ -952,6 +952,29 @@ public class UtilXml {
}
}
+ public static String nodeNameToJavaName(String nodeName, boolean capitalizeFirst) {
+ boolean capitalize = capitalizeFirst;
+ StringBuilder sb = new StringBuilder();
+ for (int index = 0; index < nodeName.length(); index++) {
+ char character = nodeName.charAt(index);
+ if (character == '-' || character == '_') {
+ capitalize = true;
+ continue;
+ }
+ if (capitalize) {
+ sb.append(String.valueOf(character).toUpperCase());
+ capitalize = false;
+ } else {
+ if (index == 0 && !capitalizeFirst) {
+ sb.append(String.valueOf(character).toLowerCase());
+ } else {
+ sb.append(character);
+ }
+ }
+ }
+ return sb.toString();
+ }
+
/**
* Local entity resolver to handle J2EE DTDs. With this a http connection
* to sun is not needed during deployment.