You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/06/10 10:36:01 UTC

svn commit: r783253 - in /myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt: CreateComponentAnnotationVisitor.java TaglibAnnotationVisitor.java generate/PropertyInfo.java

Author: lofwyr
Date: Wed Jun 10 08:36:00 2009
New Revision: 783253

URL: http://svn.apache.org/viewvc?rev=783253&view=rev
Log:
Simplify code / code style

Modified:
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java?rev=783253&r1=783252&r2=783253&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java Wed Jun 10 08:36:00 2009
@@ -17,47 +17,47 @@
  * limitations under the License.
  */
 
-import org.antlr.stringtemplate.StringTemplateGroup;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.Filer;
+import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.InterfaceDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.TypeDeclaration;
+import com.sun.mirror.type.InterfaceType;
 import org.antlr.stringtemplate.StringTemplate;
-import org.apache.myfaces.tobago.apt.generate.RendererInfo;
-import org.apache.myfaces.tobago.apt.generate.TagInfo;
-import org.apache.myfaces.tobago.apt.generate.ClassInfo;
-import org.apache.myfaces.tobago.apt.generate.PropertyInfo;
-import org.apache.myfaces.tobago.apt.generate.ComponentPropertyInfo;
-import org.apache.myfaces.tobago.apt.generate.ComponentInfo;
-import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
-import org.apache.myfaces.tobago.apt.annotation.Tag;
-import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.antlr.stringtemplate.StringTemplateGroup;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
-import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
+import org.apache.myfaces.tobago.apt.annotation.Tag;
 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
-import org.apache.commons.io.IOUtils;
+import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.apt.generate.ClassInfo;
+import org.apache.myfaces.tobago.apt.generate.ComponentInfo;
+import org.apache.myfaces.tobago.apt.generate.ComponentPropertyInfo;
+import org.apache.myfaces.tobago.apt.generate.PropertyInfo;
+import org.apache.myfaces.tobago.apt.generate.RendererInfo;
+import org.apache.myfaces.tobago.apt.generate.TagInfo;
 
+import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.Writer;
-import java.io.File;
-import java.io.IOException;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Collection;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
-import java.util.ArrayList;
+import java.util.Locale;
 import java.util.Map;
-import java.util.Collections;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.type.InterfaceType;
+import java.util.Set;
 
 /*
  * Date: Apr 22, 2007
@@ -143,8 +143,7 @@
     addProperties(decl, properties);
     if (tag != null) {
 
-      String className = "org.apache.myfaces.tobago.internal.taglib."
-          + tag.name().substring(0, 1).toUpperCase(Locale.ENGLISH) + tag.name().substring(1) + "Tag";
+      String className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(tag.name()) + "Tag";
       TagInfo tagInfo = new TagInfo(className, componentTag.rendererType());
       tagInfo.getProperties().addAll(properties);
       if (is12()) {
@@ -189,7 +188,8 @@
         Class componentBaseClass = Class.forName(componentTag.uiComponentBaseClass());
         int index = 0;
         for (PropertyInfo info:properties) {
-          String methodName = (info.getType().equals("java.lang.Boolean")?"is":"get") + info.getUpperCamelCaseName();
+          String methodName
+              = (info.getType().equals("java.lang.Boolean") ? "is" : "get") + info.getUpperCamelCaseName();
           String possibleUnifiedElAlternative = "set" + info.getUpperCamelCaseName() + "Expression";
           try {
             Method method = componentBaseClass.getMethod(methodName);

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java?rev=783253&r1=783252&r2=783253&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java Wed Jun 10 08:36:00 2009
@@ -29,15 +29,15 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.apt.annotation.BodyContent;
 import org.apache.myfaces.tobago.apt.annotation.BodyContentDescription;
+import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
+import org.apache.myfaces.tobago.apt.annotation.Facet;
 import org.apache.myfaces.tobago.apt.annotation.Preliminary;
 import org.apache.myfaces.tobago.apt.annotation.Tag;
 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
 import org.apache.myfaces.tobago.apt.annotation.Taglib;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
-import org.apache.myfaces.tobago.apt.annotation.Facet;
-import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
-import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -54,9 +54,9 @@
 import java.io.Writer;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Set;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 /*
  * Created: Mar 22, 2005 8:18:35 PM
@@ -200,11 +200,9 @@
       // TODO configure replacement
 
       String className =
-          decl.getQualifiedName().substring(0, decl.getQualifiedName().length()-"Declaration".length());
+          decl.getQualifiedName().substring(0, decl.getQualifiedName().length() - "Declaration".length());
       if (decl.getAnnotation(UIComponentTag.class) != null) {
-        className = "org.apache.myfaces.tobago.internal.taglib."
-            + annotationTag.name().substring(0, 1).toUpperCase(Locale.ENGLISH)
-            + annotationTag.name().substring(1) + "Tag";
+        className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(annotationTag.name()) + "Tag";
       }
       //decl.getQualifiedName().replaceAll("Declaration", "");
       String msg = "Replacing: " + decl.getQualifiedName()
@@ -221,7 +219,8 @@
     }
   }
 
-  protected Element createTag(Declaration decl, Tag annotationTag, String className, Document document,
+  protected Element createTag(
+      Declaration decl, Tag annotationTag, String className, Document document,
       boolean deprecated) {
     Element tagElement = document.createElement("tag");
     if (deprecated) {

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java?rev=783253&r1=783252&r2=783253&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java Wed Jun 10 08:36:00 2009
@@ -17,7 +17,7 @@
  * limitations under the License.
  */
 
-import java.util.Locale;
+import org.apache.commons.lang.StringUtils;
 
 public class PropertyInfo {
   private String name;
@@ -98,7 +98,7 @@
   }
 
   public String getShortType() {
-    String shortType = type.substring(type.lastIndexOf('.')+1, type.length());
+    String shortType = type.substring(type.lastIndexOf('.') + 1, type.length());
     return shortType.replace("[]", "Array").replace("$", ".");
   }
 
@@ -106,13 +106,13 @@
     String type = getShortType();
     int index = type.lastIndexOf('.');
     if (index != -1) {
-      return type.substring(type.lastIndexOf('.')+1, type.length());
+      return type.substring(type.lastIndexOf('.') + 1, type.length());
     }
     return type;
   }
 
   public String getUpperCamelCaseName() {
-    return name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1);
+    return StringUtils.capitalize(name);
   }
 
   public String getPropertyName() {