01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.xerces.impl.dv;
19:
20: import java.util.Hashtable;
21:
22: /**
23: * The factory to create and return DTD types. The implementation should
24: * store the created datatypes in static data, so that they can be shared by
25: * multiple parser instance, and multiple threads.
26: *
27: * @xerces.internal
28: *
29: * @author Sandy Gao, IBM
30: *
31: * @version $Id: DTDDVFactory.java 558581 2007-07-23 01:38:26Z mrglavas $
32: */
33: public abstract class DTDDVFactory {
34:
35: private static final String DEFAULT_FACTORY_CLASS = "org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl";
36:
37: /**
38: * Get an instance of the default DTDDVFactory implementation.
39: *
40: * @return an instance of DTDDVFactory implementation
41: * @exception DVFactoryException cannot create an instance of the specified
42: * class name or the default class name
43: */
44: public static final DTDDVFactory getInstance()
45: throws DVFactoryException {
46: return getInstance(DEFAULT_FACTORY_CLASS);
47: }
48:
49: /**
50: * Get an instance of DTDDVFactory implementation.
51: *
52: * @param factoryClass name of the implementation to load.
53: * @return an instance of DTDDVFactory implementation
54: * @exception DVFactoryException cannot create an instance of the specified
55: * class name or the default class name
56: */
57: public static final DTDDVFactory getInstance(String factoryClass)
58: throws DVFactoryException {
59: try {
60: // if the class name is not specified, use the default one
61: return (DTDDVFactory) (ObjectFactory
62: .newInstance(factoryClass, ObjectFactory
63: .findClassLoader(), true));
64: } catch (ClassCastException e) {
65: throw new DVFactoryException("DTD factory class "
66: + factoryClass
67: + " does not extend from DTDDVFactory.");
68: }
69: }
70:
71: // can't create a new object of this class
72: protected DTDDVFactory() {
73: }
74:
75: /**
76: * return a dtd type of the given name
77: *
78: * @param name the name of the datatype
79: * @return the datatype validator of the given name
80: */
81: public abstract DatatypeValidator getBuiltInDV(String name);
82:
83: /**
84: * get all built-in DVs, which are stored in a hashtable keyed by the name
85: *
86: * @return a hashtable which contains all datatypes
87: */
88: public abstract Hashtable getBuiltInTypes();
89:
90: }
|