boolean failure = false;
if ( ! JaxbJavaizer.javaize(sts, componentData, packageData, errors) )
return false;
JaxbConfigDocument doc = JaxbConfigDocument.Factory.newInstance();
JaxbConfig root = doc.addNewJaxbConfig();
GlobalElements elts = root.addNewGlobalElements();
GlobalTypes types = root.addNewGlobalTypes();
for (Iterator it = packageData.values().iterator() ; it.hasNext() ; )
{
PackageInfo pi = (PackageInfo) it.next();
Writer writer = null;
try
{
// First construct the jaxb.properties file for this package
String filename = pi.getPackageName().replace('.', '/') + "/jaxb.properties";
File sourcefile = new File(classesdir, filename);
sourcefile.getParentFile().mkdirs();
writer = new FileWriter(sourcefile);
JaxbCodePrinter.printPackageProperties(writer, pi);
writer.close();
writer = null;
}
catch (IOException e)
{
System.err.println("IO Error " + e);
failure = true;
}
finally {
try { if (writer != null) writer.close(); } catch (IOException e) {}
}
// TODO: generate ObjectFactory class
// Generate the interfaces & implementations for the schema components
List allComponents = new ArrayList();
allComponents.addAll(Arrays.asList(sts.globalElements()));
allComponents.addAll(Arrays.asList(sts.globalTypes()));
for (int i = 0, len = allComponents.size() ; i < len ; i++)
{
SchemaComponent sc = (SchemaComponent)allComponents.get(i);
ComponentInfo ci = (ComponentInfo)componentData.get(sc);
addComponentToConfig(sc, ci, root);
assert ci != null;
String filename = ci.getFullJavaIntfName().replace('.', '/') + ".java";
// print the java interface
try {
File sourcefile = new File(sourcedir, filename);
sourcefile.getParentFile().mkdirs();
writer = new FileWriter(sourcefile);
JaxbCodePrinter.printJavaInterface(writer, sc, ci);
writer.close();
writer = null;
sourcefiles.add(sourcefile);
}
catch (IOException e)
{
System.err.println("IO Error " + e);
failure = true;
}
finally {
try { if (writer != null) writer.close(); } catch (IOException e) {}
}
// print the java impl
filename = ci.getFullJavaImplName().replace('.', '/') + ".java";
try {
File sourcefile = new File(sourcedir, filename);
sourcefile.getParentFile().mkdirs();
writer = new FileWriter(sourcefile);
JaxbCodePrinter.printJavaImpl(writer, sc, ci);
writer.close();
writer = null;
sourcefiles.add(sourcefile);
}
catch (IOException e)
{
System.err.println("IO Error " + e);
failure = true;
}
finally {
try { if (writer != null) writer.close(); } catch (IOException e) {}
}
}
}
// Save out the jaxb config file
OutputStream os = null;
try
{
// First construct the jaxb.properties file for this package
String filename = sts.getName().replace('.', '/') + "/JaxbConfig.xml";
File sourcefile = new File(classesdir, filename);
sourcefile.getParentFile().mkdirs();
os = new FileOutputStream(sourcefile);
doc.save(os);
os.close();
os = null;
}
catch (IOException e)
{