Fix windows new-line endings
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
index 6b4788f..e54265a 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractConverterTagGenerator.java
@@ -1,193 +1,193 @@
-/*
- * 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());
-
- 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();");
- }
- if (properties.hasNext())
- {
- 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();
- }
-}
+/*
+ * 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());
+
+ 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();");
+ }
+ if (properties.hasNext())
+ {
+ 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();
+ }
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
index eb6ec9b..ada75f2 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
@@ -1,266 +1,266 @@
-/*
- * 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;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-
-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");
- }
- }
- }
-
- protected String resolveDateType(String className, boolean useMaxTime)
- {
- String type = (String)_RESOLVABLE_TYPES.get(className);
- return useMaxTime ? type + "WithMaxTime" : type;
- }
-
- protected 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
- 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");
-
- return Collections.unmodifiableMap(resolvableTypes);
- }
-
- final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
-
-}
+/*
+ * 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;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+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");
+ }
+ }
+ }
+
+ protected String resolveDateType(String className, boolean useMaxTime)
+ {
+ String type = (String)_RESOLVABLE_TYPES.get(className);
+ return useMaxTime ? type + "WithMaxTime" : type;
+ }
+
+ protected 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
+ 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");
+
+ return Collections.unmodifiableMap(resolvableTypes);
+ }
+
+ final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
+
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
index d99de41..bcf7197 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractValidatorTagGenerator.java
@@ -1,195 +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);
-
-}
+/*
+ * 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);
+
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
index b4c1ff3..0462ed8 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesConverterTagGenerator.java
@@ -1,167 +1,167 @@
-/*
- * 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.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 = 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("}");
- }
-
-}
+/*
+ * 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.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 = 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("}");
+ }
+
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
index 7dd4ed6..6564f8a 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesValidatorTagGenerator.java
@@ -1,161 +1,161 @@
-/*
- * 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 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 = 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("}");
- }
-}
+/*
+ * 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 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 = 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("}");
+ }
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
index dfbc8b2..884b5a9 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
@@ -1,167 +1,167 @@
-/*
- * 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.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 = 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("}");
- }
-
-}
+/*
+ * 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.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 = 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("}");
+ }
+
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
index dd30e0e..04c0d91 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
@@ -1,177 +1,177 @@
-/*
- * 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.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 = null;
- if ("Date".equals (propClass))
- {
- propType = resolveDateType(propFullClass, property.getUseMaxTime());
- }
- else
- {
- 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 = null;
- if ("Date".equals (propClass))
- {
- propType = resolveDateType(propFullClass, property.getUseMaxTime());
- }
- else
- {
- 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("}");
- }
-}
+/*
+ * 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.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 = null;
+ if ("Date".equals (propClass))
+ {
+ propType = resolveDateType(propFullClass, property.getUseMaxTime());
+ }
+ else
+ {
+ 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 = null;
+ if ("Date".equals (propClass))
+ {
+ propType = resolveDateType(propFullClass, property.getUseMaxTime());
+ }
+ else
+ {
+ 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("}");
+ }
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
index 7ea99f9..d9cecdc 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
@@ -1,300 +1,300 @@
-/*
- * 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.util.LinkedHashMap;
-import java.lang.reflect.Modifier;
-
-public class AbstractTagBean extends ObjectBean {
- private String _description;
- private String _longDescription;
- private QName _tagName;
- private String _tagClass;
- protected Map _properties;
- private int _tagClassModifiers;
- private Map _examples;
- private int _exampleIdx = 0;
-
- public AbstractTagBean()
- {
- this(false);
- }
-
- public AbstractTagBean(boolean isComponentBean)
- {
- // Component Bean does its own thing
- // with properties. The other bean
- // types, i.e. Converters and Validators
- // use the same properties.
- if (!isComponentBean)
- {
- _properties = new LinkedHashMap();
- }
- _examples = new LinkedHashMap();
- }
-
- /**
- * 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;
- }
-
- /**
- * Sets the JSP tag name for this component.
- *
- * @param tagName the JSP tag name
- */
- public void setTagName(
- QName tagName)
- {
- _tagName = tagName;
- }
-
-
- /**
- * 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();
- }
-
- /**
- * Adds a Example to this component.
- *
- * @param example the example to add
- */
- public void addExample(
- ExampleBean example)
- {
- String key = _generateExampleKey();
- example.setKey(key);
- _examples.put(key, example);
- }
-
- /**
- * Returns true if this component has any examples.
- *
- * @return true if this component has any examples,
- * false otherwise
- */
- public boolean hasExamples()
- {
- return !_examples.isEmpty();
- }
-
- /**
- * Returns the example for this example key.
- *
- * @param key the hashmap example key
- */
- public ExampleBean findExample(
- String key)
- {
- return (ExampleBean)_examples.get(key);
- }
-
- /**
- * Returns an iterator for all examples on this component only.
- *
- * @return the example iterator
- */
- public Iterator examples()
- {
- return _examples.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;
- }
-
- /**
- * Number of properties for this component
- * @return num of properties
- */
- public int propertiesSize()
- {
- return _properties.size();
- }
-
- /* Get a generated key to use in storing
- * this example bean in its hashmap.
- */
- private String _generateExampleKey()
- {
- String key = "Example" + Integer.toString(_exampleIdx);
- _exampleIdx++;
- return key;
- }
-}
+/*
+ * 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.util.LinkedHashMap;
+import java.lang.reflect.Modifier;
+
+public class AbstractTagBean extends ObjectBean {
+ private String _description;
+ private String _longDescription;
+ private QName _tagName;
+ private String _tagClass;
+ protected Map _properties;
+ private int _tagClassModifiers;
+ private Map _examples;
+ private int _exampleIdx = 0;
+
+ public AbstractTagBean()
+ {
+ this(false);
+ }
+
+ public AbstractTagBean(boolean isComponentBean)
+ {
+ // Component Bean does its own thing
+ // with properties. The other bean
+ // types, i.e. Converters and Validators
+ // use the same properties.
+ if (!isComponentBean)
+ {
+ _properties = new LinkedHashMap();
+ }
+ _examples = new LinkedHashMap();
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Sets the JSP tag name for this component.
+ *
+ * @param tagName the JSP tag name
+ */
+ public void setTagName(
+ QName tagName)
+ {
+ _tagName = tagName;
+ }
+
+
+ /**
+ * 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();
+ }
+
+ /**
+ * Adds a Example to this component.
+ *
+ * @param example the example to add
+ */
+ public void addExample(
+ ExampleBean example)
+ {
+ String key = _generateExampleKey();
+ example.setKey(key);
+ _examples.put(key, example);
+ }
+
+ /**
+ * Returns true if this component has any examples.
+ *
+ * @return true if this component has any examples,
+ * false otherwise
+ */
+ public boolean hasExamples()
+ {
+ return !_examples.isEmpty();
+ }
+
+ /**
+ * Returns the example for this example key.
+ *
+ * @param key the hashmap example key
+ */
+ public ExampleBean findExample(
+ String key)
+ {
+ return (ExampleBean)_examples.get(key);
+ }
+
+ /**
+ * Returns an iterator for all examples on this component only.
+ *
+ * @return the example iterator
+ */
+ public Iterator examples()
+ {
+ return _examples.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;
+ }
+
+ /**
+ * Number of properties for this component
+ * @return num of properties
+ */
+ public int propertiesSize()
+ {
+ return _properties.size();
+ }
+
+ /* Get a generated key to use in storing
+ * this example bean in its hashmap.
+ */
+ private String _generateExampleKey()
+ {
+ String key = "Example" + Integer.toString(_exampleIdx);
+ _exampleIdx++;
+ return key;
+ }
+}
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
index 27906e5..6bcf13b 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
@@ -1,91 +1,91 @@
-/*
- * 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;
-
-/**
- * ExampleBean is a Java representation of the faces-config component or
- * renderer Example XML element.
- */
-public class ExampleBean extends ObjectBean
-{
- /**
- * Get source Example Description Text
- *
- * @return source Example Description Text
- */
- public String getSourceDescription()
- {
- return _sourceDescription;
- }
-
- /**
- * Set source example Description Text.
- *
- * @param sourceDescription source example Description Text.
- */
- public void setSourceDescription( String sourceDescription )
- {
- _sourceDescription = sourceDescription;
- }
-
- /**
- * Returns source Example.
- *
- * @return source Example
- */
- public String getSourceCode()
- {
- return _source;
- }
-
- /**
- * Set source example.
- *
- * @param source source example to be added to the list.
- */
- public void setSourceCode( String source )
- {
- _source = source;
- }
-
- /**
- * Returns Example hashmap key.
- *
- * @return Example hashmap key
- */
- public String getKey()
- {
- return _key;
- }
-
- /**
- * Set source example.
- *
- * @param key Set key for this example put in
- * ComponentBean _examples hashmap.
- */
- protected void setKey( String key )
- {
- _key = key;
- }
-
- private String _sourceDescription = null;
- private String _source = null;
- private String _key = null;
-}
+/*
+ * 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;
+
+/**
+ * ExampleBean is a Java representation of the faces-config component or
+ * renderer Example XML element.
+ */
+public class ExampleBean extends ObjectBean
+{
+ /**
+ * Get source Example Description Text
+ *
+ * @return source Example Description Text
+ */
+ public String getSourceDescription()
+ {
+ return _sourceDescription;
+ }
+
+ /**
+ * Set source example Description Text.
+ *
+ * @param sourceDescription source example Description Text.
+ */
+ public void setSourceDescription( String sourceDescription )
+ {
+ _sourceDescription = sourceDescription;
+ }
+
+ /**
+ * Returns source Example.
+ *
+ * @return source Example
+ */
+ public String getSourceCode()
+ {
+ return _source;
+ }
+
+ /**
+ * Set source example.
+ *
+ * @param source source example to be added to the list.
+ */
+ public void setSourceCode( String source )
+ {
+ _source = source;
+ }
+
+ /**
+ * Returns Example hashmap key.
+ *
+ * @return Example hashmap key
+ */
+ public String getKey()
+ {
+ return _key;
+ }
+
+ /**
+ * Set source example.
+ *
+ * @param key Set key for this example put in
+ * ComponentBean _examples hashmap.
+ */
+ protected void setKey( String key )
+ {
+ _key = key;
+ }
+
+ private String _sourceDescription = null;
+ private String _source = null;
+ private String _key = null;
+}
diff --git a/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java b/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java
index abf731b..254c059 100644
--- a/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java
+++ b/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java
@@ -1,162 +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.i18n.uixtools;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Resolves locale specific elements like the names for month or date formats.
- * With Java 6 the needed resources are not stored anymore in reousrce files
- * but are hardcoded and can be accessed thru sun.util.resources.LocaleData.
- * <br>
- * This class uses reflection to access the resources to be compatible with
- * Java 1.4, 5 and 6.
- */
-class LocaleDataResolver {
-
- private static final String LOCAL_ELEMENTS_RESOURCE_BUNDLE_JAVA_5 = "sun.text.resources.LocaleElements";
-
- private static final String LOCAL_DATA_CLASS_JAVA_4 = "sun.text.resources.LocaleData";
-
- private static final String LOCAL_DATA_CLASS_JAVA_6 = "sun.util.resources.LocaleData";
-
- private static final String[] LOCAL_DATA_METHODS_JAVA_6 = new String[] {
- "getCalendarData", "getCollationData", "getCurrencyNames",
- "getDateFormatData", "getLocaleNames", "getNumberFormatData",
- "getTimeZoneNames" };
-
- private static final String DATE_TIME_ELEMENTS = "DateTimeElements";
-
- private static final String MINIMAL_DAYS_IN_FIRST_WEEK = "minimalDaysInFirstWeek";
-
- private static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek";
-
- /**
- * Returns the element data for the given key and locale.
- *
- * @param key the key for the element
- * @param locale the locale to be used
- * @return the locale dependent element
- */
- public static Object getElementData(String key, Locale locale) {
- try {
- Class.forName(LOCAL_DATA_CLASS_JAVA_4);
- return _getElementDataJava5(key, locale);
- } catch (ClassNotFoundException e) {
- try {
- Class.forName(LOCAL_DATA_CLASS_JAVA_6);
- return _getElementDataJava6(key, locale);
- } catch (ClassNotFoundException e1) {
- throw new IllegalStateException(
- "could not access the java resource bundles");
- }
- }
- }
-
- /**
- * Returns the element data for the given key and locale using
- * the java 1.4/5 mechanism to access the resources.
- *
- * @param key the key for the element
- * @param locale the locale to be used
- * @return the locale dependent element
- */
- private static Object _getElementDataJava5(String key, Locale locale) {
- ResourceBundle elementsData = ResourceBundle.getBundle(
- LOCAL_ELEMENTS_RESOURCE_BUNDLE_JAVA_5, locale);
- return elementsData.getObject(key);
- }
-
- /**
- * Returns the element data for the given key and locale using
- * the java 6 mechanism to access the resources.
- *
- * @param key the key for the element
- * @param locale the locale to be used
- * @return the locale dependent element
- */
- private static Object _getElementDataJava6(String key, Locale locale) {
-
- if (DATE_TIME_ELEMENTS.equals(key)) {
- return new Object[] {
- _getElementDataJava6(FIRST_DAY_OF_WEEK, locale),
- _getElementDataJava6(MINIMAL_DAYS_IN_FIRST_WEEK, locale) };
- } else {
- for (int i = 0; i < LOCAL_DATA_METHODS_JAVA_6.length; i++) {
- ResourceBundle bundle = _getLocaleDataResourceBundleJava6(
- LOCAL_DATA_METHODS_JAVA_6[i], locale);
- if (_containsKey(bundle, key)) {
- return bundle.getObject(key);
- }
- }
- }
-
- throw new MissingResourceException(
- "no element found in the java resource bundles for the given key",
- null, key);
- }
-
- /**
- * @param bundle
- * @param key
- * @return true if the given key exists in the given bundle
- */
- private static boolean _containsKey(ResourceBundle bundle, String key) {
- for (Enumeration e = bundle.getKeys(); e.hasMoreElements();) {
- if (((String) e.nextElement()).equals(key))
- return true;
- }
- return false;
- }
-
- /**
- * Gives access to the java 6 implementation using reflection.
- *
- * @param name
- * @param locale
- * @return the resource bundle for the given method name and locale
- */
- private static ResourceBundle _getLocaleDataResourceBundleJava6(
- String name, Locale locale) {
- try {
- Class localDataClass = Class.forName(LOCAL_DATA_CLASS_JAVA_6);
- Method method = localDataClass.getMethod(name,
- new Class[] { Locale.class });
- Object bundle = method.invoke(null, new Object[] { locale });
- return (ResourceBundle) bundle;
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException();
- } catch (SecurityException e) {
- throw new IllegalStateException();
- } catch (NoSuchMethodException e) {
- throw new IllegalStateException();
- } catch (IllegalArgumentException e) {
- throw new IllegalStateException();
- } catch (IllegalAccessException e) {
- throw new IllegalStateException();
- } catch (InvocationTargetException e) {
- throw new IllegalStateException();
- }
- }
+/*
+ * 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.i18n.uixtools;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Resolves locale specific elements like the names for month or date formats.
+ * With Java 6 the needed resources are not stored anymore in reousrce files
+ * but are hardcoded and can be accessed thru sun.util.resources.LocaleData.
+ * <br>
+ * This class uses reflection to access the resources to be compatible with
+ * Java 1.4, 5 and 6.
+ */
+class LocaleDataResolver {
+
+ private static final String LOCAL_ELEMENTS_RESOURCE_BUNDLE_JAVA_5 = "sun.text.resources.LocaleElements";
+
+ private static final String LOCAL_DATA_CLASS_JAVA_4 = "sun.text.resources.LocaleData";
+
+ private static final String LOCAL_DATA_CLASS_JAVA_6 = "sun.util.resources.LocaleData";
+
+ private static final String[] LOCAL_DATA_METHODS_JAVA_6 = new String[] {
+ "getCalendarData", "getCollationData", "getCurrencyNames",
+ "getDateFormatData", "getLocaleNames", "getNumberFormatData",
+ "getTimeZoneNames" };
+
+ private static final String DATE_TIME_ELEMENTS = "DateTimeElements";
+
+ private static final String MINIMAL_DAYS_IN_FIRST_WEEK = "minimalDaysInFirstWeek";
+
+ private static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek";
+
+ /**
+ * Returns the element data for the given key and locale.
+ *
+ * @param key the key for the element
+ * @param locale the locale to be used
+ * @return the locale dependent element
+ */
+ public static Object getElementData(String key, Locale locale) {
+ try {
+ Class.forName(LOCAL_DATA_CLASS_JAVA_4);
+ return _getElementDataJava5(key, locale);
+ } catch (ClassNotFoundException e) {
+ try {
+ Class.forName(LOCAL_DATA_CLASS_JAVA_6);
+ return _getElementDataJava6(key, locale);
+ } catch (ClassNotFoundException e1) {
+ throw new IllegalStateException(
+ "could not access the java resource bundles");
+ }
+ }
+ }
+
+ /**
+ * Returns the element data for the given key and locale using
+ * the java 1.4/5 mechanism to access the resources.
+ *
+ * @param key the key for the element
+ * @param locale the locale to be used
+ * @return the locale dependent element
+ */
+ private static Object _getElementDataJava5(String key, Locale locale) {
+ ResourceBundle elementsData = ResourceBundle.getBundle(
+ LOCAL_ELEMENTS_RESOURCE_BUNDLE_JAVA_5, locale);
+ return elementsData.getObject(key);
+ }
+
+ /**
+ * Returns the element data for the given key and locale using
+ * the java 6 mechanism to access the resources.
+ *
+ * @param key the key for the element
+ * @param locale the locale to be used
+ * @return the locale dependent element
+ */
+ private static Object _getElementDataJava6(String key, Locale locale) {
+
+ if (DATE_TIME_ELEMENTS.equals(key)) {
+ return new Object[] {
+ _getElementDataJava6(FIRST_DAY_OF_WEEK, locale),
+ _getElementDataJava6(MINIMAL_DAYS_IN_FIRST_WEEK, locale) };
+ } else {
+ for (int i = 0; i < LOCAL_DATA_METHODS_JAVA_6.length; i++) {
+ ResourceBundle bundle = _getLocaleDataResourceBundleJava6(
+ LOCAL_DATA_METHODS_JAVA_6[i], locale);
+ if (_containsKey(bundle, key)) {
+ return bundle.getObject(key);
+ }
+ }
+ }
+
+ throw new MissingResourceException(
+ "no element found in the java resource bundles for the given key",
+ null, key);
+ }
+
+ /**
+ * @param bundle
+ * @param key
+ * @return true if the given key exists in the given bundle
+ */
+ private static boolean _containsKey(ResourceBundle bundle, String key) {
+ for (Enumeration e = bundle.getKeys(); e.hasMoreElements();) {
+ if (((String) e.nextElement()).equals(key))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Gives access to the java 6 implementation using reflection.
+ *
+ * @param name
+ * @param locale
+ * @return the resource bundle for the given method name and locale
+ */
+ private static ResourceBundle _getLocaleDataResourceBundleJava6(
+ String name, Locale locale) {
+ try {
+ Class localDataClass = Class.forName(LOCAL_DATA_CLASS_JAVA_6);
+ Method method = localDataClass.getMethod(name,
+ new Class[] { Locale.class });
+ Object bundle = method.invoke(null, new Object[] { locale });
+ return (ResourceBundle) bundle;
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException();
+ } catch (SecurityException e) {
+ throw new IllegalStateException();
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException();
+ } catch (IllegalArgumentException e) {
+ throw new IllegalStateException();
+ } catch (IllegalAccessException e) {
+ throw new IllegalStateException();
+ } catch (InvocationTargetException e) {
+ throw new IllegalStateException();
+ }
+ }
}
\ No newline at end of file
diff --git a/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java b/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
index afa1a71..796d342 100644
--- a/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
+++ b/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
@@ -1,233 +1,233 @@
-/*
- * 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.jdeveloper;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-
-import org.w3c.dom.Node;
-
-import org.w3c.dom.NodeList;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class TldContentHandler
-{
- /**
- * Content Handler.
- */
- public TldContentHandler()
- {
- }
-
- /**
- * Parse the .tld file to get the information
- * needed for the .jpr
- */
- public void parseTld(File file)
- throws SAXException,
- IOException,
- ParserConfigurationException
- {
- // Create a builder factory
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
-
- // Create the Builder and parse the file
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
-
- // Set Entity Resolver to resolve external entities, i.e.
- // the "http://...." in the <!DOCTYPE tag
- EntityResolver entityResolver = new PluginEntityResolver();
- docBuilder.setEntityResolver(entityResolver);
- Document document = docBuilder.parse(file);
-
- _processTldNodes(document);
- }
-
- /*=========================================================================
- * Gettors and settors
- * ======================================================================*/
-
- public void setVersion(String version)
- {
- _version = version;
- }
-
- public void setName(String name)
- {
- _name = name;
- }
-
- public void setPrefix(String prefix)
- {
- _prefix = prefix;
- }
-
- public void setURI(String uri)
- {
- _uri = uri;
- }
-
- public void setJspVersion(String jspVersion)
- {
- _jspVersion = jspVersion;
- }
-
- public String getVersion()
- {
- return _version == null? "" : _version;
- }
-
- public String getName()
- {
- return _name == null? "" : _name;
- }
-
- public String getPrefix()
- {
- return _prefix == null? "" : _prefix;
- }
-
- public String getURI()
- {
- return _uri == null? "" : _uri;
- }
-
- public String getJspVersion()
- {
- return _jspVersion == null? "" : _jspVersion;
- }
-
-
- /**
- * Find all the TLD nodes we want, get each node's value
- * and set the value on the proper class property.
- *
- * @param document - DOM Document from the TLD file
- */
- private void _processTldNodes(Document document)
- {
- Node node = null;
-
- // Get the Nodes first node. We can be specific here
- // because we know we want the first node.
- NodeList nodeList = document.getElementsByTagName(_TLIB_VERSION);
- if (nodeList != null && nodeList.getLength() != 0)
- {
- node = nodeList.item(0);
- setVersion(node.getFirstChild().getNodeValue());
- }
-
- nodeList = document.getElementsByTagName(_JSP_VERSION);
- if (nodeList != null && nodeList.getLength() != 0)
- {
- node = nodeList.item(0);
- setJspVersion(node.getFirstChild().getNodeValue());
- }
-
- // Must go before _DISPLAY_NAME
- nodeList = document.getElementsByTagName(_SHORT_NAME);
- if (nodeList != null && nodeList.getLength() != 0)
- {
- node = nodeList.item(0);
- setPrefix(node.getFirstChild().getNodeValue());
- }
-
- // Must go after _SHORT_NAME
- nodeList = document.getElementsByTagName(_DISPLAY_NAME);
- if (nodeList != null && nodeList.getLength() != 0)
- {
- node = nodeList.item(0);
- setName(node.getFirstChild().getNodeValue());
- }
- else
- {
- setName(getPrefix());
- }
-
- nodeList = document.getElementsByTagName(_URI);
- if (nodeList != null && nodeList.getLength() != 0)
- {
- node = nodeList.item(0);
- setURI(node.getFirstChild().getNodeValue());
- }
- }
-
- //========================================================================
- // Private variables
- //========================================================================
-
- private String _version = null; // tlib-version
- private String _name = null; // display-name
- private String _prefix = null; // short-name
- private String _jspVersion = null; // jsp-version
- private String _uri = null; // uri
-
- private final static String _TLIB_VERSION = "tlib-version"; //version NOTRANS
- private final static String _DISPLAY_NAME = "display-name"; //name NOTRANS
- private final static String _SHORT_NAME = "short-name"; //prefix NOTRANS
- private final static String _JSP_VERSION = "jsp-version"; //NOTRANS
- private final static String _URI = "uri";
-
-
- /**
- * Gary Kind 01/22/2008. This class is used solely to get around a
- * java.net.NoRouteToHostException that occurs in the tag libs
- * <!DOCTYPE... tag, which is:
- *
- * <!DOCTYPE taglib
- * PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
- * "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
- *
- * The http URL causes this exception for some unknown reason. I have
- * searched high and low on the web for a real solution and finally found
- * this workaround at
- * http://forum.java.sun.com/thread.jspa?threadID=284209&forumID=34
- * Apparently a LOT of developers are seeing similar problems and they too
- * are not able to find a solution. This workaround works perfectly and all
- * is well.
- */
- private class PluginEntityResolver
- implements EntityResolver
- {
- public InputSource resolveEntity(String publicId, String systemId)
- {
- if ("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN".equals(publicId))
- {
- String xmlStr = "<?xml version='1.0' encoding='UTF-8'?>";
- byte[] buf = xmlStr.getBytes();
- ByteArrayInputStream bais = new ByteArrayInputStream(buf);
- return new InputSource(bais);
- }
- else
- return null;
- }
- }
-
-} // endclass TldContentHandler
+/*
+ * 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.jdeveloper;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+
+import org.w3c.dom.Node;
+
+import org.w3c.dom.NodeList;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class TldContentHandler
+{
+ /**
+ * Content Handler.
+ */
+ public TldContentHandler()
+ {
+ }
+
+ /**
+ * Parse the .tld file to get the information
+ * needed for the .jpr
+ */
+ public void parseTld(File file)
+ throws SAXException,
+ IOException,
+ ParserConfigurationException
+ {
+ // Create a builder factory
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+
+ // Create the Builder and parse the file
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+
+ // Set Entity Resolver to resolve external entities, i.e.
+ // the "http://...." in the <!DOCTYPE tag
+ EntityResolver entityResolver = new PluginEntityResolver();
+ docBuilder.setEntityResolver(entityResolver);
+ Document document = docBuilder.parse(file);
+
+ _processTldNodes(document);
+ }
+
+ /*=========================================================================
+ * Gettors and settors
+ * ======================================================================*/
+
+ public void setVersion(String version)
+ {
+ _version = version;
+ }
+
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public void setPrefix(String prefix)
+ {
+ _prefix = prefix;
+ }
+
+ public void setURI(String uri)
+ {
+ _uri = uri;
+ }
+
+ public void setJspVersion(String jspVersion)
+ {
+ _jspVersion = jspVersion;
+ }
+
+ public String getVersion()
+ {
+ return _version == null? "" : _version;
+ }
+
+ public String getName()
+ {
+ return _name == null? "" : _name;
+ }
+
+ public String getPrefix()
+ {
+ return _prefix == null? "" : _prefix;
+ }
+
+ public String getURI()
+ {
+ return _uri == null? "" : _uri;
+ }
+
+ public String getJspVersion()
+ {
+ return _jspVersion == null? "" : _jspVersion;
+ }
+
+
+ /**
+ * Find all the TLD nodes we want, get each node's value
+ * and set the value on the proper class property.
+ *
+ * @param document - DOM Document from the TLD file
+ */
+ private void _processTldNodes(Document document)
+ {
+ Node node = null;
+
+ // Get the Nodes first node. We can be specific here
+ // because we know we want the first node.
+ NodeList nodeList = document.getElementsByTagName(_TLIB_VERSION);
+ if (nodeList != null && nodeList.getLength() != 0)
+ {
+ node = nodeList.item(0);
+ setVersion(node.getFirstChild().getNodeValue());
+ }
+
+ nodeList = document.getElementsByTagName(_JSP_VERSION);
+ if (nodeList != null && nodeList.getLength() != 0)
+ {
+ node = nodeList.item(0);
+ setJspVersion(node.getFirstChild().getNodeValue());
+ }
+
+ // Must go before _DISPLAY_NAME
+ nodeList = document.getElementsByTagName(_SHORT_NAME);
+ if (nodeList != null && nodeList.getLength() != 0)
+ {
+ node = nodeList.item(0);
+ setPrefix(node.getFirstChild().getNodeValue());
+ }
+
+ // Must go after _SHORT_NAME
+ nodeList = document.getElementsByTagName(_DISPLAY_NAME);
+ if (nodeList != null && nodeList.getLength() != 0)
+ {
+ node = nodeList.item(0);
+ setName(node.getFirstChild().getNodeValue());
+ }
+ else
+ {
+ setName(getPrefix());
+ }
+
+ nodeList = document.getElementsByTagName(_URI);
+ if (nodeList != null && nodeList.getLength() != 0)
+ {
+ node = nodeList.item(0);
+ setURI(node.getFirstChild().getNodeValue());
+ }
+ }
+
+ //========================================================================
+ // Private variables
+ //========================================================================
+
+ private String _version = null; // tlib-version
+ private String _name = null; // display-name
+ private String _prefix = null; // short-name
+ private String _jspVersion = null; // jsp-version
+ private String _uri = null; // uri
+
+ private final static String _TLIB_VERSION = "tlib-version"; //version NOTRANS
+ private final static String _DISPLAY_NAME = "display-name"; //name NOTRANS
+ private final static String _SHORT_NAME = "short-name"; //prefix NOTRANS
+ private final static String _JSP_VERSION = "jsp-version"; //NOTRANS
+ private final static String _URI = "uri";
+
+
+ /**
+ * Gary Kind 01/22/2008. This class is used solely to get around a
+ * java.net.NoRouteToHostException that occurs in the tag libs
+ * <!DOCTYPE... tag, which is:
+ *
+ * <!DOCTYPE taglib
+ * PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
+ * "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
+ *
+ * The http URL causes this exception for some unknown reason. I have
+ * searched high and low on the web for a real solution and finally found
+ * this workaround at
+ * http://forum.java.sun.com/thread.jspa?threadID=284209&forumID=34
+ * Apparently a LOT of developers are seeing similar problems and they too
+ * are not able to find a solution. This workaround works perfectly and all
+ * is well.
+ */
+ private class PluginEntityResolver
+ implements EntityResolver
+ {
+ public InputSource resolveEntity(String publicId, String systemId)
+ {
+ if ("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN".equals(publicId))
+ {
+ String xmlStr = "<?xml version='1.0' encoding='UTF-8'?>";
+ byte[] buf = xmlStr.getBytes();
+ ByteArrayInputStream bais = new ByteArrayInputStream(buf);
+ return new InputSource(bais);
+ }
+ else
+ return null;
+ }
+ }
+
+} // endclass TldContentHandler