com.sun.org.apache.xerces.internal.utils.ObjectFactory Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.utils.ObjectFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DTDDVFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #2
Source File: CoreDOMImplementationImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #3
Source File: XMLGrammarPreparser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #4
Source File: DTDDVFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #5
Source File: CoreDOMImplementationImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #6
Source File: XMLGrammarPreparser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #7
Source File: XMLGrammarPreparser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #8
Source File: CoreDOMImplementationImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #9
Source File: DTDDVFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #10
Source File: CoreDOMImplementationImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #11
Source File: XMLGrammarPreparser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #12
Source File: XMLGrammarPreparser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #13
Source File: CoreDOMImplementationImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #14
Source File: CoreDOMImplementationImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #15
Source File: XMLGrammarPreparser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #16
Source File: XMLGrammarPreparser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #17
Source File: CoreDOMImplementationImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #18
Source File: DTDDVFactory.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #19
Source File: DTDDVFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #20
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #21
Source File: XMLGrammarPreparser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #22
Source File: CoreDOMImplementationImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #23
Source File: DTDDVFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #24
Source File: DTDDVFactory.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #25
Source File: XMLGrammarPreparser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = (String)KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #26
Source File: XMLGrammarPreparser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public boolean registerPreparser(String grammarType, XMLGrammarLoader loader) {
    if(loader == null) { // none specified!
        if(KNOWN_LOADERS.containsKey(grammarType)) {
            // got one; just instantiate it...
            String loaderName = KNOWN_LOADERS.get(grammarType);
            try {
                XMLGrammarLoader gl = (XMLGrammarLoader)(ObjectFactory.newInstance(loaderName, true));
                fLoaders.put(grammarType, gl);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        return false;
    }
    // were given one
    fLoaders.put(grammarType, loader);
    return true;
}
 
Example #27
Source File: CoreDOMImplementationImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * DOM Level 3 WD - Experimental.
 */
public Object getFeature(String feature, String version) {
    if (singleton.hasFeature(feature, version)) {
        if ((feature.equalsIgnoreCase("+XPath"))) {
            try {
                Class xpathClass = ObjectFactory.findProviderClass(
                    "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
                // Check if the DOM XPath implementation implements
                // the interface org.w3c.dom.XPathEvaluator
                Class interfaces[] = xpathClass.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    if (interfaces[i].getName().equals(
                        "org.w3c.dom.xpath.XPathEvaluator")) {
                        return xpathClass.newInstance();
                    }
                }
            } catch (Exception e) {
                return null;
            }
        } else {
            return singleton;
        }
    }
    return null;
}
 
Example #28
Source File: DTDDVFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get an instance of DTDDVFactory implementation.
 *
 * @param factoryClass  name of the implementation to load.
 * @return  an instance of DTDDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
    try {
        if (DEFAULT_FACTORY_CLASS.equals(factoryClass)) {
            return new DTDDVFactoryImpl();
        } else if (XML11_DATATYPE_VALIDATOR_FACTORY.equals(factoryClass)) {
            return new XML11DTDDVFactoryImpl();
        } else {
            //fall back for compatibility
            return (DTDDVFactory)
                (ObjectFactory.newInstance(factoryClass, true));
        }
    }
    catch (ClassCastException e) {
        throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
    }
}
 
Example #29
Source File: SchemaDVFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get an instance of SchemaDVFactory implementation.
 *
 * @param factoryClass   name of the schema factory implementation to instantiate.
 * @return  an instance of SchemaDVFactory implementation
 * @exception DVFactoryException  cannot create an instance of the specified
 *                                class name or the default class name
 */
public static synchronized final SchemaDVFactory getInstance(String factoryClass) throws DVFactoryException {

    try {
        // if the class name is not specified, use the default one
        return (SchemaDVFactory)(ObjectFactory.newInstance(factoryClass, true));
    } catch (ClassCastException e4) {
        throw new DVFactoryException("Schema factory class " + factoryClass + " does not extend from SchemaDVFactory.");
    }

}
 
Example #30
Source File: AbstractDOMParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method allows the programmer to decide which document
 * factory to use when constructing the DOM tree. However, doing
 * so will lose the functionality of the default factory. Also,
 * a document class other than the default will lose the ability
 * to defer node expansion on the DOM tree produced.
 *
 * @param documentClassName The fully qualified class name of the
 *                      document factory to use when constructing
 *                      the DOM tree.
 *
 * @see #getDocumentClassName
 * @see #DEFAULT_DOCUMENT_CLASS_NAME
 */
protected void setDocumentClassName (String documentClassName) {

    // normalize class name
    if (documentClassName == null) {
        documentClassName = DEFAULT_DOCUMENT_CLASS_NAME;
    }

    if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME) &&
        !documentClassName.equals(PSVI_DOCUMENT_CLASS_NAME)) {
        // verify that this class exists and is of the right type
        try {
            Class _class = ObjectFactory.findProviderClass (documentClassName, true);
            //if (!_class.isAssignableFrom(Document.class)) {
            if (!Document.class.isAssignableFrom (_class)) {
                throw new IllegalArgumentException (
                    DOMMessageFormatter.formatMessage(
                    DOMMessageFormatter.DOM_DOMAIN,
                    "InvalidDocumentClassName", new Object [] {documentClassName}));
            }
        }
        catch (ClassNotFoundException e) {
            throw new IllegalArgumentException (
                DOMMessageFormatter.formatMessage(
                DOMMessageFormatter.DOM_DOMAIN,
                "MissingDocumentClassName", new Object [] {documentClassName}));
        }
    }

    // set document class name
    fDocumentClassName = documentClassName;
    if (!documentClassName.equals (DEFAULT_DOCUMENT_CLASS_NAME)) {
        fDeferNodeExpansion = false;
    }

}