You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/04/24 07:32:15 UTC
svn commit: r651158 - in
/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder:
model/ qdox/
Author: lu4242
Date: Wed Apr 23 22:31:56 2008
New Revision: 651158
URL: http://svn.apache.org/viewvc?rev=651158&view=rev
Log:
add AttributeMeta.java and TagMeta.java, for allow inclusion of tag info on model
Added:
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java (with props)
Modified:
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/PropertyMeta.java
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java
Added: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java?rev=651158&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java Wed Apr 23 22:31:56 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.buildtools.maven2.plugin.builder.model;
+
+import java.util.Iterator;
+
+/**
+ * Interface for any artifact that has JSP attributes on it.
+ */
+public interface AttributeHolder
+{
+
+ Iterator attributes();
+
+ AttributeMeta getAttribute(String name);
+
+ void addAttribute(AttributeMeta prop);
+}
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeHolder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java?rev=651158&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java Wed Apr 23 22:31:56 2008
@@ -0,0 +1,174 @@
+/*
+ * 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.buildtools.maven2.plugin.builder.model;
+
+import org.apache.commons.digester.Digester;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.io.XmlWriter;
+
+/**
+ * Store metadata about a attribute of a jsp tag.
+ * <p>
+ * This metadata defines the attributes of JSP tags, among other things.
+ *
+ * Since this is a different concept from PropertyMeta, is is left as
+ * another class (Maybe PropertyMeta must AttributeMeta but I'm not sure, since
+ * there are different concepts (a property is for jsf, an attribute is for jsp)).
+ */
+public class AttributeMeta
+{
+ private String _name;
+ private String _className;
+ private Boolean _required;
+ private String _description;
+ private String _longDescription;
+ private Boolean _rtexprvalue;
+
+
+ public AttributeMeta()
+ {
+
+ }
+
+ /**
+ * Write this model out as xml.
+ */
+ public static void writeXml(XmlWriter out, AttributeMeta am)
+ {
+ out.beginElement("attribute");
+ out.writeElement("name", am._name);
+ out.writeElement("className", am._className);
+ out.writeElement("required", am._required);
+ out.writeElement("rtexprvalue", am._rtexprvalue);
+ out.writeElement("desc", am._description);
+ out.writeElement("longDesc", am._longDescription);
+ out.endElement("attribute");
+ }
+
+ /**
+ * Add digester rules to repopulate a Model instance from an xml file.
+ */
+ public static void addXmlRules(Digester digester, String prefix)
+ {
+ String newPrefix = prefix + "/attribute";
+
+ digester.addObjectCreate(newPrefix, AttributeMeta.class);
+ digester.addSetNext(newPrefix, "addAttribute");
+
+ digester.addBeanPropertySetter(newPrefix + "/name");
+ digester.addBeanPropertySetter(newPrefix + "/className");
+ digester.addBeanPropertySetter(newPrefix + "/required");
+ digester.addBeanPropertySetter(newPrefix + "/rtexprvalue");
+ digester.addBeanPropertySetter(newPrefix + "/desc", "description");
+ digester.addBeanPropertySetter(newPrefix + "/longDesc",
+ "longDescription");
+
+ }
+
+ /**
+ * Merge the data in the specified other property into this one, throwing an
+ * exception if there is an incompatibility.
+ */
+ public void merge(AttributeMeta other)
+ {
+ // don't merge className
+
+ _name = ModelUtils.merge(this._name, other._name);
+ _required = ModelUtils.merge(this._required, other._required);
+ _rtexprvalue = ModelUtils.merge(this._rtexprvalue, other._rtexprvalue);
+ _description = ModelUtils.merge(this._description, other._description);
+ _longDescription = ModelUtils.merge(this._longDescription, other._longDescription);
+ }
+
+
+ /**
+ * Set the name that users refer to this property by.
+ * <p>
+ * This sets the name of xml tag attributes, and the base names of generated
+ * getter/setter methods.
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ /**
+ * Set the fully-qualified name of the type of this property.
+ */
+ public void setClassName(String className)
+ {
+ this._className = className;
+ }
+
+ public String getClassName()
+ {
+ return _className;
+ }
+
+ /**
+ * Specify whether this property is required, ie whether it is a syntax
+ * error for someone to use a tag for a component with this property but not
+ * explicitly provide a value for this property.
+ */
+ public void setRequired(Boolean required)
+ {
+ _required = required;
+ }
+
+ public Boolean isRequired()
+ {
+ return ModelUtils.defaultOf(_required, false);
+ }
+
+ public void setRtexprvalue(Boolean rtexprvalue)
+ {
+ _rtexprvalue = rtexprvalue;
+ }
+
+ public Boolean isRtexprvalue()
+ {
+ return ModelUtils.defaultOf(_rtexprvalue, false);
+ }
+
+
+ public void setDescription(String desc)
+ {
+ _description = desc;
+ }
+
+ public String getDescription()
+ {
+ return _description;
+ }
+
+ public void setLongDescription(String desc)
+ {
+ _longDescription = desc;
+ }
+
+ public String getLongDescription()
+ {
+ return _longDescription;
+ }
+
+}
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/AttributeMeta.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java?rev=651158&r1=651157&r2=651158&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java Wed Apr 23 22:31:56 2008
@@ -42,6 +42,7 @@
private String _name;
private String _description;
private String _longDescription;
+ private String _bodyContent;
private String _type;
private String _family;
@@ -66,6 +67,7 @@
out.writeElement("name", cm._name);
out.writeElement("type", cm._type);
+ out.writeElement("bodyContent", cm._bodyContent);
out.writeElement("family", cm._family);
out.writeElement("tagClass", cm._tagClass);
out.writeElement("tagSuperclass", cm._tagSuperclass);
@@ -98,6 +100,7 @@
digester.addBeanPropertySetter(newPrefix + "/name");
digester.addBeanPropertySetter(newPrefix + "/type");
+ digester.addBeanPropertySetter(newPrefix + "/bodyContent");
digester.addBeanPropertySetter(newPrefix + "/family");
digester.addBeanPropertySetter(newPrefix + "/tagClass");
digester.addBeanPropertySetter(newPrefix + "/tagSuperclass");
@@ -123,6 +126,7 @@
public void merge(ComponentMeta other)
{
_name = ModelUtils.merge(this._name, other._name);
+ _bodyContent = ModelUtils.merge(this._bodyContent, other._bodyContent);
_description = ModelUtils.merge(this._description, other._description);
_longDescription = ModelUtils.merge(this._longDescription,
other._longDescription);
@@ -219,6 +223,16 @@
public String getLongDescription()
{
return _longDescription;
+ }
+
+ public void setBodyContent(String bodyContent)
+ {
+ this._bodyContent = bodyContent;
+ }
+
+ public String getBodyContent()
+ {
+ return _bodyContent;
}
/**
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java?rev=651158&r1=651157&r2=651158&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java Wed Apr 23 22:31:56 2008
@@ -39,11 +39,13 @@
private List _converters = new ArrayList(100);
private List _validators = new ArrayList(100);
private List _renderKits = new ArrayList(100);
+ private List _tags = new ArrayList(100);
private Map _componentsByClass = new TreeMap();
private Map _convertersByClass = new TreeMap();
private Map _validatorsByClass = new TreeMap();
private Map _renderKitsById = new TreeMap();
+ private Map _tagsByClass = new TreeMap();
private String _modelId;
@@ -81,6 +83,12 @@
{
RenderKitMeta c = (RenderKitMeta) i.next();
RenderKitMeta.writeXml(out, c);
+ }
+
+ for (Iterator i = model._tags.iterator(); i.hasNext();)
+ {
+ TagMeta c = (TagMeta) i.next();
+ TagMeta.writeXml(out, c);
}
out.endElement("model");
@@ -103,6 +111,7 @@
ConverterMeta.addXmlRules(digester, prefix);
ValidatorMeta.addXmlRules(digester, prefix);
RenderKitMeta.addXmlRules(digester, prefix);
+ TagMeta.addXmlRules(digester, prefix);
}
/**
@@ -137,14 +146,23 @@
for (Iterator it = other.getValidators().iterator(); it.hasNext();)
{
- ValidatorMeta converter = (ValidatorMeta) it.next();
+ ValidatorMeta validator = (ValidatorMeta) it.next();
- if (this.findConverterByClassName(converter.getClassName())== null)
+ if (this.findValidatorByClassName(validator.getClassName())== null)
{
- this.addValidator(converter);
+ this.addValidator(validator);
}
}
+ for (Iterator it = other.getTags().iterator(); it.hasNext();)
+ {
+ TagMeta validator = (TagMeta) it.next();
+
+ if (this.findTagByClassName(validator.getClassName())== null)
+ {
+ this.addTag(validator);
+ }
+ }
}
/**
@@ -277,6 +295,40 @@
{
return (RenderKitMeta) _renderKitsById.get(id);
}
+
+ /**
+ * Adds a tag to this faces config document.
+ *
+ * @param tag
+ * the tag to add
+ */
+ public void addTag(TagMeta tag)
+ {
+ _tags.add(tag);
+ _tagsByClass.put(tag.getClassName(), tag);
+ }
+
+ /**
+ * Returns all tags
+ */
+ public List getTags()
+ {
+ return _tags;
+ }
+
+ /**
+ * Returns an iterator for all tags.
+ */
+ public Iterator tags()
+ {
+ return _tags.iterator();
+ }
+
+ public TagMeta findTagByClassName(String className)
+ {
+ return (TagMeta) _tagsByClass.get(className);
+ }
+
public void setModelId(String _modelId)
{
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/PropertyMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/PropertyMeta.java?rev=651158&r1=651157&r2=651158&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/PropertyMeta.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/PropertyMeta.java Wed Apr 23 22:31:56 2008
@@ -154,7 +154,7 @@
_defaultValue = ModelUtils.merge(this._defaultValue, other._defaultValue);
_signature = (MethodSignatureMeta) ModelUtils.merge(this._signature, other._signature);
_generated = ModelUtils.merge(this._generated, other._generated);
-
+ _tagExcluded = ModelUtils.merge(this._tagExcluded, other._tagExcluded);
}
/**
Added: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java?rev=651158&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java Wed Apr 23 22:31:56 2008
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.buildtools.maven2.plugin.builder.model;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.commons.digester.Digester;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.io.XmlWriter;
+
+public class TagMeta extends ClassMeta implements AttributeHolder
+{
+ private String _name;
+ private String _bodyContent;
+ private String _description;
+ private String _longDescription;
+
+ protected Map _attributes;
+
+ /**
+ * Write an instance of this class out as xml.
+ */
+ public static void writeXml(XmlWriter out, TagMeta tm)
+ {
+ out.beginElement("tag");
+
+ ClassMeta.writeXml(out, tm);
+ out.writeElement("name", tm._name);
+ out.writeElement("bodyContent", tm._bodyContent);
+ out.writeElement("desc", tm._description);
+ out.writeElement("longDesc", tm._longDescription);
+
+ for (Iterator i = tm._attributes.values().iterator(); i.hasNext();)
+ {
+ AttributeMeta prop = (AttributeMeta) i.next();
+ AttributeMeta.writeXml(out, prop);
+ }
+
+ out.endElement("tag");
+ }
+
+ /**
+ * Add digester rules to repopulate an instance of this type from an xml
+ * file.
+ */
+ public static void addXmlRules(Digester digester, String prefix)
+ {
+ String newPrefix = prefix + "/tag";
+
+ digester.addObjectCreate(newPrefix, TagMeta.class);
+ digester.addSetNext(newPrefix, "addTag");
+
+ ClassMeta.addXmlRules(digester, newPrefix);
+ digester.addBeanPropertySetter(newPrefix + "/name", "name");
+ digester.addBeanPropertySetter(newPrefix + "/bodyContent", "bodyContent");
+ digester.addBeanPropertySetter(newPrefix + "/desc", "description");
+ digester.addBeanPropertySetter(newPrefix + "/longDesc",
+ "longDescription");
+
+ AttributeMeta.addXmlRules(digester, newPrefix);
+ }
+
+ /**
+ * Constructor.
+ */
+ public TagMeta()
+ {
+ _attributes = new LinkedHashMap();
+ }
+
+ /**
+ * Merge the data in the specified other property into this one, throwing an
+ * exception if there is an incompatibility.
+ */
+ public void merge(TagMeta other)
+ {
+ _name = ModelUtils.merge(this._name, other._name);
+ _description = ModelUtils.merge(this._description, other._description);
+ _longDescription = ModelUtils.merge(this._longDescription,
+ other._longDescription);
+ _bodyContent = ModelUtils.merge(this._bodyContent, other._bodyContent);
+ //TODO: Merge attributes
+ }
+
+ /**
+ * Sets the brief description of this property.
+ * <p>
+ * This description is used in tooltips, etc.
+ */
+ public void setDescription(String description)
+ {
+ _description = description;
+ }
+
+ public String getDescription()
+ {
+ return _description;
+ }
+
+ /**
+ * Sets the long description of this property.
+ */
+ public void setLongDescription(String longDescription)
+ {
+ _longDescription = longDescription;
+ }
+
+ public String getLongDescription()
+ {
+ return _longDescription;
+ }
+
+ public void setBodyContent(String bodyContent)
+ {
+ this._bodyContent = bodyContent;
+ }
+
+ public String getBodyContent()
+ {
+ return _bodyContent;
+ }
+
+ /**
+ * Sets the name that the user will refer to instances of this component by.
+ * <p>
+ * In JSP tags, this value will be used as the JSP tag name.
+ * <p>
+ * This property is optional; if not set then this Model instance represents
+ * a base class that components can be derived from, but which cannot itself
+ * be instantiated as a component.
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ /**
+ * Adds a property to this component.
+ */
+ public void addAttribute(AttributeMeta attribute)
+ {
+ _attributes.put(attribute.getName(), attribute);
+ }
+
+ public AttributeMeta getAttribute(String attributeName)
+ {
+ return (AttributeMeta) _attributes.get(attributeName);
+ }
+
+ /**
+ * Number of properties for this component
+ */
+ public int attributesSize()
+ {
+ return _attributes.size();
+ }
+
+ /**
+ * Returns true if this component has any properties.
+ */
+ public boolean hasAttributes()
+ {
+ return _attributes.size() > 0;
+ }
+
+ /**
+ * Returns an iterator for all properties
+ */
+ public Iterator attributes()
+ {
+ return _attributes.values().iterator();
+ }
+
+ //THIS METHODS ARE USED FOR VELOCITY TO GET DATA AND GENERATE CLASSES
+
+ public Collection getAttributeList(){
+ return _attributes.values();
+ }
+
+}
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/TagMeta.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java?rev=651158&r1=651157&r2=651158&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java Wed Apr 23 22:31:56 2008
@@ -16,6 +16,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.myfaces.buildtools.maven2.plugin.builder.ModelBuilder;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.AttributeMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
@@ -24,6 +25,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.PropertyMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RenderKitMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RendererMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.TagMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
import com.thoughtworks.qdox.JavaDocBuilder;
@@ -60,6 +62,9 @@
//in jsf 1.1 (in 1.2 has component counterpart). In fact, all
//properties must be defined with JSFProperty
private static final String DOC_JSP_PROPERTY = "JSFJspProperty";
+
+ private static final String DOC_TAG = "JSFJspTag";
+ private static final String DOC_JSP_ATTRIBUTE = "JSFJspAttribute";
private static final String ANNOTATION_BASE = "org.apache.myfaces.buildtools.annotation";
@@ -130,6 +135,11 @@
ValidatorMeta validator = (ValidatorMeta) it.next();
validator.setModelId(model.getModelId());
}
+ for (Iterator it = model.getTags().iterator(); it.hasNext();)
+ {
+ TagMeta tag = (TagMeta) it.next();
+ tag.setModelId(model.getModelId());
+ }
}
/**
@@ -209,6 +219,20 @@
processComponent(props, anno.getContext(), clazz, model);
}
+ //tag
+ tag = clazz.getTagByName(DOC_TAG, false);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processTag(props, tag.getContext(), clazz, model);
+ }
+ anno = getAnnotation(clazz, DOC_TAG);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processTag(props, anno.getContext(), clazz, model);
+ }
+
// renderKit
tag = clazz.getTagByName(DOC_RENDERKIT, false);
if (tag != null)
@@ -510,6 +534,34 @@
renderKit.addRenderer(renderer);
}
+ private void processTag(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, Model model) throws MojoExecutionException
+ {
+ String longDescription = clazz.getComment();
+ String descDflt = getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = getString(clazz, "desc", props, descDflt);
+
+ String tagName = getString(clazz, "name", props, null);
+ String tagClass = getString(clazz, "class", props, clazz
+ .getFullyQualifiedName());
+
+ String bodyContent = getString(clazz, "bodyContent", props, "JSP");
+
+ TagMeta tag = new TagMeta();
+ tag.setName(tagName);
+ tag.setClassName(tagClass);
+ tag.setBodyContent(bodyContent);
+ tag.setDescription(shortDescription);
+ tag.setLongDescription(longDescription);
+
+ processTagAttributes(clazz, tag);
+ model.addTag(tag);
+ }
+
private void processComponent(Map props, AbstractJavaEntity ctx,
JavaClass clazz, Model model) throws MojoExecutionException
{
@@ -568,6 +620,8 @@
}
String shortDescription = getString(clazz, "desc", props, descDflt);
+ String bodyContent = getString(clazz, "bodyContent", props, null);
+
String componentFamily = getString(clazz, "family", props,
componentTypeFamily);
String componentType = getString(clazz, "type", props,
@@ -583,6 +637,7 @@
ComponentMeta component = new ComponentMeta();
initAncestry(model, clazz, component);
component.setName(componentName);
+ component.setBodyContent(bodyContent);
component.setClassName(componentClass);
component.setParentClassName(componentParentClass);
component.setDescription(shortDescription);
@@ -614,6 +669,111 @@
model.addComponent(component);
}
+ private void processTagAttributes(JavaClass clazz,
+ TagMeta ctag)
+ {
+ JavaMethod[] methods = clazz.getMethods();
+ for (int i = 0; i < methods.length; ++i)
+ {
+ JavaMethod method = methods[i];
+
+ DocletTag tag = method.getTagByName(DOC_JSP_ATTRIBUTE);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processTagAttribute(props, tag.getContext(), clazz,
+ method, ctag);
+ }
+
+ Annotation anno = getAnnotation(method, DOC_JSP_ATTRIBUTE);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processTagAttribute(props, anno.getContext(), clazz,
+ method, ctag);
+ }
+ }
+
+ DocletTag[] jspProperties = clazz.getTagsByName(DOC_JSP_ATTRIBUTE);
+ for (int i = 0; i < jspProperties.length; ++i)
+ {
+ //We have here only doclets, because this part is only for
+ //solve problems with binding property on 1.1
+ DocletTag tag = jspProperties[i];
+
+ Map props = tag.getNamedParameterMap();
+ processTagAttribute(props, tag.getContext(), clazz,
+ ctag);
+
+ }
+ }
+
+ private void processTagAttribute(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, JavaMethod method, TagMeta tag)
+ {
+ Boolean required = getBoolean(clazz, "required", props, null);
+ Boolean rtexprvalue = getBoolean(clazz, "rtexprvalue", props, null);
+
+ String longDescription = ctx.getComment();
+ String descDflt = getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = getString(clazz, "desc", props, descDflt);
+
+ Type returnType = null;
+
+ if (method.getName().startsWith("set"))
+ {
+ returnType = method.getParameters()[0].getType();
+ }
+ else
+ {
+ returnType = method.getReturns();
+ }
+
+ AttributeMeta a = new AttributeMeta();
+ a.setName(methodToPropName(method.getName()));
+ a.setClassName(returnType.toString());
+ a.setRequired(required);
+ a.setRtexprvalue(rtexprvalue);
+ a.setDescription(shortDescription);
+ a.setLongDescription(longDescription);
+
+ tag.addAttribute(a);
+ }
+
+ private void processTagAttribute(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, TagMeta tag)
+ {
+ Boolean required = getBoolean(clazz, "required", props, null);
+ Boolean rtexprvalue = getBoolean(clazz, "rtexprvalue", props, null);
+
+ String longDescription = getString(clazz, "longDescription", props, null);
+ String descDflt = longDescription;
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = getString(clazz, "desc", props, descDflt);
+
+ String name = getString(clazz, "name", props, descDflt);
+ String className = getString(clazz, "className", props, descDflt);
+
+ AttributeMeta a = new AttributeMeta();
+ a.setName(name);
+ a.setClassName(className);
+ a.setRequired(required);
+ a.setRtexprvalue(rtexprvalue);
+ a.setDescription(shortDescription);
+ a.setLongDescription(longDescription);
+
+ tag.addAttribute(a);
+ }
+
+
+
/**
* Look for any methods on the specified class that are annotated as being
* component properties, and add metadata about them to the model.