KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2001-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 org.apache.xerces.util.SymbolHash;
20 import org.apache.xerces.xs.XSObjectList;
21
22 /**
23  * Defines a factory API that enables applications to <p>
24  * 1. to get the instance of specified SchemaDVFactory implementation <p>
25  * 2. to create/return built-in schema simple types <p>
26  * 3. to create user defined simple types. <p>
27  *
28  * Implementations of this abstract class can be used to get built-in simple
29  * types and create user-defined simle types. <p>
30  *
31  * The implementation should store the built-in datatypes in static data, so
32  * that they can be shared by multiple parser instance, and multiple threads.
33  *
34  * @xerces.internal
35  *
36  * @author Sandy Gao, IBM
37  *
38  * @version $Id: SchemaDVFactory.java,v 1.15 2004/10/06 14:56:50 mrglavas Exp $
39  */

40 public abstract class SchemaDVFactory {
41
42     private static final String JavaDoc DEFAULT_FACTORY_CLASS = "org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl";
43
44     /**
45      * Get a default instance of SchemaDVFactory implementation.
46      *
47      * @return an instance of SchemaDVFactory implementation
48      * @exception DVFactoryException cannot create an instance of the specified
49      * class name or the default class name
50      */

51     public static synchronized final SchemaDVFactory getInstance() throws DVFactoryException {
52         return getInstance(DEFAULT_FACTORY_CLASS);
53     } //getInstance(): SchemaDVFactory
54

55
56     /**
57      * Get an instance of SchemaDVFactory implementation.
58      *
59      * @param factoryClass name of the schema factory implementation to instantiate.
60      * @return an instance of SchemaDVFactory implementation
61      * @exception DVFactoryException cannot create an instance of the specified
62      * class name or the default class name
63      */

64     public static synchronized final SchemaDVFactory getInstance(String JavaDoc factoryClass) throws DVFactoryException {
65
66         try {
67             // if the class name is not specified, use the default one
68
return (SchemaDVFactory)(ObjectFactory.newInstance(
69                 factoryClass, ObjectFactory.findClassLoader(), true));
70         } catch (ClassCastException JavaDoc e4) {
71             throw new DVFactoryException("Schema factory class " + factoryClass + " does not extend from SchemaDVFactory.");
72         }
73
74     }
75
76     // can't create a new object of this class
77
protected SchemaDVFactory(){}
78
79     /**
80      * Get a built-in simple type of the given name
81      * REVISIT: its still not decided within the Schema WG how to define the
82      * ur-types and if all simple types should be derived from a
83      * complex type, so as of now we ignore the fact that anySimpleType
84      * is derived from anyType, and pass 'null' as the base of
85      * anySimpleType. It needs to be changed as per the decision taken.
86      *
87      * @param name the name of the datatype
88      * @return the datatype validator of the given name
89      */

90     public abstract XSSimpleType getBuiltInType(String JavaDoc name);
91
92     /**
93      * get all built-in simple types, which are stored in a SymbolHash keyed by
94      * the name
95      *
96      * @return a SymbolHash which contains all built-in simple types
97      */

98     public abstract SymbolHash getBuiltInTypes();
99
100     /**
101      * Create a new simple type which is derived by restriction from another
102      * simple type.
103      *
104      * @param name name of the new type, could be null
105      * @param targetNamespace target namespace of the new type, could be null
106      * @param finalSet value of "final"
107      * @param base base type of the new type
108      * @param annotations set of annotations
109      * @return the newly created simple type
110      */

111     public abstract XSSimpleType createTypeRestriction(String JavaDoc name, String JavaDoc targetNamespace,
112                                                        short finalSet, XSSimpleType base,
113                                                        XSObjectList annotations);
114
115     /**
116      * Create a new simple type which is derived by list from another simple
117      * type.
118      *
119      * @param name name of the new type, could be null
120      * @param targetNamespace target namespace of the new type, could be null
121      * @param finalSet value of "final"
122      * @param itemType item type of the list type
123      * @param annotations set of annotations
124      * @return the newly created simple type
125      */

126     public abstract XSSimpleType createTypeList(String JavaDoc name, String JavaDoc targetNamespace,
127                                                 short finalSet, XSSimpleType itemType,
128                                                 XSObjectList annotations);
129
130     /**
131      * Create a new simple type which is derived by union from a list of other
132      * simple types.
133      *
134      * @param name name of the new type, could be null
135      * @param targetNamespace target namespace of the new type, could be null
136      * @param finalSet value of "final"
137      * @param memberTypes member types of the union type
138      * @param annotations set of annotations
139      * @return the newly created simple type
140      */

141     public abstract XSSimpleType createTypeUnion(String JavaDoc name, String JavaDoc targetNamespace,
142                                                  short finalSet, XSSimpleType[] memberTypes,
143                                                  XSObjectList annotations);
144
145 }
146
Popular Tags