myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r600316 - in /myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces: generator/taglib/ parse/
Date Sun, 02 Dec 2007 15:49:07 GMT
Author: matzew
Date: Sun Dec  2 07:49:06 2007
New Revision: 600316

URL: http://svn.apache.org/viewvc?rev=600316&view=rev
Log:
more on the TRINIDAD-848 front

Added:
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
    myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,191 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AbstractTagBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
+import org.apache.maven.plugin.logging.Log;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Set;
+import java.util.Iterator;
+
+public abstract class AbstractConverterTagGenerator extends AbstractTagGenerator {
+  protected AbstractConverterTagGenerator(boolean is12, String licenseHeader, Log log) {
+    super(is12, licenseHeader, log);
+  }
+
+   public void generateTagHandler(
+    ConverterBean converter, File generatedSourceDirectory)
+  {
+    try
+    {
+      getLog().debug("Generating " + converter.getTagClass());
+
+      StringWriter sw = new StringWriter();
+      PrettyWriter out = new PrettyWriter(sw);
+
+      Set imports = createImports(converter);
+      writeHeader(out, converter, imports);
+
+      writeClass(out, converter);
+
+      writeConstructor(out, converter);
+
+      writePropertyMethods(out, converter);
+      writeDoStartTag(out, converter);
+      writeCreateConverter(out, converter);
+      writeSetProperties(out, converter);
+      writeRelease(out, converter);
+
+      writeEnd(out);
+      // delay write in case of error
+      // timestamp should not be updated when an error occurs
+      // delete target file first, because it is readonly
+      File targetFile = createFile(generatedSourceDirectory, converter.getTagClass());
+      targetFile.delete();
+      FileWriter fw = new FileWriter(targetFile);
+      StringBuffer buf = sw.getBuffer();
+      fw.write(buf.toString());
+      fw.close();
+      targetFile.setReadOnly();
+    }
+    catch (Throwable e)
+    {
+      getLog().error("Error generating " + converter.getTagClass(), e);
+    }
+  }
+
+  protected abstract Set createImports(ConverterBean converter);
+  protected abstract void writeSetProperty(PrettyWriter out, PropertyBean property);
+
+
+  private void writeSetProperties(
+    PrettyWriter  out,
+    ConverterBean converter) throws IOException
+  {
+    Iterator properties = converter.properties();
+    properties = new FilteredIterator(properties, new TagAttributeFilter());
+    if (properties.hasNext())
+    {
+      String converterFullClass = converter.getConverterClass();
+      String converterClass = Util.getClassFromFullClass(converterFullClass);
+      out.println();
+      out.println("private void _setProperties(");
+      out.indent();
+      out.println(converterClass + " converter) throws JspException");
+      out.unindent();
+      out.println("{");
+      out.indent();
+      while (properties.hasNext())
+      {
+        PropertyBean property = (PropertyBean)properties.next();
+        writeSetProperty(out, property);
+      }
+      out.unindent();
+      out.println("}");
+    }
+  }
+
+  protected void writeCreateConverter(
+    PrettyWriter  out,
+    ConverterBean converter) throws IOException
+  {
+    Iterator properties = converter.properties();
+    properties = new FilteredIterator(properties, new TagAttributeFilter());
+    if (properties.hasNext())
+    {
+      String converterFullClass = converter.getConverterClass();
+      String converterClass = Util.getClassFromFullClass(converterFullClass);
+
+      out.println();
+      // TODO: restore coding standards, and make final
+      if (is12()) {
+        out.println("@Override");
+      }
+      out.println("protected Converter createConverter() throws JspException");
+      out.println("{");
+      out.indent();
+      if (is12())
+      {
+        out.println("String converterId = " + converterClass +  ".CONVERTER_ID;");
+        out.println("Application appl = FacesContext.getCurrentInstance().getApplication();");
+        out.println(converterClass + " converter = " +
+                    "(" + converterClass + ")appl.createConverter(converterId);");
+      }
+      else
+      {
+        out.println(converterClass + " converter = " +
+                    "(" + converterClass + ")super.createConverter();");
+      }
+      out.println("_setProperties(converter);");
+      out.println("return converter;");
+      out.unindent();
+      out.println("}");
+    }
+  }
+
+
+  protected void writeDoStartTag(
+      PrettyWriter  out,
+      ConverterBean converter) throws IOException
+    {
+      if (!is12())
+      {
+        String converterFullClass = converter.getConverterClass();
+        String converterClass = Util.getClassFromFullClass(converterFullClass);
+
+        out.println();
+        // TODO: restore coding standards, and make final
+        out.println("@Override");
+        out.println("public int doStartTag() throws JspException");
+        out.println("{");
+        out.indent();
+        out.println("super.setConverterId(" + converterClass + ".CONVERTER_ID);");
+        out.println("return super.doStartTag();");
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+
+  private void writeClass(PrettyWriter out, AbstractTagBean abstractTag) {
+    String className = Util.getClassFromFullClass(abstractTag.getTagClass());
+    if (is12())
+    {
+      out.println("public class " + className +
+                  " extends ConverterELTag");
+    }
+    else
+    {
+      out.println("public class " + className +
+                  " extends ConverterTag");
+    }
+
+    out.println("{");
+    out.indent();
+  }
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,229 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AbstractTagBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.GeneratorHelper;
+import org.apache.maven.plugin.logging.Log;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+public abstract class AbstractTagGenerator {
+  protected Log _log;
+  protected boolean _is12;
+  protected 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";
+
+  public AbstractTagGenerator(boolean is12, String licenseHeader, Log log) {
+    this._log = log;
+    this._licenseHeader = licenseHeader;
+    this._is12 = is12;
+  }
+
+  protected void writePreamble(
+    PrettyWriter out)
+  {
+    out.write(_AUTO_GENERATE_WARNING);
+    out.write(_licenseHeader);
+  }
+
+  protected Log getLog() {
+    return _log;
+  }
+
+  protected boolean is12() {
+    return _is12;
+  }
+
+  protected File createFile(File generatedSourceDirectory, String fullClassName) {
+     getLog().debug("Generating " + fullClassName);
+     String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
+     File targetFile = new File(generatedSourceDirectory, sourcePath);
+
+     targetFile.getParentFile().mkdirs();
+     return targetFile;
+   }
+
+  protected void writeConstructor(
+      PrettyWriter  out,
+      AbstractTagBean abstractTag) throws IOException
+    {
+      String fullClassName = abstractTag.getTagClass();
+      String className = Util.getClassFromFullClass(fullClassName);
+      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.println("}");
+    }
+
+  protected void writePropertyMethods(
+      PrettyWriter  out,
+      AbstractTagBean abstractTag) throws IOException
+    {
+      Iterator properties = abstractTag.properties();
+      properties = new FilteredIterator(properties, new TagAttributeFilter());
+      while (properties.hasNext())
+      {
+        PropertyBean property = (PropertyBean)properties.next();
+        out.println();
+        writePropertyMember(out, property);
+        writePropertySet(out, property);
+      }
+    }
+    private void writePropertyMember(
+   PrettyWriter  out,
+   PropertyBean  property) throws IOException
+  {
+    String propName = property.getPropertyName();
+    String propVar = "_" + Util.getVariableFromName(propName);
+    String jspPropType = getJspPropertyType(property);
+
+    out.println("private " + jspPropType + " " + propVar + ";");
+  }
+
+  private void writePropertySet(
+   PrettyWriter  out,
+   PropertyBean  property) throws IOException
+  {
+    String propName = property.getPropertyName();
+    String propVar = Util.getVariableFromName(propName);
+    String setMethod = Util.getPrefixedPropertyName("set", propName);
+    String jspPropType = getJspPropertyType(property);
+
+    // TODO: restore coding standards, and make final
+    out.println("public void " + setMethod + "(" + jspPropType + " " + propVar + ")");
+    out.println("{");
+    out.indent();
+    out.println("_" + propVar + " = " + propVar + ";");
+    out.unindent();
+    out.println("}");
+  }
+
+  protected void writeRelease(
+    PrettyWriter  out,
+    AbstractTagBean abstractTag) throws IOException
+  {
+    Iterator properties = abstractTag.properties();
+    properties = new FilteredIterator(properties, new TagAttributeFilter());
+    if (properties.hasNext())
+    {
+      out.println();
+      if (is12()) {
+        out.println("@Override");
+      }
+      out.println("public void release()");
+      out.println("{");
+      out.indent();
+      out.println("super.release();");
+      while (properties.hasNext())
+      {
+        PropertyBean property = (PropertyBean)properties.next();
+        String propName = property.getPropertyName();
+        String propVar = "_" + Util.getVariableFromName(propName);
+        out.println(propVar + " = null;");
+      }
+      out.unindent();
+      out.println("}");
+    }
+  }
+
+  private String getJspPropertyType(PropertyBean property)
+  {
+    if (property.isMethodExpression())
+      return "MethodExpression";
+
+    if (is12() && property.isMethodBinding())
+      return "MethodExpression";
+
+    if (is12() && !property.isLiteralOnly())
+      return "ValueExpression";
+    return "String";
+  }
+
+  protected void writeEnd(PrettyWriter out) {
+      out.unindent();
+      out.println("}");
+      out.close();
+    }
+
+  protected void writeImports(
+    PrettyWriter   out,
+    AbstractTagBean  abstractTagBean, Set imports)
+  {
+
+    // do not import implicit!
+    imports.removeAll(Util.PRIMITIVE_TYPES);
+
+    String packageName = Util.getPackageFromFullClass(abstractTagBean.getTagClass());
+    GeneratorHelper.writeImports(out, packageName, imports);
+  }
+
+  protected final void writeHeader(PrettyWriter out, AbstractTagBean converter, Set imports) {
+    String packageName = Util.getPackageFromFullClass(converter.getTagClass());
+    // header/copyright
+    writePreamble(out);
+
+    // package
+    out.println("package " + packageName + ";");
+
+    out.println();
+    writeImports(out, converter, imports);
+
+    out.println("/**");
+    // TODO: remove this blank line.
+    out.println();
+    out.println(" * Auto-generated tag class.");
+    out.println(" */");
+  }
+
+  protected void addImportsFromPropertes(AbstractTagBean abstractTagBean, Set imports) {
+    Iterator properties = abstractTagBean.properties();
+    properties = new FilteredIterator(properties, new TagAttributeFilter());
+
+    while (properties.hasNext())
+    {
+      PropertyBean property = (PropertyBean)properties.next();
+
+      String propertyClass = property.getPropertyClass();
+      if (propertyClass != null)
+        imports.add(propertyClass);
+
+      if ("java.lang.String[]".equals(propertyClass))
+      {
+        imports.add("java.text.ParseException");
+      }
+    }
+  }
+
+
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,195 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AbstractTagBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
+import org.apache.maven.plugin.logging.Log;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Set;
+import java.util.Iterator;
+
+public abstract class AbstractValidatorTagGenerator extends AbstractTagGenerator {
+
+  public AbstractValidatorTagGenerator(boolean is12, String licenseHeader, Log log) {
+    super(is12, licenseHeader, log);
+  }
+
+   public void generateTagHandler(
+    ValidatorBean validator, File generatedSourceDirectory)
+  {
+
+    try
+    {
+      getLog().debug("Generating " + validator.getTagClass());
+
+      StringWriter sw = new StringWriter();
+      PrettyWriter out = new PrettyWriter(sw);
+      Set imports = createImports(validator);
+      writeHeader(out, validator, imports);
+
+      writeClass(out, validator);
+
+      writeConstructor(out, validator);
+
+      writePropertyMethods(out, validator);
+      writeDoStartTag(out, validator);
+      writeCreateValidator(out, validator);
+      writeSetProperties(out, validator);
+      writeRelease(out, validator);
+
+      writeEnd(out);
+
+      // delay write in case of error
+      // timestamp should not be updated when an error occurs
+      // delete target file first, because it is readonly
+      File targetFile = createFile(generatedSourceDirectory, validator.getTagClass());
+      targetFile.delete();
+      FileWriter fw = new FileWriter(targetFile);
+      StringBuffer buf = sw.getBuffer();
+      fw.write(buf.toString());
+      fw.close();
+      targetFile.setReadOnly();
+    }
+    catch (Throwable e)
+    {
+      getLog().error("Error generating " + validator.getTagClass(), e);
+    }
+  }
+
+  protected abstract Set createImports(ValidatorBean validator);
+
+  protected void writeClass(PrettyWriter out, AbstractTagBean abstractTag) {
+    String className = Util.getClassFromFullClass(abstractTag.getTagClass());
+    if (is12())
+    {
+      out.println("public class " + className +
+                  " extends ValidatorELTag");
+    }
+    else
+    {
+      out.println("public class " + className +
+                  " extends ValidatorTag");
+    }
+
+    out.println("{");
+    out.indent();
+  }
+
+  private void writeDoStartTag(
+     PrettyWriter  out,
+     ValidatorBean validator) throws IOException
+   {
+     out.println();
+     if (!is12())
+     {
+       String validatorFullClass = validator.getValidatorClass();
+       String validatorClass = Util.getClassFromFullClass(validatorFullClass);
+
+       // TODO: restore coding standards, and make final
+       //out.println("@Override");
+       out.println("public int doStartTag() throws JspException");
+       out.println("{");
+       out.indent();
+       out.println("super.setValidatorId(" + validatorClass + ".VALIDATOR_ID);");
+       out.println("return super.doStartTag();");
+       out.unindent();
+       out.println("}");
+     }
+   }
+
+
+  private void writeCreateValidator(
+    PrettyWriter  out,
+    ValidatorBean validator) throws IOException
+  {
+    Iterator properties = validator.properties();
+    properties = new FilteredIterator(properties, new TagAttributeFilter());
+    if (properties.hasNext())
+    {
+      String validatorFullClass = validator.getValidatorClass();
+      String validatorClass = Util.getClassFromFullClass(validatorFullClass);
+
+      out.println();
+      // TODO: restore coding standards, and make final
+      if (is12()) {
+        out.println("@Override");
+      }
+      out.println("protected Validator createValidator() throws JspException");
+      out.println("{");
+      out.indent();
+      if (is12())
+      {
+        out.println("String validatorId = " + validatorClass + ".VALIDATOR_ID;");
+        out.println("Application appl = FacesContext.getCurrentInstance().getApplication();");
+        out.println(validatorClass + " validator = " +
+                    "(" + validatorClass + ")appl.createValidator(validatorId);");
+      }
+      else
+      {
+        out.println(validatorClass + " validator = " +
+                    "(" + validatorClass + ")super.createValidator();");
+      }
+      out.println("_setProperties(validator);");
+      out.println("return validator;");
+      out.unindent();
+      out.println("}");
+    }
+  }
+
+  private void writeSetProperties(
+      PrettyWriter  out,
+      ValidatorBean validator) throws IOException
+    {
+      Iterator properties = validator.properties();
+      properties = new FilteredIterator(properties, new TagAttributeFilter());
+      if (properties.hasNext())
+      {
+        String validatorFullClass = validator.getValidatorClass();
+        String validatorClass = Util.getClassFromFullClass(validatorFullClass);
+        out.println();
+        out.println("private void _setProperties(");
+        out.indent();
+        out.println(validatorClass + " validator) throws JspException");
+        out.unindent();
+        out.println("{");
+        out.indent();
+        while (properties.hasNext())
+        {
+          PropertyBean property = (PropertyBean)properties.next();
+          writeSetProperty(out, property);
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+  protected abstract void writeSetProperty(
+     PrettyWriter out,
+     PropertyBean property);
+
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,168 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateJspTaglibsMojo;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+public class MyFacesConverterTagGenerator extends AbstractConverterTagGenerator {
+
+  public MyFacesConverterTagGenerator(boolean is12, String licenseHeader, Log log) {
+    super(is12, licenseHeader, log);
+  }
+
+  protected Set createImports(ConverterBean converter) {
+    Set imports = new TreeSet();
+
+    if (is12())
+    {
+      imports.add("javax.faces.webapp.ConverterELTag");
+      imports.add("javax.faces.context.FacesContext");
+      imports.add("javax.faces.application.Application");
+    }
+    else
+    {
+      imports.add("javax.faces.webapp.ConverterTag");
+    }
+
+    imports.add("javax.servlet.jsp.JspException");
+    imports.add(converter.getConverterClass());
+
+    imports.add("javax.faces.convert.Converter");
+    if (is12())
+    {
+      imports.add("javax.el.ValueExpression");
+    }
+    else
+    {
+      imports.add("javax.faces.el.ValueBinding");
+    }
+    imports.add("org.apache.myfaces.commons.util.TagUtils");
+
+
+    addImportsFromPropertes(converter, imports);
+    return imports;
+  }
+
+
+
+
+  protected void writeSetProperty(
+    PrettyWriter out,
+    PropertyBean property)
+  {
+    String propName = property.getPropertyName();
+    String propFullClass = property.getPropertyClass();
+    String propClass = Util.getClassFromFullClass(propFullClass);
+    String propVar = "_" + Util.getVariableFromName(propName);
+
+    out.println("if (" + propVar + " != null)");
+    out.println("{");
+    out.indent();
+
+    if (is12())
+    {
+      out.println("if (!" + propVar + ".isLiteralText())");
+      out.println("{");
+      out.indent();
+      out.println("converter.setValueExpression(\"" + propName + "\", " +
+                  propVar + ");");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("converter." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+    else
+    {
+      out.println("if (TagUtils.isValueReference(" + propVar + "))");
+      out.println("{");
+      out.indent();
+      out.println("ValueBinding vb = TagUtils.getValueBinding(" + propVar + ");");
+      out.println("converter.setValueBinding(\"" + propName + "\", vb);");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("converter." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+    out.unindent();
+    out.println("}");
+  }
+
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,162 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateJspTaglibsMojo;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+public class MyFacesValidatorTagGenerator extends AbstractValidatorTagGenerator {
+
+  public MyFacesValidatorTagGenerator(boolean is12, String licenseHeader, Log log) {
+    super(is12, licenseHeader, log);
+  }
+
+  protected Set createImports(ValidatorBean validator) {
+    Set imports = new TreeSet();
+
+    if (is12())
+    {
+      imports.add("javax.faces.webapp.ValidatorELTag");
+      imports.add("javax.faces.context.FacesContext");
+      imports.add("javax.faces.application.Application");
+    }
+    else
+    {
+      imports.add("javax.faces.webapp.ValidatorTag");
+    }
+    imports.add("javax.servlet.jsp.JspException");
+    imports.add(validator.getValidatorClass());
+
+    imports.add("javax.faces.validator.Validator");
+
+    if (is12())
+    {
+      imports.add("javax.el.ValueExpression");
+    }
+    else
+    {
+      imports.add("javax.faces.el.ValueBinding");
+    }
+    imports.add("org.apache.myfaces.commons.util.TagUtils");
+
+
+    addImportsFromPropertes(validator, imports);
+    return imports;
+  }
+
+  protected void writeSetProperty(
+    PrettyWriter out,
+    PropertyBean property)
+  {
+    String propName = property.getPropertyName();
+    String propFullClass = property.getPropertyClass();
+    String propClass = Util.getClassFromFullClass(propFullClass);
+    String propVar = "_" + Util.getVariableFromName(propName);
+    out.println("if (" + propVar + " != null)");
+    out.println("{");
+    out.indent();
+    if (is12())
+    {
+      out.println("if (!" + propVar + ".isLiteralText())");
+      out.println("{");
+      out.indent();
+      out.println("validator.setValueExpression(\"" + propName + "\", " +
+                  propVar + ");");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("validator." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+    else
+    {
+      out.println("if (TagUtils.isValueReference(" + propVar + "))");
+      out.println("{");
+      out.indent();
+      out.println("ValueBinding vb = TagUtils.getValueBinding(" + propVar + ");");
+      out.println("validator.setValueBinding(\"" + propName + "\", vb);");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("validator." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+    out.unindent();
+    out.println("}");
+  }
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,168 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateJspTaglibsMojo;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+public class TrinidadConverterTagGenerator extends AbstractConverterTagGenerator {
+
+  public TrinidadConverterTagGenerator(boolean is12, String licenseHeader, Log log) {
+    super(is12, licenseHeader, log);
+  }
+
+  protected Set createImports(ConverterBean converter) {
+    Set imports = new TreeSet();
+
+    if (is12())
+    {
+      imports.add("javax.faces.webapp.ConverterELTag");
+      imports.add("javax.faces.context.FacesContext");
+      imports.add("javax.faces.application.Application");
+    }
+    else
+    {
+      imports.add("javax.faces.webapp.ConverterTag");
+    }
+
+    imports.add("javax.servlet.jsp.JspException");
+    imports.add(converter.getConverterClass());
+
+    imports.add("javax.faces.convert.Converter");
+    if (is12())
+    {
+      imports.add("javax.el.ValueExpression");
+    }
+    else
+    {
+      imports.add("javax.faces.el.ValueBinding");
+    }
+    imports.add("org.apache.myfaces.trinidadinternal.taglib.util.TagUtils");
+
+
+    addImportsFromPropertes(converter, imports);
+    return imports;
+  }
+
+
+
+
+  protected void writeSetProperty(
+    PrettyWriter out,
+    PropertyBean property)
+  {
+    String propName = property.getPropertyName();
+    String propFullClass = property.getPropertyClass();
+    String propClass = Util.getClassFromFullClass(propFullClass);
+    String propVar = "_" + Util.getVariableFromName(propName);
+
+    out.println("if (" + propVar + " != null)");
+    out.println("{");
+    out.indent();
+
+    if (is12())
+    {
+      out.println("if (!" + propVar + ".isLiteralText())");
+      out.println("{");
+      out.indent();
+      out.println("converter.setValueExpression(\"" + propName + "\", " +
+                  propVar + ");");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("converter." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+    else
+    {
+      out.println("if (TagUtils.isValueReference(" + propVar + "))");
+      out.println("{");
+      out.indent();
+      out.println("ValueBinding vb = TagUtils.getValueBinding(" + propVar + ");");
+      out.println("converter.setValueBinding(\"" + propName + "\", vb);");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("converter." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+    out.unindent();
+    out.println("}");
+  }
+
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,162 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.taglib;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.myfaces.trinidadbuild.plugin.faces.GenerateJspTaglibsMojo;
+import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+public class TrinidadValidatorTagGenerator extends AbstractValidatorTagGenerator {
+
+  public TrinidadValidatorTagGenerator(boolean _is12, String _licenseHeader, Log _log) {
+    super(_is12, _licenseHeader, _log);
+  }
+
+  protected Set createImports(ValidatorBean validator) {
+    Set imports = new TreeSet();
+
+    if (is12())
+    {
+      imports.add("javax.faces.webapp.ValidatorELTag");
+      imports.add("javax.faces.context.FacesContext");
+      imports.add("javax.faces.application.Application");
+    }
+    else
+    {
+      imports.add("javax.faces.webapp.ValidatorTag");
+    }
+    imports.add("javax.servlet.jsp.JspException");
+    imports.add(validator.getValidatorClass());
+
+    imports.add("javax.faces.validator.Validator");
+
+    if (is12())
+    {
+      imports.add("javax.el.ValueExpression");
+    }
+    else
+    {
+      imports.add("javax.faces.el.ValueBinding");
+    }
+    imports.add("org.apache.myfaces.trinidadinternal.taglib.util.TagUtils");
+
+
+    addImportsFromPropertes(validator, imports);
+    return imports;
+  }
+
+  protected void writeSetProperty(
+    PrettyWriter out,
+    PropertyBean property)
+  {
+    String propName = property.getPropertyName();
+    String propFullClass = property.getPropertyClass();
+    String propClass = Util.getClassFromFullClass(propFullClass);
+    String propVar = "_" + Util.getVariableFromName(propName);
+    out.println("if (" + propVar + " != null)");
+    out.println("{");
+    out.indent();
+    if (is12())
+    {
+      out.println("if (!" + propVar + ".isLiteralText())");
+      out.println("{");
+      out.indent();
+      out.println("validator.setValueExpression(\"" + propName + "\", " +
+                  propVar + ");");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("validator." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+    else
+    {
+      out.println("if (TagUtils.isValueReference(" + propVar + "))");
+      out.println("{");
+      out.indent();
+      out.println("ValueBinding vb = TagUtils.getValueBinding(" + propVar + ");");
+      out.println("validator.setValueBinding(\"" + propName + "\", vb);");
+      out.unindent();
+      out.println("}");
+      String propType = GenerateJspTaglibsMojo.resolveType(propFullClass);
+      if (propType != null)
+      {
+        out.println("else");
+        out.println("{");
+        out.indent();
+        if ("StringArray".equals(propType))
+        {
+          out.println("try");
+          out.println("{");
+        }
+        out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+        String setMethod = Util.getPrefixedPropertyName("set", propName);
+        out.println("validator." + setMethod + "(value);");
+        if ("StringArray".equals(propType))
+        {
+          out.println("}");
+          out.println("catch (ParseException pe)");
+          out.println("{");
+          out.indent();
+          out.println("throw new JspException(");
+          out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+          out.unindent();
+          out.println("}");
+        }
+        out.unindent();
+        out.println("}");
+      }
+    }
+
+    out.unindent();
+    out.println("}");
+  }
+}

Added: myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java?rev=600316&view=auto
==============================================================================
--- myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java (added)
+++ myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java Sun Dec  2 07:49:06 2007
@@ -0,0 +1,203 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.parse;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.Map;
+import java.lang.reflect.Modifier;
+
+public class AbstractTagBean extends ObjectBean {
+  private String  _description;
+  private String  _longDescription;
+  protected QName   _tagName;
+  private String  _tagClass;
+  protected Map _properties;
+  private int     _tagClassModifiers;
+
+  /**
+   * Sets the description of this property.
+   *
+   * @param description  the property description
+   */
+  public void setDescription(
+    String description)
+  {
+    _description = description;
+  }
+
+  /**
+   * Returns the description of this property.
+   *
+   * @return  the property description
+   */
+  public String getDescription()
+  {
+    return _description;
+  }
+
+  /**
+   * Sets the long description of this property.
+   *
+   * @param longDescription  the long property description
+   */
+  public void setLongDescription(
+    String longDescription)
+  {
+    _longDescription = longDescription;
+  }
+
+  /**
+   * Returns the long description of this property.
+   *
+   * @return  the long property description
+   */
+  public String getLongDescription()
+  {
+    return _longDescription;
+  }
+
+  /**
+   * Sets the JSP tag handler class for this component.
+   *
+   * @param tagClass  the JSP tag handler class
+   */
+  public void setTagClass(
+    String tagClass)
+  {
+    _tagClass = tagClass;
+  }
+
+  /**
+   * Returns the JSP tag handler class for this component.
+   *
+   * @return  the JSP tag handler class
+   */
+  public String getTagClass()
+  {
+    return _tagClass;
+  }
+
+  /**
+   * Returns the JSP tag name for this component.
+   *
+   * @return  the JSP tag name
+   */
+  public QName getTagName()
+  {
+    return _tagName;
+  }
+
+  /**
+   * Adds a property to this component.
+   *
+   * @param property  the property to add
+   */
+  public void addProperty(
+    PropertyBean property)
+  {
+    _properties.put(property.getPropertyName(), property);
+  }
+
+  /**
+   * Returns the property for this property name.
+   *
+   * @param propertyName  the property name to find
+   */
+  public PropertyBean findProperty(
+    String propertyName)
+  {
+    return (PropertyBean)_properties.get(propertyName);
+  }
+
+  /**
+   * Returns true if this component has any properties.
+   *
+   * @return  true   if this component has any properties,
+   *          false  otherwise
+   */
+  public boolean hasProperties()
+  {
+    return !_properties.isEmpty();
+  }
+
+  /**
+   * Returns an iterator for all properties on this component only.
+   *
+   * @return  the property iterator
+   */
+  public Iterator properties()
+  {
+    return _properties.values().iterator();
+  }
+
+  public void parseTagClassModifier(
+    String modifier)
+  {
+    addTagClassModifier(_parseModifier(modifier));
+  }
+
+  protected int _parseModifier(
+    String text)
+  {
+    if ("public".equals(text))
+      return Modifier.PUBLIC;
+    else if ("protected".equals(text))
+      return Modifier.PROTECTED;
+    else if ("private".equals(text))
+      return Modifier.PRIVATE;
+    else if ("abstract".equals(text))
+      return Modifier.ABSTRACT;
+    else if ("final".equals(text))
+      return Modifier.FINAL;
+
+    throw new IllegalArgumentException("Unrecognized modifier: " + text);
+  }
+
+  /**
+   * Adds a Java Language class modifier to the tag class.
+   *
+   * @param modifier  the modifier to be added
+   */
+  public void addTagClassModifier(
+    int modifier)
+  {
+    _tagClassModifiers |= modifier;
+  }
+
+  /**
+   * Returns the Java Language class modifiers for the tag class.
+   * By default, these modifiers include Modifier.PUBLIC.
+   *
+   * @return  the Java Language class modifiers for the tag class
+   */
+  public int getTagClassModifiers()
+  {
+    int modifiers = _tagClassModifiers;
+
+    if (!Modifier.isPrivate(modifiers) &&
+        !Modifier.isProtected(modifiers) &&
+        !Modifier.isPublic(modifiers))
+    {
+      modifiers |= Modifier.PUBLIC;
+    }
+
+    return modifiers;
+  }
+}



Mime
View raw message