KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Enumeration JavaDoc;
20 import java.util.Hashtable JavaDoc;
21
22 import org.apache.xerces.impl.dv.DatatypeValidator;
23
24 /**
25  * the factory to create/return built-in XML 1.1 DVs and create user-defined DVs
26  *
27  * @xerces.internal
28  *
29  * @author Neil Graham, IBM
30  *
31  * @version $Id: XML11DTDDVFactoryImpl.java,v 1.4 2004/10/06 14:56:51 mrglavas Exp $
32  */

33 public class XML11DTDDVFactoryImpl extends DTDDVFactoryImpl {
34
35     static Hashtable JavaDoc fXML11BuiltInTypes = new Hashtable JavaDoc();
36
37     /**
38      * return a dtd type of the given name
39      * This will call the super class if and only if it does not
40      * recognize the passed-in 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         if(fXML11BuiltInTypes.get(name) != null) {
47             return (DatatypeValidator)fXML11BuiltInTypes.get(name);
48         }
49         return (DatatypeValidator)fBuiltInTypes.get(name);
50     }
51
52     /**
53      * get all built-in DVs, which are stored in a hashtable keyed by the name
54      * New XML 1.1 datatypes are inserted.
55      *
56      * @return a hashtable which contains all datatypes
57      */

58     public Hashtable JavaDoc getBuiltInTypes() {
59         Hashtable JavaDoc toReturn = (Hashtable JavaDoc)fBuiltInTypes.clone();
60         Enumeration JavaDoc xml11Keys = fXML11BuiltInTypes.keys();
61         while (xml11Keys.hasMoreElements()) {
62             Object JavaDoc key = xml11Keys.nextElement();
63             toReturn.put(key, fXML11BuiltInTypes.get(key));
64         }
65         return toReturn;
66     }
67
68     static {
69         fXML11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
70         DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
71         fXML11BuiltInTypes.put("XML11IDREF", dvTemp);
72         fXML11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
73         dvTemp = new XML11NMTOKENDatatypeValidator();
74         fXML11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
75         fXML11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
76     } // <clinit>
77

78
79 }//XML11DTDDVFactoryImpl
80

81
Popular Tags