src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java

Print this page

        

@@ -1,15 +1,15 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,

@@ -18,12 +18,14 @@
  * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl.dv;
 
-import java.util.Hashtable;
+import com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl;
+import com.sun.org.apache.xerces.internal.impl.dv.dtd.XML11DTDDVFactoryImpl;
 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
+import java.util.Hashtable;
 
 /**
  * The factory to create and return DTD types. The implementation should
  * store the created datatypes in static data, so that they can be shared by
  * multiple parser instance, and multiple threads.

@@ -33,11 +35,15 @@
  * @author Sandy Gao, IBM
  *
  */
 public abstract class DTDDVFactory {
 
-    private static final String DEFAULT_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl";
+    private static final String DEFAULT_FACTORY_CLASS =
+            "com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl";
+
+    private static final String XML11_DATATYPE_VALIDATOR_FACTORY =
+        "com.sun.org.apache.xerces.internal.impl.dv.dtd.XML11DTDDVFactoryImpl";
 
     /**
      * Get an instance of the default DTDDVFactory implementation.
      *
      * @return  an instance of DTDDVFactory implementation

@@ -56,14 +62,20 @@
      * @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 the class name is not specified, use the default one
+            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.");
         }
     }