TRINIDAD-953 - Support for Code Examples in Trinidad Components, Validators, and Converters tagdocs

ported back to 1.2.6.1 branch.
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
index b9ea79b..7ea99f9 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/AbstractTagBean.java
@@ -29,11 +29,27 @@
   private String  _longDescription;

   private QName   _tagName;

   private String  _tagClass;

-  protected Map _properties;

+  protected Map   _properties;

   private int     _tagClassModifiers;

+  private Map     _examples;

+  private int     _exampleIdx = 0;

 

-  public AbstractTagBean() {

-    _properties = new LinkedHashMap();

+  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();      

   }

 

   /**

@@ -164,6 +180,51 @@
     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)

   {

@@ -226,4 +287,14 @@
   {

     return _properties.size();

   }

+ 

+  /* Get a generated key to use in storing

+   * this example bean in its hashmap.

+   */

+  private String _generateExampleKey()

+  {

+    String key = "Example" + Integer.toString(_exampleIdx);

+    _exampleIdx++;

+    return key;

+  }

 }

diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
index 3561e31..98d270b 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
@@ -20,7 +20,6 @@
 
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.CompoundIterator;
 
-import javax.xml.namespace.QName;
 import java.lang.reflect.Modifier;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -31,13 +30,14 @@
  * ComponentBean is a Java representation of the faces-config component
  * XML element.
  */
-public class ComponentBean extends ObjectBean
+public class ComponentBean extends AbstractTagBean
 {
   /**
    * Creates a new ComponentBean.
    */
   public ComponentBean()
   {
+    super(true);
     _properties = new LinkedHashMap();
     _facets = new LinkedHashMap();
     _events = new LinkedHashMap();
@@ -206,17 +206,6 @@
   }
 
   /**
-   * Sets the JSP tag handler class for this component.
-   *
-   * @param tagClass  the JSP tag handler class
-   */
-  public void setTagClass(
-    String tagClass)
-  {
-    _tagClass = tagClass;
-  }
-
-  /**
    * Sets the unsupported agents for this component.
    *
    * @param unsupportedAgents  the unsupported agents
@@ -240,17 +229,6 @@
     return _unsupportedAgents;
   }
 
-
-  /**
-   * Returns the JSP tag handler class for this component.
-   *
-   * @return  the JSP tag handler class
-   */
-  public String getTagClass()
-  {
-    return _tagClass;
-  }
-
    /**
    * Sets the JSP tag handler superclass for this component.
    *
@@ -294,27 +272,6 @@
  }
 
   /**
-   * Returns the JSP tag name for this component.
-   *
-   * @return  the JSP tag name
-   */
-  public QName getTagName()
-  {
-    return _tagName;
-  }
-
-  /**
-   * Sets the JSP tag name for this component.
-   *
-   * @param tagName  the JSP tag name
-   */
-  public void setTagName(
-    QName tagName)
-  {
-    _tagName = tagName;
-  }
-
-  /**
    * Sets the namingContainer flag of this property.
    *
    * @param namingContainer  the component namingContainer flag
@@ -419,7 +376,6 @@
     _implementationType = implementationType;
   }
 
-
   /**
    * Adds a property to this component.
    *
@@ -652,7 +608,6 @@
     _children = children;
   }
 
-
   /**
    * Returns true if the component can have children.
    *
@@ -707,23 +662,6 @@
     addTagClassModifier(_parseModifier(modifier));
   }
 
-  private int _parseModifier(
-    String text)
-  {
-    if ("public".equals(text))
-      return Modifier.PUBLIC;
-    else if ("protected".equals(text))
-      return Modifier.PROTECTED;
-    else if ("private".equals(text))
-      return Modifier.PRIVATE;
-    else if ("abstract".equals(text))
-      return Modifier.ABSTRACT;
-    else if ("final".equals(text))
-      return Modifier.FINAL;
-
-    throw new IllegalArgumentException("Unrecognized modifier: " + text);
-  }
-
   /**
    * Parses the unsupported agents for this component into a String array
    * using space as the separator between values.
@@ -1018,8 +956,9 @@
    */
   protected String findJspTagClass()
   {
-    if (_tagClass != null)
-      return _tagClass;
+    String tagClass = getTagClass();
+    if (tagClass != null)
+      return tagClass;
 
     ComponentBean parent = resolveSupertype();
     return (parent != null) ? parent.findJspTagClass() : null;
@@ -1051,8 +990,6 @@
   private String  _componentSuperclass;
   private String  _rendererType;
   private String  _implementationType;
-  private QName   _tagName;
-  private String  _tagClass;
   private String  _tagHandler;
   private String  _tagSuperclass;
   private String  _localName;
@@ -1065,7 +1002,7 @@
   private int     _componentClassModifiers;
   private int     _tagClassModifiers;
   private String[] _unsupportedAgents = new String[0];
-
+  
   static private final String _TRINIDAD_COMPONENT_BASE =
                          "org.apache.myfaces.trinidad.component.UIXComponentBase";
 
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
new file mode 100644
index 0000000..27906e5
--- /dev/null
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ExampleBean.java
@@ -0,0 +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;

+}

diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
index 5c19ebf..362b0e4 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
@@ -6,9 +6,9 @@
  *  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
@@ -83,7 +83,7 @@
     // spf.setXIncludeAware(true);
     Digester digester = new Digester(spf.newSAXParser());
     digester.setNamespaceAware(true);
-    
+
     return digester;
   }
 
@@ -118,7 +118,7 @@
                                    "defaultValue");
     digester.addSetNext("faces-config/component/property", "addProperty",
                         PropertyBean.class.getName());
-    
+
 
     // faces-config/component/facet
     digester.addObjectCreate("faces-config/component/facet", FacetBean.class);
@@ -134,6 +134,16 @@
     // faces-config/component/facet/facet-extension
     digester.addBeanPropertySetter("faces-config/component/facet/facet-extension/hidden");
 
+    // faces-config/component/facet/example
+    digester.addObjectCreate("faces-config/component/facet/example",
+                             ExampleBean.class);
+    digester.addBeanPropertySetter("faces-config/component/facet/example/source-description",
+                                   "sourceDescription");
+    digester.addBeanPropertySetter("faces-config/component/facet/example/source-code",
+                                   "sourceCode");
+    digester.addSetNext("faces-config/component/facet/example",
+                        "addExample", ExampleBean.class.getName());
+
     // faces-config/component/component-extension
     digester.addBeanPropertySetter("faces-config/component/component-extension/long-description",
                                    "longDescription");
@@ -174,6 +184,16 @@
     digester.addBeanPropertySetter("faces-config/component/component-extension/uix2-node-class",
                                    "nodeClass");
 
+    // faces-config/component/component-extension/example
+    digester.addObjectCreate("faces-config/component/component-extension/example",
+                             ExampleBean.class);
+    digester.addBeanPropertySetter("faces-config/component/component-extension/example/source-description",
+                                   "sourceDescription");
+    digester.addBeanPropertySetter("faces-config/component/component-extension/example/source-code",
+                                   "sourceCode");
+    digester.addSetNext("faces-config/component/component-extension/example",
+                        "addExample", ExampleBean.class.getName());
+
     // faces-config/component/component-extension/event
     digester.addObjectCreate("faces-config/component/component-extension/event", EventRefBean.class);
     digester.addBeanPropertySetter("faces-config/component/component-extension/event/event-type",
@@ -228,7 +248,7 @@
                         MethodSignatureBean.class.getName());
     // faces-config/component/property/property-extension/property-metada
     digester.addBeanPropertySetter("faces-config/component/property/property-extension/property-metadata/use-max-time",
-                                   "useMaxTime");        
+                                   "useMaxTime");
 
 
     // XInclude rules
@@ -237,15 +257,9 @@
                               ComponentIncludeFactory.class);
   }
 
-  protected Digester createDigester() throws ParserConfigurationException, SAXException
+  protected static void addConverterDigesterRules(Digester digester)
   {
-    Digester digester = createEmptyDigester();
-
-    addComponentDigesterRules(digester, true);
-    
-    // Java Enterprise 5.0
     digester.setRuleNamespaceURI("http://java.sun.com/xml/ns/javaee");
-    //digester.addObjectCreate("faces-config", FacesConfigBean.class);
 
     // faces-config/converter
     digester.addObjectCreate("faces-config/converter", ConverterBean.class);
@@ -269,6 +283,40 @@
     digester.addSetNext("faces-config/converter/property", "addProperty",
                         PropertyBean.class.getName());
 
+    // Maven Faces Plugin
+    digester.setRuleNamespaceURI("http://myfaces.apache.org/maven-faces-plugin");
+
+    // faces-config/converter/converter-extension
+    digester.addBeanPropertySetter("faces-config/converter/converter-extension/long-description",
+                                   "longDescription");
+    digester.addBeanPropertySetter("faces-config/converter/converter-extension/tag-class",
+                                   "tagClass");
+    digester.addRule("faces-config/converter/converter-extension/tag-name",
+                     new BeanPropertySetterRule("tagName"));
+    digester.addCallMethod("faces-config/converter/converter-extension/tag-class-modifier",
+                           "parseTagClassModifier", 1);
+    digester.addCallParam("faces-config/converter/converter-extension/tag-class-modifier", 0);
+
+    // faces-config/converter/converter-extension/example
+    digester.addObjectCreate("faces-config/converter/converter-extension/example",
+                             ExampleBean.class);
+    digester.addBeanPropertySetter("faces-config/converter/converter-extension/example/source-description",
+                                   "sourceDescription");
+    digester.addBeanPropertySetter("faces-config/converter/converter-extension/example/source-code",
+                                   "sourceCode");
+    digester.addSetNext("faces-config/converter/converter-extension/example",
+                        "addExample", ExampleBean.class.getName());
+
+    // faces-config/converter/property/property-extension
+    digester.addBeanPropertySetter("faces-config/converter/property/property-extension/tag-attribute-excluded",
+                                   "tagAttributeExcluded");
+  }
+
+  protected static void addValidatorDigesterRules(Digester digester)
+  {
+    // Java Enterprise 5.0
+    digester.setRuleNamespaceURI("http://java.sun.com/xml/ns/javaee");
+
     // faces-config/validator
     digester.addObjectCreate("faces-config/validator", ValidatorBean.class);
     digester.addBeanPropertySetter("faces-config/validator/validator-id",
@@ -291,6 +339,42 @@
     digester.addSetNext("faces-config/validator/property", "addProperty",
                         PropertyBean.class.getName());
 
+    // Maven Faces Plugin
+    digester.setRuleNamespaceURI("http://myfaces.apache.org/maven-faces-plugin");
+
+    // faces-config/validator/validator-extension
+    digester.addBeanPropertySetter("faces-config/validator/validator-extension/long-description",
+                                   "longDescription");
+    digester.addBeanPropertySetter("faces-config/validator/validator-extension/tag-class",
+                                   "tagClass");
+    digester.addRule("faces-config/validator/validator-extension/tag-name",
+                     new BeanPropertySetterRule("tagName"));
+    digester.addCallMethod("faces-config/validator/validator-extension/tag-class-modifier",
+                           "parseTagClassModifier", 1);
+    digester.addCallParam("faces-config/validator/validator-extension/tag-class-modifier", 0);
+
+    // faces-config/validator/validator-extension/example
+    digester.addObjectCreate("faces-config/validator/validator-extension/example",
+                             ExampleBean.class);
+    digester.addBeanPropertySetter("faces-config/validator/validator-extension/example/source-description",
+                                   "sourceDescription");
+    digester.addBeanPropertySetter("faces-config/validator/validator-extension/example/source-code",
+                                   "sourceCode");
+    digester.addSetNext("faces-config/validator/validator-extension/example",
+                        "addExample", ExampleBean.class.getName());
+
+    // faces-config/validator/property/property-extension
+    digester.addBeanPropertySetter("faces-config/validator/property/property-extension/tag-attribute-excluded",
+                                   "tagAttributeExcluded");
+    // faces-config/validator/property/property-extension/property-metada
+    digester.addBeanPropertySetter("faces-config/validator/property/property-extension/property-metadata/use-max-time",
+                                 "useMaxTime");
+  }
+
+  protected static void addRenderKitDigesterRules(Digester digester)
+  {
+    // Java Enterprise 5.0
+    digester.setRuleNamespaceURI("http://java.sun.com/xml/ns/javaee");
 
     // faces-config/render-kit
     digester.addObjectCreate("faces-config/render-kit", RenderKitBean.class);
@@ -311,9 +395,20 @@
     digester.addSetNext("faces-config/render-kit/renderer", "addRenderer",
                         RendererBean.class.getName());
 
+    // Maven Faces Plugin
+    digester.setRuleNamespaceURI("http://myfaces.apache.org/maven-faces-plugin");
 
-    // TBD: JSR-276 metadata (ask Jeff Stephenson)
+    // faces-config/render-kit/renderer/renderer-extension
+    digester.addBeanPropertySetter("faces-config/render-kit/renderer/renderer-extension/component-type",
+                                   "componentType");
+    digester.addBeanPropertySetter("faces-config/render-kit/renderer/renderer-extension/renderer-superclass",
+                                   "rendererSuperclass");
+  }
 
+  protected static void addEventDigesterRules(Digester digester)
+  {
+    // Java Enterprise 5.0
+    // digester.setRuleNamespaceURI("http://java.sun.com/xml/ns/javaee");
 
     // Maven Faces Plugin
     digester.setRuleNamespaceURI("http://myfaces.apache.org/maven-faces-plugin");
@@ -331,45 +426,22 @@
                                    "eventSourceInterface");
     digester.addSetNext("faces-config/faces-config-extension/event", "addEvent",
                         EventBean.class.getName());
+  }
 
-    // faces-config/converter/converter-extension
-    digester.addBeanPropertySetter("faces-config/converter/converter-extension/long-description",
-                                   "longDescription");
-    digester.addBeanPropertySetter("faces-config/converter/converter-extension/tag-class",
-                                   "tagClass");
-    digester.addRule("faces-config/converter/converter-extension/tag-name",
-                     new BeanPropertySetterRule("tagName"));
-    digester.addCallMethod("faces-config/converter/converter-extension/tag-class-modifier",
-                           "parseTagClassModifier", 1);
-    digester.addCallParam("faces-config/converter/converter-extension/tag-class-modifier", 0);
+  protected Digester createDigester() throws ParserConfigurationException, SAXException
+  {
+    Digester digester = createEmptyDigester();
 
-    // faces-config/converter/property/property-extension
-    digester.addBeanPropertySetter("faces-config/converter/property/property-extension/tag-attribute-excluded",
-                                   "tagAttributeExcluded");
+    addComponentDigesterRules(digester, true);
 
-    // faces-config/validator/validator-extension
-    digester.addBeanPropertySetter("faces-config/validator/validator-extension/long-description",
-                                   "longDescription");
-    digester.addBeanPropertySetter("faces-config/validator/validator-extension/tag-class",
-                                   "tagClass");
-    digester.addRule("faces-config/validator/validator-extension/tag-name",
-                     new BeanPropertySetterRule("tagName"));
-    digester.addCallMethod("faces-config/validator/validator-extension/tag-class-modifier",
-                           "parseTagClassModifier", 1);
-    digester.addCallParam("faces-config/validator/validator-extension/tag-class-modifier", 0);
+   //digester.addObjectCreate("faces-config", FacesConfigBean.class);
 
-    // faces-config/validator/property/property-extension
-    digester.addBeanPropertySetter("faces-config/validator/property/property-extension/tag-attribute-excluded",
-                                   "tagAttributeExcluded");
-    // faces-config/validator/property/property-extension/property-metada
-    digester.addBeanPropertySetter("faces-config/validator/property/property-extension/property-metadata/use-max-time",
-                                 "useMaxTime");
+    addConverterDigesterRules(digester);
+    addValidatorDigesterRules(digester);
+    addRenderKitDigesterRules(digester);
+    addEventDigesterRules(digester);
 
-    // faces-config/render-kit/renderer/renderer-extension
-    digester.addBeanPropertySetter("faces-config/render-kit/renderer/renderer-extension/component-type",
-                                   "componentType");
-    digester.addBeanPropertySetter("faces-config/render-kit/renderer/renderer-extension/renderer-superclass",
-                                   "rendererSuperclass");
+    // TBD: JSR-276 metadata (ask Jeff Stephenson)
 
     return digester;
   }
@@ -400,4 +472,4 @@
       return included;
     }
   }
-}
+}
\ No newline at end of file
diff --git a/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java b/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
index 0ce723d..cb9d0f0 100644
--- a/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
+++ b/maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java
@@ -52,10 +52,12 @@
 import org.apache.maven.reporting.AbstractMavenMultiPageReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.maven.reporting.sink.SinkFactory;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AbstractTagBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventRefBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ExampleBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigParser;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacetBean;
@@ -399,6 +401,9 @@
       out.write(" <p>\n");
       _writeComponentSummary(out, component);
       out.write(" </p>\n");
+      out.write(" <p>\n");
+      _writeExamples(out, component);
+      out.write(" </p>\n");
       out.write(" </section>\n");
       
       if (component.hasEvents(true))
@@ -464,6 +469,9 @@
       out.write(" <p>\n");
       _writeConverterSummary(out, converter);
       out.write(" </p>\n");
+      out.write(" <p>\n");
+      _writeExamples(out, converter);
+      out.write(" </p>\n");
       out.write(" </section>\n");
             
       out.write(" <section name=\"Attributes\">\n");
@@ -511,6 +519,9 @@
       out.write(" <p>\n");
       _writeValidatorSummary(out, validator);
       out.write(" </p>\n");
+      out.write(" <p>\n");
+      _writeExamples(out, validator);
+      out.write(" </p>\n");
       out.write(" </section>\n");
             
       out.write(" <section name=\"Attributes\">\n");
@@ -629,7 +640,7 @@
 
     return in;
   }
-  
+
   static private final String _platformAgnosticPath(String path) {
       return path.replace('/', File.separatorChar);
   }
@@ -973,7 +984,7 @@
       {
         if (i > 0)
           out.write(",<br/>");
-        out.write((String) phases[i]);
+        out.write(phases[i]);
       }
 
       out.write("</td>");
@@ -985,9 +996,6 @@
   }
 
 
-
-
-
   private void _writeComponentFacets(Writer out, ComponentBean bean) throws IOException
   {
     // Sort the facets
@@ -1026,6 +1034,50 @@
 
 
 
+  private void _writeExamples(Writer out, AbstractTagBean bean) throws IOException
+  {
+    if (!bean.hasExamples())
+      return;
+    
+    ExampleBean exBean = null;
+
+    // Write header
+    out.write("   <b>Example(s):</b> ");
+    out.write("   <br/>\n");
+    out.write("   <html>\n");
+    
+    // Go through each example, write its description
+    // followed by the example source code.
+    Iterator iter = bean.examples();
+    while (iter.hasNext())
+    {
+      exBean = (ExampleBean) iter.next();
+      String desc   = exBean.getSourceDescription();
+      String source = exBean.getSourceCode();
+      
+      if (desc != null)
+      {
+        desc = desc.replaceAll("<", "&lt;");
+        desc = desc.replaceAll(">", "&gt;");
+        
+        if (!"".equals(desc))
+          out.write("   <p>" + desc + "</p>");
+      }
+
+      if (source != null)
+      {
+        source = source.replaceAll("<", "&lt;");
+        source = source.replaceAll(">", "&gt;");
+        if (!"".equals(source))
+        {
+          out.write("    <div class=\'source\'>\n");
+          out.write("      <pre>\n" + source + "</pre>\n");
+          out.write("    </div>\n");
+        }
+      }
+    }
+    out.write("   </html>\n");
+  }
 
   protected MavenProject getProject()
   {
@@ -1187,7 +1239,7 @@
       List classpathElements = project.getCompileClasspathElements();
       if (!classpathElements.isEmpty())
       {
-        String[] entries = (String[])classpathElements.toArray(new String[0]);
+        String[] entries = (String[]) classpathElements.toArray(new String[0]);
         URL[] urls = new URL[entries.length];
         for (int i=0; i < urls.length; i++)
         {