{
throw new NullPointerException();
}
final CompoundDataFactory compoundDataFactory = (CompoundDataFactory) dataFactory;
final String fileName = BundleUtilities.getUniqueName(bundle, state.getFileName(),
"datasources/compound-ds{0}.xml");
if (fileName == null)
{
throw new IOException("Unable to generate unique name for Inline-Data-Source");
}
final OutputStream outputStream = bundle.createEntry(fileName, "text/xml");
final DefaultTagDescription tagDescription = new DefaultTagDescription();
tagDescription.setDefaultNamespace(CompoundDataFactoryModule.NAMESPACE);
tagDescription.setNamespaceHasCData(CompoundDataFactoryModule.NAMESPACE, false);
final XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, " ",
"\n");
final AttributeList rootAttrs = new AttributeList();
rootAttrs.addNamespaceDeclaration("data", CompoundDataFactoryModule.NAMESPACE);
xmlWriter.writeTag(CompoundDataFactoryModule.NAMESPACE, "compound-datasource", rootAttrs, XmlWriterSupport.OPEN);
for (int i = 0; i < compoundDataFactory.size(); i++)
{
final DataFactory df = compoundDataFactory.get(i);
final BundleDataFactoryWriterHandler writerHandler = BundleWriterUtilities.lookupWriteHandler(df);
if (writerHandler == null)
{
throw new BundleWriterException("Unable to find writer-handler for data-factory " + df.getClass());
}