KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dv > DTDDVFactory


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.dv;
18
19 import java.util.Hashtable JavaDoc;
20
21 /**
22  * The factory to create and return DTD types. The implementation should
23  * store the created datatypes in static data, so that they can be shared by
24  * multiple parser instance, and multiple threads.
25  *
26  * @xerces.internal
27  *
28  * @author Sandy Gao, IBM
29  *
30  * @version $Id: DTDDVFactory.java,v 1.9 2004/10/06 14:56:50 mrglavas Exp $
31  */

32 public abstract class DTDDVFactory {
33
34     private static final String JavaDoc DEFAULT_FACTORY_CLASS = "org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl";
35
36     /**
37      * Get an instance of the default DTDDVFactory implementation.
38      *
39      * @return an instance of DTDDVFactory implementation
40      * @exception DVFactoryException cannot create an instance of the specified
41      * class name or the default class name
42      */

43     public static synchronized final DTDDVFactory getInstance() throws DVFactoryException {
44         return getInstance(DEFAULT_FACTORY_CLASS);
45     }
46
47     /**
48      * Get an instance of DTDDVFactory implementation.
49      *
50      * @param factoryClass name of the implementation to load.
51      * @return an instance of DTDDVFactory implementation
52      * @exception DVFactoryException cannot create an instance of the specified
53      * class name or the default class name
54      */

55     public static synchronized final DTDDVFactory getInstance(String JavaDoc factoryClass) throws DVFactoryException {
56
57         try {
58             // if the class name is not specified, use the default one
59
return (DTDDVFactory)
60                 (ObjectFactory.newInstance(factoryClass, ObjectFactory.findClassLoader(), true));
61         } catch (ClassCastException JavaDoc e) {
62             throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory.");
63         }
64     }
65
66     // can't create a new object of this class
67
protected DTDDVFactory(){}
68
69     /**
70      * return a dtd type of the given name
71      *
72      * @param name the name of the datatype
73      * @return the datatype validator of the given name
74      */

75     public abstract DatatypeValidator getBuiltInDV(String JavaDoc name);
76
77     /**
78      * get all built-in DVs, which are stored in a hashtable keyed by the name
79      *
80      * @return a hashtable which contains all datatypes
81      */

82     public abstract Hashtable JavaDoc getBuiltInTypes();
83
84 }
85
Popular Tags