tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r547878 - in /incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl: BindingSCDLProcessor.java SCDLProcessor.java
Date Sat, 16 Jun 2007 07:44:34 GMT
Author: antelder
Date: Sat Jun 16 00:44:33 2007
New Revision: 547878

URL: http://svn.apache.org/viewvc?view=rev&rev=547878
Log:
Fix up method name to field name

Modified:
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingSCDLProcessor.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingSCDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingSCDLProcessor.java?view=diff&rev=547878&r1=547877&r2=547878
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingSCDLProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingSCDLProcessor.java
Sat Jun 16 00:44:33 2007
@@ -69,9 +69,23 @@
             if ("setElementText".equals(m.getName())) {
                 elementTextSetter = m;
             } else if ((m.getName().startsWith("set"))) {
-                attributeSetters.put(m.getName().substring(3).toLowerCase(), m);
+                attributeSetters.put(getFieldName(m), m);
             }
         }
+    }
+
+    /**
+     * Remove get/set from method name, set 1st char to lowercase and
+     * remove any trailing underscore character
+     */
+    protected String getFieldName(Method m) {
+        StringBuilder sb = new StringBuilder(m.getName().substring(3));
+        sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+        String name = sb.toString();
+        if (name.endsWith("_")) {
+            name = name.substring(0,name.length()-1);
+        }
+        return name;
     }
 
     public QName getArtifactType() {

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java?view=diff&rev=547878&r1=547877&r2=547878
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
Sat Jun 16 00:44:33 2007
@@ -76,13 +76,23 @@
             if ("setElementText".equals(m.getName())) {
                 elementTextSetter = m;
             } else if ((m.getName().startsWith("set"))) {
-                String name = m.getName().substring(3).toLowerCase();
-                if (name.endsWith("_")) {
-                    name = name.substring(0,name.length()-1);
-                }
-                attributeSetters.put(name, m);
+                attributeSetters.put(getFieldName(m), m);
             }
         }
+    }
+
+    /**
+     * Remove get/set from method name, set 1st char to lowercase and
+     * remove any trailing underscore character
+     */
+    protected String getFieldName(Method m) {
+        StringBuilder sb = new StringBuilder(m.getName().substring(3));
+        sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+        String name = sb.toString();
+        if (name.endsWith("_")) {
+            name = name.substring(0,name.length()-1);
+        }
+        return name;
     }
 
     private Object[] getImplConstrArgs() {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message