FileDocCategorySizeDatePackage
DOMModuleChecker.javaAPI DocExample4588Thu Aug 16 16:52:54 BST 2001javaxml2

DOMModuleChecker

public class DOMModuleChecker extends Object
DOMModuleChecker checks a vendor's DOM implementation, and sees which modules that implementation makes available.

Fields Summary
private String
vendorImplementationClass
Vendor DOMImplementation impl class
private String[]
moduleNames
Modules to check
Constructors Summary
public DOMModuleChecker()

No args constructor uses Apache Xerces DOM implementation.

        
                   
      
    
public DOMModuleChecker(String vendorImplementationClass)

This takes the DOM implementation class to use

param
vendorImplementationClass class to use.

        this.vendorImplementationClass = vendorImplementationClass;
    
Methods Summary
public voidcheck()

This method does the actual work of checking the provided DOM implementation for the modules it supports.

throws
Exception - generic exception handling.

        DOMImplementation impl = 
            (DOMImplementation)Class.forName(vendorImplementationClass)
                                    .newInstance();
        for (int i=0; i<moduleNames.length; i++) {
            if (impl.hasFeature(moduleNames[i], "2.0")) {
                System.out.println("Support for " + moduleNames[i] +
                    " is included in this DOM implementation.");
            } else {
                System.out.println("Support for " + moduleNames[i] +
                    " is not included in this DOM implementation.");                
            }            
        }        
    
public static voidmain(java.lang.String[] args)

Provide a static entry point.

        if ((args.length != 0) && (args.length != 1)) {
            System.out.println("Usage: java javaxml2.DOMModuleChecker " +
                "[DOMImplementation impl class to query]");
            System.exit(-1);
        }
        
        try {
            DOMModuleChecker checker = null;
            if (args.length == 1) {
                checker = new DOMModuleChecker(args[1]);
            } else {
                checker = new DOMModuleChecker();
            }
            checker.check();
        } catch (Exception e) {
            e.printStackTrace();
        }