Author: mrdon
Date: Sat Jan  6 12:25:24 2007
New Revision: 493563

URL: http://svn.apache.org/viewvc?view=rev&rev=493563
Log:
Improving annotations and processing for html taglib docs
WW-1392

Modified:
    struts/maven/trunk/struts-annotations/pom.xml
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTag.java
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTagAttribute.java
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
    
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java

Modified: struts/maven/trunk/struts-annotations/pom.xml
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/pom.xml?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- struts/maven/trunk/struts-annotations/pom.xml (original)
+++ struts/maven/trunk/struts-annotations/pom.xml Sat Jan  6 12:25:24 2007
@@ -1,73 +1,79 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-
-    <parent>
-        <groupId>org.apache.struts</groupId>
-        <artifactId>struts-master</artifactId>
-        <version>3</version>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.apache.struts</groupId>
-    <artifactId>struts-annotations</artifactId>
-    <version>2.0.2-SNAPSHOT</version>
-    <packaging>jar</packaging>
-    <name>Struts Annotations</name>
-    <url>http://struts.apache.org</url>
-
-    <scm>
-        
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/maven/trunk/</connection>
-        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/maven/trunk/</developerConnection>
-        <url>http://svn.apache.org/viewcvs.cgi/struts/maven/trunk/</url>
-    </scm>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <distributionManagement>
-        <repository>
-            <id>apache.snapshots</id>
-            <name>Apache Maven Repository (Snapshots and Test Builds)</name>
-            
<url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
-        </repository>
-        <snapshotRepository>
-            <id>apache.snapshots</id>
-            <uniqueVersion>false</uniqueVersion>
-            <name>Apache Maven Repository (Snapshots and Test Builds)</name>
-            
<url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
-        </snapshotRepository>
-        <site>
-            <id>apache-site</id>
-            <url>scp://people.apache.org/www/struts.apache.org/2.x/</url>
-        </site>
-    </distributionManagement>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>com.sun</groupId>
-            <artifactId>tools</artifactId>
-            <version>1.5.0</version>
-            <scope>system</scope>
-            <systemPath>${java.home}/../lib/tools.jar</systemPath>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>3.8.1</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <parent>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts-master</artifactId>
+        <version>3</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.struts</groupId>
+    <artifactId>struts-annotations</artifactId>
+    <version>2.0.2-SNAPSHOT</version>
+    <packaging>jar</packaging>
+    <name>Struts Annotations</name>
+    <url>http://struts.apache.org</url>
+
+    <scm>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/maven/trunk/</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/maven/trunk/</developerConnection>
+        <url>http://svn.apache.org/viewcvs.cgi/struts/maven/trunk/</url>
+    </scm>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <distributionManagement>
+        <repository>
+            <id>apache.snapshots</id>
+            <name>Apache Maven Repository (Snapshots and Test Builds)</name>
+            
<url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
+        </repository>
+        <snapshotRepository>
+            <id>apache.snapshots</id>
+            <uniqueVersion>false</uniqueVersion>
+            <name>Apache Maven Repository (Snapshots and Test Builds)</name>
+            
<url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
+        </snapshotRepository>
+        <site>
+            <id>apache-site</id>
+            <url>scp://people.apache.org/www/struts.apache.org/2.x/</url>
+        </site>
+    </distributionManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+            <version>1.5.0</version>
+            <scope>system</scope>
+            <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+
+       <dependency>
+            <groupId>freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>2.3.4</version>
+        </dependency>
+    </dependencies>
+</project>

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTag.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTag.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTag.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTag.java
 Sat Jan  6 12:25:24 2007
@@ -1,33 +1,36 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
[EMAIL PROTECTED](ElementType.TYPE)
-public @interface StrutsTag {
-  String name();
-  String tldBodyContent();
-  String tldTagClass();
-  String description();
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
[EMAIL PROTECTED](ElementType.TYPE)
[EMAIL PROTECTED](RetentionPolicy.SOURCE)
+public @interface StrutsTag {
+  String name();
+  String tldBodyContent() default "JSP";
+  String tldTagClass();
+  String description();
+}

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTagAttribute.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTagAttribute.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTagAttribute.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/StrutsTagAttribute.java
 Sat Jan  6 12:25:24 2007
@@ -1,35 +1,38 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
[EMAIL PROTECTED](ElementType.METHOD)
-public @interface StrutsTagAttribute {
-  String name() default "";
-  boolean required();
-  boolean rtexprvalue() default true;
-  String description();
-  String defaultValue() default "";
-  String type() default "String";
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
[EMAIL PROTECTED](ElementType.METHOD)
[EMAIL PROTECTED](RetentionPolicy.SOURCE)
+public @interface StrutsTagAttribute {
+  String name() default "";
+  boolean required() default false;
+  boolean rtexprvalue() default true;
+  String description();
+  String defaultValue() default "";
+  String type() default "String";
+}

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TLDAnnotationProcessorFactory.java
 Sat Jan  6 12:25:24 2007
@@ -1,76 +1,77 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations.taglib.apt;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessors;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class TLDAnnotationProcessorFactory implements 
AnnotationProcessorFactory {
-
-  /**
-   * Returns a TLD annotation processor.
-   *
-   * @return An annotation processor for note annotations if requested, 
otherwise, returns the NO_OP
-   *         annotation processor.
-   */
-  public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 
declarations,
-      AnnotationProcessorEnvironment env) {
-    AnnotationProcessor result;
-    if (declarations.isEmpty()) {
-      result = AnnotationProcessors.NO_OP;
-    } else {
-      result = new TagAnnotationProcessor(env);
-    }
-    return result;
-  }
-
-  /**
-   * This factory builds a processor for Tag and TagAttribute
-   *
-   * @return a collection containing StutsTag and StrutsTagAttribute
-   */
-  public Collection<String> supportedAnnotationTypes() {
-    return Arrays.asList(TagAnnotationProcessor.TAG, 
TagAnnotationProcessor.TAG_ATTRIBUTE);
-  }
-
-  /**
-   * Options used to generate the TLD
-   *
-   * @return an empty list.
-   */
-  public Collection<String> supportedOptions() {
-    return Arrays.asList("-AoutFile",
-        "-AtlibVersion",
-        "-AjspVersion",
-        "-AshortName",
-        "-Auri",
-        "-Adescription",
-        "-AdisplayName");
-  }
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations.taglib.apt;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Set;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.AnnotationProcessorFactory;
+import com.sun.mirror.apt.AnnotationProcessors;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+
+public class TLDAnnotationProcessorFactory implements 
AnnotationProcessorFactory {
+
+  /**
+   * Returns a TLD annotation processor.
+   *
+   * @return An annotation processor for note annotations if requested, 
otherwise, returns the NO_OP
+   *         annotation processor.
+   */
+  public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 
declarations,
+      AnnotationProcessorEnvironment env) {
+    AnnotationProcessor result;
+    if (declarations.isEmpty()) {
+      result = AnnotationProcessors.NO_OP;
+    } else {
+      result = new TagAnnotationProcessor(env);
+    }
+    return result;
+  }
+
+  /**
+   * This factory builds a processor for Tag and TagAttribute
+   *
+   * @return a collection containing StutsTag and StrutsTagAttribute
+   */
+  public Collection<String> supportedAnnotationTypes() {
+    return Arrays.asList(TagAnnotationProcessor.TAG, 
TagAnnotationProcessor.TAG_ATTRIBUTE);
+  }
+
+  /**
+   * Options used to generate the TLD
+   *
+   * @return an empty list.
+   */
+  public Collection<String> supportedOptions() {
+    return Arrays.asList("-AoutFile",
+        "-AtlibVersion",
+        "-AjspVersion",
+        "-AshortName",
+        "-Auri",
+        "-Adescription",
+        "-AdisplayName",
+        "-outTemplatesDir");
+  }
+}

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/Tag.java
 Sat Jan  6 12:25:24 2007
@@ -1,92 +1,93 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations.taglib.apt;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-public class Tag {
-  private String name;
-  private String tldBodyContent;
-  private String tldTagClass;
-  private String description;
-  private boolean include = true;
-  private String declaredType;
-
-  private Map<String, TagAttribute> attributes = new HashMap<String, 
TagAttribute>();
-
-  public String getDescription() {
-    return description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getTldBodyContent() {
-    return tldBodyContent;
-  }
-
-  public void setTldBodyContent(String tldBodyContent) {
-    this.tldBodyContent = tldBodyContent;
-  }
-
-  public String getTldTagClass() {
-    return tldTagClass;
-  }
-
-  public void setTldTagClass(String tldTagClass) {
-    this.tldTagClass = tldTagClass;
-  }
-
-  public void addTagAttribute(TagAttribute attribute) {
-    attributes.put(attribute.getName(), attribute);
-  }
-
-  public Collection<TagAttribute> getAttributes() {
-    return attributes.values();
-  }
-
-  public boolean isInclude() {
-    return include;
-  }
-
-  public void setInclude(boolean include) {
-    this.include = include;
-  }
-
-  public String getDeclaredType() {
-    return declaredType;
-  }
-
-  public void setDeclaredType(String declaredType) {
-    this.declaredType = declaredType;
-  }
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations.taglib.apt;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Tag {
+  private String name;
+  private String tldBodyContent;
+  private String tldTagClass;
+  private String description;
+  private boolean include = true;
+  private String declaredType;
+
+  private Map<String, TagAttribute> attributes = new HashMap<String, 
TagAttribute>();
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getTldBodyContent() {
+    return tldBodyContent;
+  }
+
+  public void setTldBodyContent(String tldBodyContent) {
+    this.tldBodyContent = tldBodyContent;
+  }
+
+  public String getTldTagClass() {
+    return tldTagClass;
+  }
+
+  public void setTldTagClass(String tldTagClass) {
+    this.tldTagClass = tldTagClass;
+  }
+
+  public void addTagAttribute(TagAttribute attribute) {
+    if(!attributes.containsKey(attribute.getName()))
+      attributes.put(attribute.getName(), attribute);
+  }
+
+  public Collection<TagAttribute> getAttributes() {
+    return attributes.values();
+  }
+
+  public boolean isInclude() {
+    return include;
+  }
+
+  public void setInclude(boolean include) {
+    this.include = include;
+  }
+
+  public String getDeclaredType() {
+    return declaredType;
+  }
+
+  public void setDeclaredType(String declaredType) {
+    this.declaredType = declaredType;
+  }
+}

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
 Sat Jan  6 12:25:24 2007
@@ -1,299 +1,352 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations.taglib.apt;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class TagAnnotationProcessor implements AnnotationProcessor {
-  public static final String TAG = "org.apache.struts.annotations.StrutsTag";
-  public static final String TAG_ATTRIBUTE = 
"org.apache.struts.annotations.StrutsTagAttribute";
-
-  private AnnotationProcessorEnvironment environment;
-  private AnnotationTypeDeclaration tagDeclaration;
-  private AnnotationTypeDeclaration tagAttributeDeclaration;
-  private Map<String, Tag> tags = new HashMap<String, Tag>();
-
-  public TagAnnotationProcessor(AnnotationProcessorEnvironment env) {
-    environment = env;
-    tagDeclaration = (AnnotationTypeDeclaration) 
environment.getTypeDeclaration(TAG);
-    tagAttributeDeclaration = (AnnotationTypeDeclaration) environment
-        .getTypeDeclaration(TAG_ATTRIBUTE);
-  }
-
-  public void process() {
-    //make sure all paramters were set
-    checkOptions();
-
-    // tags
-    Collection<Declaration> tagDeclarations = environment
-        .getDeclarationsAnnotatedWith(tagDeclaration);
-    Collection<Declaration> attributesDeclarations = environment
-        .getDeclarationsAnnotatedWith(tagAttributeDeclaration);
-
-    // find Tags
-    for (Declaration declaration : tagDeclarations) {
-      // type
-      TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
-      String typeName = typeDeclaration.getQualifiedName();
-      HashMap<String, Object> values = getValues(typeDeclaration, 
tagDeclaration);
-      // create Tag and apply values found
-      Tag tag = new Tag();
-      tag.setDescription((String) values.get("description"));
-      tag.setName((String) values.get("name"));
-      tag.setTldBodyContent((String) values.get("tldBodyContent"));
-      tag.setTldTagClass((String) values.get("tldTagClass"));
-      tag.setDeclaredType(typeName);
-      // add to map
-      tags.put(typeName, tag);
-    }
-
-    // find Tags Attributes
-    for (Declaration declaration : attributesDeclarations) {
-      // type
-      MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
-      String typeName = 
methodDeclaration.getDeclaringType().getQualifiedName();
-      HashMap<String, Object> values = getValues(methodDeclaration, 
tagAttributeDeclaration);
-      // create Attribute and apply values found
-      TagAttribute attribute = new TagAttribute();
-      attribute.setDescription((String) values.get("description"));
-      String name = (String) values.get("name");
-      if(name == null || name.length() == 0) {
-        //get name from method
-        String methodName = methodDeclaration.getSimpleName();
-        name = String.valueOf(Character.toLowerCase(methodName.charAt(3))) + 
methodName.substring(4);
-      }
-      methodDeclaration.getSimpleName();
-      attribute.setName(name);
-      attribute.setRequired((Boolean) values.get("required"));
-      attribute.setRtexprvalue((Boolean) values.get("rtexprvalue"));
-      // add to map
-      Tag parentTag = tags.get(typeName);
-      if(parentTag != null)
-        tags.get(typeName).addTagAttribute(attribute);
-      else {
-        //an abstract or base class
-        parentTag = new Tag();
-        parentTag.setDeclaredType(typeName);
-        parentTag.setInclude(false);
-        parentTag.addTagAttribute(attribute);
-        tags.put(typeName, parentTag);
-      }
-    }
-
-    //we can't process the hierarchy on the first pass because
-    //apt does not garantees that the base classes will be processed
-    //before their subclasses
-    for(Map.Entry<String, Tag> entry : tags.entrySet()) {
-      processHierarchy(entry.getValue());
-    }
-    // save as xml
-    save();
-  }
-
-  private void processHierarchy(Tag tag) {
-    try {
-      Class clazz = Class.forName(tag.getDeclaredType());
-      while((clazz = clazz.getSuperclass()) != null) {
-        Tag parentTag = tags.get(clazz.getName());
-        //copy parent annotations to this tag
-        if(parentTag != null) {
-          for(TagAttribute attribute : parentTag.getAttributes()) {
-            tag.addTagAttribute(attribute);
-          }
-        }
-      }
-    } catch (ClassNotFoundException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  private void checkOptions() {
-    if(getOption("tlibVersion") == null)
-      throw new IllegalArgumentException("'tlibVersion' is missing");
-    if(getOption("jspVersion") == null)
-      throw new IllegalArgumentException("'jspVersion' is missing");
-    if(getOption("shortName") == null)
-      throw new IllegalArgumentException("'shortName' is missing");
-    if(getOption("description") == null)
-      throw new IllegalArgumentException("'description' is missing");
-    if(getOption("displayName") == null)
-      throw new IllegalArgumentException("'displayName' is missing");
-    if(getOption("uri") == null)
-      throw new IllegalArgumentException("'uri' is missing");
-  }
-
-  private void save() {
-    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-    DocumentBuilder builder;
-
-    try {
-      // create xml document
-      builder = factory.newDocumentBuilder();
-      Document document = builder.newDocument();
-      document.setXmlVersion("1.0");
-
-      // taglib
-      Element tagLib = document.createElement("taglib");
-      document.appendChild(tagLib);
-      // tag lib attributes
-      appendTextNode(document, tagLib, "tlib-version", 
getOption("tlibVersion"), false);
-      appendTextNode(document, tagLib, "jsp-version", getOption("jspVersion"), 
false);
-      appendTextNode(document, tagLib, "short-name", getOption("shortName"), 
false);
-      appendTextNode(document, tagLib, "uri", getOption("uri"), false);
-      appendTextNode(document, tagLib, "display-name", 
getOption("displayName"), false);
-      appendTextNode(document, tagLib, "description", 
getOption("description"), true);
-
-      // create tags
-      for (Map.Entry<String, Tag> entry : tags.entrySet()) {
-        Tag tag = entry.getValue();
-        if(tag.isInclude())
-          createElement(document, tagLib, tag);
-      }
-
-      // save to file
-      TransformerFactory tf = TransformerFactory.newInstance();
-      tf.setAttribute("indent-number", new Integer(2));
-      Transformer transformer = tf.newTransformer();
-      //if tiger would just format it :(
-      //formatting bug in tiger 
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446)
-
-      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-      transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "-//Sun 
Microsystems, Inc.//DTD JSP Tag Library 1.2//EN");
-      transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, 
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd";);
-      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-
-      Source source = new DOMSource(document);
-      Result result = new StreamResult(new OutputStreamWriter(new 
FileOutputStream(getOption("out"))));
-      transformer.transform(source, result);
-    } catch (Exception e) {
-      // oops we cannot throw checked exceptions
-      throw new RuntimeException(e);
-    }
-  }
-
-  private String getOption(String name) {
-    // there is a bug in the 1.5 apt implementation:
-    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6258929
-    // this is a hack-around
-    if (environment.getOptions().containsKey(name))
-      return environment.getOptions().get(name);
-
-    for (Map.Entry<String, String> entry : 
environment.getOptions().entrySet()) {
-      String key = entry.getKey();
-      if (key.startsWith("-A" + name))
-        return key.substring(key.indexOf("=") + 1);
-    }
-    return null;
-  }
-
-  private void createElement(Document doc, Element tagLibElement, Tag tag) {
-    Element tagElement = doc.createElement("tag");
-    tagLibElement.appendChild(tagElement);
-    appendTextNode(doc, tagElement, "name", tag.getName(), false);
-    appendTextNode(doc, tagElement, "tag-class", tag.getTldTagClass(), false);
-    appendTextNode(doc, tagElement, "body-content", tag.getTldBodyContent(), 
false);
-    appendTextNode(doc, tagElement, "description", tag.getDescription(), true);
-
-    // save attributes
-    for (TagAttribute attribute : tag.getAttributes()) {
-      createElement(doc, tagElement, attribute);
-    }
-
-  }
-
-  private void createElement(Document doc, Element tagElement, TagAttribute 
attribute) {
-    Element attributeElement = doc.createElement("attribute");
-    tagElement.appendChild(attributeElement);
-    appendTextNode(doc, attributeElement, "name", attribute.getName(), false);
-    appendTextNode(doc, attributeElement, "required", 
String.valueOf(attribute.isRequired()), false);
-    appendTextNode(doc,
-        attributeElement,
-        "rtexprvalue",
-        String.valueOf(attribute.isRtexprvalue()),
-        false);
-    appendTextNode(doc, attributeElement, "description", 
attribute.getDescription(), true);
-  }
-
-  private void appendTextNode(Document doc, Element element, String name, 
String text, boolean cdata) {
-    Text textNode = cdata ? doc.createCDATASection(text) : 
doc.createTextNode(text);
-    Element newElement = doc.createElement(name);
-    newElement.appendChild(textNode);
-    element.appendChild(newElement);
-  }
-
-  /**
-   * Get values of annotation
-   *
-   * @param declaration
-   * @param type
-   *          The type of the annotation
-   * @return name->value map of annotation values
-   */
-  private HashMap<String, Object> getValues(Declaration declaration, 
AnnotationTypeDeclaration type) {
-    HashMap<String, Object> values = new HashMap<String, Object>();
-    Collection<AnnotationMirror> annotations = 
declaration.getAnnotationMirrors();
-    // iterate over the mirrors.
-    for (AnnotationMirror mirror : annotations) {
-      // if the mirror in this iteration is for our note declaration...
-      if (mirror.getAnnotationType().getDeclaration().equals(type)) {
-
-        // print out the goodies.
-        Map<AnnotationTypeElementDeclaration, AnnotationValue> 
annotationValues = mirror
-            .getElementValues();
-
-        for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> 
entry : annotationValues
-            .entrySet()) {
-          AnnotationTypeElementDeclaration key = entry.getKey();
-          AnnotationValue value = entry.getValue();
-          values.put(key.getSimpleName(), value.getValue());
-        }
-      }
-    }
-    return values;
-  }
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations.taglib.apt;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
+import com.sun.mirror.declaration.AnnotationValue;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.TypeDeclaration;
+
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.Template;
+
+public class TagAnnotationProcessor implements AnnotationProcessor {
+  public static final String TAG = "org.apache.struts.annotations.StrutsTag";
+  public static final String TAG_ATTRIBUTE = 
"org.apache.struts.annotations.StrutsTagAttribute";
+
+  private AnnotationProcessorEnvironment environment;
+  private AnnotationTypeDeclaration tagDeclaration;
+  private AnnotationTypeDeclaration tagAttributeDeclaration;
+  private Map<String, Tag> tags = new HashMap<String, Tag>();
+
+  public TagAnnotationProcessor(AnnotationProcessorEnvironment env) {
+    environment = env;
+    tagDeclaration = (AnnotationTypeDeclaration) 
environment.getTypeDeclaration(TAG);
+    tagAttributeDeclaration = (AnnotationTypeDeclaration) environment
+        .getTypeDeclaration(TAG_ATTRIBUTE);
+  }
+
+  public void process() {
+    //make sure all paramters were set
+    checkOptions();
+
+    // tags
+    Collection<Declaration> tagDeclarations = environment
+        .getDeclarationsAnnotatedWith(tagDeclaration);
+    Collection<Declaration> attributesDeclarations = environment
+        .getDeclarationsAnnotatedWith(tagAttributeDeclaration);
+
+    // find Tags
+    for (Declaration declaration : tagDeclarations) {
+      // type
+      TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
+      String typeName = typeDeclaration.getQualifiedName();
+      HashMap<String, Object> values = getValues(typeDeclaration, 
tagDeclaration);
+      // create Tag and apply values found
+      Tag tag = new Tag();
+      tag.setDescription((String) values.get("description"));
+      tag.setName((String) values.get("name"));
+      tag.setTldBodyContent((String) values.get("tldBodyContent"));
+      tag.setTldTagClass((String) values.get("tldTagClass"));
+      tag.setDeclaredType(typeName);
+      // add to map
+      tags.put(typeName, tag);
+    }
+
+    // find Tags Attributes
+    for (Declaration declaration : attributesDeclarations) {
+      // type
+      MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
+      String typeName = 
methodDeclaration.getDeclaringType().getQualifiedName();
+      HashMap<String, Object> values = getValues(methodDeclaration, 
tagAttributeDeclaration);
+      // create Attribute and apply values found
+      TagAttribute attribute = new TagAttribute();
+      attribute.setDescription((String) values.get("description"));
+      String name = (String) values.get("name");
+      if(name == null || name.length() == 0) {
+        //get name from method
+        String methodName = methodDeclaration.getSimpleName();
+        name = String.valueOf(Character.toLowerCase(methodName.charAt(3))) + 
methodName.substring(4);
+      }
+      attribute.setName(name);
+      attribute.setRequired((Boolean) values.get("required"));
+      attribute.setRtexprvalue((Boolean) values.get("rtexprvalue"));
+      attribute.setDefaultValue((String) values.get("defaultValue"));
+      // add to map
+      Tag parentTag = tags.get(typeName);
+      if(parentTag != null)
+        tags.get(typeName).addTagAttribute(attribute);
+      else {
+        //an abstract or base class
+        parentTag = new Tag();
+        parentTag.setDeclaredType(typeName);
+        parentTag.setInclude(false);
+        parentTag.addTagAttribute(attribute);
+        tags.put(typeName, parentTag);
+      }
+    }
+
+    //we can't process the hierarchy on the first pass because
+    //apt does not garantees that the base classes will be processed
+    //before their subclasses
+    for(Map.Entry<String, Tag> entry : tags.entrySet()) {
+      processHierarchy(entry.getValue());
+    }
+
+    //save
+    saveAsXml();
+    saveTemplates();
+  }
+
+  private void processHierarchy(Tag tag) {
+    try {
+      Class clazz = Class.forName(tag.getDeclaredType());
+      while((clazz = clazz.getSuperclass()) != null) {
+        Tag parentTag = tags.get(clazz.getName());
+        //copy parent annotations to this tag
+        if(parentTag != null) {
+          for(TagAttribute attribute : parentTag.getAttributes()) {
+            tag.addTagAttribute(attribute);
+          }
+        }
+      }
+    } catch (ClassNotFoundException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  private void checkOptions() {
+    if(getOption("tlibVersion") == null)
+      throw new IllegalArgumentException("'tlibVersion' is missing");
+    if(getOption("jspVersion") == null)
+      throw new IllegalArgumentException("'jspVersion' is missing");
+    if(getOption("shortName") == null)
+      throw new IllegalArgumentException("'shortName' is missing");
+    if(getOption("description") == null)
+      throw new IllegalArgumentException("'description' is missing");
+    if(getOption("displayName") == null)
+      throw new IllegalArgumentException("'displayName' is missing");
+    if(getOption("uri") == null)
+      throw new IllegalArgumentException("'uri' is missing");
+    if(getOption("outTemplatesDir") == null)
+      throw new IllegalArgumentException("'outTemplatesDir' is missing");
+    if(getOption("outFile") == null)
+             throw new IllegalArgumentException("'outFile' is missing");
+  }
+
+  private void saveTemplates() {
+      //freemarker configuration
+      Configuration config = new Configuration();
+      config.setClassForTemplateLoading(getClass(), "");
+      config.setObjectWrapper(new DefaultObjectWrapper());
+
+      try {
+        //load template
+        Template template = config.getTemplate("tag.ftl");
+        String rootDir = (new 
File(getOption("outTemplatesDir"))).getAbsolutePath();
+        for(Tag tag : tags.values()) {
+            if(tag.isInclude()) {
+                //model
+                HashMap root = new HashMap();
+                root.put("tag", tag);
+
+                //save file
+                BufferedWriter writer = new BufferedWriter(new FileWriter(new 
File(rootDir, tag.getName() + ".html")));
+                try {
+                    template.process(root, writer);
+                } finally {
+                    writer.close();
+                }
+            }
+        }
+      } catch (Exception e) {
+        //oops we cannot throw checked exceptions
+        throw new RuntimeException(e);
+      }
+  }
+
+
+  private void saveAsXml() {
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    DocumentBuilder builder;
+
+    try {
+      // create xml document
+      builder = factory.newDocumentBuilder();
+      Document document = builder.newDocument();
+      document.setXmlVersion("1.0");
+
+      // taglib
+      Element tagLib = document.createElement("taglib");
+      document.appendChild(tagLib);
+      // tag lib attributes
+      appendTextNode(document, tagLib, "tlib-version", 
getOption("tlibVersion"), false);
+      appendTextNode(document, tagLib, "jsp-version", getOption("jspVersion"), 
false);
+      appendTextNode(document, tagLib, "short-name", getOption("shortName"), 
false);
+      appendTextNode(document, tagLib, "uri", getOption("uri"), false);
+      appendTextNode(document, tagLib, "display-name", 
getOption("displayName"), false);
+      appendTextNode(document, tagLib, "description", 
getOption("description"), true);
+
+      // create tags
+      for (Map.Entry<String, Tag> entry : tags.entrySet()) {
+        Tag tag = entry.getValue();
+        if(tag.isInclude())
+          createElement(document, tagLib, tag);
+      }
+
+      // save to file
+      TransformerFactory tf = TransformerFactory.newInstance();
+      tf.setAttribute("indent-number", new Integer(2));
+      Transformer transformer = tf.newTransformer();
+      //if tiger would just format it :(
+      //formatting bug in tiger 
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446)
+
+      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+      transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "-//Sun 
Microsystems, Inc.//DTD JSP Tag Library 1.2//EN");
+      transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, 
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd";);
+      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+
+      Source source = new DOMSource(document);
+      Result result = new StreamResult(new OutputStreamWriter(new 
FileOutputStream(getOption("outFile"))));
+      transformer.transform(source, result);
+    } catch (Exception e) {
+      // oops we cannot throw checked exceptions
+      throw new RuntimeException(e);
+    }
+  }
+
+  private String getOption(String name) {
+    // there is a bug in the 1.5 apt implementation:
+    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6258929
+    // this is a hack-around
+    if (environment.getOptions().containsKey(name))
+      return environment.getOptions().get(name);
+
+    for (Map.Entry<String, String> entry : 
environment.getOptions().entrySet()) {
+      String key = entry.getKey();
+      String[] splitted = key.split("=");
+      if (splitted[0].equals("-A" + name))
+        return splitted[1];
+    }
+    return null;
+  }
+
+  private void createElement(Document doc, Element tagLibElement, Tag tag) {
+    Element tagElement = doc.createElement("tag");
+    tagLibElement.appendChild(tagElement);
+    appendTextNode(doc, tagElement, "name", tag.getName(), false);
+    appendTextNode(doc, tagElement, "tag-class", tag.getTldTagClass(), false);
+    appendTextNode(doc, tagElement, "body-content", tag.getTldBodyContent(), 
false);
+    appendTextNode(doc, tagElement, "description", tag.getDescription(), true);
+
+    // save attributes
+    for (TagAttribute attribute : tag.getAttributes()) {
+      createElement(doc, tagElement, attribute);
+    }
+
+  }
+
+  private void createElement(Document doc, Element tagElement, TagAttribute 
attribute) {
+    Element attributeElement = doc.createElement("attribute");
+    tagElement.appendChild(attributeElement);
+    appendTextNode(doc, attributeElement, "name", attribute.getName(), false);
+    appendTextNode(doc, attributeElement, "required", 
String.valueOf(attribute.isRequired()), false);
+    appendTextNode(doc,
+        attributeElement,
+        "rtexprvalue",
+        String.valueOf(attribute.isRtexprvalue()),
+        false);
+    appendTextNode(doc, attributeElement, "description", 
attribute.getDescription(), true);
+  }
+
+  private void appendTextNode(Document doc, Element element, String name, 
String text, boolean cdata) {
+    Text textNode = cdata ? doc.createCDATASection(text) : 
doc.createTextNode(text);
+    Element newElement = doc.createElement(name);
+    newElement.appendChild(textNode);
+    element.appendChild(newElement);
+  }
+
+  /**
+   * Get values of annotation
+   *
+   * @param declaration
+   * @param type
+   *          The type of the annotation
+   * @return name->value map of annotation values
+   */
+  private HashMap<String, Object> getValues(Declaration declaration, 
AnnotationTypeDeclaration type) {
+    HashMap<String, Object> values = new HashMap<String, Object>();
+    Collection<AnnotationMirror> annotations = 
declaration.getAnnotationMirrors();
+    // iterate over the mirrors.
+
+    for (AnnotationMirror mirror : annotations) {
+      // if the mirror in this iteration is for our note declaration...
+      if (mirror.getAnnotationType().getDeclaration().equals(type)) {
+        for(AnnotationTypeElementDeclaration annotationType : 
mirror.getElementValues().keySet()) {
+          Object value = 
mirror.getElementValues().get(annotationType).getValue();
+          Object defaultValue = annotationType.getDefaultValue();
+          values.put(annotationType.getSimpleName(), value != null ? value : 
defaultValue);
+        }
+      }
+    }
+
+    //find default values...painful
+    for(AnnotationTypeElementDeclaration annotationType : type.getMethods()) {
+        AnnotationValue value = annotationType.getDefaultValue();
+        if(value != null) {
+            String name = annotationType.getSimpleName();
+            if(!values.containsKey(name))
+                values.put(name, value.getValue());
+        }
+    }
+
+    return values;
+  }
+}

Modified: 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java
URL: 
http://svn.apache.org/viewvc/struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java?view=diff&rev=493563&r1=493562&r2=493563
==============================================================================
--- 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java
 (original)
+++ 
struts/maven/trunk/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAttribute.java
 Sat Jan  6 12:25:24 2007
@@ -1,65 +1,74 @@
-/*
- * $Id:  $
- *
- * 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.struts.annotations.taglib.apt;
-
-/**
- * Used to hold tag attribute information for TLD generation
- *
- */
-class TagAttribute {
-  private String name;
-  private boolean required;
-  private boolean rtexprvalue;
-  private String description;
-
-  public String getDescription() {
-    return description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public boolean isRequired() {
-    return required;
-  }
-
-  public void setRequired(boolean required) {
-    this.required = required;
-  }
-
-  public boolean isRtexprvalue() {
-    return rtexprvalue;
-  }
-
-  public void setRtexprvalue(boolean rtexprvalue) {
-    this.rtexprvalue = rtexprvalue;
-  }
-}
+/*
+ * $Id:  $
+ *
+ * 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.struts.annotations.taglib.apt;
+
+/**
+ * Used to hold tag attribute information for TLD generation
+ *
+ */
+public class TagAttribute {
+  private String name;
+  private boolean required;
+  private boolean rtexprvalue;
+  private String description;
+  private String defaultValue;
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public boolean isRequired() {
+    return required;
+  }
+
+  public void setRequired(boolean required) {
+    this.required = required;
+  }
+
+  public boolean isRtexprvalue() {
+    return rtexprvalue;
+  }
+
+  public void setRtexprvalue(boolean rtexprvalue) {
+    this.rtexprvalue = rtexprvalue;
+  }
+
+  public String getDefaultValue() {
+    return defaultValue;
+  }
+
+  public void setDefaultValue(String defaultValue) {
+    this.defaultValue = defaultValue;
+  }
+}


Reply via email to