You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2007/12/05 13:25:15 UTC
svn commit: r601314 - in
/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces:
./ generator/taglib/ parse/
Author: matzew
Date: Wed Dec 5 04:25:13 2007
New Revision: 601314
URL: http://svn.apache.org/viewvc?rev=601314&view=rev
Log:
TRINIDAD-848 - merge the changes to trunk;
Added:
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
- copied unchanged from r601297, 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/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
- copied unchanged from r601297, myfaces/trinidad-maven/branches/bommel_matzew_mfp_overhaul/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
Modified:
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFaceletsTaglibsMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateMasterFacesConfigMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ConverterBean.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ValidatorBean.java
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java Wed Dec 5 04:25:13 2007
@@ -92,8 +92,21 @@
protected List getMasterConfigs(
MavenProject project) throws MojoExecutionException
{
- String resourcePath = "META-INF/maven-faces-plugin/faces-config.xml";
- return getCompileDependencyResources(project, resourcePath);
+ if (localResource != null)
+ {
+ List urls = new ArrayList();
+ try {
+ urls.add(localResource.toURL());
+ } catch (MalformedURLException e) {
+ getLog().error("", e);
+ }
+ return urls;
+ }
+ else
+ {
+ String resourcePath = "META-INF/maven-faces-plugin/faces-config.xml";
+ return getCompileDependencyResources(project, resourcePath);
+ }
}
protected URL[] readIndex(
@@ -261,6 +274,7 @@
protected void processIndexEntry(
URL entry) throws MojoExecutionException
{
+ System.err.println("ProcessEntry " + entry.toString());
URL old = _facesConfig.setCurrentResource(entry);
try
{
@@ -614,6 +628,13 @@
* @parameter default-value = "true"
*/
private boolean skipApiOrBaseClasses;
+
+ /**
+ * @parameter
+ */
+ private File localResource;
+
+
private FacesConfigBean _facesConfig;
private String _licenseHeader;
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFaceletsTaglibsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFaceletsTaglibsMojo.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFaceletsTaglibsMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFaceletsTaglibsMojo.java Wed Dec 5 04:25:13 2007
@@ -109,7 +109,8 @@
targetFile.delete();
- if (components.hasNext() && configFile.exists())
+ if ((components.hasNext()||validators.hasNext()||converters.hasNext())
+ && configFile.exists())
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
@@ -123,19 +124,7 @@
stream.writeAttribute("href", configFile.toURL().toExternalForm());
stream.writeAttribute("xpointer", "/facelet-taglib/*");
stream.writeEndElement();
- while (components.hasNext())
- {
- ComponentBean component = (ComponentBean)components.next();
- _writeTag(stream, component);
- }
- while (validators.hasNext())
- {
- _writeValidatorTag(stream, (ValidatorBean) validators.next());
- }
- while (converters.hasNext())
- {
- _writeConverterTag(stream, (ConverterBean) converters.next());
- }
+ _writeTags(components, validators, converters, stream);
_writeEndTagLibrary(stream);
stream.close();
@@ -179,7 +168,7 @@
targetFile.setReadOnly();
}
- else if (components.hasNext())
+ else if (components.hasNext()||validators.hasNext()||converters.hasNext())
{
targetFile.getParentFile().mkdirs();
OutputStream out = new FileOutputStream(targetFile);
@@ -192,11 +181,7 @@
stream.writeCharacters(namespaceURI);
stream.writeEndElement();
- while (components.hasNext())
- {
- ComponentBean component = (ComponentBean)components.next();
- _writeTag(stream, component);
- }
+ _writeTags(components, validators, converters, stream);
_writeEndTagLibrary(stream);
stream.close();
}
@@ -234,6 +219,22 @@
catch (IOException e)
{
throw new MojoExecutionException("Error during generation", e);
+ }
+ }
+
+ private void _writeTags(Iterator components, Iterator validators, Iterator converters, XMLStreamWriter stream) throws XMLStreamException {
+ while (components.hasNext())
+ {
+ ComponentBean component = (ComponentBean)components.next();
+ _writeTag(stream, component);
+ }
+ while (validators.hasNext())
+ {
+ _writeValidatorTag(stream, (ValidatorBean) validators.next());
+ }
+ while (converters.hasNext())
+ {
+ _writeConverterTag(stream, (ConverterBean) converters.next());
}
}
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java Wed Dec 5 04:25:13 2007
@@ -20,13 +20,29 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.AbstractConverterTagGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.AbstractValidatorTagGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.ComponentTagGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.MyFacesComponentTagGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.MyFacesConverterTagGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.MyFacesValidatorTagGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.TagAttributeFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.TrinidadComponentTagGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.TrinidadConverterTagGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib.TrinidadValidatorTagGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.*;
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.*;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.MethodSignatureBean;
+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.ComponentFilter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.ConverterFilter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.ValidatorFilter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.XIncludeFilter;
import org.codehaus.plexus.util.FileUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -39,12 +55,28 @@
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.*;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
/**
* @version $Id$
@@ -685,14 +717,13 @@
/**
* Generates tag handlers for parsed component metadata.
*/
- private void _generateTagHandlers() throws IOException
- {
+ private void _generateTagHandlers() throws IOException, MojoExecutionException {
// Make sure generated source directory
// is added to compilation source path
project.addCompileSourceRoot(generatedSourceDirectory.getCanonicalPath());
FacesConfigBean facesConfig = getFacesConfig();
- if (!facesConfig.hasComponents())
+ if (!facesConfig.hasComponents() && !facesConfig.hasConverters() && !facesConfig.hasValidators())
{
getLog().info("Nothing to generate - no components found");
}
@@ -719,15 +750,22 @@
validators = new FilteredIterator(validators, new IfValidatorModifiedFilter());
}
- if (!components.hasNext() && !converters.hasNext())
+ if (!components.hasNext() && !converters.hasNext() && !validators.hasNext())
{
getLog().info("Nothing to generate - all JSP tags are up to date");
}
else
{
ComponentTagHandlerGenerator componentGen = new ComponentTagHandlerGenerator();
- ConverterTagGenerator converterGen = new ConverterTagGenerator();
- ValidatorTagGenerator validatorGen = new ValidatorTagGenerator();
+ AbstractConverterTagGenerator converterGen = null;
+ AbstractValidatorTagGenerator validatorGen = null;
+ if ("trinidad".equals(type)) {
+ converterGen = new TrinidadConverterTagGenerator(is12(), getLicenseHeader(), getLog());
+ validatorGen = new TrinidadValidatorTagGenerator(is12(), getLicenseHeader(), getLog());
+ } else {
+ converterGen = new MyFacesConverterTagGenerator(is12(), getLicenseHeader(), getLog());
+ validatorGen = new MyFacesValidatorTagGenerator(is12(), getLicenseHeader(), getLog());
+ }
int count = 0;
while (components.hasNext())
{
@@ -736,12 +774,12 @@
}
while (converters.hasNext())
{
- converterGen.generateTagHandler((ConverterBean)converters.next());
+ converterGen.generateTagHandler((ConverterBean)converters.next(), generatedSourceDirectory);
count++;
}
while (validators.hasNext())
{
- validatorGen.generateTagHandler((ValidatorBean)validators.next());
+ validatorGen.generateTagHandler((ValidatorBean)validators.next(), generatedSourceDirectory);
count++;
}
getLog().info("Generated " + count + " JSP tag(s)");
@@ -749,825 +787,6 @@
}
}
- class ConverterTagGenerator
- {
- public void generateTagHandler(
- ConverterBean converter)
- {
- String fullClassName = converter.getTagClass();
-
- try
- {
- getLog().debug("Generating " + fullClassName);
-
- String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
- File targetFile = new File(generatedSourceDirectory, sourcePath);
-
- targetFile.getParentFile().mkdirs();
- StringWriter sw = new StringWriter();
- PrettyWriter out = new PrettyWriter(sw);
-
- String className = Util.getClassFromFullClass(fullClassName);
- String packageName = Util.getPackageFromFullClass(fullClassName);
-
- // header/copyright
- writePreamble(out);
-
- // package
- out.println("package " + packageName + ";");
-
- out.println();
- _writeImports(out, converter);
-
- out.println("/**");
- // TODO: remove this blank line.
- out.println();
- out.println(" * Auto-generated tag class.");
- out.println(" */");
-
- if (_is12())
- {
- out.println("public class " + className +
- " extends ConverterELTag");
- }
- else
- {
- out.println("public class " + className +
- " extends ConverterTag");
- }
-
- out.println("{");
- out.indent();
-
- _writeConstructor(out, converter);
-
- _writePropertyMethods(out, converter);
- _writeDoStartTag(out, converter);
- _writeCreateConverter(out, converter);
- _writeSetProperties(out, converter);
- _writeRelease(out, converter);
-
- out.unindent();
- out.println("}");
- out.close();
-
- // delay write in case of error
- // timestamp should not be updated when an error occurs
- // delete target file first, because it is readonly
- 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 " + fullClassName, e);
- }
- }
-
- private void _writeImports(
- PrettyWriter out,
- 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());
-
- Iterator properties = converter.properties();
- properties = new FilteredIterator(properties, new TagAttributeFilter());
- if (properties.hasNext())
- {
- 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");
- }
-
- 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");
- }
- }
-
- // do not import implicit!
- imports.removeAll(Util.PRIMITIVE_TYPES);
-
- String tagClass = converter.getTagClass();
- String packageName = Util.getPackageFromFullClass(tagClass);
- writeImports(out, packageName, imports);
- }
-
- private void _writeConstructor(
- PrettyWriter out,
- ConverterBean converter) throws IOException
- {
- String fullClassName = converter.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("}");
- }
-
- private void _writePropertyMethods(
- PrettyWriter out,
- ConverterBean converter) throws IOException
- {
- Iterator properties = converter.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("}");
- }
-
- private 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 _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
- 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("}");
- }
- }
-
- 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("}");
- }
- }
-
- private 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 = _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 = _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("}");
- }
-
- private void _writeRelease(
- PrettyWriter out,
- ConverterBean converter) throws IOException
- {
- Iterator properties = converter.properties();
- properties = new FilteredIterator(properties, new TagAttributeFilter());
- if (properties.hasNext())
- {
- out.println();
- 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";
- }
- }
-
- class ValidatorTagGenerator
- {
- public void generateTagHandler(
- ValidatorBean validator)
- {
- String fullClassName = validator.getTagClass();
-
- try
- {
- getLog().debug("Generating " + fullClassName);
- String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
- File targetFile = new File(generatedSourceDirectory, sourcePath);
-
- targetFile.getParentFile().mkdirs();
- StringWriter sw = new StringWriter();
- PrettyWriter out = new PrettyWriter(sw);
-
- String className = Util.getClassFromFullClass(fullClassName);
- String packageName = Util.getPackageFromFullClass(fullClassName);
-
- // header/copyright
- writePreamble(out);
-
- // package
- out.println("package " + packageName + ";");
-
- out.println();
- _writeImports(out, validator);
-
- out.println("/**");
- // TODO: remove this blank line.
- out.println();
- out.println(" * Auto-generated tag class.");
- out.println(" */");
-
- if (_is12())
- {
- out.println("public class " + className +
- " extends ValidatorELTag");
- }
- else
- {
- out.println("public class " + className +
- " extends ValidatorTag");
- }
-
- out.println("{");
- out.indent();
-
- _writeConstructor(out, validator);
-
- _writePropertyMethods(out, validator);
- _writeDoStartTag(out, validator);
- _writeCreateValidator(out, validator);
- _writeSetProperties(out, validator);
- _writeRelease(out, validator);
-
- out.unindent();
- out.println("}");
- out.close();
-
- // delay write in case of error
- // timestamp should not be updated when an error occurs
- // delete target file first, because it is readonly
- 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 " + fullClassName, e);
- }
- }
-
- private void _writeImports(
- PrettyWriter out,
- 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());
-
- Iterator properties = validator.properties();
- properties = new FilteredIterator(properties, new TagAttributeFilter());
- if (properties.hasNext())
- {
- 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");
- }
-
- 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");
- }
- }
-
- // do not import implicit!
- imports.removeAll(Util.PRIMITIVE_TYPES);
-
- String tagClass = validator.getTagClass();
- String packageName = Util.getPackageFromFullClass(tagClass);
- writeImports(out, packageName, imports);
- }
-
- private void _writeConstructor(
- PrettyWriter out,
- ValidatorBean validator) throws IOException
- {
- String fullClassName = validator.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("}");
- }
-
- private void _writePropertyMethods(
- PrettyWriter out,
- ValidatorBean validator) throws IOException
- {
- Iterator properties = validator.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("}");
- }
-
- 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
- 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("}");
- }
- }
-
- private 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 = _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 = _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("}");
- }
-
- private void _writeRelease(
- PrettyWriter out,
- ValidatorBean validator) throws IOException
- {
- Iterator properties = validator.properties();
- properties = new FilteredIterator(properties, new TagAttributeFilter());
- if (properties.hasNext())
- {
- out.println();
- 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";
- }
- }
-
class ComponentTagHandlerGenerator
{
@@ -1624,7 +843,9 @@
{
generator = new MyFacesComponentTagGenerator(_is12());
}
-
+
+ getLog().debug("Generating " + fullClassName+", with generator: "+generator.getClass().getName());
+
String className = Util.getClassFromFullClass(fullClassName);
String packageName = Util.getPackageFromFullClass(fullClassName);
@@ -1816,35 +1037,12 @@
*/
private String jsfVersion;
- static private String _resolveType(
- String className)
- {
- return (String)_RESOLVABLE_TYPES.get(className);
- }
-
- // TODO: for everything but Locale, String[], Date, and TimeZone,
- // in JSF 1.2 we should already be going through coercion, and
- // not need any of the "TagUtils" functions
- static private Map _createResolvableTypes()
- {
- Map resolvableTypes = new HashMap();
-
- resolvableTypes.put("boolean", "Boolean");
- resolvableTypes.put("char", "Character");
- resolvableTypes.put("java.util.Date", "Date");
- resolvableTypes.put("int", "Integer");
- resolvableTypes.put("float", "Float");
- resolvableTypes.put("double", "Double");
- resolvableTypes.put("java.util.Locale", "Locale");
- resolvableTypes.put("long", "Long");
- resolvableTypes.put("java.lang.String", "String");
- resolvableTypes.put("java.lang.String[]", "StringArray");
- resolvableTypes.put("java.util.TimeZone", "TimeZone");
+ /**
+ * @parameter expression="trinidad"
+ */
+ private String type;
- return Collections.unmodifiableMap(resolvableTypes);
- }
- static final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
static final private String _JSP_TAG_LIBRARY_DOCTYPE_PUBLIC =
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateMasterFacesConfigMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateMasterFacesConfigMojo.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateMasterFacesConfigMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateMasterFacesConfigMojo.java Wed Dec 5 04:25:13 2007
@@ -130,10 +130,10 @@
private String[] excludes;
/**
- * @parameter
- * @readonly
+ * @parameter expression="META-INF/maven-faces-plugin";
+ * @required
*/
- private String sourcePath = "META-INF/maven-faces-plugin";
+ private String sourcePath;
/**
* @parameter expression="src/main/resources"
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ConverterBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ConverterBean.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ConverterBean.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ConverterBean.java Wed Dec 5 04:25:13 2007
@@ -18,26 +18,14 @@
*/
package org.apache.myfaces.trinidadbuild.plugin.faces.parse;
-import javax.xml.namespace.QName;
import java.lang.reflect.Modifier;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
import java.util.logging.Logger;
/**
* ConverterBean is a Java representation of the faces-config converter
* XML element.
*/
-public class ConverterBean extends ObjectBean
-{
- /**
- * Creates a new ConverterBean.
- */
- public ConverterBean()
- {
- _properties = new LinkedHashMap();
- }
+public class ConverterBean extends AbstractTagBean {
/**
* Sets the converter identifer for this component.
@@ -93,90 +81,6 @@
}
/**
- * 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;
- }
-
- /**
- * Sets the JSP tag name for this component.
- *
- * @param tagName the JSP tag name
- */
- public void setTagName(
- QName tagName)
- {
- _tagName = tagName;
- }
-
- /**
* Sets the converter super class for this component.
*
* @param converterSuperClass the converter super class
@@ -198,49 +102,6 @@
}
/**
- * 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();
- }
-
- /**
* Adds a Java Language class modifier to the converter class.
*
* @param modifier the modifier to be added
@@ -277,70 +138,12 @@
addConverterClassModifier(_parseModifier(modifier));
}
- public void parseTagClassModifier(
- String modifier)
- {
- addTagClassModifier(_parseModifier(modifier));
- }
- private 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;
- }
- private String _description;
- private String _longDescription;
private String _converterId;
private String _converterClass;
private String _converterSuperClass;
- private QName _tagName;
- private String _tagClass;
- private Map _properties;
private int _converterClassModifiers;
- private int _tagClassModifiers;
static private final Logger _LOG = Logger.getLogger(ConverterBean.class.getName());
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ValidatorBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ValidatorBean.java?rev=601314&r1=601313&r2=601314&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ValidatorBean.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ValidatorBean.java Wed Dec 5 04:25:13 2007
@@ -19,26 +19,13 @@
package org.apache.myfaces.trinidadbuild.plugin.faces.parse;
import java.lang.reflect.Modifier;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
import java.util.logging.Logger;
-import javax.xml.namespace.QName;
-
/**
* ValidatorBean is a Java representation of the faces-config validator
* XML element.
*/
-public class ValidatorBean extends ObjectBean
-{
- /**
- * Creates a new ValidatorBean.
- */
- public ValidatorBean()
- {
- _properties = new LinkedHashMap();
- }
+public class ValidatorBean extends AbstractTagBean {
/**
* Sets the validator identifer for this component.
@@ -94,90 +81,6 @@
}
/**
- * 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;
- }
-
- /**
- * Sets the JSP tag name for this component.
- *
- * @param tagClass the JSP tag name
- */
- public void setTagName(
- QName tagName)
- {
- _tagName = tagName;
- }
-
- /**
* Sets the validator super class for this component.
*
* @param validatorSuperClass the validator super class
@@ -199,49 +102,6 @@
}
/**
- * 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();
- }
-
- /**
* Adds a Java Language class modifier to the validator class.
*
* @param modifier the modifier to be added
@@ -278,70 +138,10 @@
addValidatorClassModifier(_parseModifier(modifier));
}
- public void parseTagClassModifier(
- String modifier)
- {
- addTagClassModifier(_parseModifier(modifier));
- }
-
- private 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;
- }
-
- private String _description;
- private String _longDescription;
private String _validatorId;
private String _validatorClass;
private String _validatorSuperClass;
- private QName _tagName;
- private String _tagClass;
- private Map _properties;
private int _validatorClassModifiers;
- private int _tagClassModifiers;
static private final Logger _LOG = Logger.getLogger(ValidatorBean.class.getName());