Author: nickarls
Date: 2009-03-17 07:54:05 -0400 (Tue, 17 Mar 2009)
New Revision: 2066
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.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-17
11:37:31 UTC (rev 2065)
+++
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-17
11:54:05 UTC (rev 2066)
@@ -35,7 +35,6 @@
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.Elements;
import org.jboss.webbeans.xsd.helpers.DataSetter;
import org.jboss.webbeans.xsd.helpers.XSDHelper;
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
11:37:31 UTC (rev 2065)
+++
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17
11:54:05 UTC (rev 2066)
@@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
-import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.PackageElement;
import javax.tools.StandardLocation;
@@ -32,7 +31,6 @@
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
-import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
@@ -47,7 +45,6 @@
*/
public class XSDHelper
{
-
// The annotation processing environment
private ProcessingEnvironment processingEnvironment;
// The cache of already processed classes
@@ -90,7 +87,7 @@
private Document createSchema(String packageName)
{
Document packageXSD = DocumentHelper.createDocument();
- packageXSD.addElement("Package");
+ packageXSD.addElement("schema");
return packageXSD;
}
@@ -123,39 +120,15 @@
}
}
- /**
- * Writes package info to the disk
- *
- * @param schema The package info to store
- */
- private void writePackageInfo(Schema schema)
+ private void writeSchema(Schema schema) throws IOException
{
- try
- {
- writeSchema(schema.getPackageName(), schema.getDocument());
- }
- catch (IOException e)
- {
- throw new RuntimeException("Could not write schema for " +
schema.getPackageName());
- }
- }
-
- /**
- * Writes a schema to disk
- *
- * @param packageName The package name
- * @param schema The schema
- * @throws IOException If the file could not be written
- */
- private void writeSchema(String packageName, Document schema) throws IOException
- {
OutputStream out = null;
try
{
OutputFormat format = OutputFormat.createPrettyPrint();
- out =
processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
packageName, "schema.xsd").openOutputStream();
+ out =
processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
schema.getPackageName(), "schema.xsd").openOutputStream();
XMLWriter writer = new XMLWriter(out, format);
- writer.write(schema);
+ writer.write(schema.getDocument());
writer.flush();
writer.close();
}
@@ -209,7 +182,14 @@
{
schema.rebuild(packageModels.get(schema.getPackageName()));
System.out.println(schema.getPackageName() + " (" +
schema.getNamespaces() + ")");
- writePackageInfo(schema);
+ try
+ {
+ writeSchema(schema);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Could not write schema for " +
schema.getPackageName());
+ }
}
}
Show replies by date