xml-commons-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject cvs commit: xml-commons/java/src/org/apache/xml/resolver/tools CatalogResolver.java ResolvingParser.java
Date Wed, 13 Nov 2002 20:54:33 GMT
ndw         2002/11/13 12:54:32

  Modified:    java/src/org/apache/xml/resolver/tools CatalogResolver.java
                        ResolvingParser.java
  Log:
  Add interfaces for constructing a filter with a particular CatalogManager
  
  Revision  Changes    Path
  1.2       +19 -46    xml-commons/java/src/org/apache/xml/resolver/tools/CatalogResolver.java
  
  Index: CatalogResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-commons/java/src/org/apache/xml/resolver/tools/CatalogResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CatalogResolver.java	30 Jan 2002 12:25:00 -0000	1.1
  +++ CatalogResolver.java	13 Nov 2002 20:54:30 -0000	1.2
  @@ -104,9 +104,11 @@
     public boolean validating = false;
   
     /** The underlying catalog */
  -  private static Catalog staticCatalog = null;
     private Catalog catalog = null;
   
  +  /** The catalog manager */
  +  private CatalogManager catalogManager = CatalogManager.getStaticManager();
  +
     /** Constructor */
     public CatalogResolver() {
       initializeCatalogs(false);
  @@ -117,44 +119,15 @@
       initializeCatalogs(privateCatalog);
     }
   
  +  /** Constructor */
  +  public CatalogResolver(CatalogManager manager) {
  +    catalogManager = manager;
  +    initializeCatalogs(!catalogManager.getUseStaticCatalog());
  +  }
  +
     /** Initialize catalog */
     private void initializeCatalogs(boolean privateCatalog) {
  -    catalog = staticCatalog;
  -
  -    if (privateCatalog || catalog == null) {
  -      try {
  -	String catalogClassName = CatalogManager.catalogClassName();
  -	if (catalogClassName == null) {
  -	  catalog = new Catalog();
  -	} else {
  -	  try {
  -	    catalog = (Catalog) Class.forName(catalogClassName).newInstance();
  -	  } catch (ClassNotFoundException cnfe) {
  -	    Debug.message(1,"Catalog class named '"
  -			  + catalogClassName
  -			  + "' could not be found. Using default.");
  -	    catalog = new Catalog();
  -	  } catch (ClassCastException cnfe) {
  -	    Debug.message(1,"Class named '"
  -			  + catalogClassName
  -			  + "' is not a Catalog. Using default.");
  -	    catalog = new Catalog();
  -	  }
  -	}
  -
  -	catalog.setupReaders();
  -
  -	if (!privateCatalog) {
  -	  catalog.loadSystemCatalogs();
  -	}
  -      } catch (Exception ex) {
  -	ex.printStackTrace();
  -      }
  -    }
  -
  -    if (!privateCatalog && catalog != null && CatalogManager.staticCatalog())
{
  -      staticCatalog = catalog;
  -    }
  +    catalog = catalogManager.getCatalog();
     }
   
     /** Return the underlying catalog */
  @@ -186,7 +159,7 @@
       String resolved = null;
   
       if (catalog == null) {
  -      Debug.message(1, "Catalog resolution attempted with null catalog; ignored");
  +      catalogManager.debug.message(1, "Catalog resolution attempted with null catalog;
ignored");
         return null;
       }
   
  @@ -194,11 +167,11 @@
         try {
   	resolved = catalog.resolveSystem(systemId);
         } catch (MalformedURLException me) {
  -	Debug.message(1, "Malformed URL exception trying to resolve",
  +	catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
   		      publicId);
   	resolved = null;
         } catch (IOException ie) {
  -	Debug.message(1, "I/O exception trying to resolve", publicId);
  +	catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
   	resolved = null;
         }
       }
  @@ -208,18 +181,18 @@
   	try {
   	  resolved = catalog.resolvePublic(publicId, systemId);
   	} catch (MalformedURLException me) {
  -	  Debug.message(1, "Malformed URL exception trying to resolve",
  +	  catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
   			publicId);
   	} catch (IOException ie) {
  -	  Debug.message(1, "I/O exception trying to resolve", publicId);
  +	  catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
   	}
         }
   
         if (resolved != null) {
  -	Debug.message(2, "Resolved public", publicId, resolved);
  +	catalogManager.debug.message(2, "Resolved public", publicId, resolved);
         }
       } else {
  -      Debug.message(2, "Resolved system", systemId, resolved);
  +      catalogManager.debug.message(2, "Resolved system", systemId, resolved);
       }
   
       return resolved;
  @@ -277,7 +250,7 @@
   
   	return iSource;
         } catch (Exception e) {
  -	Debug.message(1, "Failed to create InputSource", resolved);
  +	catalogManager.debug.message(1, "Failed to create InputSource", resolved);
   	return null;
         }
       }
  @@ -332,7 +305,7 @@
       }
   
       //    if (!href.equals(result)) {
  -      Debug.message(2, "Resolved URI", href, result);
  +      catalogManager.debug.message(2, "Resolved URI", href, result);
         //    }
   
       SAXSource source = new SAXSource();
  
  
  
  1.2       +25 -9     xml-commons/java/src/org/apache/xml/resolver/tools/ResolvingParser.java
  
  Index: ResolvingParser.java
  ===================================================================
  RCS file: /home/cvs/xml-commons/java/src/org/apache/xml/resolver/tools/ResolvingParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResolvingParser.java	30 Jan 2002 12:25:00 -0000	1.1
  +++ ResolvingParser.java	13 Nov 2002 20:54:30 -0000	1.2
  @@ -117,8 +117,11 @@
     /** The underlying DTDHandler */
     private DTDHandler dtdHandler = null;
   
  +  /** The manager for the underlying resolver */
  +  private CatalogManager catalogManager = CatalogManager.getStaticManager();
  +
     /** The underlying catalog resolver */
  -  private CatalogResolver catalogResolver = new CatalogResolver();
  +  private CatalogResolver catalogResolver = null;
   
     /** A separate resolver for oasis-xml-pi catalogs */
     private CatalogResolver piCatalogResolver = null;
  @@ -134,6 +137,19 @@
   
     /** Constructor */
     public ResolvingParser() {
  +    initParser();
  +  }
  +
  +  /** Constructor */
  +  public ResolvingParser(CatalogManager manager) {
  +    catalogManager = manager;
  +    initParser();
  +  }
  +
  +  /** Initialize the parser */
  +  private void initParser() {
  +    catalogResolver = new CatalogResolver(catalogManager);
  +
       SAXParserFactory spf = SAXParserFactory.newInstance();
       spf.setNamespaceAware(namespaceAware);
       spf.setValidating(validating);
  @@ -293,12 +309,12 @@
         }
   
         if (allowXMLCatalogPI) {
  -	if (CatalogManager.allowOasisXMLCatalogPI()) {
  -	  Debug.message(4,"oasis-xml-catalog PI", pidata);
  +	if (catalogManager.allowOasisXMLCatalogPI()) {
  +	  catalogManager.debug.message(4,"oasis-xml-catalog PI", pidata);
   
   	  if (catalog != null) {
   	    try {
  -	      Debug.message(4,"oasis-xml-catalog", catalog.toString());
  +	      catalogManager.debug.message(4,"oasis-xml-catalog", catalog.toString());
   	      oasisXMLCatalogPI = true;
   
   	      if (piCatalogResolver == null) {
  @@ -307,17 +323,17 @@
   
   	      piCatalogResolver.getCatalog().parseCatalog(catalog.toString());
   	    } catch (Exception e) {
  -	      Debug.message(3, "Exception parsing oasis-xml-catalog: "
  +	      catalogManager.debug.message(3, "Exception parsing oasis-xml-catalog: "
   			    + catalog.toString());
   	    }
   	  } else {
  -	    Debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata);
  +	    catalogManager.debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata);
   	  }
   	} else {
  -	  Debug.message(4,"PI oasis-xml-catalog ignored: " + pidata);
  +	  catalogManager.debug.message(4,"PI oasis-xml-catalog ignored: " + pidata);
   	}
         } else {
  -	Debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: "
  +	catalogManager.debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: "
   		      + pidata);
         }
       } else {
  @@ -406,7 +422,7 @@
   
   	return iSource;
         } catch (Exception e) {
  -	Debug.message(1, "Failed to create InputSource", resolved);
  +	catalogManager.debug.message(1, "Failed to create InputSource", resolved);
   	return null;
         }
       } else {
  
  
  

Mime
View raw message