src/main/java/org/jboss/util/xml/catalog/Catalog.java
protected synchronized void parsePendingCatalogs()
    throws MalformedURLException, IOException {

    if (!localCatalogFiles.isEmpty()) {
      // Move all the localCatalogFiles into the front of
      // the catalogFiles queue
      Vector newQueue = new Vector();
      Enumeration q = localCatalogFiles.elements();
      while (q.hasMoreElements()) {
	newQueue.addElement(q.nextElement());
      }

      // Put the rest of the catalogs on the end of the new list
      for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
	String catfile = (String) catalogFiles.elementAt(curCat);
	newQueue.addElement(catfile);
      }

      catalogFiles = newQueue;
      localCatalogFiles.clear();
    }

    // Suppose there are no catalog files to process, but the
    // single catalog already parsed included some delegate
    // entries? Make sure they don't get lost.
    if (catalogFiles.isEmpty() && !localDelegate.isEmpty()) {
      Enumeration e = localDelegate.elements();
      while (e.hasMoreElements()) {
	catalogEntries.addElement(e.nextElement());
      }
      localDelegate.clear();
    }

    // Now process all the files on the catalogFiles vector. This
    // vector can grow during processing if CATALOG entries are
    // encountered in the catalog
    while (!catalogFiles.isEmpty()) {
      String catfile = (String) catalogFiles.elementAt(0);
      try {
	catalogFiles.remove(0);
      } catch (ArrayIndexOutOfBoundsException e) {
	// can't happen
      }

      if (catalogEntries.size() == 0 && catalogs.size() == 0) {
	// We haven't parsed any catalogs yet, let this
	// catalog be the first...
	try {
	  parseCatalogFile(catfile);
	} catch (CatalogException ce) {
	  System.out.println("FIXME: " + ce.toString());
	}
      } else {
	// This is a subordinate catalog. We save its name,
	// but don't bother to load it unless it's necessary.
	catalogs.addElement(catfile);
      }

      if (!localCatalogFiles.isEmpty()) {
	// Move all the localCatalogFiles into the front of
	// the catalogFiles queue
	Vector newQueue = new Vector();
	Enumeration q = localCatalogFiles.elements();
	while (q.hasMoreElements()) {
	  newQueue.addElement(q.nextElement());
	}

	// Put the rest of the catalogs on the end of the new list
	for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
	  catfile = (String) catalogFiles.elementAt(curCat);
	  newQueue.addElement(catfile);
	}

	catalogFiles = newQueue;
	localCatalogFiles.clear();
      }

      if (!localDelegate.isEmpty()) {
	Enumeration e = localDelegate.elements();
	while (e.hasMoreElements()) {
	  catalogEntries.addElement(e.nextElement());
	}
	localDelegate.clear();
      }
    }

    // We've parsed them all, reinit the vector...
    catalogFiles.clear();
  }
protected synchronized void parsePendingCatalogs()
    throws MalformedURLException, IOException {

    if (!localCatalogFiles.isEmpty()) {
      // Move all the localCatalogFiles into the front of
      // the catalogFiles queue
      Vector newQueue = new Vector();
      Enumeration q = localCatalogFiles.elements();
      while (q.hasMoreElements()) {
	newQueue.addElement(q.nextElement());
      }

      // Put the rest of the catalogs on the end of the new list
      for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
	String catfile = (String) catalogFiles.elementAt(curCat);
	newQueue.addElement(catfile);
      }

      catalogFiles = newQueue;
      localCatalogFiles.clear();
    }

    // Suppose there are no catalog files to process, but the
    // single catalog already parsed included some delegate
    // entries? Make sure they don't get lost.
    if (catalogFiles.isEmpty() && !localDelegate.isEmpty()) {
      Enumeration e = localDelegate.elements();
      while (e.hasMoreElements()) {
	catalogEntries.addElement(e.nextElement());
      }
      localDelegate.clear();
    }

    // Now process all the files on the catalogFiles vector. This
    // vector can grow during processing if CATALOG entries are
    // encountered in the catalog
    while (!catalogFiles.isEmpty()) {
      String catfile = (String) catalogFiles.elementAt(0);
      try {
	catalogFiles.remove(0);
      } catch (ArrayIndexOutOfBoundsException e) {
	// can't happen
      }

      if (catalogEntries.size() == 0 && catalogs.size() == 0) {
	// We haven't parsed any catalogs yet, let this
	// catalog be the first...
	try {
	  parseCatalogFile(catfile);
	} catch (CatalogException ce) {
	  System.out.println("FIXME: " + ce.toString());
	}
      } else {
	// This is a subordinate catalog. We save its name,
	// but don't bother to load it unless it's necessary.
	catalogs.addElement(catfile);
      }

      if (!localCatalogFiles.isEmpty()) {
	// Move all the localCatalogFiles into the front of
	// the catalogFiles queue
	Vector newQueue = new Vector();
	Enumeration q = localCatalogFiles.elements();
	while (q.hasMoreElements()) {
	  newQueue.addElement(q.nextElement());
	}

	// Put the rest of the catalogs on the end of the new list
	for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
	  catfile = (String) catalogFiles.elementAt(curCat);
	  newQueue.addElement(catfile);
	}

	catalogFiles = newQueue;
	localCatalogFiles.clear();
      }

      if (!localDelegate.isEmpty()) {
	Enumeration e = localDelegate.elements();
	while (e.hasMoreElements()) {
	  catalogEntries.addElement(e.nextElement());
	}
	localDelegate.clear();
      }
    }

    // We've parsed them all, reinit the vector...
    catalogFiles.clear();
  }
Parse all of the pending catalogs.

<p>Catalogs may refer to other catalogs, this method parses
all of the currently pending catalog files.</p>
@throws MalformedURLException
@throws IOException