private void generateHandlerChainFile(Element hChains, String name) {
Filer filer = options.filer;
try {
IndentingWriter p;
FileObject jfo;
if (filer != null) {
jfo = filer.createResource(StandardLocation.SOURCE_OUTPUT,
Names.getPackageName(name), getHandlerConfigFileName(name));
options.addGeneratedFile(new File(jfo.toUri()));
p = new IndentingWriter(new OutputStreamWriter(jfo.openOutputStream()));
} else { // leave for backw. compatibility now
String hcName = getHandlerConfigFileName(name);
File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir);
File hcFile = new File(packageDir, hcName);
options.addGeneratedFile(hcFile);
p = new IndentingWriter(new OutputStreamWriter(new FileOutputStream(hcFile)));
}
Transformer it = XmlUtil.newTransformer();
it.setOutputProperty(OutputKeys.METHOD, "xml");
it.setOutputProperty(OutputKeys.INDENT, "yes");
it.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount",
"2");
it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
it.transform( new DOMSource(hChains), new StreamResult(p) );
p.close();
} catch (Exception e) {
throw new GeneratorException(
"generator.nestedGeneratorError",
e);
}