// Path: generator/src/prj/net/sf/aceunit/util/FileComparator.java
// public class FileComparator implements Comparator<File> {
// 
//     // Optimization Idea:
//     // For multiple or large sort operations, many comparisons are done.
//     // Thus many conversions from File to String would happen.
//     // A WeakHashMap<File, String> could cache the File.toString() results.
//     // If performance is an issue, this also could be a WeakHashMap<File, CollationKey>.
// 
//     /**
//      * The Collator of this FileComparator.
//      */
//     private final Collator collator;
// 
//     /**
//      * Creates a FileComparator.
//      *
//      * @param locale Locale for comparing file(name)s.
//      */
//     public FileComparator(final Locale locale) {
//         this(Collator.getInstance(locale));
//     }
// 
//     /**
//      * Creates a FileComparator.
//      *
//      * @param collator Collator for comparing file(name)s.
//      */
//     public FileComparator(@NotNull final Collator collator) {
//         this.collator = collator;
//     }
// 
//     @Override
//     public int compare(final File o1, final File o2) {
//         return collator.compare(o1.toString(), o2.toString());
//     }
// 
// }
// 
// Path: generator/src/prj/net/sf/aceunit/util/IdGenerator.java
// public class IdGenerator {
// 
//     /**
//      * The last used id.
//      */
//     private int lastId;
// 
//     /**
//      * Creates an IdGenerator.
//      * The {@link #lastId} will be 0 which means the id returned by {@link #getNextId()} will be 1.
//      */
//     public IdGenerator() {
//         this(0);
//     }
// 
//     /**
//      * Creates an IdGenerator.
//      *
//      * @param lastId Last id used, the first call to {@link #getNextId()} will return that value + 1.
//      */
//     public IdGenerator(final int lastId) {
//         this.lastId = lastId;
//     }
// 
//     /**
//      * Returns the next id.
//      *
//      * @return The next id.
//      */
//     public synchronized int getNextId() {
//         return ++lastId;
//     }
// 
// }


import net.sf.aceunit.util.FileComparator;
import net.sf.aceunit.util.IdGenerator;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.Option;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
     * @param pckgDir Directory to treat as package.
     * @return {@code true} if the package tree contained a fixture, otherwise {@code false}
     * @throws IOException In case of I/O problems.
     */
    private boolean performPckg(@NotNull final File base, @Nullable final Pckg parent, @NotNull final File pckgDir) throws IOException {
        assert pckgDir.isDirectory();
        boolean containedFixture = false;
        final Pckg pckg = new Pckg("dummy");
        // XXX:2009-08-16:christianhujer:Hack to keep the first suite id "1".
        //     The correct solution would be to separate scan and output.
        //     However, that solution might require more memory.
        //     So before that solution is implemented, a footprint analysis is required.
        final boolean hasParent = parent != null;
        if (!hasParent) {
            pckg.setId(idGenerator);
            roots.add(pckg);
        }
        for (final File dir : listSortedFiles(pckgDir, SourceFiles.DIR_FILTER))
            containedFixture |= performPckg(base, pckg, dir);
        for (final File fixtureFile : listSortedFiles(pckgDir, SourceFiles.C_AND_CPP_SOURCE_FILTER))
            containedFixture |= performFixture(base, pckg, fixtureFile);
        if (containedFixture) {
            // XXX:2009-08-16:christianhujer:The id is already set above if there is no parent.
            if (hasParent)
                pckg.setId(idGenerator);
            final File cFile = getFileForSuiteC(pckgDir, pckg);
            if (printSet.contains(Print.sources) || printSet.contains(Print.suites) || printSet.contains(Print.generated))
                System.out.println(cFile);
            final String hSource = pckg.getCode(getPackageName(pckgDir));
            if (genSuites)
// Path: generator/src/prj/net/sf/aceunit/util/FileComparator.java
// public class FileComparator implements Comparator<File> {
// 
//     // Optimization Idea:
//     // For multiple or large sort operations, many comparisons are done.
//     // Thus many conversions from File to String would happen.
//     // A WeakHashMap<File, String> could cache the File.toString() results.
//     // If performance is an issue, this also could be a WeakHashMap<File, CollationKey>.
// 
//     /**
//      * The Collator of this FileComparator.
//      */
//     private final Collator collator;
// 
//     /**
//      * Creates a FileComparator.
//      *
//      * @param locale Locale for comparing file(name)s.
//      */
//     public FileComparator(final Locale locale) {
//         this(Collator.getInstance(locale));
//     }
// 
//     /**
//      * Creates a FileComparator.
//      *
//      * @param collator Collator for comparing file(name)s.
//      */
//     public FileComparator(@NotNull final Collator collator) {
//         this.collator = collator;
//     }
// 
//     @Override
//     public int compare(final File o1, final File o2) {
//         return collator.compare(o1.toString(), o2.toString());
//     }
// 
// }
// 
// Path: generator/src/prj/net/sf/aceunit/util/IdGenerator.java
// public class IdGenerator {
// 
//     /**
//      * The last used id.
//      */
//     private int lastId;
// 
//     /**
//      * Creates an IdGenerator.
//      * The {@link #lastId} will be 0 which means the id returned by {@link #getNextId()} will be 1.
//      */
//     public IdGenerator() {
//         this(0);
//     }
// 
//     /**
//      * Creates an IdGenerator.
//      *
//      * @param lastId Last id used, the first call to {@link #getNextId()} will return that value + 1.
//      */
//     public IdGenerator(final int lastId) {
//         this.lastId = lastId;
//     }
// 
//     /**
//      * Returns the next id.
//      *
//      * @return The next id.
//      */
//     public synchronized int getNextId() {
//         return ++lastId;
//     }
// 
// }


// Path: generator/src/prj/net/sf/aceunit/GenTest.java
import net.sf.aceunit.util.FileComparator;
import net.sf.aceunit.util.IdGenerator;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.Option;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;

     * @param pckgDir Directory to treat as package.
     * @return {@code true} if the package tree contained a fixture, otherwise {@code false}
     * @throws IOException In case of I/O problems.
     */
    private boolean performPckg(@NotNull final File base, @Nullable final Pckg parent, @NotNull final File pckgDir) throws IOException {
        assert pckgDir.isDirectory();
        boolean containedFixture = false;
        final Pckg pckg = new Pckg("dummy");
        // XXX:2009-08-16:christianhujer:Hack to keep the first suite id "1".
        //     The correct solution would be to separate scan and output.
        //     However, that solution might require more memory.
        //     So before that solution is implemented, a footprint analysis is required.
        final boolean hasParent = parent != null;
        if (!hasParent) {
            pckg.setId(idGenerator);
            roots.add(pckg);
        }
        for (final File dir : listSortedFiles(pckgDir, SourceFiles.DIR_FILTER))
            containedFixture |= performPckg(base, pckg, dir);
        for (final File fixtureFile : listSortedFiles(pckgDir, SourceFiles.C_AND_CPP_SOURCE_FILTER))
            containedFixture |= performFixture(base, pckg, fixtureFile);
        if (containedFixture) {
            // XXX:2009-08-16:christianhujer:The id is already set above if there is no parent.
            if (hasParent)
                pckg.setId(idGenerator);
            final File cFile = getFileForSuiteC(pckgDir, pckg);
            if (printSet.contains(Print.sources) || printSet.contains(Print.suites) || printSet.contains(Print.generated))
                System.out.println(cFile);
            final String hSource = pckg.getCode(getPackageName(pckgDir));
            if (genSuites)
                SourceFiles.writeIfChanged(cFile, hSource, force);