/** * Generates an XML description of files inside a folder structure. * * @param buffer - where to place the description */ private static final void generateFiles(StringBuffer buffer, ResourceComposer composer) throws Exception { int base = composer.getFileBase(); int fileNo = composer.getFileCount(); for (int i = 0; i < fileNo; i++) { composer.setFileBase(base + i); generateOneFile(buffer, composer); } }
/** * Generates an XML description of a folder inside a filesystem structure. * * @param buffer - where to place the description */ private static final void generateFolder(StringBuffer buffer, ResourceComposer composer) throws Exception { buffer.append(FOLDER_START1); int base = composer.getFileBase(); if (base != 0) { buffer.append(base); } buffer.append(FOLDER_START2); generateFiles(buffer, composer); buffer.append(FOLDER_END); }
/** * Generates an XML file that describes a filesystem structure. * * @param folder - where to place the file * @param composer a factory that assemblies resource strings */ public static final File generateXMLFile(File folder, ResourceComposer composer) throws Exception { String name = MF_NAME + '-' + String.valueOf(composer.getFileBase()); File dest = new File(folder, name.concat(".xml")); OutputStream os = new FileOutputStream(dest); Writer writer = new OutputStreamWriter(os); writer.write(generate(composer)); writer.close(); os.close(); return dest; }