}    int level = 0; String dbName = null; if (Initializer.getDatabase() == Initializer.POSTGRES) { dbName = "postgres"; } else { dbName = "oracle-se"; } while (dirs.size() > 0) { File dir = (File) dirs.pop(); File[] listing = dir.listFiles(new FileFilter() { public boolean accept(File file) { return file.isDirectory() || file.getName().endsWith(".pdl"); } }); for (int i = 0; i < listing.length; i++) { if (listing[i].isDirectory()) { if (level > 0 || listing[i].getName().startsWith(dbName) || listing[i].getName().equals("default")) { System.out.println("adding " + listing[i].getName()); dirs.push(listing[i]); } } else { try { files.add(listing[i].getCanonicalPath()); } catch (IOException e) { throw new PDLException(e.getMessage()); } } } level++;
    public static final void main(String[] argArray) throws PDLException {        List args = new ArrayList(java.util.Arrays.asList(argArray));        while (args.size() > 0) {            String arg = (String) args.get(0);            if (OPTIONS.containsKey(arg)) {                args.remove(0);                Object value = OPTIONS.get(arg);                if (Boolean.FALSE.equals(value)) {                    OPTIONS.put(arg, Boolean.TRUE);                } else if (Boolean.TRUE.equals(value)) {                    OPTIONS.put(arg, Boolean.FALSE);                } else if (args.size() > 0) {                    OPTIONS.put(arg, args.get(0));                    args.remove(0);                } else {                    usage();                }            } else {                break;            }        }        String debugDir = (String) OPTIONS.get("-debugDirectory");        if (debugDir != null) {            setDebugDirectory(debugDir);        }        String database = (String) OPTIONS.get("-database");        if (database != null) {            if ("postgres".equalsIgnoreCase(database)) {                Initializer.setDatabase(Initializer.POSTGRES);            } else {                Initializer.setDatabase(Initializer.ORACLE);            }        }        List files = new ArrayList();        Stack dirs = new Stack();        String path = (String) OPTIONS.get("-path");        if (path != null) {            String[] parts = StringUtils.split(path, ':');            for (int i = 0; i < parts.length; i++) {                dirs.push(new File(parts[i]));            }        }        // the level is used to determine whether or not the        // directory should be filtered based on the database        int level = 0;        String dbName = null;        if (Initializer.getDatabase() == Initializer.POSTGRES) {            dbName = "postgres";        } else {            dbName = "oracle-se";        }        while (dirs.size() > 0) {            File dir = (File) dirs.pop();            File[] listing = dir.listFiles(new FileFilter() {                    public boolean accept(File file) {                        return file.isDirectory() ||                            file.getName().endsWith(".pdl");                    }                });            for (int i = 0; i < listing.length; i++) {                if (listing[i].isDirectory()) {                    if (level > 0 || listing[i].getName().startsWith(dbName) ||                        listing[i].getName().equals("default")) {                        System.out.println("adding " + listing[i].getName());                        dirs.push(listing[i]);                    }                 } else {                    try {                        files.add(listing[i].getCanonicalPath());                    } catch (IOException e) {                        throw new PDLException(e.getMessage());                    }                }            }            level++;        }        files.addAll(args);        if (files.size() < 1) {            usage();        } else {            BasicConfigurator.configure();            Logger.getRootLogger().setLevel(Level.INFO);            DDLWriter writer = null;            String base = (String) OPTIONS.get("-ddl");            if (base != null) {                writer = new DDLWriter(base);            }                        compilePDL(files);            if (writer != null) {                try {                    writer.write(MetadataRoot.getMetadataRoot());                } catch (IOException ioe) {                    throw new PDLException(ioe.getMessage());                }            }            String dot = (String) OPTIONS.get("-dot");            if (dot != null) {                String[] parts = StringUtils.split(dot, ':');                if (parts.length > 2) {                    throw new PDLException(                        "Badly formated specification: " + dot                        );                }                MetadataRoot root = MetadataRoot.getMetadataRoot();                ObjectType type = root.getObjectType(parts[0]);                if (type == null) {                    throw new PDLException("No such type: " + parts[0]);                }                Query query = new Query(type);                if (parts.length == 2) {                    query.fetch(parts[1]);                } else {                    query.fetchDefault();                }                query.generate();                query.dumpDot(new File("/tmp/out.dot"));            }        }    }