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 2011/02/25 23:29:46 UTC
svn commit: r1074722 [3/3] - in
/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox:
./ parse/
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/JspTagParsingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/JspTagParsingStrategy.java?rev=1074722&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/JspTagParsingStrategy.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/JspTagParsingStrategy.java Fri Feb 25 22:29:45 2011
@@ -0,0 +1,228 @@
+/*
+ * 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.qdox.parse;
+
+import java.util.Map;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.AttributeMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.TagMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.qdox.QdoxHelper;
+
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.Type;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 1.0.9
+ *
+ */
+public class JspTagParsingStrategy extends ClassMetaParsingStrategy
+{
+ private static final String DOC_TAG = "JSFJspTag";
+ private static final String DOC_JSP_ATTRIBUTE = "JSFJspAttribute";
+
+ public void parseClass(JavaClass clazz, Model model)
+ {
+ DocletTag tag;
+ Annotation anno;
+ //tag
+ tag = clazz.getTagByName(DOC_TAG, false);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processTag(props, (AbstractJavaEntity)tag.getContext(), clazz, model);
+ }
+ anno = QdoxHelper.getAnnotation(clazz, DOC_TAG);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processTag(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+ }
+
+ private void processTag(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, Model model)
+ {
+ String longDescription = clazz.getComment();
+ String descDflt = QdoxHelper.getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ String tagName = QdoxHelper.getString(clazz, "name", props, null);
+ String classNameOverride = QdoxHelper.getString(clazz, "class", props, null);
+ classNameOverride = QdoxHelper.getString(clazz,"clazz",props,classNameOverride);
+
+ String bodyContent = QdoxHelper.getString(clazz, "bodyContent", props, "JSP");
+ String tagHandler = QdoxHelper.getString(clazz, "tagHandler", props, null);
+
+ TagMeta tag = new TagMeta();
+ initClassMeta(model, clazz, tag, classNameOverride);
+ tag.setName(tagName);
+ tag.setBodyContent(bodyContent);
+ tag.setDescription(shortDescription);
+ tag.setLongDescription(longDescription);
+ tag.setTagHandler(tagHandler);
+
+ processTagAttributes(clazz, tag);
+ model.addTag(tag);
+ }
+
+ 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, (AbstractJavaEntity)tag.getContext(), clazz,
+ method, ctag);
+ }
+
+ Annotation anno = QdoxHelper.getAnnotation(method, DOC_JSP_ATTRIBUTE);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processTagAttribute(props, (AbstractJavaEntity)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, (AbstractJavaEntity)tag.getContext(), clazz,
+ ctag);
+
+ }
+ }
+
+ private void processTagAttribute(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, JavaMethod method, TagMeta tag)
+ {
+ Boolean required = QdoxHelper.getBoolean(clazz, "required", props, null);
+ Boolean rtexprvalue = QdoxHelper.getBoolean(clazz, "rtexprvalue", props, null);
+
+ String longDescription = ctx.getComment();
+ String descDflt = QdoxHelper.getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ Type returnType = null;
+
+ if (method.getName().startsWith("set"))
+ {
+ returnType = method.getParameters()[0].getType();
+ }
+ else
+ {
+ returnType = method.getReturns();
+ }
+
+ String fullyQualifiedReturnType = returnType.getJavaClass().getFullyQualifiedName();
+
+ fullyQualifiedReturnType = QdoxHelper.getFullyQualifiedClassName(clazz,fullyQualifiedReturnType);
+
+ if (returnType.isArray() && (fullyQualifiedReturnType.indexOf('[') == -1))
+ {
+ for (int i = 0; i < returnType.getDimensions();i++)
+ {
+ fullyQualifiedReturnType = fullyQualifiedReturnType + "[]";
+ }
+ }
+
+ String className = QdoxHelper.getString(clazz,"className",props, fullyQualifiedReturnType);
+ String deferredValueType = QdoxHelper.getString(clazz, "deferredValueType", props, null);
+ String deferredMethodSignature = QdoxHelper.getString(clazz, "deferredMethodSignature", props, null);
+ Boolean exclude = QdoxHelper.getBoolean(clazz, "exclude", props, null);
+ Boolean faceletsOnly = QdoxHelper.getBoolean(clazz, "faceletsOnly", props, null);
+
+ AttributeMeta a = new AttributeMeta();
+ a.setName(QdoxHelper.methodToPropName(method.getName()));
+ a.setClassName(className);
+ a.setRequired(required);
+ a.setRtexprvalue(rtexprvalue);
+ a.setDescription(shortDescription);
+ a.setLongDescription(longDescription);
+ a.setDeferredValueType(deferredValueType);
+ a.setDeferredMethodSignature(deferredMethodSignature);
+ a.setExclude(exclude);
+ a.setFaceletsOnly(faceletsOnly);
+
+ tag.addAttribute(a);
+ }
+
+ private void processTagAttribute(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, TagMeta tag)
+ {
+ Boolean required = QdoxHelper.getBoolean(clazz, "required", props, null);
+ Boolean rtexprvalue = QdoxHelper.getBoolean(clazz, "rtexprvalue", props, null);
+
+ String longDescription = QdoxHelper.getString(clazz, "longDescription", props, null);
+ String descDflt = longDescription;
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ String name = QdoxHelper.getString(clazz, "name", props, null);
+ String className = QdoxHelper.getString(clazz, "className", props, null);
+ String deferredValueType = QdoxHelper.getString(clazz, "deferredValueType", props, null);
+ String deferredMethodSignature = QdoxHelper.getString(clazz, "deferredMethodSignature", props, null);
+ Boolean exclude = QdoxHelper.getBoolean(clazz, "exclude", props, null);
+ Boolean faceletsOnly = QdoxHelper.getBoolean(clazz, "faceletsOnly", props, null);
+
+ AttributeMeta a = new AttributeMeta();
+ a.setName(name);
+ a.setClassName(className);
+ a.setRequired(required);
+ a.setRtexprvalue(rtexprvalue);
+ a.setDescription(shortDescription);
+ a.setLongDescription(longDescription);
+ a.setDeferredValueType(deferredValueType);
+ a.setDeferredMethodSignature(deferredMethodSignature);
+ a.setExclude(exclude);
+ a.setFaceletsOnly(faceletsOnly);
+
+ tag.addAttribute(a);
+ }
+
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RenderKitParsingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RenderKitParsingStrategy.java?rev=1074722&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RenderKitParsingStrategy.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RenderKitParsingStrategy.java Fri Feb 25 22:29:45 2011
@@ -0,0 +1,85 @@
+/*
+ * 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.qdox.parse;
+
+import java.util.Map;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RenderKitMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.qdox.QdoxHelper;
+
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 1.0.9
+ *
+ */
+public class RenderKitParsingStrategy implements JavaClassParsingStrategy
+{
+ private static final String DOC_RENDERKIT = "JSFRenderKit";
+
+ public void parseClass(JavaClass clazz, Model model)
+ {
+ DocletTag tag = null;
+ Annotation anno = null;
+ // renderKit
+ tag = clazz.getTagByName(DOC_RENDERKIT, false);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processRenderKit(props, (AbstractJavaEntity)tag.getContext(), clazz, model);
+ }
+ anno = QdoxHelper.getAnnotation(clazz, DOC_RENDERKIT);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processRenderKit(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+ }
+
+ private void processRenderKit(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, Model model)
+ {
+
+ String renderKitId = QdoxHelper.getString(clazz, "renderKitId", props, null);
+ String renderKitClass = QdoxHelper.getString(clazz, "class", props, clazz
+ .getFullyQualifiedName());
+ renderKitClass = QdoxHelper.getString(clazz,"clazz",props,renderKitClass);
+
+ RenderKitMeta renderKit = model.findRenderKitById(renderKitId);
+
+ if (renderKit == null)
+ {
+ renderKit = new RenderKitMeta();
+ renderKit.setClassName(renderKitClass);
+ renderKit.setRenderKitId(renderKitId);
+ model.addRenderKit(renderKit);
+ }
+ else
+ {
+ renderKit.setClassName(renderKitClass);
+ renderKit.setRenderKitId(renderKitId);
+ }
+ }
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RendererParsingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RendererParsingStrategy.java?rev=1074722&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RendererParsingStrategy.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/RendererParsingStrategy.java Fri Feb 25 22:29:45 2011
@@ -0,0 +1,125 @@
+/*
+ * 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.qdox.parse;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
+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.qdox.QdoxHelper;
+
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 1.0.9
+ *
+ */
+public class RendererParsingStrategy implements JavaClassParsingStrategy
+{
+ private static final String DOC_RENDERER = "JSFRenderer";
+ private static final String DOC_RENDERERS = "JSFRenderers";
+
+ public void parseClass(JavaClass clazz, Model model)
+ {
+ DocletTag tag = null;
+ Annotation anno = null;
+ // renderer
+ DocletTag [] tags = clazz.getTagsByName(DOC_RENDERER, false);
+ for (int i = 0; i < tags.length; i++)
+ {
+ tag = tags[i];
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processRenderer(props, (AbstractJavaEntity)tag.getContext(), clazz, model);
+ }
+ }
+ anno = QdoxHelper.getAnnotation(clazz, DOC_RENDERER);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processRenderer(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+ anno = QdoxHelper.getAnnotation(clazz, DOC_RENDERERS);
+ if (anno != null)
+ {
+ Object jspProps = anno.getNamedParameter("renderers");
+
+ if (jspProps instanceof Annotation)
+ {
+ Annotation jspPropertiesAnno = (Annotation) jspProps;
+ Map props = jspPropertiesAnno.getNamedParameterMap();
+ processRenderer(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+ else
+ {
+ List jspPropsList = (List) jspProps;
+ for (int i = 0; i < jspPropsList.size();i++)
+ {
+ Annotation ranno = (Annotation) jspPropsList.get(i);
+ Map props = ranno.getNamedParameterMap();
+ processRenderer(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+ }
+ }
+ }
+
+ private void processRenderer(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, Model model)
+ {
+ String longDescription = clazz.getComment();
+ String descDflt = QdoxHelper.getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ String renderKitId = QdoxHelper.getString(clazz, "renderKitId", props, null);
+ String rendererClass = QdoxHelper.getString(clazz, "class", props, clazz
+ .getFullyQualifiedName());
+ rendererClass = QdoxHelper.getString(clazz,"clazz",props,rendererClass);
+
+ String componentFamily = QdoxHelper.getString(clazz,"family", props,null);
+ String rendererType = QdoxHelper.getString(clazz,"type", props,null);
+
+ RenderKitMeta renderKit = model.findRenderKitById(renderKitId);
+
+ if (renderKit == null)
+ {
+ renderKit = new RenderKitMeta();
+ renderKit.setRenderKitId(renderKitId);
+ model.addRenderKit(renderKit);
+ }
+
+ RendererMeta renderer = new RendererMeta();
+ renderer.setClassName(rendererClass);
+ renderer.setDescription(shortDescription);
+ renderer.setComponentFamily(componentFamily);
+ renderer.setRendererType(rendererType);
+ renderKit.addRenderer(renderer);
+ }
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/ValidatorParsingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/ValidatorParsingStrategy.java?rev=1074722&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/ValidatorParsingStrategy.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/ValidatorParsingStrategy.java Fri Feb 25 22:29:45 2011
@@ -0,0 +1,117 @@
+/*
+ * 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.qdox.parse;
+
+import java.util.Map;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.qdox.QdoxHelper;
+
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 1.0.9
+ *
+ */
+public class ValidatorParsingStrategy extends ClassMetaPropertyParsingStrategy
+{
+ private static final String DOC_VALIDATOR = "JSFValidator";
+
+ public void parseClass(JavaClass clazz, Model model)
+ {
+ DocletTag tag;
+ Annotation anno;
+ // validators
+ tag = clazz.getTagByName(DOC_VALIDATOR, false);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processValidator(props, (AbstractJavaEntity)tag.getContext(), clazz, model);
+ }
+ anno = QdoxHelper.getAnnotation(clazz, DOC_VALIDATOR);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processValidator(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
+ }
+
+ }
+
+ private void processValidator(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, Model model)
+ {
+ String longDescription = clazz.getComment();
+ String descDflt = QdoxHelper.getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ String validatorIdDflt = null;
+ JavaField fieldConverterId = clazz
+ .getFieldByName("VALIDATOR_ID");
+ if (fieldConverterId != null)
+ {
+ String value = fieldConverterId.getInitializationExpression();
+ validatorIdDflt = QdoxHelper.clean(value.substring(value.indexOf('"')));
+ }
+ String validatorId = QdoxHelper.getString(clazz, "id", props, validatorIdDflt);
+
+ // Check for both "class" and "clazz" in order to support
+ // doclet and real annotations.
+ String classNameOverride = QdoxHelper.getString(clazz, "class", props, null);
+ classNameOverride = QdoxHelper.getString(clazz,"clazz",props,classNameOverride);
+
+ String componentName = QdoxHelper.getString(clazz, "name", props, null);
+ String bodyContent = QdoxHelper.getString(clazz, "bodyContent", props, null);
+ String tagClass = QdoxHelper.getString(clazz, "tagClass", props, null);
+ String tagSuperclass = QdoxHelper.getString(clazz, "tagSuperclass", props, null);
+ String tagHandler = QdoxHelper.getString(clazz, "tagHandler", props, null);
+ String serialuidtag = QdoxHelper.getString(clazz, "serialuidtag", props, null);
+ Boolean configExcluded = QdoxHelper.getBoolean(clazz,"configExcluded",props,null);
+ Boolean evaluateELOnExecution = QdoxHelper.getBoolean(clazz,"evaluateELOnExecution",props,null);
+
+ ValidatorMeta validator = new ValidatorMeta();
+ initClassMeta(model, clazz, validator, classNameOverride);
+ validator.setName(componentName);
+ validator.setBodyContent(bodyContent);
+ validator.setTagClass(tagClass);
+ validator.setTagSuperclass(tagSuperclass);
+ validator.setTagHandler(tagHandler);
+ validator.setValidatorId(validatorId);
+ validator.setDescription(shortDescription);
+ validator.setLongDescription(longDescription);
+ validator.setSerialuidtag(serialuidtag);
+ validator.setConfigExcluded(configExcluded);
+ validator.setEvaluateELOnExecution(evaluateELOnExecution);
+
+ // Now here walk the component looking for property annotations.
+ processComponentProperties(clazz, validator);
+
+ model.addValidator(validator);
+ }
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/WebConfigParamParsingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/WebConfigParamParsingStrategy.java?rev=1074722&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/WebConfigParamParsingStrategy.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/parse/WebConfigParamParsingStrategy.java Fri Feb 25 22:29:45 2011
@@ -0,0 +1,111 @@
+/*
+ * 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.qdox.parse;
+
+import java.util.Map;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.WebConfigMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.WebConfigParamMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.qdox.QdoxHelper;
+
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 1.0.9
+ *
+ */
+public class WebConfigParamParsingStrategy implements JavaClassParsingStrategy
+{
+ private static final String DOC_WEB_CONFIG_PARAM = "JSFWebConfigParam";
+
+ public void parseClass(JavaClass clazz, Model model)
+ {
+ DocletTag tag;
+ Annotation anno;
+ WebConfigMeta webConfig = model.findWebConfigsByModelId(model.getModelId());
+ boolean createWebConfig = false;
+ if (webConfig == null)
+ {
+ createWebConfig = true;
+ webConfig = new WebConfigMeta();
+ webConfig.setModelId(model.getModelId());
+ }
+ //Web Config Params
+ JavaField[] fields = clazz.getFields();
+ for (int i = 0; i < fields.length; ++i)
+ {
+ JavaField field = fields[i];
+ tag = field.getTagByName(DOC_WEB_CONFIG_PARAM);
+ if (tag != null)
+ {
+ Map props = tag.getNamedParameterMap();
+ processWebConfigParam(props, (AbstractJavaEntity)tag.getContext(),
+ clazz, field, webConfig);
+ }
+ anno = QdoxHelper.getAnnotation(field, DOC_WEB_CONFIG_PARAM);
+ if (anno != null)
+ {
+ Map props = anno.getNamedParameterMap();
+ processWebConfigParam(props, (AbstractJavaEntity)anno.getContext(),
+ clazz, field, webConfig);
+ }
+ }
+ if (webConfig.webConfigParametersSize() > 0 && createWebConfig)
+ {
+ model.addWebConfig(webConfig);
+ }
+ }
+
+ private void processWebConfigParam(Map props, AbstractJavaEntity ctx,
+ JavaClass clazz, JavaField field, WebConfigMeta webConfig)
+ {
+ String longDescription = field.getComment();
+ String descDflt = QdoxHelper.getFirstSentence(longDescription);
+ if ((descDflt == null) || (descDflt.length() < 2))
+ {
+ descDflt = "no description";
+ }
+ String shortDescription = QdoxHelper.getString(clazz, "desc", props, descDflt);
+
+ String name = QdoxHelper.getString(clazz, "name", props,
+ QdoxHelper.evaluateParameterInitializationExpression(
+ field.getInitializationExpression()));
+ String defaultValue = QdoxHelper.getString(clazz,"defaultValue",props,null);
+ String expectedValues = QdoxHelper.getString(clazz,"expectedValues",props,null);
+ String since = QdoxHelper.getString(clazz,"since",props,null);
+
+ WebConfigParamMeta wcp = new WebConfigParamMeta();
+ wcp.setName(name);
+ wcp.setFieldName(field.getName());
+ wcp.setSourceClassName(clazz.getFullyQualifiedName());
+ wcp.setDefaultValue(defaultValue);
+ wcp.setExpectedValues(expectedValues);
+ wcp.setLongDescription(longDescription);
+ wcp.setDescription(shortDescription);
+ wcp.setSince(since);
+ webConfig.addWebConfigParam(wcp);
+ }
+}