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

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Mar 23 04:24:05 EDT 2009


Author: nickarls
Date: 2009-03-23 04:24:05 -0400 (Mon, 23 Mar 2009)
New Revision: 2140

Modified:
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ConstructorModel.java
   extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
Log:
minor

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-23 07:56:32 UTC (rev 2139)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java	2009-03-23 08:24:05 UTC (rev 2140)
@@ -36,6 +36,8 @@
 import javax.lang.model.util.ElementFilter;
 
 import org.dom4j.DocumentException;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.xsd.helpers.DataSetter;
 import org.jboss.webbeans.xsd.model.ClassModel;
 
@@ -50,6 +52,8 @@
 @SupportedAnnotationTypes("*")
 public class PackageSchemaGenerator extends AbstractProcessor
 {
+   private static LogProvider log = Logging.getLogProvider(PackageSchemaGenerator.class);
+   
    private Map<String, ClassModel> classModelCache;
    private Map<String, Schema> schemas;
 
@@ -75,8 +79,7 @@
             }
             catch (DocumentException e)
             {
-               // TODO: real logging
-               System.out.println("Could not read or create schema for " + classModel.getPackage());
+               log.error("Could not read or create schema for package " + classModel.getPackage());
             }
          }
       }
@@ -90,8 +93,7 @@
             }
             catch (IOException e)
             {
-               // TODO: real logging
-               System.out.println("Could not write schema.xsd for " + schema);
+               log.error("Could not write schema.xsd for " + schema, e);
             }
          }
       }

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java	2009-03-23 07:56:32 UTC (rev 2139)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java	2009-03-23 08:24:05 UTC (rev 2140)
@@ -52,6 +52,7 @@
  */
 public class Schema
 {
+   // The default namespace of the schema
    public static final List<Namespace> defaultNamespaces = new ArrayList<Namespace>();
 
    static
@@ -95,6 +96,11 @@
       init();
    }
 
+   /**
+    * Creates a new schema document
+    * 
+    * @return The document
+    */
    private Document createDocument()
    {
       Document document = DocumentHelper.createDocument();
@@ -112,17 +118,45 @@
       return document;
    }
 
+   /**
+    * Static factory method
+    * 
+    * @param packageName The package name
+    * @param packageElement The package content representation
+    * @param filer The filer for resources
+    * 
+    * @return A new schema instance
+    * 
+    * @throws DocumentException If an existing schema could not be parsed
+    */
    public static Schema of(String packageName, PackageElement packageElement, Filer filer) throws DocumentException
    {
       return new Schema(packageName, packageElement, filer);
    }
 
+   /**
+    * Reads a schema document
+    * 
+    * @param filer The filer to be used for resource reading
+    * 
+    * @return The schema documetn
+    * 
+    * @throws IOException If the file could not be find or there was an error reading it
+    * @throws DocumentException If the read document could not be parsed
+    */
    private Document readDocument(Filer filer) throws IOException, DocumentException
    {
       InputStream in = filer.getResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openInputStream();
       return new SAXReader().read(in);
    }
 
+   /**
+    * Writes a schema back to disk
+    * 
+    * @param filer The filer to be used for resource writing
+    * 
+    * @throws IOException If the file could not be written
+    */
    public void write(Filer filer) throws IOException
    {
       OutputFormat format = OutputFormat.createPrettyPrint();
@@ -164,6 +198,7 @@
          }
       }
 
+      // Collect namespaces that are references in the document
       Set<Namespace> referencedNamespaces = new HashSet<Namespace>(defaultNamespaces);
       for (Object attribute : document.getRootElement().selectNodes("//@type"))
       {
@@ -173,6 +208,8 @@
          referencedNamespaces.add(document.getRootElement().getNamespaceForPrefix(prefix));
       }
 
+      // Register the namespaces with the namespace handler if they are present, otherwise
+      // remove them from the document
       for (Object item : document.getRootElement().additionalNamespaces())
       {
          Namespace namespace = (Namespace) item;
@@ -211,6 +248,7 @@
     * Rebuilds the schema document
     * 
     * @param packageElement The package abstraction
+    * @return the schema for fluent interface
     */
    public Schema rebuild()
    {
@@ -223,9 +261,9 @@
          }
       }
 
+      // Remove old version of class xsd (if present) and add the fresh version
       for (ClassModel classModel : classModels)
       {
-         // Remove old version of class xsd (if present)
          for (Object previousClass : document.selectNodes("/xs:schema/xs:element[@name=\"" + classModel.getSimpleName() + "\"]"))
          {
             ((Element) previousClass).detach();

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-23 07:56:32 UTC (rev 2139)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java	2009-03-23 08:24:05 UTC (rev 2140)
@@ -58,8 +58,7 @@
       {
          return;
       }
-      FieldModel field = FieldModel.of(element.getSimpleName().toString());
-      classModel.addField(field);
+      classModel.addField(FieldModel.of(element.getSimpleName().toString()));
    }
 
    /**
@@ -74,18 +73,22 @@
       {
          return;
       }
-      ConstructorModel constructor = ConstructorModel.of((ExecutableElement) element);
-      classModel.addConstructor(constructor);
+      classModel.addConstructor(ConstructorModel.of((ExecutableElement) element));
    }
 
+   /**
+    * Inspects a method and populates a class model
+    * 
+    * @param classModel The class model to populate
+    * @param element The element to inspect
+    */
    public static void populateMethodModel(ClassModel classModel, Element element)
    {
       if (!isPublic(element))
       {
          return;
       }
-      MethodModel method = MethodModel.of((ExecutableElement) element);
-      classModel.addMethod(method);
+      classModel.addMethod(MethodModel.of((ExecutableElement) element));
    }
 
 }

Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ConstructorModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ConstructorModel.java	2009-03-23 07:56:32 UTC (rev 2139)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ConstructorModel.java	2009-03-23 08:24:05 UTC (rev 2140)
@@ -1,3 +1,20 @@
+/*
+ * 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;
 
 import javax.lang.model.element.ExecutableElement;
@@ -6,6 +23,12 @@
 import org.dom4j.Element;
 import org.jboss.webbeans.xsd.NamespaceHandler;
 
+/**
+ * The model of a method
+ * 
+ * @author Nicklas Karlsson
+ *
+ */
 public class ConstructorModel extends MethodModel
 {
 

Modified: 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-23 07:56:32 UTC (rev 2139)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java	2009-03-23 08:24:05 UTC (rev 2140)
@@ -1,3 +1,20 @@
+/*
+ * 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;
 
 import org.dom4j.Element;
@@ -3,4 +20,10 @@
 import org.jboss.webbeans.xsd.NamespaceHandler;
 
+/**
+ * The model of a field
+ * 
+ * @author Nicklas Karlsson
+ *
+ */
 public class FieldModel extends NamedModel
 {




More information about the weld-commits mailing list