< prev index next >

src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java

Print this page

        

@@ -86,10 +86,11 @@
     SAXParser parser;
 
     /**
      * Construct a Catalog with specified URI.
      *
+     * @param f the features object
      * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
      */
     public CatalogImpl(CatalogFeatures f, URI... uris) throws CatalogException {

@@ -98,10 +99,11 @@
 
     /**
      * Construct a Catalog with specified URI.
      *
      * @param parent The parent catalog
+     * @param f the features object
      * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
      */
     public CatalogImpl(CatalogImpl parent, CatalogFeatures f, URI... uris) throws CatalogException {

@@ -135,11 +137,11 @@
             int start = 0;
             URI uri = null;
             for (String temp : catalogFile) {
                 uri = URI.create(temp);
                 start++;
-                if (verifyCatalogFile(uri)) {
+                if (verifyCatalogFile(null, uri)) {
                     systemId = temp;
                     try {
                         baseURI = new URL(systemId);
                     } catch (MalformedURLException e) {
                         CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH,

@@ -167,16 +169,18 @@
     void load() {
         if (systemId != null) {
             parse(systemId);
         }
 
+        setCatalog(this);
+
         //save this catalog before loading the next
         loadedCatalogs.put(systemId, this);
 
         //Load delegate and alternative catalogs if defer is false.
         if (!isDeferred()) {
-           loadDelegateCatalogs();
+           loadDelegateCatalogs(this);
            loadNextCatalogs();
         }
     }
 
     private void init(CatalogFeatures f) {

@@ -363,18 +367,20 @@
                 Catalog c = null;
 
                 //Check those specified in nextCatalogs
                 if (nextCatalogs != null) {
                     while (c == null && nextCatalogIndex < nextCatalogs.size()) {
-                        c = getCatalog(nextCatalogs.get(nextCatalogIndex++).getCatalogURI());
+                        c = getCatalog(catalog,
+                                nextCatalogs.get(nextCatalogIndex++).getCatalogURI());
                     }
                 }
 
                 //Check the input list
                 if (c == null && inputFiles != null) {
                     while (c == null && inputFilesIndex < inputFiles.size()) {
-                        c = getCatalog(URI.create(inputFiles.get(inputFilesIndex++)));
+                        c = getCatalog(null,
+                                URI.create(inputFiles.get(inputFilesIndex++)));
                     }
                 }
 
                 return c;
             }

@@ -406,36 +412,38 @@
      */
     void loadNextCatalogs() {
         //loads catalogs specified in nextCatalogs
         if (nextCatalogs != null) {
             nextCatalogs.stream().forEach((next) -> {
-                getCatalog(next.getCatalogURI());
+                getCatalog(this, next.getCatalogURI());
             });
         }
 
         //loads catalogs from the input list
         if (inputFiles != null) {
             inputFiles.stream().forEach((uri) -> {
-                getCatalog(URI.create(uri));
+                getCatalog(null, URI.create(uri));
             });
         }
     }
 
     /**
      * Returns a Catalog object by the specified path.
      *
-     * @param path the path to a catalog
+     * @param parent the parent catalog for the alternative catalogs to be loaded.
+     * It will be null if the ones to be loaded are from the input list.
+     * @param uri the path to a catalog
      * @return a Catalog object
      */
-    Catalog getCatalog(URI uri) {
+    Catalog getCatalog(CatalogImpl parent, URI uri) {
         if (uri == null) {
             return null;
         }
 
         CatalogImpl c = null;
 
-        if (verifyCatalogFile(uri)) {
+        if (verifyCatalogFile(parent, uri)) {
             c = getLoadedCatalog(uri.toASCIIString());
             if (c == null) {
                 c = new CatalogImpl(this, features, uri);
                 c.load();
             }

@@ -457,8 +465,8 @@
      * Returns a count of all loaded catalogs, including delegate catalogs.
      *
      * @return a count of all loaded catalogs
      */
     int loadedCatalogCount() {
-        return loadedCatalogs.size() + delegateCatalogs.size();
+        return loadedCatalogs.size();
     }
 }
< prev index next >