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

Print this page




  28  * store the created datatypes in static data, so that they can be shared by
  29  * multiple parser instance, and multiple threads.
  30  *
  31  * @xerces.internal
  32  *
  33  * @author Sandy Gao, IBM
  34  *
  35  * @version $Id: DTDDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $
  36  */
  37 public abstract class DTDDVFactory {
  38 
  39     private static final String DEFAULT_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl";
  40 
  41     /**
  42      * Get an instance of the default DTDDVFactory implementation.
  43      *
  44      * @return  an instance of DTDDVFactory implementation
  45      * @exception DVFactoryException  cannot create an instance of the specified
  46      *                                class name or the default class name
  47      */
  48     public static synchronized final DTDDVFactory getInstance() throws DVFactoryException {
  49         return getInstance(DEFAULT_FACTORY_CLASS);
  50     }
  51 
  52     /**
  53      * Get an instance of DTDDVFactory implementation.
  54      *
  55      * @param factoryClass  name of the implementation to load.
  56      * @return  an instance of DTDDVFactory implementation
  57      * @exception DVFactoryException  cannot create an instance of the specified
  58      *                                class name or the default class name
  59      */
  60     public static synchronized final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {
  61 
  62         try {
  63             // if the class name is not specified, use the default one
  64             return (DTDDVFactory)
  65                 (ObjectFactory.newInstance(factoryClass, true));
  66         } catch (ClassCastException e) {

  67             throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
  68         }
  69     }
  70 
  71     // can't create a new object of this class
  72     protected DTDDVFactory(){}
  73 
  74     /**
  75      * return a dtd type of the given name
  76      *
  77      * @param name  the name of the datatype
  78      * @return      the datatype validator of the given name
  79      */
  80     public abstract DatatypeValidator getBuiltInDV(String name);
  81 
  82     /**
  83      * get all built-in DVs, which are stored in a hashtable keyed by the name
  84      *
  85      * @return      a hashtable which contains all datatypes
  86      */
  87     public abstract Hashtable getBuiltInTypes();
  88 
  89 }


  28  * store the created datatypes in static data, so that they can be shared by
  29  * multiple parser instance, and multiple threads.
  30  *
  31  * @xerces.internal
  32  *
  33  * @author Sandy Gao, IBM
  34  *
  35  * @version $Id: DTDDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $
  36  */
  37 public abstract class DTDDVFactory {
  38 
  39     private static final String DEFAULT_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl";
  40 
  41     /**
  42      * Get an instance of the default DTDDVFactory implementation.
  43      *
  44      * @return  an instance of DTDDVFactory implementation
  45      * @exception DVFactoryException  cannot create an instance of the specified
  46      *                                class name or the default class name
  47      */
  48     public static final DTDDVFactory getInstance() throws DVFactoryException {
  49         return getInstance(DEFAULT_FACTORY_CLASS);
  50     }
  51 
  52     /**
  53      * Get an instance of DTDDVFactory implementation.
  54      *
  55      * @param factoryClass  name of the implementation to load.
  56      * @return  an instance of DTDDVFactory implementation
  57      * @exception DVFactoryException  cannot create an instance of the specified
  58      *                                class name or the default class name
  59      */
  60     public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException {

  61         try {
  62             // if the class name is not specified, use the default one
  63             return (DTDDVFactory)
  64                 (ObjectFactory.newInstance(factoryClass, true));
  65         }
  66         catch (ClassCastException e) {
  67             throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
  68         }
  69     }
  70 
  71     // can't create a new object of this class
  72     protected DTDDVFactory() {}
  73 
  74     /**
  75      * return a dtd type of the given name
  76      *
  77      * @param name  the name of the datatype
  78      * @return      the datatype validator of the given name
  79      */
  80     public abstract DatatypeValidator getBuiltInDV(String name);
  81 
  82     /**
  83      * get all built-in DVs, which are stored in a hashtable keyed by the name
  84      *
  85      * @return      a hashtable which contains all datatypes
  86      */
  87     public abstract Hashtable getBuiltInTypes();
  88 
  89 }