1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 2001, 2002,2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package com.sun.org.apache.xerces.internal.impl.dv; 22 23 import java.util.Hashtable; 24 import com.sun.org.apache.xerces.internal.utils.ObjectFactory; 25 26 /** 27 * The factory to create and return DTD types. The implementation should 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 */ 36 public abstract class DTDDVFactory { 37 38 private static final String DEFAULT_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl"; 39 40 /** 41 * Get an instance of the default DTDDVFactory implementation. 42 * 43 * @return an instance of DTDDVFactory implementation 44 * @exception DVFactoryException cannot create an instance of the specified 45 * class name or the default class name 46 */ 47 public static final DTDDVFactory getInstance() throws DVFactoryException { 48 return getInstance(DEFAULT_FACTORY_CLASS); 49 } 50 51 /** 52 * Get an instance of DTDDVFactory implementation. 53 * 54 * @param factoryClass name of the implementation to load. 55 * @return an instance of DTDDVFactory implementation 56 * @exception DVFactoryException cannot create an instance of the specified 57 * class name or the default class name 58 */ 59 public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException { 60 try { 61 // if the class name is not specified, use the default one 62 return (DTDDVFactory) 63 (ObjectFactory.newInstance(factoryClass, true)); 64 } 65 catch (ClassCastException e) { 66 throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory."); 67 } 68 } 69 70 // can't create a new object of this class 71 protected DTDDVFactory() {} 72 73 /** 74 * return a dtd type of the given name 75 * 76 * @param name the name of the datatype 77 * @return the datatype validator of the given name 78 */ 79 public abstract DatatypeValidator getBuiltInDV(String name); 80 81 /** 82 * get all built-in DVs, which are stored in a hashtable keyed by the name 83 * 84 * @return a hashtable which contains all datatypes 85 */ 86 public abstract Hashtable getBuiltInTypes(); 87 88 }