[webbeans-commits] Webbeans SVN: r2068 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Mar 17 09:55:57 EDT 2009


Author: nickarls
Date: 2009-03-17 09:55:57 -0400 (Tue, 17 Mar 2009)
New Revision: 2068

Removed:
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
Modified:
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Bar.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
Log:
Overly(?) simplified model

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -126,6 +126,7 @@
       }
       // Place the new class model in the cache
       helper.cacheClassModel(classModel);
+      System.out.println(classModel);
       return classModel;
    }
 

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -17,12 +17,6 @@
 
 package org.jboss.webbeans.xsd.helpers;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.Modifier;
@@ -31,9 +25,8 @@
 import javax.lang.model.type.TypeKind;
 
 import org.jboss.webbeans.xsd.model.ClassModel;
-import org.jboss.webbeans.xsd.model.FieldModel;
 import org.jboss.webbeans.xsd.model.MethodModel;
-import org.jboss.webbeans.xsd.model.ParameterModel;
+import org.jboss.webbeans.xsd.model.NamedModel;
 import org.jboss.webbeans.xsd.model.TypedModel;
 
 /**
@@ -65,11 +58,9 @@
     */
    public static void populateClassModel(ClassModel classModel, Element element, ClassModel parent)
    {
-      Map<String, Set<String>> annotations = getAnnotations(element);
       TypeElement typeElement = (TypeElement) element;
       classModel.setName(typeElement.getQualifiedName().toString());
       classModel.setParent(parent);
-      classModel.setAnnotations(annotations);
    }
 
    /**
@@ -85,14 +76,8 @@
          return;
       }
       String name = element.getSimpleName().toString();
-      String type = element.asType().toString();
-      boolean primitive = element.asType().getKind().isPrimitive();
-      Map<String, Set<String>> annotations = getAnnotations(element);
-      FieldModel field = new FieldModel();
+      NamedModel field = new NamedModel();
       field.setName(name);
-      field.setType(type);
-      field.setPrimitive(primitive);
-      field.setAnnotations(annotations);
       classModel.addField(field);
    }
 
@@ -118,20 +103,14 @@
       
       MethodModel method = new MethodModel();
       method.setName(name);
-      method.setAnnotations(getAnnotations(executableElement));
-      method.setReturnType(returnType);
-
+   
       for (VariableElement parameterElement : executableElement.getParameters())
       {
-         String paramName = parameterElement.getSimpleName().toString();
          String paramType = parameterElement.asType().toString();
          boolean paramPrimitive = parameterElement.asType().getKind().isPrimitive();
-         Map<String, Set<String>> paramAnnotations = getAnnotations(parameterElement);
-         ParameterModel parameter = new ParameterModel();
-         parameter.setName(paramName);
+         TypedModel parameter = new TypedModel();
          parameter.setType(paramType);
          parameter.setPrimitive(paramPrimitive);
-         parameter.setAnnotations(paramAnnotations);
          method.addParameter(parameter);
       }
       // OK, cheating a little with a common model for methods and constructors
@@ -144,20 +123,5 @@
          classModel.addMethod(method);
       }
    }
-
-   private static Map<String, Set<String>> getAnnotations(Element element)
-   {
-      Map<String, Set<String>> annotations = new HashMap<String, Set<String>>();
-      for (AnnotationMirror annotation : element.getAnnotationMirrors())
-      {
-         Set<String> metaAnnotations = new HashSet<String>();
-         for (AnnotationMirror metaAnnotation : annotation.getAnnotationType().asElement().getAnnotationMirrors())
-         {
-            metaAnnotations.add(metaAnnotation.getAnnotationType().toString());
-         }
-         annotations.put(annotation.getAnnotationType().toString(), metaAnnotations);
-      }
-      return annotations;
-   }
-
+   
 }

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -70,28 +70,19 @@
     * @throws DocumentException If the schema could not be parsed
     * @throws IOException If the schema could not be read
     */
-   private Schema getSchema(String packageName) throws DocumentException, IOException
+   private Schema createSchema(String packageName) throws DocumentException, IOException
    {
       Schema schema = new Schema(packageName);
       Document document = readSchema(packageName);
-      schema.setDocument(document != null ? document : createSchema(packageName));
+      if (document == null) {
+         document = DocumentHelper.createDocument();
+         document.addElement("schema");
+      }
+      schema.setDocument(document);
       return schema;
    }
 
    /**
-    * Creates a new schema document
-    * 
-    * @param packageName The package name of the schema
-    * @return The document
-    */
-   private Document createSchema(String packageName)
-   {
-      Document packageXSD = DocumentHelper.createDocument();
-      packageXSD.addElement("schema");
-      return packageXSD;
-   }
-
-   /**
     * Reads a schema for a package
     * 
     * @param packageName The package name
@@ -156,7 +147,7 @@
          {
             try
             {
-               schema = getSchema(packageName);
+               schema = createSchema(packageName);
             }
             catch (DocumentException e)
             {

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -34,7 +34,7 @@
    private ClassModel parent;
 
    // The fields of the class
-   private List<FieldModel> fields = new ArrayList<FieldModel>();
+   private List<NamedModel> fields = new ArrayList<NamedModel>();
    // The methods of the class
    private List<MethodModel> methods = new ArrayList<MethodModel>();
    // The constructors of the class
@@ -43,31 +43,31 @@
    /**
     * Adds a field to the class model
     * 
-    * @param fieldModel The field to add
+    * @param field The field to add
     */
-   public void addField(FieldModel fieldModel)
+   public void addField(NamedModel field)
    {
-      fields.add(fieldModel);
+      fields.add(field);
    }
 
    /**
     * Adds a constructor to the model
     * 
-    * @param constructorModel The constructor to add
+    * @param constructor The constructor to add
     */
-   public void addConstructor(MethodModel constructorModel)
+   public void addConstructor(MethodModel constructor)
    {
-      constructors.add(constructorModel);
+      constructors.add(constructor);
    }
 
    /**
     * Adds a method to the model
     * 
-    * @param methodModel The method to add
+    * @param method The method to add
     */
-   public void addMethod(MethodModel methodModel)
+   public void addMethod(MethodModel method)
    {
-      methods.add(methodModel);
+      methods.add(method);
    }
 
    /**
@@ -106,7 +106,7 @@
     * 
     * @return The public fields
     */
-   public List<FieldModel> getFields()
+   public List<NamedModel> getFields()
    {
       return fields;
    }
@@ -116,9 +116,9 @@
     * 
     * @return The set of public fields available
     */
-   public Set<FieldModel> getMergedFields()
+   public Set<NamedModel> getMergedFields()
    {
-      Set<FieldModel> mergedFields = new HashSet<FieldModel>(fields);
+      Set<NamedModel> mergedFields = new HashSet<NamedModel>(fields);
       ClassModel currentParent = parent;
       while (currentParent != null)
       {
@@ -163,22 +163,10 @@
    public Set<TypedModel> getTypeReferences()
    {
       Set<TypedModel> typeReferences = new HashSet<TypedModel>();
-      for (FieldModel field : getMergedFields())
-      {
-         if (!field.isPrimitive())
-         {
-            typeReferences.add(field);
-         }
-      }
       for (MethodModel method : getMergedMethods())
       {
-         TypedModel returnValue = method.getReturnType();
-         if (!returnValue.isPrimitive())
+         for (TypedModel parameter : method.getParameters())
          {
-            typeReferences.add(returnValue);
-         }
-         for (ParameterModel parameter : method.getParameters())
-         {
             if (!parameter.isPrimitive())
             {
                typeReferences.add(parameter);
@@ -187,7 +175,7 @@
       }
       for (MethodModel constructor : getMergedConstructors())
       {
-         for (ParameterModel parameter : constructor.getParameters())
+         for (TypedModel parameter : constructor.getParameters())
          {
             if (!parameter.isPrimitive())
             {
@@ -224,8 +212,7 @@
    public String toString()
    {
       StringBuilder buffer = new StringBuilder();
-      String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
-      buffer.append("----------------------------------\n" + annotationString + name + "\n");
+      buffer.append("----------------------------------\n" + name + "\n");
       buffer.append("Constructors:\n " + getMergedConstructors() + "\n");
       buffer.append("Methods:\n" + getMergedMethods() + "\n");
       buffer.append("Fields:\n" + getMergedFields() + "\n");

Deleted: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.xsd.model;
-
-/**
- * A model of a field
- * 
- * @author Nicklas Karlsson
- *
- */
-public class FieldModel extends NamedModel
-{
-
-   @Override
-   public boolean equals(Object other)
-   {
-      FieldModel otherModel = (FieldModel) other;
-      return name.equals(otherModel.getName()) && type.equals(otherModel.getType());
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return name.hashCode() + type.hashCode();
-   }
-
-   @Override
-   public String toString()
-   {
-      String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
-      return "\n  " + annotationString + type + " " + name;
-   }
-
-}

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -28,31 +28,15 @@
  */
 public class MethodModel extends NamedModel
 {
-   private TypedModel returnType;
-   private List<ParameterModel> parameters = new ArrayList<ParameterModel>();
+   private List<TypedModel> parameters = new ArrayList<TypedModel>();
 
-   public TypedModel getReturnType()
+   public List<TypedModel> getParameters()
    {
-      return returnType;
-   }
-
-   public void setReturnType(TypedModel returnType)
-   {
-      this.returnType = returnType;
-   }
-
-   public List<ParameterModel> getParameters()
-   {
       return parameters;
    }
 
-   public void setParameters(List<ParameterModel> parameters)
+   public void addParameter(TypedModel parameter)
    {
-      this.parameters = parameters;
-   }
-   
-   public void addParameter(ParameterModel parameter)
-   {
       parameters.add(parameter);
    }
 
@@ -60,20 +44,19 @@
    public boolean equals(Object other)
    {
       MethodModel otherModel = (MethodModel) other;
-      return name.equals(otherModel.getName()) && returnType.equals(otherModel.getReturnType()) && parameters.equals(otherModel.getParameters());
+      return name.equals(otherModel.getName()) && parameters.equals(otherModel.getParameters());
    }
 
    @Override
    public int hashCode()
    {
-      return name.hashCode() + returnType.hashCode() + parameters.hashCode();
+      return name.hashCode() + parameters.hashCode();
    }
    
    @Override
    public String toString()
    {
-      String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
-      return "\n  " + annotationString + returnType.getType() + " " + name + "(" + (parameters.isEmpty() ? "" : parameters) + ")";
+      return "\n  " + name + "(" + (parameters.isEmpty() ? "" : parameters) + ")";
    }
 
 }

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/NamedModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -17,20 +17,15 @@
 
 package org.jboss.webbeans.xsd.model;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * A superclass for named models
  * 
  * @author Nicklas Karlsson
  * 
  */
-public class NamedModel extends TypedModel
+public class NamedModel
 {
    protected String name;
-   protected Map<String, Set<String>> annotations = new HashMap<String, Set<String>>();
 
    public String getName()
    {
@@ -42,20 +37,17 @@
       this.name = name;
    }
 
-   public Map<String, Set<String>> getAnnotations()
+   @Override
+   public String toString()
    {
-      return annotations;
+      return name;
    }
 
-   public void setAnnotations(Map<String, Set<String>> annotations)
-   {
-      this.annotations = annotations;
-   }
-
    @Override
    public boolean equals(Object other)
    {
-      return name.equals(other);
+      NamedModel otherNamed = (NamedModel) other;
+      return name.equals(otherNamed.getName());
    }
 
    @Override
@@ -63,5 +55,4 @@
    {
       return name.hashCode();
    }
-
 }

Deleted: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.xsd.model;
-
-
-/**
- * The model of a method or constrcutor parameter
- * 
- * @author  Nicklas Karlsson
- *
- */
-public class ParameterModel extends FieldModel
-{
-   
-   @Override
-   public boolean equals(Object other)
-   {
-      TypedModel otherModel = (TypedModel) other;
-      return type.equals(otherModel.getType());
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return type.hashCode();
-   }   
-   
-   @Override
-   public String toString()
-   {
-      String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
-      return "\n    " + annotationString + type + " " + name;
-   }   
-
-}

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -21,7 +21,7 @@
  * The model of a typed member
  * 
  * @author Nicklas Karlsson
- *
+ * 
  */
 public class TypedModel
 {
@@ -48,6 +48,12 @@
       this.primitive = primitive;
    }
 
+   @Override
+   public String toString()
+   {
+      return type;
+   }
+
    public String getTypePackage()
    {
       if (primitive)

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Bar.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Bar.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Bar.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -2,5 +2,9 @@
 
 public class Bar
 {
-
+   public int poo;
+   public void testy() {
+      
+   }
+   
 }

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java	2009-03-17 12:55:57 UTC (rev 2067)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java	2009-03-17 13:55:57 UTC (rev 2068)
@@ -6,7 +6,7 @@
 import org.jboss.webbeans.xsd.test.test.test.Tar;
 
 @Current
-public class Foo
+public class Foo extends Bar
 {
    @Current
    public String foo;
@@ -26,4 +26,8 @@
       return foo;
    }
 
+   public void testy() {
+      
+   }
+   
 }




More information about the weld-commits mailing list