Ejemplo n.º 1
0
 /**
  * Generates file start inside a folder description.
  *
  * @param buffer - where to place the description
  */
 private static void addFileHeader(StringBuffer buffer, ResourceComposer composer) {
   addIndent(buffer, FOLDER_INDENT + 1);
   buffer.append("<file name=\"");
   composer.assemblyResourceString(buffer);
   buffer.append("\" url=\"");
   composer.assemblyResourceString(buffer);
   buffer.append("\">").append('\n');
 }
Ejemplo n.º 2
0
 /**
  * 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);
   }
 }
Ejemplo n.º 3
0
 /**
  * Generates an XML description of a file inside a folder structure.
  *
  * @param buffer - where to place the description
  */
 private static void generateOneFile(StringBuffer buffer, ResourceComposer composer)
     throws Exception {
   buffer.append('\n');
   addFileHeader(buffer, composer);
   generateAttributes(buffer, composer.getPaddingSize());
   addFileEnd(buffer);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
  /**
   * 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;
  }