KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > impl > dv > SchemaDVFactory


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.impl.dv;
59
60 import com.sun.org.apache.xerces.internal.util.SymbolHash;
61 import com.sun.org.apache.xerces.internal.xs.XSObjectList;
62
63 /**
64  * Defines a factory API that enables applications to <p>
65  * 1. to get the instance of specified SchemaDVFactory implementation <p>
66  * 2. to create/return built-in schema simple types <p>
67  * 3. to create user defined simple types. <p>
68  *
69  * Implementations of this abstract class can be used to get built-in simple
70  * types and create user-defined simle types. <p>
71  *
72  * The implementation should store the built-in datatypes in static data, so
73  * that they can be shared by multiple parser instance, and multiple threads.
74  *
75  * @author Sandy Gao, IBM
76  *
77  * @version $Id: SchemaDVFactory.java,v 1.12 2004/02/17 07:14:48 neeraj Exp $
78  */

79 public abstract class SchemaDVFactory {
80
81     private static final String JavaDoc DEFAULT_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl";
82
83     /**
84      * Get a default instance of SchemaDVFactory implementation.
85      *
86      * @return an instance of SchemaDVFactory implementation
87      * @exception DVFactoryException cannot create an instance of the specified
88      * class name or the default class name
89      */

90     public static synchronized final SchemaDVFactory getInstance() throws DVFactoryException {
91         return getInstance(DEFAULT_FACTORY_CLASS);
92     } //getInstance(): SchemaDVFactory
93

94
95     /**
96      * Get an instance of SchemaDVFactory implementation.
97      *
98      * @param factoryClass name of the schema factory implementation to instantiate.
99      * @return an instance of SchemaDVFactory implementation
100      * @exception DVFactoryException cannot create an instance of the specified
101      * class name or the default class name
102      */

103     public static synchronized final SchemaDVFactory getInstance(String JavaDoc factoryClass) throws DVFactoryException {
104
105         try {
106             // if the class name is not specified, use the default one
107
return (SchemaDVFactory)(ObjectFactory.newInstance(
108                 factoryClass, ObjectFactory.findClassLoader(), true));
109         } catch (ClassCastException JavaDoc e4) {
110             throw new DVFactoryException("Schema factory class " + factoryClass + " does not extend from SchemaDVFactory.");
111         }
112
113     }
114
115     // can't create a new object of this class
116
protected SchemaDVFactory(){}
117
118     /**
119      * Get a built-in simple type of the given name
120      * REVISIT: its still not decided within the Schema WG how to define the
121      * ur-types and if all simple types should be derived from a
122      * complex type, so as of now we ignore the fact that anySimpleType
123      * is derived from anyType, and pass 'null' as the base of
124      * anySimpleType. It needs to be changed as per the decision taken.
125      *
126      * @param name the name of the datatype
127      * @return the datatype validator of the given name
128      */

129     public abstract XSSimpleType getBuiltInType(String JavaDoc name);
130
131     /**
132      * get all built-in simple types, which are stored in a SymbolHash keyed by
133      * the name
134      *
135      * @return a SymbolHash which contains all built-in simple types
136      */

137     public abstract SymbolHash getBuiltInTypes();
138
139     /**
140      * Create a new simple type which is derived by restriction from another
141      * simple type.
142      *
143      * @param name name of the new type, could be null
144      * @param targetNamespace target namespace of the new type, could be null
145      * @param finalSet value of "final"
146      * @param base base type of the new type
147      * @param annotation set of annotations
148      * @return the newly created simple type
149      */

150     public abstract XSSimpleType createTypeRestriction(String JavaDoc name, String JavaDoc targetNamespace,
151                                                        short finalSet, XSSimpleType base,
152                                                        XSObjectList annotations);
153
154     /**
155      * Create a new simple type which is derived by list from another simple
156      * type.
157      *
158      * @param name name of the new type, could be null
159      * @param targetNamespace target namespace of the new type, could be null
160      * @param finalSet value of "final"
161      * @param itemType item type of the list type
162      * @param annotation set of annotations
163      * @return the newly created simple type
164      */

165     public abstract XSSimpleType createTypeList(String JavaDoc name, String JavaDoc targetNamespace,
166                                                 short finalSet, XSSimpleType itemType,
167                                                 XSObjectList annotations);
168
169     /**
170      * Create a new simple type which is derived by union from a list of other
171      * simple types.
172      *
173      * @param name name of the new type, could be null
174      * @param targetNamespace target namespace of the new type, could be null
175      * @param finalSet value of "final"
176      * @param base member types of the union type
177      * @param annotation set of annotations
178      * @return the newly created simple type
179      */

180     public abstract XSSimpleType createTypeUnion(String JavaDoc name, String JavaDoc targetNamespace,
181                                                  short finalSet, XSSimpleType[] memberTypes,
182                                                  XSObjectList annotations);
183
184 }
185
Popular Tags