KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dv > dtd > DTDDVFactoryImpl


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.dtd;
18
19 import org.apache.xerces.impl.dv.DTDDVFactory;
20 import org.apache.xerces.impl.dv.DatatypeValidator;
21 import java.util.Hashtable JavaDoc;
22
23 /**
24  * the factory to create/return built-in schema DVs and create user-defined DVs
25  *
26  * @xerces.internal
27  *
28  * @author Sandy Gao, IBM
29  *
30  * @version $Id: DTDDVFactoryImpl.java,v 1.6 2004/10/06 14:56:51 mrglavas Exp $
31  */

32 public class DTDDVFactoryImpl extends DTDDVFactory {
33
34     static Hashtable JavaDoc fBuiltInTypes = new Hashtable JavaDoc();
35     static {
36         createBuiltInTypes();
37     }
38
39     /**
40      * return a dtd type of the given name
41      *
42      * @param name the name of the datatype
43      * @return the datatype validator of the given name
44      */

45     public DatatypeValidator getBuiltInDV(String JavaDoc name) {
46         return (DatatypeValidator)fBuiltInTypes.get(name);
47     }
48
49     /**
50      * get all built-in DVs, which are stored in a hashtable keyed by the name
51      *
52      * @return a hashtable which contains all datatypes
53      */

54     public Hashtable JavaDoc getBuiltInTypes() {
55         return (Hashtable JavaDoc)fBuiltInTypes.clone();
56     }
57
58     // create all built-in types
59
static void createBuiltInTypes() {
60
61         DatatypeValidator dvTemp;
62
63         fBuiltInTypes.put("string", new StringDatatypeValidator());
64         fBuiltInTypes.put("ID", new IDDatatypeValidator());
65         dvTemp = new IDREFDatatypeValidator();
66         fBuiltInTypes.put("IDREF", dvTemp);
67         fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
68         dvTemp = new ENTITYDatatypeValidator();
69         fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
70         fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
71         fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
72         dvTemp = new NMTOKENDatatypeValidator();
73         fBuiltInTypes.put("NMTOKEN", dvTemp);
74         fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
75
76     }//createBuiltInTypes()
77

78 }// DTDDVFactoryImpl
79

80
Popular Tags