FileDocCategorySizeDatePackage
ApacheCatalog.javaAPI DocApache Ant 1.704531Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.types.resolver

ApacheCatalog

public class ApacheCatalog extends org.apache.xml.resolver.Catalog
This class extends the Catalog class provided by Norman Walsh's resolver library in xml-commons in order to add classpath entity and URI resolution. Since XMLCatalog already does classpath resolution, we simply add all CatalogEntry instances back to the controlling XMLCatalog instance. This is done via a callback mechanism. ApacheCatalog is only used for external catalog files. Inline entries (currently <dtd> and <entity>) are not added to ApacheCatalog. See XMLCatalog.java for the details of the entity and URI resolution algorithms.
see
org.apache.tools.ant.types.XMLCatalog.CatalogResolver
since
Ant 1.6

Fields Summary
private ApacheCatalogResolver
resolver
The resolver object to callback.
Constructors Summary
Methods Summary
public voidaddEntry(org.apache.xml.resolver.CatalogEntry entry)

This method overrides the superclass method of the same name in order to add catalog entries back to the controlling XMLCatalog instance. In this way, we can add classpath lookup for these entries.

When we add an external catalog file, the entries inside it get parsed by this method. Therefore, we override it to add each of them back to the controlling XMLCatalog instance. This is done by performing a callback to the ApacheCatalogResolver, which in turn calls the XMLCatalog.

XMLCatalog currently only understands PUBLIC and URI entry types, so we ignore the other types.

param
entry The CatalogEntry to process.


        int type = entry.getEntryType();

        if (type == PUBLIC) {

            String publicid = PublicId.normalize(entry.getEntryArg(0));
            String systemid = normalizeURI(entry.getEntryArg(1));

            if (resolver == null) {
                catalogManager.debug
                    .message(1, "Internal Error: null ApacheCatalogResolver");
            } else {
                resolver.addPublicEntry(publicid, systemid, base);
            }

        } else if (type == URI) {

            String uri = normalizeURI(entry.getEntryArg(0));
            String altURI = normalizeURI(entry.getEntryArg(1));

            if (resolver == null) {
                catalogManager.debug
                    .message(1, "Internal Error: null ApacheCatalogResolver");
            } else {
                resolver.addURIEntry(uri, altURI, base);
            }

        }

        super.addEntry(entry);
    
protected org.apache.xml.resolver.CatalognewCatalog()

Create a new ApacheCatalog instance.

This method overrides the superclass method of the same name in order to set the resolver object for callbacks. The reason we have to do this is that internally Catalog creates a new instance of itself for each external catalog file processed. That is, if two external catalog files are processed, there will be a total of two ApacheCatalog instances, and so on.

return
the catalog.


                                                                                      
       
        ApacheCatalog cat = (ApacheCatalog) super.newCatalog();
        cat.setResolver(resolver);
        return cat;
    
public voidsetResolver(ApacheCatalogResolver resolver)
Set the resolver object to callback.

param
resolver the apache catalog resolver.

        this.resolver = resolver;