You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2009/07/10 20:21:41 UTC
svn commit: r793065 [2/2] - in /myfaces/trinidad-maven/trunk:
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/
maven-faces-p...
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java?rev=793065&r1=793064&r2=793065&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java Fri Jul 10 18:21:41 2009
@@ -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("}");
+ }
+}
Propchange: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadValidatorTagGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java?rev=793065&r1=793064&r2=793065&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java Fri Jul 10 18:21:41 2009
@@ -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;
+ }
+}
Propchange: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java?rev=793065&r1=793064&r2=793065&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java Fri Jul 10 18:21:41 2009
@@ -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;
+}
Propchange: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad-maven/trunk/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java?rev=793065&r1=793064&r2=793065&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java (original)
+++ myfaces/trinidad-maven/trunk/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java Fri Jul 10 18:21:41 2009
@@ -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
Propchange: myfaces/trinidad-maven/trunk/maven-i18n-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/i18n/uixtools/LocaleDataResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java?rev=793065&r1=793064&r2=793065&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java (original)
+++ myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java Fri Jul 10 18:21:41 2009
@@ -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
Propchange: myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
------------------------------------------------------------------------------
svn:eol-style = native