You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/04/15 11:13:06 UTC

svn commit: r1587479 [6/6] - in /myfaces/tobago/branches/tobago-3.0.x: ./ tobago-assembly/ tobago-core/ tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/ tobago-core/src/m...

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java?rev=1587479&r1=1587478&r2=1587479&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java Tue Apr 15 09:13:03 2014
@@ -22,8 +22,6 @@ package org.apache.myfaces.tobago.apt.pr
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.apt.AnnotationUtils;
-import org.apache.myfaces.tobago.apt.annotation.BodyContent;
-import org.apache.myfaces.tobago.apt.annotation.BodyContentDescription;
 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
 import org.apache.myfaces.tobago.apt.annotation.Facet;
 import org.apache.myfaces.tobago.apt.annotation.Preliminary;
@@ -72,7 +70,6 @@ import java.util.Set;
     "org.apache.myfaces.tobago.apt.annotation.TagAttribute",
     "org.apache.myfaces.tobago.apt.annotation.Taglib"})
 @SupportedOptions({
-    TaglibGenerator.JSF_VERSION,
     TaglibGenerator.TARGET_TAGLIB})
 public class TaglibGenerator extends AbstractGenerator {
 
@@ -82,17 +79,14 @@ public class TaglibGenerator extends Abs
   private Set<String> attributeSet = new HashSet<String>();
   private String currentTag;
 
-  private String jsfVersion;
   private String targetTaglib;
 
   public void configure() {
     final Map<String, String> options = processingEnv.getOptions();
-    jsfVersion = options.get(JSF_VERSION);
     targetTaglib = options.get(TARGET_TAGLIB);
 
     info("Generating the *.tld and *.taglib.xml");
     info("Options:");
-    info(JSF_VERSION + ": " + jsfVersion);
     info(TARGET_TAGLIB + ": " + targetTaglib);
   }
 
@@ -101,12 +95,11 @@ public class TaglibGenerator extends Abs
     for (final PackageElement packageElement : getPackages()) {
       final Taglib taglibAnnotation = packageElement.getAnnotation(Taglib.class);
 
-      createTaglib(taglibAnnotation, packageElement, Type.JSP);
-      createTaglib(taglibAnnotation, packageElement, Type.FACELETS);
+      createTaglib(taglibAnnotation, packageElement);
     }
   }
 
-  protected void createTaglib(final Taglib taglibAnnotation, final PackageElement packageElement, final Type type)
+  protected void createTaglib(final Taglib taglibAnnotation, final PackageElement packageElement)
       throws ParserConfigurationException, ClassNotFoundException, IOException, TransformerException {
     resetDuplicateList();
     final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -117,7 +110,7 @@ public class TaglibGenerator extends Abs
     final DocumentBuilder parser = dbf.newDocumentBuilder();
     final Document document = parser.newDocument();
 
-    final Element taglib = type.createTaglib(document);
+    final Element taglib = createTaglib(document);
     final String description = processingEnv.getElementUtils().getDocComment(packageElement);
 
     addComment("The next tags are commented because of MYFACES-3537. "
@@ -133,13 +126,11 @@ public class TaglibGenerator extends Abs
     addLeafTextElement(taglibAnnotation.displayName(), "display-name", taglib, document);
 */
 
-    type.addMisc(taglib, document, taglibAnnotation);
-
-    type.addListeners(taglib, document, taglibAnnotation);
+    addLeafTextElement(taglibAnnotation.uri(), "namespace", taglib, document);
 
     for (final TypeElement typeElement : getTypes()) {
       if (processingEnv.getElementUtils().getPackageOf(typeElement).equals(packageElement)) {
-        appendTag(typeElement, taglib, document, type);
+        appendTag(typeElement, taglib, document);
       }
     }
     document.appendChild(taglib);
@@ -148,8 +139,9 @@ public class TaglibGenerator extends Abs
 
     Writer writer = null;
     try {
-      final String name
-          = type.filename(targetTaglib, packageElement.getQualifiedName().toString(), taglibAnnotation.name());
+      String target = targetTaglib;
+      target = StringUtils.isNotBlank(target) ? target + '/' : "";
+      final String name = target + taglibAnnotation.name() + ".taglib.xml";
       final FileObject resource = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", name);
       info("Writing to file: " + resource.toUri());
       writer = resource.openWriter();
@@ -165,42 +157,42 @@ public class TaglibGenerator extends Abs
   }
 
   protected void appendTag(
-      final TypeElement typeElement, final Element parent, final Document document, final Type type)
+      final TypeElement typeElement, final Element parent, final Document document)
       throws ClassNotFoundException {
     final Tag annotationTag = typeElement.getAnnotation(Tag.class);
     if (annotationTag != null) {
       checkDuplicates(annotationTag.name());
       resetAttributeDuplicateList();
       // TODO configure replacement
-      final String className;
-      if (typeElement.getAnnotation(SimpleTag.class) != null || typeElement.getAnnotation(ValidatorTag.class) != null) {
-        className = AnnotationUtils.generatedTagName(typeElement);
-      } else if (typeElement.getAnnotation(ExtensionTag.class) != null) {
-        className = typeElement.getQualifiedName().toString();
-      } else if (typeElement.getAnnotation(UIComponentTag.class) != null) {
-        className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(annotationTag.name())
-            + "Tag";
-      } else {
-        throw new RuntimeException("Not supported: " + typeElement.getQualifiedName());
-      }
-      info("Replacing: " + typeElement.getQualifiedName() + " -> " + className);
-      final Element tag = createTag(typeElement, annotationTag, className, document, false, type);
-      addAttributes(typeElement, tag, document, type);
+//      final String className;
+//      if (typeElement.getAnnotation(SimpleTag.class) != null || typeElement.getAnnotation(ValidatorTag.class) != null) {
+//        className = AnnotationUtils.generatedTagName(typeElement);
+//      } else if (typeElement.getAnnotation(ExtensionTag.class) != null) {
+//        className = typeElement.getQualifiedName().toString();
+//      } else if (typeElement.getAnnotation(UIComponentTag.class) != null) {
+//        className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(annotationTag.name())
+//            + "Tag";
+//      } else {
+//        throw new RuntimeException("Not supported: " + typeElement.getQualifiedName());
+//      }
+//      info("Replacing: " + typeElement.getQualifiedName() + " -> " + className);
+      final Element tag = createTag(typeElement, annotationTag, document, false);
+      addAttributes(typeElement, tag, document);
       parent.appendChild(tag);
       if (annotationTag.deprecatedName() != null && annotationTag.deprecatedName().length() > 0) {
-        final Element deprecatedTag = createTag(typeElement, annotationTag, className, document, true, type);
-        addAttributes(typeElement, deprecatedTag, document, type);
+        final Element deprecatedTag = createTag(typeElement, annotationTag, document, true);
+        addAttributes(typeElement, deprecatedTag, document);
         parent.appendChild(deprecatedTag);
       }
     }
   }
 
   protected Element createTag(
-      final TypeElement typeElement, final Tag annotationTag, final String className, final Document document,
-      final boolean deprecated, final Type type) {
+      final TypeElement typeElement, final Tag annotationTag, final Document document,
+      final boolean deprecated) {
     final Element tagElement = document.createElement("tag");
     addDescription(typeElement, tagElement, document, deprecated);
-    type.addTagContent(typeElement, tagElement, document, deprecated, annotationTag, className);
+    addTagContent(typeElement, tagElement, document, deprecated, annotationTag);
     return tagElement;
   }
 
@@ -222,11 +214,6 @@ public class TaglibGenerator extends Abs
   }
 
   protected void addDescription(
-      final javax.lang.model.element.Element typeElement, final Element element, final Document document) {
-    addDescription(typeElement, element, document, false);
-  }
-
-  protected void addDescription(
       final javax.lang.model.element.Element typeElement, final Element element, final Document document,
       final boolean deprecated) {
     final StringBuilder description = new StringBuilder();
@@ -364,7 +351,7 @@ public class TaglibGenerator extends Abs
   }
 
   protected void addAttributes(
-      final TypeElement typeElement, final Element tagElement, final Document document, final Type type)
+      final TypeElement typeElement, final Element tagElement, final Document document)
       throws ClassNotFoundException {
 
     for (final javax.lang.model.element.Element element : getAllMembers(typeElement)) {
@@ -374,7 +361,7 @@ public class TaglibGenerator extends Abs
             && executableElement.getAnnotation(UIComponentTagAttribute.class) == null) {
           continue;
         }
-        addAttribute(executableElement, tagElement, document, type);
+        addAttribute(executableElement, tagElement, document);
       }
     }
   }
@@ -399,7 +386,7 @@ public class TaglibGenerator extends Abs
   }
 
   protected void addAttribute(
-      final ExecutableElement element, final Element tagElement, final Document document, final Type type)
+      final ExecutableElement element, final Element tagElement, final Document document)
       throws ClassNotFoundException {
     final TagAttribute tagAttribute = element.getAnnotation(TagAttribute.class);
     if (tagAttribute != null) {
@@ -416,7 +403,7 @@ public class TaglibGenerator extends Abs
 
         addLeafTextElement(Boolean.toString(tagAttribute.required()), "required", attribute, document);
         final UIComponentTagAttribute componentTagAttribute = element.getAnnotation(UIComponentTagAttribute.class);
-        type.addAttributeType(attribute, tagAttribute, componentTagAttribute, document, attributeName);
+        addAttributeType(attribute, tagAttribute, componentTagAttribute, document);
         tagElement.appendChild(attribute);
       } else {
         throw new IllegalArgumentException("Only setter allowed found: " + simpleName);
@@ -424,199 +411,96 @@ public class TaglibGenerator extends Abs
     }
   }
 
-  protected static void addComment(final String text, final org.w3c.dom.Element parent, final Document document) {
+  protected void addComment(final String text, final org.w3c.dom.Element parent, final Document document) {
     final Comment comment = document.createComment(text);
     parent.appendChild(comment);
   }
 
-  protected static void addLeafTextElement(
+  protected void addLeafTextElement(
       final String text, final String node, final org.w3c.dom.Element parent, final Document document) {
     final org.w3c.dom.Element element = document.createElement(node);
     element.appendChild(document.createTextNode(text));
     parent.appendChild(element);
   }
 
-  protected static void addLeafCDATAElement(
+  protected void addLeafCDATAElement(
       final String text, final String node, final org.w3c.dom.Element parent, final Document document) {
     final org.w3c.dom.Element element = document.createElement(node);
     element.appendChild(document.createCDATASection(text));
     parent.appendChild(element);
   }
 
-  protected static enum Type {
-    JSP,
-    FACELETS;
-
-    public String filename(String target, final String path, final String name) {
-      target = StringUtils.isNotBlank(target) ? target + '/' : "";
-      switch (this) {
-        case JSP:
-          return target + path.replace('.', '/') + '/' + name + ".tld";
-        case FACELETS:
-          return target + name + ".taglib.xml";
-        default:
-          throw new IllegalArgumentException("Program error");
-      }
-    }
+  protected Element createTaglib(final Document document) {
+    final Element taglib;
+    taglib = document.createElement("facelet-taglib");
+    taglib.setAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
+    taglib.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+    taglib.setAttribute("xsi:schemaLocation",
+        "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
+    taglib.setAttribute("version", "2.0");
+    return taglib;
+  }
 
-    public Element createTaglib(final Document document) {
-      final Element taglib;
-      switch (this) {
-        case JSP:
-          taglib = document.createElement("taglib");
-          taglib.setAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
-          taglib.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-          taglib.setAttribute("xsi:schemaLocation",
-              "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd");
-          taglib.setAttribute("version", "2.1");
-          break;
-        case FACELETS:
-          taglib = document.createElement("facelet-taglib");
-          taglib.setAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
-          taglib.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-          taglib.setAttribute("xsi:schemaLocation",
-              "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
-          taglib.setAttribute("version", "2.0");
-          break;
-        default:
-          throw new IllegalArgumentException("Program error");
-      }
-      return taglib;
-    }
-
-    public void addMisc(final Element taglib, final Document document, final Taglib taglibAnnotation) {
-      switch (this) {
-        case JSP:
-          addLeafTextElement("1.2", "tlib-version", taglib, document);
-          addLeafTextElement(taglibAnnotation.shortName(), "short-name", taglib, document);
-          addLeafTextElement(taglibAnnotation.uri(), "uri", taglib, document);
-          break;
-        case FACELETS:
-          addLeafTextElement(taglibAnnotation.uri(), "namespace", taglib, document);
-          break;
-        default:
-          throw new IllegalArgumentException("Program error");
-      }
+  protected void addTagContent(
+      final TypeElement typeElement, final Element tagElement, final Document document, final boolean deprecated,
+      final Tag annotationTag) {
+    if (deprecated) {
+      addLeafTextElement(annotationTag.deprecatedName(), "tag-name", tagElement, document);
+    } else {
+      addLeafTextElement(annotationTag.name(), "tag-name", tagElement, document);
     }
 
-    public void addListeners(final Element taglib, final Document document, final Taglib taglibAnnotation) {
-      switch (this) {
-        case JSP:
-          for (final String listenerClass : taglibAnnotation.listener()) {
-            final Element listener = document.createElement("listener");
-            addLeafTextElement(listenerClass, "listener-class", listener, document);
-            taglib.appendChild(listener);
-          }
-          break;
-        case FACELETS:
-          break;
-        default:
-          throw new IllegalArgumentException("Program error");
+    final UIComponentTag componentTag = typeElement.getAnnotation(UIComponentTag.class);
+    if (componentTag != null) {
+      final Element componentElement = document.createElement("component");
+      tagElement.appendChild(componentElement);
+      addLeafTextElement(
+          AnnotationUtils.componentType(componentTag), "component-type", componentElement, document);
+      if (StringUtils.isNotBlank(componentTag.rendererType())) {
+        addLeafTextElement(componentTag.rendererType(), "renderer-type", componentElement, document);
       }
+      addLeafTextElement(componentTag.faceletHandler(), "handler-class", componentElement, document);
     }
 
-    public void addTagContent(
-        final TypeElement typeElement, final Element tagElement, final Document document, final boolean deprecated,
-        final Tag annotationTag, final String className) {
-      switch (this) {
-        case JSP:
-          if (deprecated) {
-            addLeafTextElement(annotationTag.deprecatedName(), "name", tagElement, document);
-          } else {
-            addLeafTextElement(annotationTag.name(), "name", tagElement, document);
-          }
-          addLeafTextElement(className, "tag-class", tagElement, document);
-          final String tagExtraInfo = annotationTag.tagExtraInfoClassName();
-          if (tagExtraInfo != null && tagExtraInfo.length() > 0) {
-            // TODO check tagExtraInfo extends TagExtraInfo
-            addLeafTextElement(tagExtraInfo, "tei-class", tagElement, document);
-          }
-          final BodyContent bodyContent = annotationTag.bodyContent();
-          final BodyContentDescription contentDescription = typeElement.getAnnotation(BodyContentDescription.class);
-          // TODO more error checking
-          if (contentDescription != null) {
-            if (bodyContent.equals(BodyContent.JSP) && contentDescription.contentType().length() > 0) {
-              throw new IllegalArgumentException(
-                  "contentType " + contentDescription.contentType() + " for bodyContent JSP not allowed!");
-            } else if (bodyContent.equals(BodyContent.TAGDEPENDENT) && contentDescription.contentType().length() == 0) {
-              throw new IllegalArgumentException("contentType should set for tagdependent bodyContent");
-            }
-          }
-          addLeafTextElement(bodyContent.toString(), "body-content", tagElement, document);
-          break;
-        case FACELETS:
-          if (deprecated) {
-            addLeafTextElement(annotationTag.deprecatedName(), "tag-name", tagElement, document);
-          } else {
-            addLeafTextElement(annotationTag.name(), "tag-name", tagElement, document);
-          }
-
-          final UIComponentTag componentTag = typeElement.getAnnotation(UIComponentTag.class);
-          if (componentTag != null) {
-            final Element componentElement = document.createElement("component");
-            tagElement.appendChild(componentElement);
-            addLeafTextElement(
-                AnnotationUtils.componentType(componentTag), "component-type", componentElement, document);
-            if (StringUtils.isNotBlank(componentTag.rendererType())) {
-              addLeafTextElement(componentTag.rendererType(), "renderer-type", componentElement, document);
-            }
-            addLeafTextElement(componentTag.faceletHandler(), "handler-class", componentElement, document);
-          }
-
-          final ExtensionTag extensionTag = typeElement.getAnnotation(ExtensionTag.class);
-          if (extensionTag != null) {
-            final Element componentElement = document.createElement("component");
-            tagElement.appendChild(componentElement);
-            addLeafTextElement(extensionTag.componentType(), "component-type", componentElement, document);
-            addLeafTextElement(extensionTag.rendererType(), "renderer-type", componentElement, document);
-            addLeafTextElement(extensionTag.faceletHandler(), "handler-class", componentElement, document);
-          }
-
-          final SimpleTag simpleTag = typeElement.getAnnotation(SimpleTag.class);
-          if (simpleTag != null) {
-            addLeafTextElement(simpleTag.faceletHandler(), "handler-class", tagElement, document);
-          }
-
-          final ValidatorTag validatorTag = typeElement.getAnnotation(ValidatorTag.class);
-          if (validatorTag != null) {
-            final Element validatorElement = document.createElement("validator");
-            tagElement.appendChild(validatorElement);
-            addLeafTextElement(validatorTag.validatorId(), "validator-id", validatorElement, document);
-            if (StringUtils.isNotBlank(validatorTag.faceletHandler())) {
-              addLeafTextElement(validatorTag.faceletHandler(), "handler-class", validatorElement, document);
-            }
-          }
-          break;
-        default:
-          throw new IllegalArgumentException("Program error");
+    final ExtensionTag extensionTag = typeElement.getAnnotation(ExtensionTag.class);
+    if (extensionTag != null) {
+      final Element componentElement = document.createElement("component");
+      tagElement.appendChild(componentElement);
+      addLeafTextElement(extensionTag.componentType(), "component-type", componentElement, document);
+      addLeafTextElement(extensionTag.rendererType(), "renderer-type", componentElement, document);
+      addLeafTextElement(extensionTag.faceletHandler(), "handler-class", componentElement, document);
+    }
+
+    final SimpleTag simpleTag = typeElement.getAnnotation(SimpleTag.class);
+    if (simpleTag != null) {
+      addLeafTextElement(simpleTag.faceletHandler(), "handler-class", tagElement, document);
+    }
+
+    final ValidatorTag validatorTag = typeElement.getAnnotation(ValidatorTag.class);
+    if (validatorTag != null) {
+      final Element validatorElement = document.createElement("validator");
+      tagElement.appendChild(validatorElement);
+      addLeafTextElement(validatorTag.validatorId(), "validator-id", validatorElement, document);
+      if (StringUtils.isNotBlank(validatorTag.faceletHandler())) {
+        addLeafTextElement(validatorTag.faceletHandler(), "handler-class", validatorElement, document);
       }
     }
+  }
 
-    public void addAttributeType(
-        final Element attribute, final TagAttribute tagAttribute, final UIComponentTagAttribute componentTagAttribute,
-        final Document document, final String attributeName) {
-      switch (this) {
-        case JSP:
-          if (!tagAttribute.rtexprvalue()) {
-            if (componentTagAttribute != null) {
-              if (componentTagAttribute.expression().isMethodExpression()) {
-                final Element deferredMethod = document.createElement("deferred-method");
-                addLeafTextElement(
-                    componentTagAttribute.methodReturnType() + " " + attributeName + "("
-                        + StringUtils.join(componentTagAttribute.methodSignature(), ", ")
-                        + ")", "method-signature", deferredMethod, document);
-                attribute.appendChild(deferredMethod);
-              } else if (componentTagAttribute.expression().isValueExpression()) {
-                final Element deferredValue = document.createElement("deferred-value");
-                String clazz;
-                if (componentTagAttribute.type().length == 1
-                    // XXX This is because an enum will not be converted in JSP with the PropertyEditor
-                    && !"org.apache.myfaces.tobago.layout.TextAlign".equals(componentTagAttribute.type()[0])
-                    && !"org.apache.myfaces.tobago.model.SuggestFilter".equals(componentTagAttribute.type()[0])) {
-                  clazz = componentTagAttribute.type()[0];
-                  final Class wrapper = ClassUtils.getWrapper(clazz);
-                  if (wrapper != null) {
-                    clazz = wrapper.getName(); // primitive types aren't allowed here
+  protected void addAttributeType(
+      final Element attribute, final TagAttribute tagAttribute, final UIComponentTagAttribute componentTagAttribute,
+      final Document document) {
+    if (!tagAttribute.rtexprvalue()) {
+      if (componentTagAttribute != null) {
+        if (componentTagAttribute.expression().isMethodExpression()) {
+          // todo
+        } else if (componentTagAttribute.expression().isValueExpression()) {
+          String clazz;
+          if (componentTagAttribute.type().length == 1) {
+            clazz = componentTagAttribute.type()[0];
+            final Class wrapper = ClassUtils.getWrapper(clazz);
+            if (wrapper != null) {
+              clazz = wrapper.getName(); // primitive types aren't allowed here
       /*                } else {
                       XXX what is with inner classes and arrays?
                       if (clazz.endsWith("[]")) {
@@ -625,58 +509,15 @@ public class TaglibGenerator extends Abs
                         Class.forName(clazz); // type check
                       }
       */
-                  }
-                } else {
-                  clazz = "java.lang.Object";
-                }
-                addLeafTextElement(clazz, "type", deferredValue, document);
-                attribute.appendChild(deferredValue);
-              }
-            } else {
-              final Element deferredValue = document.createElement("deferred-value");
-              addLeafTextElement(tagAttribute.type(), "type", deferredValue, document);
-              attribute.appendChild(deferredValue);
-            }
-          }
-          if (tagAttribute.rtexprvalue()) {
-            addLeafTextElement(Boolean.toString(tagAttribute.rtexprvalue()), "rtexprvalue", attribute, document);
-          }
-          break;
-        case FACELETS:
-          if (!tagAttribute.rtexprvalue()) {
-            if (componentTagAttribute != null) {
-              if (componentTagAttribute.expression().isMethodExpression()) {
-                // todo
-              } else if (componentTagAttribute.expression().isValueExpression()) {
-                String clazz;
-                if (componentTagAttribute.type().length == 1) {
-                  clazz = componentTagAttribute.type()[0];
-                  final Class wrapper = ClassUtils.getWrapper(clazz);
-                  if (wrapper != null) {
-                    clazz = wrapper.getName(); // primitive types aren't allowed here
-      /*                } else {
-                      XXX what is with inner classes and arrays?
-                      if (clazz.endsWith("[]")) {
-                        Class.forName(clazz.substring(0, clazz.length() - 2)); // type check
-                      } else {
-                        Class.forName(clazz); // type check
-                      }
-      */
-                  }
-                } else {
-                  clazz = "java.lang.Object";
-                }
-                addLeafTextElement(clazz, "type", attribute, document);
-              }
-            } else {
-              addLeafTextElement(tagAttribute.type(), "type", attribute, document);
             }
+          } else {
+            clazz = "java.lang.Object";
           }
-          break;
-        default:
-          throw new IllegalArgumentException("Program error");
+          addLeafTextElement(clazz, "type", attribute, document);
+        }
+      } else {
+        addLeafTextElement(tagAttribute.type(), "type", attribute, document);
       }
-
     }
   }
 }