You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ba...@apache.org on 2006/10/29 16:49:56 UTC

svn commit: r468935 [1/2] - in /incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces: ./ generator/ parse/ util/

Author: baranda
Date: Sun Oct 29 08:49:55 2006
New Revision: 468935

URL: http://svn.apache.org/viewvc?view=rev&rev=468935
Log:
First refactoring of the code to adapt the plugin to be able to create the myfaces components.
A new ComponentGenerator interface with implementations has been created to allow the possibility of having different component generators (e.g. myfaces, trinidad...)

Added:
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java   (with props)
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java   (with props)
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java   (with props)
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/TrinidadComponentGenerator.java   (with props)
Modified:
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java
    incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java

Modified: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java?view=diff&rev=468935&r1=468934&r2=468935
==============================================================================
--- incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java (original)
+++ incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java Sun Oct 29 08:49:55 2006
@@ -17,6 +17,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.FileReader;
 
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -30,6 +32,9 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.util.GregorianCalendar;
+import java.util.Calendar;
+import java.sql.Date;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
@@ -190,25 +195,69 @@
     return false;
   }
 
+  /**
+  * @deprecated call Util.convertStringToLiteral instead
+  */
   protected String convertStringToLiteral(String value)
   {
-    return convertStringToLiteral("String", value);
+    return Util.convertStringToLiteral("String", value);
   }
 
+ /**
+  * @deprecated call Util.convertStringToLiteral instead
+  */
   protected String convertStringToLiteral(String className, String value)
   {
-    if (value == null)
+    return Util.convertStringToLiteral(className, value);
+  }
+
+  protected String readLicenseHeader() throws MojoExecutionException
+  {
+    if (licenseHeaderFile == null)
     {
-      return null;
+        return _DEFAULT_LICENSE_HEADER;
     }
-    else if ("String".equals(className))
+
+    if (!licenseHeaderFile.exists())
     {
-      return "\"" + value.replaceAll("\'", "\\'") + "\"";
+       throw new MojoExecutionException("License header file not found: "
+               +licenseHeaderFile.getName());
     }
-    else
+
+    if (licenseHeaderFile.isDirectory())
     {
-      return value;
+       throw new MojoExecutionException("Expecting a file and found a directory: "
+               +licenseHeaderFile.getName());
     }
+
+      StringBuffer sb = new StringBuffer();
+
+      try
+      {
+          BufferedReader reader = new BufferedReader(new FileReader(licenseHeaderFile));
+          String line;
+
+          while ((line = reader.readLine()) != null)
+          {
+              sb.append(line+"\n");
+          }
+      }
+      catch (IOException e)
+      {
+          throw new MojoExecutionException("Exception reading license header file", e);
+      }
+
+      return sb.toString();
+  }
+
+  protected String getLicenseHeader() throws MojoExecutionException
+  {
+      if (_licenseHeader == null)
+      {
+           _licenseHeader = readLicenseHeader();
+      }
+
+      return _licenseHeader;
   }
 
   static public class URLCreationFactory extends AbstractObjectCreationFactory
@@ -258,10 +307,10 @@
   }
 
   protected void writePreamble(
-    PrettyWriter out)
+    PrettyWriter out) throws MojoExecutionException
   {
     out.write(_AUTO_GENERATE_WARNING);
-    out.write(_COPYRIGHT);
+    out.write(getLicenseHeader());
   }
 
   protected void copyFile(
@@ -290,27 +339,15 @@
     }
   }
 
+ /**
+  * @deprecated use Util.writeImports instead
+  */
   protected void writeImports(
     PrettyWriter out,
     String       packageName,
     Set          imports)
   {
-    Iterator iterator = imports.iterator();
-    iterator = new FilteredIterator(iterator,
-                                    new PackageImportsFilter(packageName));
-    while (iterator.hasNext())
-    {
-      String className = (String)iterator.next();
-      out.println("import " + className + ";");
-    }
-
-    out.println();
-  }
-
-  protected String convertMultilineComment(
-    String commentBody)
-  {
-    return commentBody.replaceAll("\n", "\n * ");
+    Util.writeImports(out,packageName,imports);
   }
 
   private ClassLoader createCompileClassLoader(
@@ -573,34 +610,35 @@
     }
   }
 
-  static private class PackageImportsFilter implements Filter
-  {
-    public PackageImportsFilter(
-      String packageName)
-    {
-      _packageName = packageName;
-    }
-
-    public boolean accept(
-      Object object)
-    {
-      String className = (String)object;
-      String packageName = Util.getPackageFromFullClass(className);
-      return (!packageName.equals(_packageName) &&
-              !packageName.equals("java.lang"));
-    }
-
-    private final String _packageName;
-  }
+ /**
+  * @parameter
+  */
+  private File licenseHeaderFile;
 
   private FacesConfigBean _facesConfig;
+  private String _licenseHeader;
 
   static final private String _AUTO_GENERATE_WARNING =
 "// WARNING: This file was automatically generated. Do not edit it directly,\n"+
 "//          or you will lose your changes.\n\n";
 
-  static private final String _COPYRIGHT =
-"/*\n"                                                                         +
-"** (TBD - insert proper license in generated code).\n"             +
-"*/\n";
+
+  static private final int _CURRENT_YEAR = new GregorianCalendar().get(Calendar.YEAR);
+
+  static final private String _DEFAULT_LICENSE_HEADER =
+        "/*\n" +
+        "* Copyright "+_CURRENT_YEAR+" The Apache Software Foundation.\n" +
+        "*\n" +
+        "* Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
+        "* you may not use this file except in compliance with the License.\n" +
+        "* You may obtain a copy of the License at\n" +
+        "*\n" +
+        "*     http://www.apache.org/licenses/LICENSE-2.0\n" +
+        "*\n" +
+        "* Unless required by applicable law or agreed to in writing, software\n" +
+        "* distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
+        "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
+        "* See the License for the specific language governing permissions and\n" +
+        "* limitations under the License.\n" +
+        "*/\n";
 }

Modified: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java?view=diff&rev=468935&r1=468934&r2=468935
==============================================================================
--- incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java (original)
+++ incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java Sun Oct 29 08:49:55 2006
@@ -47,6 +47,9 @@
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.PropertyFilter;
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.ComponentGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.TrinidadComponentGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.MyFacesComponentGenerator;
 
 /**
  * @version $Id$
@@ -75,7 +78,7 @@
   /**
    * Generates parsed components.
    */
-  private void _generateComponents() throws IOException
+  private void _generateComponents() throws IOException, MojoExecutionException
   {
     // Make sure generated source directory
     // is added to compilation source path
@@ -123,13 +126,24 @@
    * @param component  the parsed component metadata
    */
   private void _generateComponent(
-    ComponentBean component)
+    ComponentBean component) throws MojoExecutionException
   {
+    ComponentGenerator generator;
+
     String fullClassName = component.getComponentClass();
-    
+
+    if (component.isTrinidadComponent())
+    {
+      generator = new TrinidadComponentGenerator(getLog());
+    }
+    else
+    {
+      generator = new MyFacesComponentGenerator(getLog());
+    }
+
     try
     {
-      getLog().debug("Generating " + fullClassName);
+      getLog().debug("Generating " + fullClassName+", with generator: "+generator.getClass().getName());
 
       String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
       File targetFile = new File(generatedSourceDirectory, sourcePath);
@@ -189,21 +203,21 @@
         out.println();
 
         // imports
-        _writeImports(out, template, packageName,
+        generator.writeImports(out, template, packageName,
                       fullSuperclassName, superclassName,
                       component);
 
         // class
-        _writeClassBegin(out, className, superclassName, component, template);
+        generator.writeClassBegin(out, className, superclassName, component, template);
 
         // static final constants
-        _writePropertyValueConstants(out, component);
-        _writePropertyConstants(out, superclassName, component);
-        _writeFacetConstants(out, component);
-        _writeGenericConstants(out, componentFamily, componentType);
+        generator.writePropertyValueConstants(out, component);
+        generator.writePropertyConstants(out, superclassName, component);
+        generator.writeFacetConstants(out, component);
+        generator.writeGenericConstants(out, componentFamily, componentType);
 
         // public constructors and methods
-        _writeConstructor(out, component, Modifier.PUBLIC);
+        generator.writeConstructor(out, component, Modifier.PUBLIC);
 
         // insert template code
         if (template != null)
@@ -212,24 +226,21 @@
           template.close();
         }
 
-        _writeFacetMethods(out, component);
-        _writePropertyMethods(out, component);
+        generator.writeFacetMethods(out, component);
+
+        generator.writePropertyMethods(out, component);
 
         if (!suppressListenerMethods)
-          _writeListenerMethods(out, component);
+          generator.writeListenerMethods(out, component);
 
-        _writeGetFamily(out);
+        generator.writeGetFamily(out);
 
         // protected constructors and methods
         // TODO: reverse this order, to make protected constructor go first
         //       for now we want consistency with previous code generation
-        _writeGetBeanType(out);
-        _writeConstructor(out, component, Modifier.PROTECTED);
+        generator.writeOther(out, component);
 
-        // static initializer
-        _writeTypeLock(out, component);
-
-        _writeClassEnd(out);
+        generator.writeClassEnd(out);
 
         out.close();
 
@@ -251,1051 +262,6 @@
     }
   }
 
-  private void _writeClassBegin(
-    PrettyWriter   out,
-    String         className,
-    String         superclassName,
-    ComponentBean  component,
-    SourceTemplate template)
-  {
-    out.println("/**");
-
-    // TODO: restore description (needs escaping?)
-//    String description = component.getDescription();
-//    if (description != null)
-//    {
-//      out.println(" *");
-//      out.println(" * " + convertMultilineComment(description));
-//    }
-
-    String longDescription = component.getLongDescription();
-    if (longDescription != null)
-    {
-      out.println(" *");
-      out.println(" * " + convertMultilineComment(longDescription));
-    }
-
-    if (component.hasEvents(true))
-    {
-      // the events javadoc
-      out.println(" *");
-      out.println(" * <h4>Events:</h4>");
-      out.println(" * <table border=\"1\" width=\"100%\" cellpadding=\"3\" summary=\"\">");
-      out.println(" * <tr bgcolor=\"#CCCCFF\" class=\"TableHeadingColor\">");
-      out.println(" * <th align=\"left\">Type</th>");
-      out.println(" * <th align=\"left\">Phases</th>");
-      out.println(" * <th align=\"left\">Description</th>");
-      out.println(" * </tr>");
-      Iterator events = component.events(true);
-      while (events.hasNext())
-      {
-        EventRefBean eventRef = (EventRefBean)events.next();
-        EventBean event = eventRef.resolveEventType();
-        if (event != null)
-        {
-          String eventClass = event.getEventClass();
-          String[] eventPhases = eventRef.getEventDeliveryPhases();
-          String eventDescription = event.getDescription();
-          out.println(" * <tr class=\"TableRowColor\">");
-          out.println(" * <td valign=\"top\"><code>" + eventClass + "</code></td>");
-          out.print(" * <td valign=\"top\" nowrap>");
-          if (eventPhases != null)
-          {
-            for (int i=0; i < eventPhases.length; i++)
-            {
-              if (i > 0)
-                out.print("<br>");
-              out.print(eventPhases[i]);
-            }
-          }
-          out.println("</td>");
-          out.println(" * <td valign=\"top\">" + eventDescription + "</td>");
-          out.println(" * </tr>");
-        }
-      }
-      out.println(" * </table>");
-    }
-
-    if (!component.hasChildren())
-    {
-      out.println(" * <p>");
-      out.println(" * It does not support any children.");
-    }
-
-    out.println(" */");
-
-    // TODO: eliminate <mfp:component-class-modifier> metadata
-    int modifiers = component.getComponentClassModifiers();
-    String classStart = Modifier.toString(modifiers);
-    // TODO: use canonical ordering
-    classStart = classStart.replaceAll("public abstract", "abstract public");
-    out.println(classStart + " class " + className +
-                             " extends " + superclassName);
-
-    Set interfaces = new HashSet();
-    if (template != null)
-      interfaces.addAll(template.getImplements());
-
-    if (component.isNamingContainer())
-      interfaces.add("javax.faces.component.NamingContainer");
-
-    Iterator events = component.events();
-    while (events.hasNext())
-    {
-      EventRefBean eventRef = (EventRefBean)events.next();
-      EventBean event = eventRef.resolveEventType();
-      if (event != null)
-      {
-        if (!eventRef.isIgnoreSourceInterface())
-        {
-          String source = event.getEventSourceInterface();
-          if (source != null)
-            interfaces.add(Util.getClassFromFullClass(source));
-        }
-      }
-    }
-
-    if (!interfaces.isEmpty())
-    {
-      Set implementsSet = new HashSet();
-      for (Iterator iter=interfaces.iterator(); iter.hasNext();)
-      {
-        String fcqn = (String)iter.next();
-        implementsSet.add(Util.getClassFromFullClass(fcqn));
-      }
-
-      // implements clause spans multiple lines
-      char[] indent = new char[classStart.length() +
-                               " class ".length() +
-                               className.length() + 1];
-      Arrays.fill(indent, ' ');
-      out.print(indent);
-      out.print("implements ");
-      for (Iterator iter=implementsSet.iterator(); iter.hasNext();)
-      {
-        out.print((String)iter.next());
-        if (iter.hasNext())
-        {
-          out.println(",");
-          out.print(indent);
-          out.print("           ");  // same length as "implements "
-        }
-      }
-      out.println();
-    }
-
-    out.println("{");
-    out.indent();
-  }
-
-  private void _writeClassEnd(
-    PrettyWriter out)
-  {
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeImports(
-    PrettyWriter   out,
-    SourceTemplate template,
-    String         packageName,
-    String         fullSuperclassName,
-    String         superclassName,
-    ComponentBean  component)
-  {
-    Set imports = new TreeSet();
-
-    // Use the template imports
-    if (template != null)
-      imports.addAll(template.getImports());
-
-    // FacesBean is always needed to define the TYPE
-    imports.add("org.apache.myfaces.trinidad.bean.FacesBean");
-
-    // Detect NamingContainer
-    if (component.isNamingContainer())
-      imports.add("javax.faces.component.NamingContainer");
-
-    Iterator properties = component.properties();
-    properties = new FilteredIterator(properties, new NonVirtualFilter());
-    // PropertyKey only needed if there are properties
-    if (properties.hasNext())
-    {
-      imports.add("org.apache.myfaces.trinidad.bean.PropertyKey");
-
-      PropertyFilter resolvable = new ResolvableTypeFilter();
-      while (properties.hasNext())
-      {
-        PropertyBean property = (PropertyBean)properties.next();
-        String propertyClass = property.getPropertyClass();
-        if (propertyClass != null)
-        {
-          imports.add(propertyClass);
-          // Check for generics
-          String[] types = property.getAttributeClassParameters();
-          if(types != null)
-          {
-            for(int i = types.length - 1; i >= 0; i--)
-            {
-              _addGenericImports(imports, types[i]);
-            }
-          }
-        }
-
-        // ComponentUtils only needed for resolvable properties
-        if (resolvable.accept(property))
-          imports.add("org.apache.myfaces.trinidad.util.ComponentUtils");
-      }
-    }
-
-    Iterator facets = component.facets();
-    // UIComponent needed if there are facets
-    if (facets.hasNext())
-      imports.add("javax.faces.component.UIComponent");
-
-    Iterator events = component.events();
-    while (events.hasNext())
-    {
-      EventRefBean eventRef = (EventRefBean)events.next();
-      EventBean event = eventRef.resolveEventType();
-
-      if (event == null)
-      {
-        getLog().warn("Unknown event type \"" + eventRef.getEventType() + "\""+
-          " in component:"+component.getComponentType());
-      }
-      else
-      {
-        String listenerClass = event.getEventListenerClass();
-        if (listenerClass != null)
-          imports.add(listenerClass);
-
-        if (!eventRef.isIgnoreSourceInterface())
-        {
-          String sourceInterface = event.getEventSourceInterface();
-          if (sourceInterface != null)
-            imports.add(sourceInterface);
-        }
-      }
-    }
-
-    // Import causes a collision if className and superclassName are equal
-    if (!superclassName.equals(fullSuperclassName))
-    {
-      String superPackageName = Util.getPackageFromFullClass(fullSuperclassName);
-      // component superclass only needed if not in
-      // same package as component class
-      if (superPackageName != packageName)
-        imports.add(fullSuperclassName);
-    }
-
-    // do not import implicit types!
-    imports.removeAll(Util.PRIMITIVE_TYPES);
-
-    writeImports(out, packageName, imports);
-  }
-  
-  private void _addGenericImports(Set imports, String type)
-  {
-    Matcher matcher = _GENERIC_TYPE.matcher(type);
-    if(matcher.matches())
-    {
-      // Generic type
-      imports.add(matcher.group(1));
-      String[] types = matcher.group(2).split(",");
-      for(int i = types.length - 1; i >= 0; i--)
-      {
-        _addGenericImports(imports, types[i]);
-      }
-    }
-    else
-    {
-      // Non-generic type
-      imports.add(type);
-    }
-  }
-
-  private void _writeGenericConstants(
-    PrettyWriter out,
-    String       componentFamily,
-    String       componentType) throws IOException
-  {
-    out.println();
-    out.println("static public final String COMPONENT_FAMILY =");
-    out.println("  \"" + componentFamily + "\";");
-    out.println("static public final String COMPONENT_TYPE =");
-    out.println("  \"" + componentType + "\";");
-  }
-
-  private void _writePropertyConstants(
-    PrettyWriter   out,
-    String         superclassName,
-    ComponentBean  component) throws IOException
-  {
-    out.println("static public final FacesBean.Type TYPE = new FacesBean.Type(");
-    out.indent();
-    out.println(superclassName + ".TYPE);");
-    out.unindent();
-
-    //  component property keys
-    Iterator properties = component.properties();
-    properties = new FilteredIterator(properties, new NonVirtualFilter());
-    while (properties.hasNext())
-    {
-      PropertyBean property = (PropertyBean)properties.next();
-      String propName = property.getPropertyName();
-      String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
-      String propAlias = property.getAliasOf();
-
-      out.println("static public final PropertyKey " + propKey + " =");
-      out.indent();
-      if (propAlias != null)
-      {
-        String aliasKey = Util.getConstantNameFromProperty(propAlias, "_KEY");
-        out.print("TYPE.registerAlias(" + aliasKey + ", \"" + propName + "\");");
-      }
-      else
-      {
-        out.print("TYPE.registerKey(\"" + propName + "\"");
-
-        // property class
-        String propFullClass = property.getPropertyClass();
-        String propClass = Util.getClassFromFullClass(propFullClass);
-        if (propClass == null)
-        {
-          propClass = "String";
-        }
-        String propDefault = property.getDefaultValue();
-
-        if (!"Object".equals(propClass) || propDefault != null)
-        {
-          // TODO: do not use boxed class here
-          String boxedClass = Util.getBoxedClass(propClass);
-          out.print(", " + boxedClass + ".class");
-        }
-
-        if (propDefault != null)
-        {
-          out.print(", " + _convertStringToBoxedLiteral(propClass, propDefault));
-        }
-
-        // property capabilities
-        String propCaps = _getPropertyCapabilities(property);
-        if (propCaps != null)
-          out.print(", " + propCaps);
-        out.println(");");
-      }
-      out.unindent();
-    }
-  }
-
-  private void _writePropertyValueConstants(
-    PrettyWriter   out,
-    ComponentBean  component) throws IOException
-  {
-    //  component property keys
-    Iterator properties = component.properties();
-    properties = new FilteredIterator(properties, new NonVirtualFilter());
-    while (properties.hasNext())
-    {
-      PropertyBean property = (PropertyBean)properties.next();
-      String[] propertyValues = property.getPropertyValues();
-
-      if (propertyValues != null)
-      {
-        String propName = property.getPropertyName();
-
-        for (int i=0; i < propertyValues.length; i++)
-        {
-          String propValue = propertyValues[i];
-          String propValueName = propName +
-                                 Character.toUpperCase(propValue.charAt(0)) +
-                                 propValue.substring(1);
-          String propValueKey = Util.getConstantNameFromProperty(propValueName);
-
-          out.println("static public final String " + propValueKey + " = \"" + propValue + "\";");
-        }
-
-      }
-    }
-  }
-
-  private void _writeFacetConstants(
-    PrettyWriter  out,
-    ComponentBean component) throws IOException
-  {
-    Iterator facets = component.facets();
-    while (facets.hasNext())
-    {
-      FacetBean facet = (FacetBean)facets.next();
-      String facetName = facet.getFacetName();
-      String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
-      out.println("static public final " +
-                    "String " + facetKey + " = \"" + facetName + "\";");
-    }
-  }
-
-  private String _convertStringToBoxedLiteral(
-    String  className,
-    String  value)
-  {
-    if (value == null)
-    {
-      return null;
-    }
-    else if ("String".equals(className))
-    {
-      return "\"" + value.replaceAll("\'", "\\'") + "\"";
-    }
-    else if ("boolean".equals(className))
-    {
-      return ("true".equals(value)) ? "Boolean.TRUE" : "Boolean.FALSE";
-    }
-    else if ("char".equals(className))
-    {
-      return "new Character('" + value.replaceAll("\'", "\\'") + "')";
-    }
-    else if ("int".equals(className))
-    {
-      return "new Integer(" + value + ")";
-    }
-    else if ("float".equals(className))
-    {
-      return "new Float(" + value + ")";
-    }
-    else
-    {
-      throw new IllegalStateException();
-    }
-  }
-
-  private void _writeConstructor(
-    PrettyWriter   out,
-    ComponentBean  component,
-    int            modifiers) throws IOException
-  {
-    String fullClassName = component.getComponentClass();
-    String className = Util.getClassFromFullClass(fullClassName);
-
-    if (Modifier.isPublic(modifiers))
-    {
-      // TODO: eliminate this inconsistency
-      if (!Modifier.isAbstract(component.getComponentClassModifiers()))
-      {
-        String rendererType = component.getRendererType();
-
-        if (rendererType != null)
-          rendererType = _convertStringToBoxedLiteral("String", rendererType);
-
-        out.println();
-        out.println("/**");
-        // TODO: restore this correctly phrased comment (tense vs. command)
-        //out.println(" * Constructs an instance of " + className + ".");
-        out.println(" * Construct an instance of the " + className + ".");
-        out.println(" */");
-        out.println("public " + className + "()");
-        out.println("{");
-        out.indent();
-        out.println("super(" + rendererType + ");");
-        out.unindent();
-        out.println("}");
-      }
-    }
-    else if (Modifier.isProtected(modifiers))
-    {
-      out.println();
-      out.println("/**");
-      // TODO: restore this more descriptive comment with param docs
-      //out.println(" * Construct an instance of the " + className);
-      //out.println(" * with the specified renderer type.");
-      //out.println(" * ");
-      //out.println(" * @param rendererType  the renderer type");
-      out.println(" * Construct an instance of the " + className + ".");
-      out.println(" */");
-      out.println("protected " + className + "(");
-      out.indent();
-      out.println("String rendererType");
-      out.println(")");
-      out.unindent();
-      out.println("{");
-      out.indent();
-      out.println("super(rendererType);");
-      out.unindent();
-      out.println("}");
-
-      // TODO: eliminate this inconsistency
-      if (Modifier.isAbstract(component.getComponentClassModifiers()))
-      {
-        out.println();
-        out.println("/**");
-        // TODO: restore this correctly phrased comment (tense vs. command)
-        //out.println(" * Constructs an instance of " + className + ".");
-        out.println(" * Construct an instance of the " + className + ".");
-        out.println(" */");
-        out.println("protected " + className + "()");
-        out.println("{");
-        out.indent();
-        out.println("this(null);");
-        out.unindent();
-        out.println("}");
-      }
-    }
-  }
-
-  private void _writeGetFamily(
-    PrettyWriter out) throws IOException
-  {
-    out.println();
-    out.println("@Override");
-    out.println("public String getFamily()");
-    out.println("{");
-    out.indent();
-    out.println("return COMPONENT_FAMILY;");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeGetBeanType(
-    PrettyWriter out) throws IOException
-  {
-    out.println();
-    out.println("@Override");
-    out.println("protected FacesBean.Type getBeanType()");
-    out.println("{");
-    out.indent();
-    out.println("return TYPE;");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writePropertyMethods(
-   PrettyWriter  out,
-   ComponentBean component) throws IOException
-  {
-    Iterator properties = component.properties();
-    properties = new FilteredIterator(properties, new NonVirtualFilter());
-    while (properties.hasNext())
-    {
-      PropertyBean property = (PropertyBean)properties.next();
-      if (property.isList())
-        _writePropertyListMethods(out, property);
-      else
-      {
-        _writePropertyGet(out, property);
-        _writePropertySet(out, property);
-      }
-    }
-  }
-
-  private void _writePropertyListMethods(
-   PrettyWriter  out,
-   PropertyBean  property) throws IOException
-  {
-    String propName = property.getPropertyName();
-    String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
-    String propertyClass = property.getPropertyClass();
-    if (!"java.util.List".equals(propertyClass))
-    {
-      getLog().error("Invalid list type: " + propertyClass);
-      return;
-    }
-
-    // Look for the generic type - if it doesn't exist, then
-    // we'll be an Object.
-    String[] params = property.getPropertyClassParameters();
-    if ((params == null) || (params.length == 0))
-      propertyClass = "java.lang.Object";
-    else
-      propertyClass = params[0];
-
-    propertyClass = Util.getClassFromFullClass(propertyClass);
-
-    String singularName = _getSingular(propName);
-    String propVar = Util.getVariableFromName(singularName);
-    String description = property.getDescription();
-    String addMethod = Util.getPrefixedPropertyName("add", singularName);
-    String removeMethod = Util.getPrefixedPropertyName("remove", singularName);
-    String getMethod = Util.getPrefixedPropertyName("get", propName);
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * Adds a " + convertMultilineComment(description));
-    }
-    out.println(" */");
-    out.println("final public void " + addMethod + "(" + propertyClass + " " +
-                propVar + ")");
-    out.println("{");
-    out.indent();
-    out.println("if (" + propVar + " == null)");
-    out.println("  throw new NullPointerException();");
-    out.println();
-    out.println("getFacesBean().addEntry(" + propKey + ", " + propVar + ");");
-    out.unindent();
-    out.println("}");
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * Removes a " + convertMultilineComment(description));
-    }
-    out.println(" */");
-    out.println("final public void " + removeMethod + "(" + propertyClass + " " +
-                propVar + ")");
-    out.println("{");
-    out.indent();
-    out.println("if (" + propVar + " == null)");
-    out.println("  throw new NullPointerException();");
-    out.println();
-    out.println("getFacesBean().removeEntry(" + propKey + ", " + propVar + ");");
-    out.unindent();
-    out.println("}");
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * Gets all " + convertMultilineComment(description));
-    }
-    out.println(" */");
-    out.println("final public " + propertyClass + "[] " + getMethod + "()");
-    out.println("{");
-    out.indent();
-    out.println("return (" + propertyClass + "[]) getFacesBean().getEntries(");
-    out.println("         " + propKey + ", " + propertyClass + ".class);");
-    out.unindent();
-    out.println("}");
-  }
-
-  static private String _getSingular(String plural)
-  {
-    if (plural.endsWith("s"))
-      return plural.substring(0, plural.length() - 1);
-    return plural;
-  }
-
-  private void _writePropertySet(
-   PrettyWriter  out,
-   PropertyBean  property) throws IOException
-  {
-    String propertyClass = Util.getPropertyClass(property);
-    _writePropertySet(out, property, propertyClass);
-
-    if (property.getAlternateClass() != null)
-    {
-      String alternateClass = Util.getAlternatePropertyClass(property);
-      _writePropertySet(out, property, alternateClass);
-    }
-  }
-
-  private void _writePropertySet(
-   PrettyWriter  out,
-   PropertyBean  property,
-   String        propertyClass) throws IOException
-  {
-    String propName = property.getPropertyName();
-    String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
-    String propVar = Util.getVariableFromName(propName);
-    String description = property.getDescription();
-    String setMethod = Util.getPrefixedPropertyName("set", propName);
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * Sets " + convertMultilineComment(description));
-    }
-    // TODO: restore this comment.
-//    if (property.isRequired())
-//    {
-//      out.println(" * <p>");
-//      out.println(" * This is a required property on the component.");
-//    }
-    // TODO: put this back in
-    //out.println(" * ");
-    //out.println(" * @param " + propName + "  the new " + propName + " value");
-    out.println(" */");
-
-    out.println("final public void " + setMethod + "(" + propertyClass + " " + propVar + ")");
-    out.println("{");
-    out.indent();
-    if (Util.isPrimitiveClass(propertyClass))
-    {
-      // TODO: use UIXComponentBase setXXXProperty methods when possible
-      if (propertyClass.equals("boolean"))
-      {
-        // TODO: add back space before ternary operator
-        out.println("setProperty(" + propKey + ", " + propVar + "? Boolean.TRUE : Boolean.FALSE);");
-      }
-      else
-      {
-        String boxedClass = Util.getBoxedClass(propertyClass);
-        out.println("setProperty(" + propKey + ", new " + boxedClass + "(" + propVar + "));");
-      }
-    }
-    else
-    {
-      out.println("setProperty(" + propKey + ", (" + propVar + "));");
-    }
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writePropertyGet(
-   PrettyWriter  out,
-   PropertyBean  property) throws IOException
-  {
-    String propName = property.getPropertyName();
-    String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
-    String propertyFullClass = property.getPropertyClass();
-    String propertyClass = Util.getClassFromFullClass(propertyFullClass);
-    String description = property.getDescription();
-    String getMethod = Util.getMethodReaderFromProperty(propName, propertyClass);
-    
-    boolean isUnchecked = false;
-    String[] genericTypes = property.getPropertyClassParameters();
-    if(genericTypes != null && genericTypes.length > 0)
-    {
-      isUnchecked = true;
-      propertyClass = Util.getPropertyClass(property);
-    }
-    
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * Gets " + convertMultilineComment(description));
-    }
-    if (property.isRequired())
-    {
-      out.println(" * <p>");
-      out.println(" * This is a required property on the component.");
-      out.println(" * </p>");
-    }
-    // TODO: put this back in
-    //out.println(" *");
-    //out.println(" * @return  the new " + propName + " value");
-    out.println(" */");
-
-    if(isUnchecked)
-    {
-      out.println("@SuppressWarnings(\"unchecked\")");
-    }
-    
-    out.println("final public " + propertyClass + " " + getMethod + "()");
-    out.println("{");
-    out.indent();
-
-    String resolvableType = _resolveType(propertyFullClass);
-    if (resolvableType != null)
-    {
-      // TODO: change signature of ComponentUtils.resolveCharacter
-      //       to take Object instead of Character
-      if (resolvableType.equals("Character"))
-      {
-        out.println("return ComponentUtils.resolveCharacter((Character)getProperty(" + propKey + "));");
-      }
-      else
-      {
-        // TODO: stop specifying default values in the getters
-        String resolveMethod = Util.getPrefixedPropertyName("resolve", resolvableType);
-        String propertyDefault = property.getDefaultValue();
-        out.print("return ComponentUtils." + resolveMethod + "(getProperty(" + propKey + ")");
-        if (propertyDefault != null)
-        {
-          out.print(", " + convertStringToLiteral(propertyClass,
-                                                   propertyDefault));
-        }
-        out.println(");");
-      }
-    }
-    else
-    {
-      if(propertyClass.equals("Object"))
-      {
-        // Cast is not necessary if the property class is Object
-        out.println("return getProperty(" + propKey + ");");
-      }
-      else
-      {
-        out.println("return (" + propertyClass + ")" +
-                    "getProperty(" + propKey + ");");
-      }
-    }
-    out.unindent();
-    out.println("}");
-  }
-  
-  private void _writeFacetMethods(
-   PrettyWriter  out,
-   ComponentBean component) throws IOException
-  {
-    Iterator facets = component.facets();
-    while (facets.hasNext())
-    {
-      FacetBean facet = (FacetBean)facets.next();
-      _writeFacetGet(out, facet);
-      _writeFacetSet(out, facet);
-    }
-  }
-
-  private void _writeFacetSet(
-   PrettyWriter  out,
-   FacetBean     facet) throws IOException
-  {
-    String facetName = facet.getFacetName();
-    // TODO: drop the unnecessary "Facet" suffix
-    String facetVar = facetName + "Facet";
-    String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
-    String setMethod = Util.getPrefixedPropertyName("set", facetName);
-    String description = facet.getDescription();
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * " + convertMultilineComment(description));
-    }
-    if (facet.isRequired())
-    {
-      out.println(" * <p>");
-      out.println(" * This is a required facet on the component.");
-    }
-    // TODO: put this back in
-    //out.println(" * ");
-    //out.println(" * @param " + facetVar + "  the new " + facetName + " facet");
-    out.println(" */");
-
-    // Remove type safety warning since getFacets is not generics enabled 
-    // under JSF 1.1 spec
-    // TODO: Remove this line when Trinidad switch to JSF 1.2
-    out.println("@SuppressWarnings(\"unchecked\")");
-    
-    out.println("final public void " + setMethod + "(UIComponent " + facetVar + ")");
-    out.println("{");
-    out.indent();
-    out.println("getFacets().put(" + facetKey + ", " + facetVar + ");");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeFacetGet(
-   PrettyWriter  out,
-   FacetBean     facet) throws IOException
-  {
-    String facetName = facet.getFacetName();
-    String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
-    String getMethod = Util.getPrefixedPropertyName("get", facetName);
-    String description = facet.getDescription();
-
-    out.println();
-    out.println("/**");
-    if (description != null)
-    {
-      out.println(" * " + convertMultilineComment(description));
-    }
-    if (facet.isRequired())
-    {
-      out.println(" * <p>");
-      out.println(" * This is a required facet on the component.");
-    }
-    // TODO: put this back in
-    //out.println(" * ");
-    //out.println(" * @return  the " + facetName + " facet");
-    out.println(" */");
-
-    out.println("final public UIComponent " + getMethod + "()");
-    out.println("{");
-    out.indent();
-    out.println("return getFacet(" + facetKey + ");");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeListenerMethods(
-    PrettyWriter  out,
-    ComponentBean component) throws IOException
-  {
-    Iterator events = component.events();
-    while (events.hasNext())
-    {
-      EventRefBean eventRef = (EventRefBean)events.next();
-      EventBean event = eventRef.resolveEventType();
-      if (event != null)
-      {
-        _writeListenerAdd(out, event);
-        _writeListenerRemove(out, event);
-        _writeListenersGet(out, event);
-      }
-    }
-  }
-
-  private void _writeListenerAdd(
-    PrettyWriter  out,
-    EventBean     event) throws IOException
-  {
-    String listenerFullClass = event.getEventListenerClass();
-    String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
-    String eventName = event.getEventName();
-    String addMethod = Util.getMethodNameFromEvent("add", eventName, "Listener");
-
-    out.println();
-    out.println("/**");
-    out.println(" * Adds a " + eventName + " listener.");
-    out.println(" *");
-    out.println(" * @param listener  the " + eventName + " listener to add");
-    out.println(" */");
-
-    out.println("final public void " + addMethod + "(");
-    out.indent();
-    out.println(listenerClass + " listener)");
-    out.unindent();
-    out.println("{");
-    out.indent();
-    out.println("addFacesListener(listener);");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeListenerRemove(
-    PrettyWriter  out,
-    EventBean     event) throws IOException
-  {
-    String listenerFullClass = event.getEventListenerClass();
-    String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
-    String eventName = event.getEventName();
-    String removeMethod = Util.getMethodNameFromEvent("remove", eventName, "Listener");
-
-    out.println();
-    out.println("/**");
-    out.println(" * Removes a " + eventName + " listener.");
-    out.println(" *");
-    out.println(" * @param listener  the " + eventName + " listener to remove");
-    out.println(" */");
-
-    out.println("final public void " + removeMethod + "(");
-    out.indent();
-    out.println(listenerClass + " listener)");
-    out.unindent();
-    out.println("{");
-    out.indent();
-    out.println("removeFacesListener(listener);");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeListenersGet(
-    PrettyWriter  out,
-    EventBean     event) throws IOException
-  {
-    String listenerFullClass = event.getEventListenerClass();
-    String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
-    String eventName = event.getEventName();
-    String getMethod = Util.getMethodNameFromEvent("get", eventName, "Listeners");
-
-    out.println();
-    out.println("/**");
-    out.println(" * Returns an array of attached " + eventName + " listeners.");
-    out.println(" *");
-    out.println(" * @return  an array of attached " + eventName + " listeners.");
-    out.println(" */");
-
-    out.println("final public " + listenerClass + "[] " + getMethod + "()");
-    out.println("{");
-    out.indent();
-    out.println("return (" + listenerClass + "[])" +
-                        "getFacesListeners(" +  listenerClass + ".class);");
-    out.unindent();
-    out.println("}");
-  }
-
-  private void _writeTypeLock(
-    PrettyWriter out, ComponentBean component) throws IOException
-  {
-    out.println();
-    out.println("static");
-    out.println("{");
-    out.indent();
-    String rendererType = component.getRendererType();
-    if (rendererType == null)
-    {
-      out.println("TYPE.lock();");
-    }
-    else
-    {
-      String componentFamily = component.findComponentFamily();
-      out.println("TYPE.lockAndRegister(\"" + componentFamily + "\"," +
-                  "\"" + rendererType + "\");");
-    }
-
-    out.unindent();
-    out.println("}");
-  }
-
-  private String _getPropertyCapabilities(
-    PropertyBean property)
-  {
-    List caps = new ArrayList();
-
-    if (property.isMethodBinding() ||
-        property.isLiteralOnly())
-    {
-      caps.add("PropertyKey.CAP_NOT_BOUND");
-    }
-
-    if (property.isStateHolder())
-    {
-      caps.add("PropertyKey.CAP_STATE_HOLDER");
-    }
-
-    if (property.isTransient())
-    {
-      caps.add("PropertyKey.CAP_TRANSIENT");
-    }
-
-    if (property.isList())
-    {
-      caps.add("PropertyKey.CAP_LIST");
-    }
-
-    if (caps.isEmpty())
-      return null;
-
-    StringBuffer sb = new StringBuffer();
-    for (int i=0; i < caps.size(); i++)
-    {
-      if (i > 0)
-        sb.append(" | ");
-      sb.append(caps.get(i));
-    }
-    return sb.toString();
-  }
-
-  private class NonVirtualFilter extends PropertyFilter
-  {
-    protected boolean accept(
-      PropertyBean property)
-    {
-      return (!property.isVirtual());
-    }
-  }
-
-  private class ResolvableTypeFilter extends PropertyFilter
-  {
-    protected boolean accept(
-      PropertyBean property)
-    {
-      String propertyClass = property.getPropertyClass();
-      String resolvableType = _resolveType(propertyClass);
-      return (resolvableType != null);
-    }
-  }
-
   private class IfModifiedFilter extends ComponentFilter
   {
     protected boolean accept(
@@ -1313,32 +279,6 @@
     }
   }
 
-  static private String _resolveType(
-    String className)
-  {
-    return (String)_RESOLVABLE_TYPES.get(className);
-  }
-
-  static private Map _createResolvableTypes()
-  {
-    Map resolvableTypes = new HashMap();
-
-    resolvableTypes.put("boolean", "Boolean");
-    resolvableTypes.put("char", "Character");
-    // TODO: put this back in
-    //resolvableTypes.put("java.util.Date", "Date");
-    resolvableTypes.put("int", "Integer");
-    resolvableTypes.put("float", "Float");
-    resolvableTypes.put("java.util.Locale", "Locale");
-    resolvableTypes.put("long", "Long");
-    resolvableTypes.put("java.lang.String", "String");
-    // TODO: put this back in
-    //resolvableTypes.put("java.lang.String[]", "StringArray");
-    resolvableTypes.put("java.util.TimeZone", "TimeZone");
-
-    return Collections.unmodifiableMap(resolvableTypes);
-  }
-
   /**
    * @parameter expression="${project}"
    * @readonly
@@ -1384,7 +324,4 @@
    * @parameter
    */
   private boolean suppressListenerMethods;
-
-  static private final Pattern _GENERIC_TYPE = Pattern.compile("([^<]+)<(.+)>");
-  static final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
 }

Added: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java?view=auto&rev=468935
==============================================================================
--- incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java (added)
+++ incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java Sun Oct 29 08:49:55 2006
@@ -0,0 +1,915 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.faces.generator;
+
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventRefBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacetBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.PropertyFilter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.maven.plugin.logging.Log;
+
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public abstract class AbstractComponentGenerator implements ComponentGenerator
+{
+
+    private Log _log;
+
+    public AbstractComponentGenerator(Log log)
+    {
+        _log = log;
+    }
+
+    protected Log getLog()
+    {
+        return _log;
+    }
+
+    public void writeClassBegin(
+            PrettyWriter out,
+            String className,
+            String superclassName,
+            ComponentBean component,
+            SourceTemplate template)
+    {
+        out.println("/**");
+
+        // TODO: restore description (needs escaping?)
+//    String description = component.getDescription();
+//    if (description != null)
+//    {
+//      out.println(" *");
+//      out.println(" * " + convertMultilineComment(description));
+//    }
+
+        String longDescription = component.getLongDescription();
+        if (longDescription != null)
+        {
+            out.println(" *");
+            out.println(" * " + convertMultilineComment(longDescription));
+        }
+
+        if (component.hasEvents(true))
+        {
+            // the events javadoc
+            out.println(" *");
+            out.println(" * <h4>Events:</h4>");
+            out.println(" * <table border=\"1\" width=\"100%\" cellpadding=\"3\" summary=\"\">");
+            out.println(" * <tr bgcolor=\"#CCCCFF\" class=\"TableHeadingColor\">");
+            out.println(" * <th align=\"left\">Type</th>");
+            out.println(" * <th align=\"left\">Phases</th>");
+            out.println(" * <th align=\"left\">Description</th>");
+            out.println(" * </tr>");
+            Iterator events = component.events(true);
+            while (events.hasNext())
+            {
+                EventRefBean eventRef = (EventRefBean) events.next();
+                EventBean event = eventRef.resolveEventType();
+                if (event != null)
+                {
+                    String eventClass = event.getEventClass();
+                    String[] eventPhases = eventRef.getEventDeliveryPhases();
+                    String eventDescription = event.getDescription();
+                    out.println(" * <tr class=\"TableRowColor\">");
+                    out.println(" * <td valign=\"top\"><code>" + eventClass + "</code></td>");
+                    out.print(" * <td valign=\"top\" nowrap>");
+                    if (eventPhases != null)
+                    {
+                        for (int i = 0; i < eventPhases.length; i++)
+                        {
+                            if (i > 0)
+                                out.print("<br>");
+                            out.print(eventPhases[i]);
+                        }
+                    }
+                    out.println("</td>");
+                    out.println(" * <td valign=\"top\">" + eventDescription + "</td>");
+                    out.println(" * </tr>");
+                }
+            }
+            out.println(" * </table>");
+        }
+
+        if (!component.hasChildren())
+        {
+            out.println(" * <p>");
+            out.println(" * It does not support any children.");
+        }
+
+        out.println(" */");
+
+        // TODO: eliminate <mfp:component-class-modifier> metadata
+        int modifiers = component.getComponentClassModifiers();
+        String classStart = Modifier.toString(modifiers);
+        // TODO: use canonical ordering
+        classStart = classStart.replaceAll("public abstract", "abstract public");
+        out.println(classStart + " class " + className +
+                " extends " + superclassName);
+
+        Set interfaces = new HashSet();
+        if (template != null)
+            interfaces.addAll(template.getImplements());
+
+        if (component.isNamingContainer())
+            interfaces.add("javax.faces.component.NamingContainer");
+
+        Iterator events = component.events();
+        while (events.hasNext())
+        {
+            EventRefBean eventRef = (EventRefBean) events.next();
+            EventBean event = eventRef.resolveEventType();
+            if (event != null)
+            {
+                if (!eventRef.isIgnoreSourceInterface())
+                {
+                    String source = event.getEventSourceInterface();
+                    if (source != null)
+                        interfaces.add(Util.getClassFromFullClass(source));
+                }
+            }
+        }
+
+        if (!interfaces.isEmpty())
+        {
+            Set implementsSet = new HashSet();
+            for (Iterator iter = interfaces.iterator(); iter.hasNext();)
+            {
+                String fcqn = (String) iter.next();
+                implementsSet.add(Util.getClassFromFullClass(fcqn));
+            }
+
+            // implements clause spans multiple lines
+            char[] indent = new char[classStart.length() +
+                    " class ".length() +
+                    className.length() + 1];
+            Arrays.fill(indent, ' ');
+            out.print(indent);
+            out.print("implements ");
+            for (Iterator iter = implementsSet.iterator(); iter.hasNext();)
+            {
+                out.print((String) iter.next());
+                if (iter.hasNext())
+                {
+                    out.println(",");
+                    out.print(indent);
+                    out.print("           ");  // same length as "implements "
+                }
+            }
+            out.println();
+        }
+
+        out.println("{");
+        out.indent();
+    }
+
+    public void writeClassEnd(
+            PrettyWriter out)
+    {
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeImports(
+            PrettyWriter out,
+            SourceTemplate template,
+            String packageName,
+            String fullSuperclassName,
+            String superclassName,
+            ComponentBean component)
+    {
+        Set imports = new TreeSet();
+
+        // Use the template imports
+        if (template != null)
+            imports.addAll(template.getImports());
+
+        // Detect NamingContainer
+        if (component.isNamingContainer())
+            imports.add("javax.faces.component.NamingContainer");
+
+        Iterator properties = component.properties();
+        properties = new FilteredIterator(properties, new NonVirtualFilter());
+        // PropertyKey only needed if there are properties
+        if (properties.hasNext())
+        {
+            while (properties.hasNext())
+            {
+                PropertyBean property = (PropertyBean) properties.next();
+                String propertyClass = property.getPropertyClass();
+                if (propertyClass != null)
+                {
+                    imports.add(propertyClass);
+                    // Check for generics
+                    String[] types = property.getAttributeClassParameters();
+                    if (types != null)
+                    {
+                        for (int i = types.length - 1; i >= 0; i--)
+                        {
+                            addGenericImports(imports, types[i]);
+                        }
+                    }
+                }
+            }
+        }
+
+        Iterator facets = component.facets();
+        // UIComponent needed if there are facets
+        if (facets.hasNext())
+            imports.add("javax.faces.component.UIComponent");
+
+        Iterator events = component.events();
+        while (events.hasNext())
+        {
+            EventRefBean eventRef = (EventRefBean) events.next();
+            EventBean event = eventRef.resolveEventType();
+
+            if (event == null)
+            {
+                getLog().warn("Unknown event type \"" + eventRef.getEventType() + "\"" +
+                        " in component:" + component.getComponentType());
+            }
+            else
+            {
+                String listenerClass = event.getEventListenerClass();
+                if (listenerClass != null)
+                    imports.add(listenerClass);
+
+                if (!eventRef.isIgnoreSourceInterface())
+                {
+                    String sourceInterface = event.getEventSourceInterface();
+                    if (sourceInterface != null)
+                        imports.add(sourceInterface);
+                }
+            }
+        }
+
+        // Import causes a collision if className and superclassName are equal
+        if (!superclassName.equals(fullSuperclassName))
+        {
+            String superPackageName = Util.getPackageFromFullClass(fullSuperclassName);
+            // component superclass only needed if not in
+            // same package as component class
+            if (superPackageName != packageName)
+                imports.add(fullSuperclassName);
+        }
+
+        // add other imports (generator specific)
+        addSpecificImports(imports, component);
+
+        // do not import implicit types!
+        imports.removeAll(Util.PRIMITIVE_TYPES);
+
+        Util.writeImports(out, packageName, imports);
+    }
+
+    protected void addSpecificImports(
+            Set imports,
+            ComponentBean component)
+    {
+        // nothing by default
+    }
+
+    public void addGenericImports(Set imports, String type)
+    {
+        Matcher matcher = _GENERIC_TYPE.matcher(type);
+        if (matcher.matches())
+        {
+            // Generic type
+            imports.add(matcher.group(1));
+            String[] types = matcher.group(2).split(",");
+            for (int i = types.length - 1; i >= 0; i--)
+            {
+                addGenericImports(imports, types[i]);
+            }
+        }
+        else
+        {
+            // Non-generic type
+            imports.add(type);
+        }
+    }
+
+    public void writeGenericConstants(
+            PrettyWriter out,
+            String componentFamily,
+            String componentType) throws IOException
+    {
+        out.println();
+        out.println("static public final String COMPONENT_FAMILY =");
+        out.println("  \"" + componentFamily + "\";");
+        out.println("static public final String COMPONENT_TYPE =");
+        out.println("  \"" + componentType + "\";");
+    }
+
+    public void writePropertyConstants(
+            PrettyWriter out,
+            String superclassName,
+            ComponentBean component) throws IOException
+    {
+        // nothing
+    }
+
+    public void writePropertyValueConstants(
+            PrettyWriter out,
+            ComponentBean component) throws IOException
+    {
+        //  component property keys
+        Iterator properties = component.properties();
+        properties = new FilteredIterator(properties, new NonVirtualFilter());
+        while (properties.hasNext())
+        {
+            PropertyBean property = (PropertyBean) properties.next();
+            String[] propertyValues = property.getPropertyValues();
+
+            if (propertyValues != null)
+            {
+                String propName = property.getPropertyName();
+
+                for (int i = 0; i < propertyValues.length; i++)
+                {
+                    String propValue = propertyValues[i];
+                    String propValueName = propName +
+                            Character.toUpperCase(propValue.charAt(0)) +
+                            propValue.substring(1);
+                    String propValueKey = Util.getConstantNameFromProperty(propValueName);
+
+                    out.println("static public final String " + propValueKey + " = \"" + propValue + "\";");
+                }
+
+            }
+        }
+    }
+
+    public void writeFacetConstants(
+            PrettyWriter out,
+            ComponentBean component) throws IOException
+    {
+        Iterator facets = component.facets();
+        while (facets.hasNext())
+        {
+            FacetBean facet = (FacetBean) facets.next();
+            String facetName = facet.getFacetName();
+            String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
+            out.println("static public final " +
+                    "String " + facetKey + " = \"" + facetName + "\";");
+        }
+    }
+
+    protected String convertStringToBoxedLiteral(
+            String className,
+            String value)
+    {
+        if (value == null)
+        {
+            return null;
+        }
+        else
+            if ("String".equals(className))
+            {
+                return "\"" + value.replaceAll("\'", "\\'") + "\"";
+            }
+            else
+                if ("boolean".equals(className))
+                {
+                    return ("true".equals(value)) ? "Boolean.TRUE" : "Boolean.FALSE";
+                }
+                else
+                    if ("char".equals(className))
+                    {
+                        return "new Character('" + value.replaceAll("\'", "\\'") + "')";
+                    }
+                    else
+                        if ("int".equals(className))
+                        {
+                            return "new Integer(" + value + ")";
+                        }
+                        else
+                            if ("float".equals(className))
+                            {
+                                return "new Float(" + value + ")";
+                            }
+                            else
+                            {
+                                throw new IllegalStateException();
+                            }
+    }
+
+    public void writeConstructor(
+            PrettyWriter out,
+            ComponentBean component,
+            int modifiers) throws IOException
+    {
+        String fullClassName = component.getComponentClass();
+        String className = Util.getClassFromFullClass(fullClassName);
+
+        if (Modifier.isPublic(modifiers))
+        {
+            // TODO: eliminate this inconsistency
+            if (!Modifier.isAbstract(component.getComponentClassModifiers()))
+            {
+                String rendererType = component.getRendererType();
+
+                if (rendererType != null)
+                    rendererType = convertStringToBoxedLiteral("String", rendererType);
+
+                out.println();
+                out.println("/**");
+                // TODO: restore this correctly phrased comment (tense vs. command)
+                //out.println(" * Constructs an instance of " + className + ".");
+                out.println(" * Construct an instance of the " + className + ".");
+                out.println(" */");
+                out.println("public " + className + "()");
+                out.println("{");
+                out.indent();
+
+                writeConstructorContent(out, component, modifiers, rendererType);
+
+                out.unindent();
+                out.println("}");
+            }
+        }
+        else
+            if (Modifier.isProtected(modifiers))
+            {
+                out.println();
+                out.println("/**");
+                // TODO: restore this more descriptive comment with param docs
+                //out.println(" * Construct an instance of the " + className);
+                //out.println(" * with the specified renderer type.");
+                //out.println(" * ");
+                //out.println(" * @param rendererType  the renderer type");
+                out.println(" * Construct an instance of the " + className + ".");
+                out.println(" */");
+                out.println("protected " + className + "(");
+                out.indent();
+                out.println("String rendererType");
+                out.println(")");
+                out.unindent();
+                out.println("{");
+                out.indent();
+
+                writeConstructorContent(out, component, modifiers, "rendererType");
+
+                out.unindent();
+                out.println("}");
+
+                // TODO: eliminate this inconsistency
+                if (Modifier.isAbstract(component.getComponentClassModifiers()))
+                {
+                    out.println();
+                    out.println("/**");
+                    // TODO: restore this correctly phrased comment (tense vs. command)
+                    //out.println(" * Constructs an instance of " + className + ".");
+                    out.println(" * Construct an instance of the " + className + ".");
+                    out.println(" */");
+                    out.println("protected " + className + "()");
+                    out.println("{");
+                    out.indent();
+                    out.println("this(null);");
+                    out.unindent();
+                    out.println("}");
+                }
+            }
+    }
+
+    protected abstract void writeConstructorContent(
+            PrettyWriter out,
+            ComponentBean component,
+            int modifiers, String rendererType) throws IOException;
+
+    public void writeGetFamily(
+            PrettyWriter out) throws IOException
+    {
+        out.println();
+        out.println("@Override");
+        out.println("public String getFamily()");
+        out.println("{");
+        out.indent();
+        out.println("return COMPONENT_FAMILY;");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writePropertyMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException
+    {
+        Iterator properties = component.properties();
+        properties = new FilteredIterator(properties, new NonVirtualFilter());
+        while (properties.hasNext())
+        {
+            PropertyBean property = (PropertyBean) properties.next();
+            if (property.isList())
+                writePropertyListMethods(out, property);
+            else
+            {
+                writePropertyDeclaration(out, property);
+                writePropertyGet(out, property);
+                writePropertySet(out, property);
+            }
+        }
+    }
+
+    abstract protected void writePropertyListMethods(
+            PrettyWriter out,
+            PropertyBean property) throws IOException;
+
+    static protected String getSingular(String plural)
+    {
+        if (plural.endsWith("s"))
+            return plural.substring(0, plural.length() - 1);
+        return plural;
+    }
+
+    protected abstract void writePropertyDeclaration(
+            PrettyWriter out,
+            PropertyBean property) throws IOException;
+
+    protected void writePropertySet(
+            PrettyWriter out,
+            PropertyBean property) throws IOException
+    {
+        String propertyClass = Util.getPropertyClass(property);
+        writePropertySet(out, property, propertyClass);
+
+        if (property.getAlternateClass() != null)
+        {
+            String alternateClass = Util.getAlternatePropertyClass(property);
+            writePropertySet(out, property, alternateClass);
+        }
+    }
+
+    protected void writePropertySet(
+            PrettyWriter out,
+            PropertyBean property,
+            String propertyClass) throws IOException
+    {
+        String propName = property.getPropertyName();
+        String propVar = Util.getVariableFromName(propName);
+        String description = property.getDescription();
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+
+        out.println();
+        out.println("/**");
+        if (description != null)
+        {
+            out.println(" * Sets " + convertMultilineComment(description));
+        }
+        // TODO: restore this comment.
+//    if (property.isRequired())
+//    {
+//      out.println(" * <p>");
+//      out.println(" * This is a required property on the component.");
+//    }
+        // TODO: put this back in
+        //out.println(" * ");
+        //out.println(" * @param " + propName + "  the new " + propName + " value");
+        out.println(" */");
+
+        out.println("final public void " + setMethod + "(" + propertyClass + " " + propVar + ")");
+        out.println("{");
+        out.indent();
+        writePropertySetterContent(out, property, propertyClass);
+        out.unindent();
+        out.println("}");
+    }
+
+    protected abstract void writePropertySetterContent(
+            PrettyWriter out,
+            PropertyBean property,
+            String propertyClass) throws IOException;
+
+    protected void writePropertyGet(
+            PrettyWriter out,
+            PropertyBean property) throws IOException
+    {
+        String propName = property.getPropertyName();
+        String propertyFullClass = property.getPropertyClass();
+        String propertyClass = Util.getClassFromFullClass(propertyFullClass);
+        String description = property.getDescription();
+        String getMethod = Util.getMethodReaderFromProperty(propName, propertyClass);
+
+        boolean isUnchecked = false;
+        String[] genericTypes = property.getPropertyClassParameters();
+        if (genericTypes != null && genericTypes.length > 0)
+        {
+            isUnchecked = true;
+            propertyClass = Util.getPropertyClass(property);
+        }
+
+        out.println();
+        out.println("/**");
+        if (description != null)
+        {
+            out.println(" * Gets " + convertMultilineComment(description));
+        }
+        if (property.isRequired())
+        {
+            out.println(" * <p>");
+            out.println(" * This is a required property on the component.");
+            out.println(" * </p>");
+        }
+        // TODO: put this back in
+        //out.println(" *");
+        //out.println(" * @return  the new " + propName + " value");
+        out.println(" */");
+
+        if (isUnchecked)
+        {
+            out.println("@SuppressWarnings(\"unchecked\")");
+        }
+
+        out.println("final public " + propertyClass + " " + getMethod + "()");
+        out.println("{");
+        out.indent();
+
+        writePropertyGetterContent(out, property);
+
+        out.unindent();
+        out.println("}");
+    }
+
+    protected abstract void writePropertyGetterContent(
+            PrettyWriter out,
+            PropertyBean property) throws IOException;
+
+    public void writeFacetMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException
+    {
+        Iterator facets = component.facets();
+        while (facets.hasNext())
+        {
+            FacetBean facet = (FacetBean) facets.next();
+            writeFacetGet(out, facet);
+            writeFacetSet(out, facet);
+        }
+    }
+
+    public void writeFacetSet(
+            PrettyWriter out,
+            FacetBean facet) throws IOException
+    {
+        String facetName = facet.getFacetName();
+        // TODO: drop the unnecessary "Facet" suffix
+        String facetVar = facetName + "Facet";
+        String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
+        String setMethod = Util.getPrefixedPropertyName("set", facetName);
+        String description = facet.getDescription();
+
+        out.println();
+        out.println("/**");
+        if (description != null)
+        {
+            out.println(" * " + convertMultilineComment(description));
+        }
+        if (facet.isRequired())
+        {
+            out.println(" * <p>");
+            out.println(" * This is a required facet on the component.");
+        }
+        // TODO: put this back in
+        //out.println(" * ");
+        //out.println(" * @param " + facetVar + "  the new " + facetName + " facet");
+        out.println(" */");
+
+        // Remove type safety warning since getFacets is not generics enabled
+        // under JSF 1.1 spec
+        // TODO: Remove this line when Trinidad switch to JSF 1.2
+        out.println("@SuppressWarnings(\"unchecked\")");
+
+        out.println("final public void " + setMethod + "(UIComponent " + facetVar + ")");
+        out.println("{");
+        out.indent();
+        out.println("getFacets().put(" + facetKey + ", " + facetVar + ");");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeFacetGet(
+            PrettyWriter out,
+            FacetBean facet) throws IOException
+    {
+        String facetName = facet.getFacetName();
+        String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
+        String getMethod = Util.getPrefixedPropertyName("get", facetName);
+        String description = facet.getDescription();
+
+        out.println();
+        out.println("/**");
+        if (description != null)
+        {
+            out.println(" * " + convertMultilineComment(description));
+        }
+        if (facet.isRequired())
+        {
+            out.println(" * <p>");
+            out.println(" * This is a required facet on the component.");
+        }
+        // TODO: put this back in
+        //out.println(" * ");
+        //out.println(" * @return  the " + facetName + " facet");
+        out.println(" */");
+
+        out.println("final public UIComponent " + getMethod + "()");
+        out.println("{");
+        out.indent();
+        out.println("return getFacet(" + facetKey + ");");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeListenerMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException
+    {
+        Iterator events = component.events();
+        while (events.hasNext())
+        {
+            EventRefBean eventRef = (EventRefBean) events.next();
+            EventBean event = eventRef.resolveEventType();
+            if (event != null)
+            {
+                writeListenerAdd(out, event);
+                writeListenerRemove(out, event);
+                writeListenersGet(out, event);
+            }
+        }
+    }
+
+    public void writeListenerAdd(
+            PrettyWriter out,
+            EventBean event) throws IOException
+    {
+        String listenerFullClass = event.getEventListenerClass();
+        String listenerClass = Util.getClassFromFullClass(listenerFullClass);
+
+        String eventName = event.getEventName();
+        String addMethod = Util.getMethodNameFromEvent("add", eventName, "Listener");
+
+        out.println();
+        out.println("/**");
+        out.println(" * Adds a " + eventName + " listener.");
+        out.println(" *");
+        out.println(" * @param listener  the " + eventName + " listener to add");
+        out.println(" */");
+
+        out.println("final public void " + addMethod + "(");
+        out.indent();
+        out.println(listenerClass + " listener)");
+        out.unindent();
+        out.println("{");
+        out.indent();
+        out.println("addFacesListener(listener);");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeListenerRemove(
+            PrettyWriter out,
+            EventBean event) throws IOException
+    {
+        String listenerFullClass = event.getEventListenerClass();
+        String listenerClass = Util.getClassFromFullClass(listenerFullClass);
+
+        String eventName = event.getEventName();
+        String removeMethod = Util.getMethodNameFromEvent("remove", eventName, "Listener");
+
+        out.println();
+        out.println("/**");
+        out.println(" * Removes a " + eventName + " listener.");
+        out.println(" *");
+        out.println(" * @param listener  the " + eventName + " listener to remove");
+        out.println(" */");
+
+        out.println("final public void " + removeMethod + "(");
+        out.indent();
+        out.println(listenerClass + " listener)");
+        out.unindent();
+        out.println("{");
+        out.indent();
+        out.println("removeFacesListener(listener);");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeListenersGet(
+            PrettyWriter out,
+            EventBean event) throws IOException
+    {
+        String listenerFullClass = event.getEventListenerClass();
+        String listenerClass = Util.getClassFromFullClass(listenerFullClass);
+
+        String eventName = event.getEventName();
+        String getMethod = Util.getMethodNameFromEvent("get", eventName, "Listeners");
+
+        out.println();
+        out.println("/**");
+        out.println(" * Returns an array of attached " + eventName + " listeners.");
+        out.println(" *");
+        out.println(" * @return  an array of attached " + eventName + " listeners.");
+        out.println(" */");
+
+        out.println("final public " + listenerClass + "[] " + getMethod + "()");
+        out.println("{");
+        out.indent();
+        out.println("return (" + listenerClass + "[])" +
+                "getFacesListeners(" + listenerClass + ".class);");
+        out.unindent();
+        out.println("}");
+    }
+
+    public void writeOther(
+            PrettyWriter out, ComponentBean component) throws IOException
+    {
+        // nothing
+    }
+
+    protected String convertMultilineComment(
+            String commentBody)
+    {
+        return commentBody.replaceAll("\n", "\n * ");
+    }
+
+    protected class ResolvableTypeFilter extends PropertyFilter
+    {
+        protected boolean accept(
+                PropertyBean property)
+        {
+            String propertyClass = property.getPropertyClass();
+            String resolvableType = resolveType(propertyClass);
+            return (resolvableType != null);
+        }
+    }
+
+    protected class NonVirtualFilter extends PropertyFilter
+    {
+        protected boolean accept(
+                PropertyBean property)
+        {
+            return (!property.isVirtual());
+        }
+    }
+
+    static protected String resolveType(
+            String className)
+    {
+        return (String) _RESOLVABLE_TYPES.get(className);
+    }
+
+
+    static private Map _createResolvableTypes()
+    {
+        Map resolvableTypes = new HashMap();
+
+        resolvableTypes.put("boolean", "Boolean");
+        resolvableTypes.put("char", "Character");
+        // TODO: put this back in
+        //resolvableTypes.put("java.util.Date", "Date");
+        resolvableTypes.put("int", "Integer");
+        resolvableTypes.put("float", "Float");
+        resolvableTypes.put("java.util.Locale", "Locale");
+        resolvableTypes.put("long", "Long");
+        resolvableTypes.put("java.lang.String", "String");
+        // TODO: put this back in
+        //resolvableTypes.put("java.lang.String[]", "StringArray");
+        resolvableTypes.put("java.util.TimeZone", "TimeZone");
+
+        return Collections.unmodifiableMap(resolvableTypes);
+    }
+
+    static private final Pattern _GENERIC_TYPE = Pattern.compile("([^<]+)<(.+)>");
+    static final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
+}

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/AbstractComponentGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java?view=auto&rev=468935
==============================================================================
--- incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java (added)
+++ incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java Sun Oct 29 08:49:55 2006
@@ -0,0 +1,75 @@
+package org.apache.myfaces.trinidadbuild.plugin.faces.generator;
+
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
+
+import java.io.IOException;
+
+/**
+ * Generates component classes
+ *
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public interface ComponentGenerator
+{
+    void writeClassBegin(
+            PrettyWriter out,
+            String className,
+            String superclassName,
+            ComponentBean component,
+            SourceTemplate template);
+
+    void writeClassEnd(
+            PrettyWriter out);
+
+    void writeImports(
+            PrettyWriter out,
+            SourceTemplate template,
+            String packageName,
+            String fullSuperclassName,
+            String superclassName,
+            ComponentBean component);
+
+    void writeGenericConstants(
+            PrettyWriter out,
+            String componentFamily,
+            String componentType) throws IOException;
+
+    void writePropertyConstants(
+            PrettyWriter out,
+            String superclassName,
+            ComponentBean component) throws IOException;
+
+    void writePropertyValueConstants(
+            PrettyWriter out,
+            ComponentBean component) throws IOException;
+
+    void writeFacetConstants(
+            PrettyWriter out,
+            ComponentBean component) throws IOException;
+
+    void writeConstructor(
+            PrettyWriter out,
+            ComponentBean component,
+            int modifiers) throws IOException;
+
+    void writeGetFamily(
+            PrettyWriter out) throws IOException;
+
+    void writePropertyMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException;
+
+    void writeFacetMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException;
+
+    void writeListenerMethods(
+            PrettyWriter out,
+            ComponentBean component) throws IOException;
+
+    void writeOther(
+            PrettyWriter out, ComponentBean component) throws IOException;
+}

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ComponentGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java?view=auto&rev=468935
==============================================================================
--- incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java (added)
+++ incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java Sun Oct 29 08:49:55 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.faces.generator;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+
+import java.io.IOException;
+
+/**
+ * Component generator for MyFaces
+ *
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class MyFacesComponentGenerator extends AbstractComponentGenerator
+{
+    public MyFacesComponentGenerator(Log log)
+    {
+        super(log);
+    }
+
+    protected void writeConstructorContent(PrettyWriter out, ComponentBean component, int modifiers, String rendererType) throws IOException
+    {
+        out.println("setRendererType("+rendererType+");");
+    }
+
+    public void writePropertyDeclaration(PrettyWriter out,
+                                         PropertyBean property) throws IOException
+    {
+        String propName = property.getPropertyName();
+        String fieldPropName = property.getFieldPropertyName();
+        String propertyFullClass = property.getPropertyClass();
+        String propertyClass = Util.getClassFromFullClass(propertyFullClass);
+
+        out.println();
+        out.println("// Property: " + propName);
+        out.println("private " + propertyClass + " " + fieldPropName + ";");
+    }
+
+    protected void writePropertySetterContent(PrettyWriter out,
+                                              PropertyBean property,
+                                              String propertyClass) throws IOException
+    {
+        out.println("this."+property.getFieldPropertyName()+" = "+property.getPropertyName()+";");
+    }
+
+    protected void writePropertyGetterContent(PrettyWriter out,
+                                              PropertyBean property) throws IOException
+    {
+        out.println("return this."+property.getFieldPropertyName()+";");
+    }
+
+    public void writePropertyListMethods(
+            PrettyWriter out,
+            PropertyBean property) throws IOException
+    {
+        // nothing
+    }
+}

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/MyFacesComponentGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL